Java Code Examples for com.esri.core.geometry.Geometry#getType()
The following examples show how to use
com.esri.core.geometry.Geometry#getType() .
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 File: GeoFunctions.java From Bats with Apache License 2.0 | 6 votes |
/** Returns the OGC type of a geometry. */ private static Type type(Geometry g) { switch (g.getType()) { case Point: return Type.POINT; case Polyline: return Type.LINESTRING; case Polygon: return Type.POLYGON; case MultiPoint: return Type.MULTIPOINT; case Envelope: return Type.POLYGON; case Line: return Type.LINESTRING; case Unknown: return Type.Geometry; default: throw new AssertionError(g); } }
Example 2
Source File: GeoFunctions.java From Quicksql with MIT License | 6 votes |
/** Returns the OGC type of a geometry. */ private static Type type(Geometry g) { switch (g.getType()) { case Point: return Type.POINT; case Polyline: return Type.LINESTRING; case Polygon: return Type.POLYGON; case MultiPoint: return Type.MULTIPOINT; case Envelope: return Type.POLYGON; case Line: return Type.LINESTRING; case Unknown: return Type.Geometry; default: throw new AssertionError(g); } }
Example 3
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 6 votes |
/** Returns the OGC type of a geometry. */ private static Type type(Geometry g) { switch (g.getType()) { case Point: return Type.POINT; case Polyline: return Type.LINESTRING; case Polygon: return Type.POLYGON; case MultiPoint: return Type.MULTIPOINT; case Envelope: return Type.POLYGON; case Line: return Type.LINESTRING; case Unknown: return Type.Geometry; default: throw new AssertionError(g); } }
Example 4
Source File: GeometrySerde.java From presto with 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 5
Source File: Polygon2PtProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
@Override public GeoEvent process(GeoEvent ge) throws Exception { MapGeometry mapGeo = ge.getGeometry(); Geometry geo = mapGeo.getGeometry(); if(geo.getType()!=Geometry.Type.Polygon) return null; Point center = GeometryUtility.CenterOfMass((Polygon)geo); MapGeometry outMapGeo = new MapGeometry(center, mapGeo.getSpatialReference()); ge.setGeometry(outMapGeo); return ge; }
Example 6
Source File: ST_NumPoints.java From spatial-framework-for-hadoop with Apache License 2.0 | 5 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; } Geometry esriGeom = ogcGeometry.getEsriGeometry(); switch(esriGeom.getType()) { case Point: resultInt.set(esriGeom.isEmpty() ? 0 : 1); break; case MultiPoint: resultInt.set(((MultiPoint)(esriGeom)).getPointCount()); break; case Polygon: Polygon polygon = (Polygon)(esriGeom); resultInt.set(polygon.getPointCount() + polygon.getPathCount()); break; default: resultInt.set(((MultiPath)(esriGeom)).getPointCount()); break; } return resultInt; }
Example 7
Source File: ST_GeomFromShape.java From spatial-framework-for-hadoop with Apache License 2.0 | 5 votes |
public BytesWritable evaluate(BytesWritable shape, int wkid) throws UDFArgumentException { try { Geometry geometry = GeometryEngine.geometryFromEsriShape(shape.getBytes(), Geometry.Type.Unknown); switch (geometry.getType()) { case Point: return GeometryUtils.geometryToEsriShapeBytesWritable(geometry, wkid, OGCType.ST_POINT); case MultiPoint: return GeometryUtils.geometryToEsriShapeBytesWritable(geometry, wkid, OGCType.ST_MULTIPOINT); case Line: return GeometryUtils.geometryToEsriShapeBytesWritable(geometry, wkid, OGCType.ST_LINESTRING); case Polyline: return GeometryUtils.geometryToEsriShapeBytesWritable(geometry, wkid, OGCType.ST_MULTILINESTRING); case Envelope: return GeometryUtils.geometryToEsriShapeBytesWritable(geometry, wkid, OGCType.ST_POLYGON); case Polygon: return GeometryUtils.geometryToEsriShapeBytesWritable(geometry, wkid, OGCType.ST_MULTIPOLYGON); default: return GeometryUtils.geometryToEsriShapeBytesWritable(geometry, wkid, OGCType.UNKNOWN); } } catch (Exception e) { LogUtils.Log_ExceptionThrown(LOG, "geom-from-shape", e); return null; } }
Example 8
Source File: MGRSProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 4 votes |
@Override public GeoEvent process(GeoEvent evt) throws Exception { MapGeometry mapGeo = (MapGeometry) evt.getField(geofld); Geometry geo = mapGeo.getGeometry(); int wkid = mapGeo.getSpatialReference().getID(); if(wkid != 4326) { return null; } if(geo.getType() != Geometry.Type.Point) { return null; } Point pt = (Point)geo; double[] coords = {pt.getX(), pt.getY()}; PeGeogcs pegeocs = PeFactory.geogcs(4326); String[] mgrsvals = new String[1]; PeNotationMgrs.geog_to_mgrs(pegeocs, 1, coords, accuracy, false, mgrsvals); String mgrs = mgrsvals[0]; //LL ll = new LL(pt.getX(), pt.getY()); //ll.setAccuracy(accuracy); //MGRS2LatLongConverter converter = new MGRS2LatLongConverter(); //String mgrs = converter.LL2MRGS(ll); GeoEventDefinition edOut; GeoEventDefinition geoDef = evt.getGeoEventDefinition(); if((edOut=manager.searchGeoEventDefinition(newdef, getId()))==null) { edOut = geoDef.augment(fds); edOut.setOwner(getId()); edOut.setName(newdef); manager.addGeoEventDefinition(edOut); } GeoEventCreator geoEventCreator = messaging.createGeoEventCreator(); GeoEvent geOut = geoEventCreator.create(edOut.getGuid(), new Object[] { evt.getAllFields(), mgrs }); geOut.setProperty(GeoEventPropertyName.TYPE, "message"); geOut.setProperty(GeoEventPropertyName.OWNER_ID, getId()); geOut.setProperty(GeoEventPropertyName.OWNER_ID, definition.getUri()); return geOut; }
Example 9
Source File: ST_GeodesicLengthWGS84.java From spatial-framework-for-hadoop with Apache License 2.0 | 4 votes |
public DoubleWritable evaluate(BytesWritable geomref) { if (geomref == null || geomref.getLength() == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } int WGS84 = 4326; if (GeometryUtils.getWKID(geomref) != WGS84) { LogUtils.Log_SRIDMismatch(LOG, geomref, WGS84); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ LogUtils.Log_ArgumentsNull(LOG); return null; } Geometry esriGeom = ogcGeometry.getEsriGeometry(); switch(esriGeom.getType()) { case Point: case MultiPoint: resultDouble.set(0.); break; default: MultiPath lines = (MultiPath)(esriGeom); int nPath = lines.getPathCount(); double length = 0.; for (int ix = 0; ix < nPath; ix++) { int curPt = lines.getPathStart(ix); int pastPt = lines.getPathEnd(ix); Point fromPt = lines.getPoint(curPt); Point toPt = null; for (int vx = curPt+1; vx < pastPt; vx++) { toPt = lines.getPoint(vx); length += GeometryEngine.geodesicDistanceOnWGS84(fromPt, toPt); fromPt = toPt; } } resultDouble.set(length); break; } return resultDouble; }
Example 10
Source File: OGCGeometry.java From geometry-api-java with Apache License 2.0 | 4 votes |
public static OGCGeometry createFromEsriGeometry(Geometry geom, SpatialReference sr, boolean multiType) { if (geom == null) return null; Geometry.Type t = geom.getType(); if (t == Geometry.Type.Polygon) { if (!multiType && ((Polygon) geom).getExteriorRingCount() == 1) return new OGCPolygon((Polygon) geom, sr); else return new OGCMultiPolygon((Polygon) geom, sr); } if (t == Geometry.Type.Polyline) { if (!multiType && ((Polyline) geom).getPathCount() == 1) return new OGCLineString((Polyline) geom, 0, sr); else return new OGCMultiLineString((Polyline) geom, sr); } if (t == Geometry.Type.MultiPoint) { if (!multiType && ((MultiPoint) geom).getPointCount() <= 1) { if (geom.isEmpty()) return new OGCPoint(new Point(), sr); else return new OGCPoint(((MultiPoint) geom).getPoint(0), sr); } else return new OGCMultiPoint((MultiPoint) geom, sr); } if (t == Geometry.Type.Point) { if (!multiType) { return new OGCPoint((Point) geom, sr); } else { return new OGCMultiPoint((Point) geom, sr); } } if (t == Geometry.Type.Envelope) { Polygon p = new Polygon(); p.addEnvelope((Envelope) geom, false); return createFromEsriGeometry(p, sr, multiType); } throw new UnsupportedOperationException(); }