Java Code Examples for mil.nga.sf.Polygon#addRing()
The following examples show how to use
mil.nga.sf.Polygon#addRing() .
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: GeoPackagePerformance.java From geopackage-android with MIT License | 6 votes |
private static Geometry createGeometry() { Polygon polygon = new Polygon(); LineString ring = new LineString(); ring.addPoint(new Point(-104.802246, 39.720343)); ring.addPoint(new Point(-104.802246, 39.719753)); ring.addPoint(new Point(-104.802183, 39.719754)); ring.addPoint(new Point(-104.802184, 39.719719)); ring.addPoint(new Point(-104.802138, 39.719694)); ring.addPoint(new Point(-104.802097, 39.719691)); ring.addPoint(new Point(-104.802096, 39.719648)); ring.addPoint(new Point(-104.801646, 39.719648)); ring.addPoint(new Point(-104.801644, 39.719722)); ring.addPoint(new Point(-104.801550, 39.719723)); ring.addPoint(new Point(-104.801549, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720341)); ring.addPoint(new Point(-104.802246, 39.720343)); polygon.addRing(ring); return polygon; }
Example 2
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 6 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example 3
Source File: GeoPackagePerformance.java From geopackage-java with MIT License | 6 votes |
private static Geometry createGeometry() { Polygon polygon = new Polygon(); LineString ring = new LineString(); ring.addPoint(new Point(-104.802246, 39.720343)); ring.addPoint(new Point(-104.802246, 39.719753)); ring.addPoint(new Point(-104.802183, 39.719754)); ring.addPoint(new Point(-104.802184, 39.719719)); ring.addPoint(new Point(-104.802138, 39.719694)); ring.addPoint(new Point(-104.802097, 39.719691)); ring.addPoint(new Point(-104.802096, 39.719648)); ring.addPoint(new Point(-104.801646, 39.719648)); ring.addPoint(new Point(-104.801644, 39.719722)); ring.addPoint(new Point(-104.801550, 39.719723)); ring.addPoint(new Point(-104.801549, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720207)); ring.addPoint(new Point(-104.801648, 39.720341)); ring.addPoint(new Point(-104.802246, 39.720343)); polygon.addRing(ring); return polygon; }
Example 4
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 5 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example 5
Source File: GeoPackageExample.java From geopackage-android with MIT License | 4 votes |
private static void createFeatures2(GeoPackage geoPackage, SpatialReferenceSystem srs) throws SQLException { List<Geometry> points = new ArrayList<>(); List<String> pointNames = new ArrayList<>(); points.add(new Point(-77.196736, 38.753370)); pointNames.add("NGA"); createFeatures(geoPackage, srs, "point2", GeometryType.POINT, points, pointNames); List<Geometry> lines = new ArrayList<>(); List<String> lineNames = new ArrayList<>(); LineString line1 = new LineString(); line1.addPoint(new Point(-77.196650, 38.756501)); line1.addPoint(new Point(-77.196414, 38.755979)); line1.addPoint(new Point(-77.195518, 38.755208)); line1.addPoint(new Point(-77.195303, 38.755272)); line1.addPoint(new Point(-77.195351, 38.755459)); line1.addPoint(new Point(-77.195863, 38.755697)); line1.addPoint(new Point(-77.196328, 38.756069)); line1.addPoint(new Point(-77.196568, 38.756526)); lines.add(line1); lineNames.add("NGA"); createFeatures(geoPackage, srs, "line2", GeometryType.LINESTRING, lines, lineNames); List<Geometry> polygons = new ArrayList<>(); List<String> polygonNames = new ArrayList<>(); Polygon polygon1 = new Polygon(); LineString ring1 = new LineString(); ring1.addPoint(new Point(-77.195299, 38.755159)); ring1.addPoint(new Point(-77.195203, 38.755080)); ring1.addPoint(new Point(-77.195410, 38.754930)); ring1.addPoint(new Point(-77.195350, 38.754884)); ring1.addPoint(new Point(-77.195228, 38.754966)); ring1.addPoint(new Point(-77.195135, 38.754889)); ring1.addPoint(new Point(-77.195048, 38.754956)); ring1.addPoint(new Point(-77.194986, 38.754906)); ring1.addPoint(new Point(-77.194897, 38.754976)); ring1.addPoint(new Point(-77.194953, 38.755025)); ring1.addPoint(new Point(-77.194763, 38.755173)); ring1.addPoint(new Point(-77.194827, 38.755224)); ring1.addPoint(new Point(-77.195012, 38.755082)); ring1.addPoint(new Point(-77.195041, 38.755104)); ring1.addPoint(new Point(-77.195028, 38.755116)); ring1.addPoint(new Point(-77.195090, 38.755167)); ring1.addPoint(new Point(-77.195106, 38.755154)); ring1.addPoint(new Point(-77.195205, 38.755233)); ring1.addPoint(new Point(-77.195299, 38.755159)); polygon1.addRing(ring1); polygons.add(polygon1); polygonNames.add("NGA Visitor Center"); createFeatures(geoPackage, srs, "polygon2", GeometryType.POLYGON, polygons, polygonNames); List<Geometry> geometries = new ArrayList<>(); List<String> geometryNames = new ArrayList<>(); geometries.addAll(points); geometryNames.addAll(pointNames); geometries.addAll(lines); geometryNames.addAll(lineNames); geometries.addAll(polygons); geometryNames.addAll(polygonNames); createFeatures(geoPackage, srs, "geometry2", GeometryType.GEOMETRY, geometries, geometryNames); }
Example 6
Source File: GeoPackageExample.java From geopackage-android with MIT License | 4 votes |
private static void createNonLinearGeometryTypesExtension( GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); SpatialReferenceSystem srs = srsDao.getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, (long) ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); GeometryExtensions extensions = new GeometryExtensions(geoPackage); String tableName = "non_linear_geometries"; List<Geometry> geometries = new ArrayList<>(); List<String> geometryNames = new ArrayList<>(); CircularString circularString = new CircularString(); circularString.addPoint(new Point(-122.358, 47.653)); circularString.addPoint(new Point(-122.348, 47.649)); circularString.addPoint(new Point(-122.348, 47.658)); circularString.addPoint(new Point(-122.358, 47.658)); circularString.addPoint(new Point(-122.358, 47.653)); for (int i = GeometryCodes.getCode(GeometryType.CIRCULARSTRING); i <= GeometryCodes.getCode(GeometryType.SURFACE); i++) { GeometryType geometryType = GeometryCodes.getGeometryType(i); extensions.getOrCreate(tableName, GEOMETRY_COLUMN, geometryType); Geometry geometry = null; String name = geometryType.getName().toLowerCase(); switch (geometryType) { case CIRCULARSTRING: geometry = circularString; break; case COMPOUNDCURVE: CompoundCurve compoundCurve = new CompoundCurve(); compoundCurve.addLineString(circularString); geometry = compoundCurve; break; case CURVEPOLYGON: CurvePolygon<CircularString> curvePolygon = new CurvePolygon<>(); curvePolygon.addRing(circularString); geometry = curvePolygon; break; case MULTICURVE: MultiLineString multiCurve = new MultiLineString(); multiCurve.addLineString(circularString); geometry = multiCurve; break; case MULTISURFACE: MultiPolygon multiSurface = new MultiPolygon(); Polygon polygon = new Polygon(); polygon.addRing(circularString); multiSurface.addPolygon(polygon); geometry = multiSurface; break; case CURVE: CompoundCurve curve = new CompoundCurve(); curve.addLineString(circularString); geometry = curve; break; case SURFACE: CurvePolygon<CircularString> surface = new CurvePolygon<>(); surface.addRing(circularString); geometry = surface; break; default: throw new GeoPackageException("Unexpected Geometry Type: " + geometryType); } geometries.add(geometry); geometryNames.add(name); } createFeatures(geoPackage, srs, tableName, GeometryType.GEOMETRY, geometries, geometryNames); }
Example 7
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createFeatures2(GeoPackage geoPackage, SpatialReferenceSystem srs) throws SQLException { List<Geometry> points = new ArrayList<>(); List<String> pointNames = new ArrayList<>(); points.add(new Point(-77.196736, 38.753370)); pointNames.add("NGA"); createFeatures(geoPackage, srs, "point2", GeometryType.POINT, points, pointNames); List<Geometry> lines = new ArrayList<>(); List<String> lineNames = new ArrayList<>(); LineString line1 = new LineString(); line1.addPoint(new Point(-77.196650, 38.756501)); line1.addPoint(new Point(-77.196414, 38.755979)); line1.addPoint(new Point(-77.195518, 38.755208)); line1.addPoint(new Point(-77.195303, 38.755272)); line1.addPoint(new Point(-77.195351, 38.755459)); line1.addPoint(new Point(-77.195863, 38.755697)); line1.addPoint(new Point(-77.196328, 38.756069)); line1.addPoint(new Point(-77.196568, 38.756526)); lines.add(line1); lineNames.add("NGA"); createFeatures(geoPackage, srs, "line2", GeometryType.LINESTRING, lines, lineNames); List<Geometry> polygons = new ArrayList<>(); List<String> polygonNames = new ArrayList<>(); Polygon polygon1 = new Polygon(); LineString ring1 = new LineString(); ring1.addPoint(new Point(-77.195299, 38.755159)); ring1.addPoint(new Point(-77.195203, 38.755080)); ring1.addPoint(new Point(-77.195410, 38.754930)); ring1.addPoint(new Point(-77.195350, 38.754884)); ring1.addPoint(new Point(-77.195228, 38.754966)); ring1.addPoint(new Point(-77.195135, 38.754889)); ring1.addPoint(new Point(-77.195048, 38.754956)); ring1.addPoint(new Point(-77.194986, 38.754906)); ring1.addPoint(new Point(-77.194897, 38.754976)); ring1.addPoint(new Point(-77.194953, 38.755025)); ring1.addPoint(new Point(-77.194763, 38.755173)); ring1.addPoint(new Point(-77.194827, 38.755224)); ring1.addPoint(new Point(-77.195012, 38.755082)); ring1.addPoint(new Point(-77.195041, 38.755104)); ring1.addPoint(new Point(-77.195028, 38.755116)); ring1.addPoint(new Point(-77.195090, 38.755167)); ring1.addPoint(new Point(-77.195106, 38.755154)); ring1.addPoint(new Point(-77.195205, 38.755233)); ring1.addPoint(new Point(-77.195299, 38.755159)); polygon1.addRing(ring1); polygons.add(polygon1); polygonNames.add("NGA Visitor Center"); createFeatures(geoPackage, srs, "polygon2", GeometryType.POLYGON, polygons, polygonNames); List<Geometry> geometries = new ArrayList<>(); List<String> geometryNames = new ArrayList<>(); geometries.addAll(points); geometryNames.addAll(pointNames); geometries.addAll(lines); geometryNames.addAll(lineNames); geometries.addAll(polygons); geometryNames.addAll(polygonNames); createFeatures(geoPackage, srs, "geometry2", GeometryType.GEOMETRY, geometries, geometryNames); }
Example 8
Source File: GeoPackageExample.java From geopackage-java with MIT License | 4 votes |
private static void createNonLinearGeometryTypesExtension( GeoPackage geoPackage) throws SQLException { SpatialReferenceSystemDao srsDao = geoPackage .getSpatialReferenceSystemDao(); SpatialReferenceSystem srs = srsDao.getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, (long) ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); GeometryExtensions extensions = new GeometryExtensions(geoPackage); String tableName = "non_linear_geometries"; List<Geometry> geometries = new ArrayList<>(); List<String> geometryNames = new ArrayList<>(); CircularString circularString = new CircularString(); circularString.addPoint(new Point(-122.358, 47.653)); circularString.addPoint(new Point(-122.348, 47.649)); circularString.addPoint(new Point(-122.348, 47.658)); circularString.addPoint(new Point(-122.358, 47.658)); circularString.addPoint(new Point(-122.358, 47.653)); for (int i = GeometryCodes .getCode(GeometryType.CIRCULARSTRING); i <= GeometryCodes .getCode(GeometryType.SURFACE); i++) { GeometryType geometryType = GeometryCodes.getGeometryType(i); extensions.getOrCreate(tableName, GEOMETRY_COLUMN, geometryType); Geometry geometry = null; String name = geometryType.getName().toLowerCase(); switch (geometryType) { case CIRCULARSTRING: geometry = circularString; break; case COMPOUNDCURVE: CompoundCurve compoundCurve = new CompoundCurve(); compoundCurve.addLineString(circularString); geometry = compoundCurve; break; case CURVEPOLYGON: CurvePolygon<CircularString> curvePolygon = new CurvePolygon<>(); curvePolygon.addRing(circularString); geometry = curvePolygon; break; case MULTICURVE: MultiLineString multiCurve = new MultiLineString(); multiCurve.addLineString(circularString); geometry = multiCurve; break; case MULTISURFACE: MultiPolygon multiSurface = new MultiPolygon(); Polygon polygon = new Polygon(); polygon.addRing(circularString); multiSurface.addPolygon(polygon); geometry = multiSurface; break; case CURVE: CompoundCurve curve = new CompoundCurve(); curve.addLineString(circularString); geometry = curve; break; case SURFACE: CurvePolygon<CircularString> surface = new CurvePolygon<>(); surface.addRing(circularString); geometry = surface; break; default: throw new GeoPackageException( "Unexpected Geometry Type: " + geometryType); } geometries.add(geometry); geometryNames.add(name); } createFeatures(geoPackage, srs, tableName, GeometryType.GEOMETRY, geometries, geometryNames); }
Example 9
Source File: TestUtils.java From geopackage-android-map with MIT License | 3 votes |
/** * Create a random polygon * * @param hasZ * @param hasM * @return */ public static Polygon createPolygon(boolean hasZ, boolean hasM) { Polygon polygon = new Polygon(hasZ, hasM); int numLineStrings = 1 + ((int) (Math.random() * 5)); for (int i = 0; i < numLineStrings; i++) { polygon.addRing(createLineString(hasZ, hasM, true)); } return polygon; }
Example 10
Source File: TestUtils.java From geopackage-android with MIT License | 3 votes |
/** * Create a random polygon * * @param hasZ * @param hasM * @return */ public static Polygon createPolygon(boolean hasZ, boolean hasM) { Polygon polygon = new Polygon(hasZ, hasM); int numLineStrings = 1 + ((int) (Math.random() * 5)); for (int i = 0; i < numLineStrings; i++) { polygon.addRing(createLineString(hasZ, hasM, true)); } return polygon; }
Example 11
Source File: TestUtils.java From geopackage-java with MIT License | 3 votes |
/** * Create a random polygon * * @param hasZ * @param hasM * @return polygon */ public static Polygon createPolygon(boolean hasZ, boolean hasM) { Polygon polygon = new Polygon(hasZ, hasM); int numLineStrings = 1 + ((int) (Math.random() * 5)); for (int i = 0; i < numLineStrings; i++) { polygon.addRing(createLineString(hasZ, hasM, true)); } return polygon; }