Java Code Examples for com.esri.core.geometry.ogc.OGCMultiLineString
The following examples show how to use
com.esri.core.geometry.ogc.OGCMultiLineString. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spatial-framework-for-hadoop Source File: ST_Boundary.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable geomref) { if (geomref == null || geomref.getLength() == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ LogUtils.Log_ArgumentsNull(LOG); return null; } try { OGCGeometry boundGeom = ogcGeometry.boundary(); if (boundGeom.geometryType().equals("MultiLineString") && ((OGCMultiLineString)boundGeom).numGeometries() == 1) boundGeom = ((OGCMultiLineString)boundGeom).geometryN(0); // match ST_Boundary/SQL-RDBMS return GeometryUtils.geometryToEsriShapeBytesWritable(boundGeom); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_Boundary: " + e); return null; } }
Example 2
Source Project: geometry-api-java Source File: TestOGC.java License: Apache License 2.0 | 6 votes |
@Test public void testPolylineSimplifyIssueGithub52() throws Exception { String json = "{\"paths\":[[[2,0],[4,3],[5,1],[3.25,1.875],[1,3]]],\"spatialReference\":{\"wkid\":4326}}"; { OGCGeometry g = OGCGeometry.fromJson(json); assertTrue(g.geometryType().equals("LineString")); OGCGeometry simpleG = g.makeSimple();//make ogc simple assertTrue(simpleG.geometryType().equals("MultiLineString")); assertTrue(simpleG.isSimpleRelaxed());//geodatabase simple assertTrue(simpleG.isSimple());//ogc simple OGCMultiLineString mls =(OGCMultiLineString)simpleG; assertTrue(mls.numGeometries() == 4); OGCGeometry baseGeom = OGCGeometry.fromJson("{\"paths\":[[[2,0],[3.25,1.875]],[[3.25,1.875],[4,3],[5,1]],[[5,1],[3.25,1.875]],[[3.25,1.875],[1,3]]],\"spatialReference\":{\"wkid\":4326}}"); assertTrue(simpleG.equals(baseGeom)); } }
Example 3
Source Project: presto Source File: GeometrySerde.java License: Apache License 2.0 | 5 votes |
private static OGCGeometry createFromEsriGeometry(Geometry geometry, boolean multiType) { Geometry.Type type = geometry.getType(); switch (type) { case Polygon: { if (!multiType && ((Polygon) geometry).getExteriorRingCount() <= 1) { return new OGCPolygon((Polygon) geometry, null); } return new OGCMultiPolygon((Polygon) geometry, null); } case Polyline: { if (!multiType && ((Polyline) geometry).getPathCount() <= 1) { return new OGCLineString((Polyline) geometry, 0, null); } return new OGCMultiLineString((Polyline) geometry, null); } case MultiPoint: { if (!multiType && ((MultiPoint) geometry).getPointCount() <= 1) { if (geometry.isEmpty()) { return new OGCPoint(new Point(), null); } return new OGCPoint(((MultiPoint) geometry).getPoint(0), null); } return new OGCMultiPoint((MultiPoint) geometry, null); } case Point: { if (!multiType) { return new OGCPoint((Point) geometry, null); } return new OGCMultiPoint((Point) geometry, null); } case Envelope: { Polygon polygon = new Polygon(); polygon.addEnvelope((Envelope) geometry, false); return new OGCPolygon(polygon, null); } default: throw new IllegalArgumentException("Unexpected geometry type: " + type); } }
Example 4
Source Project: geometry-api-java Source File: TestEstimateMemorySize.java License: Apache License 2.0 | 5 votes |
@Test public void testInstanceSizes() { assertEquals(getInstanceSize(AttributeStreamOfFloat.class), SizeOf.SIZE_OF_ATTRIBUTE_STREAM_OF_FLOAT); assertEquals(getInstanceSize(AttributeStreamOfDbl.class), SizeOf.SIZE_OF_ATTRIBUTE_STREAM_OF_DBL); assertEquals(getInstanceSize(AttributeStreamOfInt8.class), SizeOf.SIZE_OF_ATTRIBUTE_STREAM_OF_INT8); assertEquals(getInstanceSize(AttributeStreamOfInt16.class), SizeOf.SIZE_OF_ATTRIBUTE_STREAM_OF_INT16); assertEquals(getInstanceSize(AttributeStreamOfInt32.class), SizeOf.SIZE_OF_ATTRIBUTE_STREAM_OF_INT32); assertEquals(getInstanceSize(AttributeStreamOfInt64.class), SizeOf.SIZE_OF_ATTRIBUTE_STREAM_OF_INT64); assertEquals(getInstanceSize(Envelope.class), SizeOf.SIZE_OF_ENVELOPE); assertEquals(getInstanceSize(Envelope2D.class), SizeOf.SIZE_OF_ENVELOPE2D); assertEquals(getInstanceSize(Line.class), SizeOf.SIZE_OF_LINE); assertEquals(getInstanceSize(MultiPath.class), SizeOf.SIZE_OF_MULTI_PATH); assertEquals(getInstanceSize(MultiPathImpl.class), SizeOf.SIZE_OF_MULTI_PATH_IMPL); assertEquals(getInstanceSize(MultiPoint.class), SizeOf.SIZE_OF_MULTI_POINT); assertEquals(getInstanceSize(MultiPointImpl.class), SizeOf.SIZE_OF_MULTI_POINT_IMPL); assertEquals(getInstanceSize(Point.class), SizeOf.SIZE_OF_POINT); assertEquals(getInstanceSize(Polygon.class), SizeOf.SIZE_OF_POLYGON); assertEquals(getInstanceSize(Polyline.class), SizeOf.SIZE_OF_POLYLINE); assertEquals(getInstanceSize(OGCConcreteGeometryCollection.class), SizeOf.SIZE_OF_OGC_CONCRETE_GEOMETRY_COLLECTION); assertEquals(getInstanceSize(OGCLineString.class), SizeOf.SIZE_OF_OGC_LINE_STRING); assertEquals(getInstanceSize(OGCMultiLineString.class), SizeOf.SIZE_OF_OGC_MULTI_LINE_STRING); assertEquals(getInstanceSize(OGCMultiPoint.class), SizeOf.SIZE_OF_OGC_MULTI_POINT); assertEquals(getInstanceSize(OGCMultiPolygon.class), SizeOf.SIZE_OF_OGC_MULTI_POLYGON); assertEquals(getInstanceSize(OGCPoint.class), SizeOf.SIZE_OF_OGC_POINT); assertEquals(getInstanceSize(OGCPolygon.class), SizeOf.SIZE_OF_OGC_POLYGON); assertEquals(getInstanceSize(RasterizedGeometry2DImpl.class), SizeOf.SIZE_OF_RASTERIZED_GEOMETRY_2D_IMPL); assertEquals(getInstanceSize(RasterizedGeometry2DImpl.ScanCallbackImpl.class), SizeOf.SIZE_OF_SCAN_CALLBACK_IMPL); assertEquals(getInstanceSize(Transformation2D.class), SizeOf.SIZE_OF_TRANSFORMATION_2D); assertEquals(getInstanceSize(SimpleRasterizer.class), SizeOf.SIZE_OF_SIMPLE_RASTERIZER); assertEquals(getInstanceSize(SimpleRasterizer.Edge.class), SizeOf.SIZE_OF_EDGE); assertEquals(getInstanceSize(QuadTreeImpl.class), SizeOf.SIZE_OF_QUAD_TREE_IMPL); assertEquals(getInstanceSize(QuadTreeImpl.Data.class), SizeOf.SIZE_OF_DATA); assertEquals(getInstanceSize(StridedIndexTypeCollection.class), SizeOf.SIZE_OF_STRIDED_INDEX_TYPE_COLLECTION); }
Example 5
Source Project: spatial-framework-for-hadoop Source File: ST_NumGeometries.java License: Apache License 2.0 | 4 votes |
public IntWritable evaluate(BytesWritable geomref) { if (geomref == null || geomref.getLength() == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ LogUtils.Log_ArgumentsNull(LOG); return null; } try { GeometryUtils.OGCType ogcType = GeometryUtils.getType(geomref); switch(ogcType) { case ST_POINT: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOINT, ogcType); return null; case ST_LINESTRING: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTILINESTRING, ogcType); return null; case ST_POLYGON: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOLYGON, ogcType); return null; case ST_MULTIPOINT: resultInt.set(((OGCMultiPoint)ogcGeometry).numGeometries()); break; case ST_MULTILINESTRING: resultInt.set(((OGCMultiLineString)ogcGeometry).numGeometries()); break; case ST_MULTIPOLYGON: resultInt.set(((OGCMultiPolygon)ogcGeometry).numGeometries()); break; } } catch (ClassCastException cce) { // single vs Multi geometry type resultInt.set(1); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_NumGeometries: " + e); return null; } return resultInt; }
Example 6
Source Project: spatial-framework-for-hadoop Source File: ST_GeometryN.java License: Apache License 2.0 | 4 votes |
public BytesWritable evaluate(BytesWritable geomref, IntWritable index) { if (geomref == null || geomref.getLength() == 0 || index == null) { LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ LogUtils.Log_ArgumentsNull(LOG); return null; } int idx = index.get() - 1; // 1-based UI, 0-based engine try { GeometryUtils.OGCType ogcType = GeometryUtils.getType(geomref); OGCGeometry ogcGeom = null; switch(ogcType) { case ST_POINT: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOINT, ogcType); return null; case ST_LINESTRING: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTILINESTRING, ogcType); return null; case ST_POLYGON: LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOLYGON, ogcType); return null; case ST_MULTIPOINT: ogcGeom = ((OGCMultiPoint)ogcGeometry).geometryN(idx); break; case ST_MULTILINESTRING: ogcGeom = ((OGCMultiLineString)ogcGeometry).geometryN(idx); break; case ST_MULTIPOLYGON: ogcGeom = ((OGCMultiPolygon)ogcGeometry).geometryN(idx); break; } return GeometryUtils.geometryToEsriShapeBytesWritable(ogcGeom); } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_GeometryN: " + e); return null; } }