com.esri.core.geometry.Polygon Java Examples
The following examples show how to use
com.esri.core.geometry.Polygon.
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: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #2
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #3
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #4
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 #5
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(GeometryType t) { String type = null; if(t == GeometryType.Point) { type = "esriGeometryPoint"; } else if (t==GeometryType.Polyline) { type = "esriGeometryPolyline"; } else if (t==GeometryType.Polygon) { type = "esriGeometryPolygon"; } else if (t==GeometryType.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #6
Source File: GeoFunctions.java From presto with Apache License 2.0 | 6 votes |
private static Point getPolygonSansHolesCentroid(Polygon polygon) { int pointCount = polygon.getPointCount(); double xSum = 0; double ySum = 0; double signedArea = 0; for (int i = 0; i < pointCount; i++) { Point current = polygon.getPoint(i); Point next = polygon.getPoint((i + 1) % polygon.getPointCount()); double ladder = current.getX() * next.getY() - next.getX() * current.getY(); xSum += (current.getX() + next.getX()) * ladder; ySum += (current.getY() + next.getY()) * ladder; signedArea += ladder / 2; } return new Point(xSum / (signedArea * 6), ySum / (signedArea * 6)); }
Example #7
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #8
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #9
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #10
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #11
Source File: EllipseProcessor.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private MapGeometry constructEllipse(double x, double y, double majorAxis, double minorAxis, double rotation, int wkidin, int wkidbuffer, int wkidout) { Point center = new Point(); center.setX(x); center.setY(y); SpatialReference srIn = SpatialReference.create(wkidin); SpatialReference srBuffer = SpatialReference.create(wkidbuffer); SpatialReference srOut = SpatialReference.create(wkidout); UnitConverter uc = new UnitConverter(); majorAxis = uc.Convert(majorAxis, units, srBuffer); minorAxis = uc.Convert(minorAxis, units, srBuffer); Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer); GeometryUtility geoutil = new GeometryUtility(); Polygon ellipse = geoutil.GenerateEllipse(centerProj, majorAxis, minorAxis, rotation); Geometry ellipseOut = GeometryEngine.project(ellipse, srBuffer, srOut); MapGeometry mapGeo = new MapGeometry(ellipseOut, srOut); return mapGeo; }
Example #12
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #13
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #14
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #15
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #16
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 #17
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #18
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #19
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #20
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
private static String _parseGeometryType(Geometry.Type t) { String type = null; if(t == Geometry.Type.Point) { type = "esriGeometryPoint"; } else if (t==Geometry.Type.Polyline) { type = "esriGeometryPolyline"; } else if (t==Geometry.Type.Polygon) { type = "esriGeometryPolygon"; } else if (t==Geometry.Type.MultiPoint) { type = "esriGeometryMultiPoint"; } return type; }
Example #21
Source File: GeometryUtility.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 6 votes |
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra) { Polygon ellipse = new Polygon(); for (int i = 0; i < 360; ++i) { double theta = Math.toRadians(i); Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta); p = GeometryUtility.Rotate(center, p, ra); if (i == 0) { ellipse.startPath(p); } else{ ellipse.lineTo(p); } } ellipse.closeAllPaths(); return ellipse; }
Example #22
Source File: PostGISReaderTest.java From barefoot with Apache License 2.0 | 6 votes |
@Test public void testPolygon() throws IOException, JSONException { Properties properties = new Properties(); properties.load(new FileInputStream("config/oberbayern.properties")); RoadReader reader = Loader.reader(properties); Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt( "POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))", WktImportFlags.wktImportDefaults, Type.Polygon); BaseRoad road = null; reader.open(polygon, null); int count = 0; while ((road = reader.next()) != null) { assertTrue( GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326)) || GeometryEngine.contains(polygon, road.geometry(), SpatialReference.create(4326))); count += 1; } reader.close(); assertTrue(count > 0); }
Example #23
Source File: PostGISReaderTest.java From barefoot with Apache License 2.0 | 6 votes |
@Test public void testExclusion() throws IOException, JSONException { Properties properties = new Properties(); properties.load(new FileInputStream("config/oberbayern.properties")); RoadReader reader = Loader.reader(properties); Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt( "POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))", WktImportFlags.wktImportDefaults, Type.Polygon); HashSet<Short> exclusion = new HashSet<>(Arrays.asList((short) 117)); BaseRoad road = null; reader.open(polygon, exclusion); int count = 0; while ((road = reader.next()) != null) { assertTrue( GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326)) || GeometryEngine.contains(polygon, road.geometry(), SpatialReference.create(4326))); assertTrue(!exclusion.contains(road.type())); count += 1; } reader.close(); assertTrue(count > 0); }
Example #24
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 #25
Source File: LocalGeofence.java From arcgis-runtime-demos-android with Apache License 2.0 | 6 votes |
public static void setFence(Polygon newFence, SpatialReference fenceSpatialReference) { // Keep the original geometries. mFenceSr = fenceSpatialReference; mFence = newFence; // Work with the fence in WGS84, as that's what the location updates will be in. // Note that transformations could be used here to increase accuracy. if ( mFenceSr.getID() != mWgs84Sr.getID() ) { Geometry densified = GeometryEngine.geodesicDensifyGeometry(mFence, mFenceSr, 20, null); mFenceWgs84 = (Polygon)GeometryEngine.project(densified, mFenceSr, mWgs84Sr); } else { mFenceWgs84 = mFence; } }
Example #26
Source File: MainActivity.java From arcgis-runtime-demos-android with Apache License 2.0 | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Receive results from either map or list geofence selection - both give // exactly the same information. if (data == null) return; if (resultCode == RESULT_OK) { long fenceOid = data.getLongExtra(GEOFENCE_FEATURE_OBJECTID_EXTRA_ID, -1); Feature fenceFeature = getFeatureFromGeodatabase(fenceOid); if (fenceFeature != null) { Polygon fencePolygon = (Polygon)fenceFeature.getGeometry(); String fenceName = fenceFeature.getAttributeValue(FENCE_NAME_FIELD).toString(); LocalGeofence.setFence(fencePolygon, mGdbFeatureTable.getSpatialReference()); LocalGeofence.setFeatureName(fenceName); LocalGeofence.setFeatureOid(fenceOid); mFenceNameTextView.setText(fenceName); } } }
Example #27
Source File: LocalGeofence.java From arcgis-runtime-demos-android with Apache License 2.0 | 6 votes |
public static void setFence(Polygon newFence, SpatialReference fenceSpatialReference) { // Keep the original geometries. mFenceSr = fenceSpatialReference; mFence = newFence; // Work with the fence in WGS84, as that's what the location updates will be in. // Note that transformations could be used here to increase accuracy. if ( mFenceSr.getID() != mWgs84Sr.getID() ) { Geometry densified = GeometryEngine.geodesicDensifyGeometry(mFence, mFenceSr, 20, null); mFenceWgs84 = (Polygon)GeometryEngine.project(densified, mFenceSr, mWgs84Sr); } else { mFenceWgs84 = mFence; } }
Example #28
Source File: TestStGeomFromShape.java From spatial-framework-for-hadoop with Apache License 2.0 | 6 votes |
@Test public void testGeomFromPolygonShape() throws UDFArgumentException { Polygon polygon = createPolygon(); byte[] esriShape = GeometryEngine.geometryToEsriShape(polygon); assertNotNull("The shape must not be null!", esriShape); BytesWritable shapeAsWritable = new BytesWritable(esriShape); assertNotNull("The shape writable must not be null!", shapeAsWritable); final int wkid = 4326; ST_GeomFromShape fromShape = new ST_GeomFromShape(); BytesWritable geometryAsWritable = fromShape.evaluate(shapeAsWritable, wkid); assertNotNull("The geometry writable must not be null!", geometryAsWritable); OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryAsWritable); assertNotNull("The OGC geometry must not be null!", ogcGeometry); Geometry esriGeometry = ogcGeometry.getEsriGeometry(); assertNotNull("The Esri geometry must not be null!", esriGeometry); assertTrue("The geometries are different!", GeometryEngine.equals(polygon, esriGeometry, SpatialReference.create(wkid))); }
Example #29
Source File: GeoJsonParser.java From arcgis-runtime-demo-java with Apache License 2.0 | 6 votes |
/** * Example: * [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] * @param parser * @return a polygon * @throws JsonParseException * @throws IOException */ private Polygon parseSimplePolygonCoordinates(JsonNode node) { Polygon g = new Polygon(); boolean first = true; ArrayNode points = (ArrayNode) node; for (JsonNode point : points) { Point p = parsePointCoordinates(point); if (first) { g.startPath(p); first = false; } else { g.lineTo(p); } } g.closeAllPaths(); return g; }
Example #30
Source File: EnvelopeOperationTest.java From sis with Apache License 2.0 | 6 votes |
/** * Creates a feature type with a bounds operation. * The feature contains the following properties: * * <ul> * <li>{@code name} as a {@link String}</li> * <li>{@code classes} as a {@link Polygon}</li> * <li>{@code climbing wall} as a {@link Point}</li> * <li>{@code gymnasium} as a {@link Polygon}</li> * <li>{@code sis:geometry} as a link to the default geometry</li> * <li>{@code bounds} as the feature envelope attribute.</li> * </ul> * * @param defaultGeometry 1 for using "classes" as the default geometry, or 3 for "gymnasium". * @return the feature for a school. */ private static DefaultFeatureType school(final int defaultGeometry) throws FactoryException { final DefaultAttributeType<?> standardCRS = new DefaultAttributeType<>( name(AttributeConvention.CRS_CHARACTERISTIC), CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84_φλ); final DefaultAttributeType<?> normalizedCRS = new DefaultAttributeType<>( name(AttributeConvention.CRS_CHARACTERISTIC), CoordinateReferenceSystem.class, 1, 1, HardCodedCRS.WGS84); final AbstractIdentifiedType[] attributes = { new DefaultAttributeType<>(name("name"), String.class, 1, 1, null), new DefaultAttributeType<>(name("classes"), Polygon.class, 1, 1, null, standardCRS), new DefaultAttributeType<>(name("climbing wall"), Point.class, 1, 1, null, standardCRS), new DefaultAttributeType<>(name("gymnasium"), Polygon.class, 1, 1, null, normalizedCRS), null, null }; attributes[4] = FeatureOperations.link(name(AttributeConvention.GEOMETRY_PROPERTY), attributes[defaultGeometry]); attributes[5] = FeatureOperations.envelope(name("bounds"), null, attributes); return new DefaultFeatureType(name("school"), false, null, attributes); }