Examples of OGCConcreteGeometryCollection


Examples of com.esri.core.geometry.ogc.OGCConcreteGeometryCollection

  @Test
  public void testGeometryCollection() throws JSONException {
    OGCGeometry g = OGCGeometry
        .fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)");
    assertTrue(g.geometryType().equals("GeometryCollection"));
    OGCConcreteGeometryCollection gc = (OGCConcreteGeometryCollection) g;
    assertTrue(gc.numGeometries() == 5);
    assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
    assertTrue(gc.geometryN(1).geometryType().equals("Point"));
    assertTrue(gc.geometryN(2).geometryType().equals("LineString"));
    assertTrue(gc.geometryN(3).geometryType().equals("MultiPolygon"));
    assertTrue(gc.geometryN(4).geometryType().equals("MultiLineString"));

    g = OGCGeometry
        .fromText("GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION(POLYGON EMPTY, POINT(1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)");
    assertTrue(g.geometryType().equals("GeometryCollection"));
    gc = (OGCConcreteGeometryCollection) g;
    assertTrue(gc.numGeometries() == 7);
    assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
    assertTrue(gc.geometryN(1).geometryType().equals("Point"));
    assertTrue(gc.geometryN(2).geometryType().equals("GeometryCollection"));
    assertTrue(gc.geometryN(3).geometryType().equals("LineString"));
    assertTrue(gc.geometryN(4).geometryType().equals("GeometryCollection"));
    assertTrue(gc.geometryN(5).geometryType().equals("MultiPolygon"));
    assertTrue(gc.geometryN(6).geometryType().equals("MultiLineString"));

    OGCConcreteGeometryCollection gc2 = (OGCConcreteGeometryCollection) gc
        .geometryN(4);
    assertTrue(gc2.numGeometries() == 6);
    assertTrue(gc2.geometryN(0).geometryType().equals("Polygon"));
    assertTrue(gc2.geometryN(1).geometryType().equals("Point"));
    assertTrue(gc2.geometryN(2).geometryType().equals("LineString"));
    assertTrue(gc2.geometryN(3).geometryType().equals("MultiPolygon"));
    assertTrue(gc2.geometryN(4).geometryType().equals("MultiLineString"));
    assertTrue(gc2.geometryN(5).geometryType().equals("MultiPoint"));

    ByteBuffer wkbBuffer = g.asBinary();
    g = OGCGeometry.fromBinary(wkbBuffer);

    assertTrue(g.geometryType().equals("GeometryCollection"));
    gc = (OGCConcreteGeometryCollection) g;
    assertTrue(gc.numGeometries() == 7);
    assertTrue(gc.geometryN(0).geometryType().equals("Polygon"));
    assertTrue(gc.geometryN(1).geometryType().equals("Point"));
    assertTrue(gc.geometryN(2).geometryType().equals("GeometryCollection"));
    assertTrue(gc.geometryN(3).geometryType().equals("LineString"));
    assertTrue(gc.geometryN(4).geometryType().equals("GeometryCollection"));
    assertTrue(gc.geometryN(5).geometryType().equals("MultiPolygon"));
    assertTrue(gc.geometryN(6).geometryType().equals("MultiLineString"));

    gc2 = (OGCConcreteGeometryCollection) gc.geometryN(4);
    assertTrue(gc2.numGeometries() == 6);
    assertTrue(gc2.geometryN(0).geometryType().equals("Polygon"));
    assertTrue(gc2.geometryN(1).geometryType().equals("Point"));
    assertTrue(gc2.geometryN(2).geometryType().equals("LineString"));
    assertTrue(gc2.geometryN(3).geometryType().equals("MultiPolygon"));
    assertTrue(gc2.geometryN(4).geometryType().equals("MultiLineString"));
    assertTrue(gc2.geometryN(5).geometryType().equals("MultiPoint"));

    String wktString = g.asText();
    assertTrue(wktString
        .equals("GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), GEOMETRYCOLLECTION EMPTY, LINESTRING EMPTY, GEOMETRYCOLLECTION (POLYGON EMPTY, POINT (1 1), LINESTRING EMPTY, MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY, MULTIPOINT EMPTY), MULTIPOLYGON EMPTY, MULTILINESTRING EMPTY)"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.