本文整理汇总了Java中mil.nga.wkb.geom.Polygon.addRing方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.addRing方法的具体用法?Java Polygon.addRing怎么用?Java Polygon.addRing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.wkb.geom.Polygon
的用法示例。
在下文中一共展示了Polygon.addRing方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
private static Polygon createPolygon() {
Polygon polygon = new Polygon();
LineString lineString = new LineString();
lineString.addPoint(createPoint(-180.0, 45.0, 90.0, 45.0));
lineString.addPoint(createPoint(-180.0, -90.0, 90.0, 45.0));
lineString.addPoint(createPoint(90.0, -90.0, 90.0, 45.0));
lineString.addPoint(createPoint(90.0, 45.0, 90.0, 45.0));
polygon.addRing(lineString);
LineString holeLineString = new LineString();
holeLineString.addPoint(createPoint(-90.0, 0.0, 90.0, 45.0));
holeLineString.addPoint(createPoint(-90.0, -45.0, 90.0, 45.0));
holeLineString.addPoint(createPoint(0.0, -45.0, 90.0, 45.0));
holeLineString.addPoint(createPoint(0.0, 0.0, 90.0, 45.0));
polygon.addRing(holeLineString);
return polygon;
}
示例2: insertPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
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);
}
示例3: transform
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
/**
* Transform the projected polygon
*
* @param polygon
* @return projected polygon
*/
public Polygon transform(Polygon polygon) {
Polygon to = new Polygon(polygon.hasZ(), polygon.hasM());
for (LineString ring : polygon.getRings()) {
LineString toRing = transform(ring);
to.addRing(toRing);
}
return to;
}
示例4: insertPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
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);
}
示例5: testPolygonCentroidWithAndWithoutHole
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
@Test
public void testPolygonCentroidWithAndWithoutHole() throws IOException {
Polygon polygon = new Polygon();
LineString lineString = new LineString();
lineString.addPoint(new Point(-90, 45));
lineString.addPoint(new Point(-90, -45));
lineString.addPoint(new Point(90, -45));
lineString.addPoint(new Point(90, 45));
polygon.addRing(lineString);
TestCase.assertEquals(2, GeometryUtils.getDimension(polygon));
Point centroid = geometryCentroidTester(polygon);
TestCase.assertEquals(0.0, centroid.getX());
TestCase.assertEquals(0.0, centroid.getY());
LineString holeLineString = new LineString();
holeLineString.addPoint(new Point(0, 45));
holeLineString.addPoint(new Point(0, 0));
holeLineString.addPoint(new Point(90, 0));
holeLineString.addPoint(new Point(90, 45));
polygon.addRing(holeLineString);
TestCase.assertEquals(2, GeometryUtils.getDimension(polygon));
centroid = geometryCentroidTester(polygon);
TestCase.assertEquals(-15.0, centroid.getX());
TestCase.assertEquals(-7.5, centroid.getY());
}
示例6: onMapLongClick
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onMapLongClick(LatLng point) {
// Add a new point to a line or polygon
if (shapeType != GeometryType.POINT) {
if (!isRectangle) {
vibrator.vibrate(getResources().getInteger(
R.integer.shape_edit_add_long_click_vibrate));
if (shapeMarkers == null) {
Geometry geometry = null;
Point firstPoint = new Point(point.longitude, point.latitude);
switch (shapeType) {
case LINESTRING:
LineString lineString = new LineString();
lineString.addPoint(firstPoint);
geometry = lineString;
break;
case POLYGON:
Polygon polygon = new Polygon();
LineString ring = new LineString();
ring.addPoint(firstPoint);
polygon.addRing(ring);
geometry = polygon;
break;
default:
throw new IllegalArgumentException("Unsupported Geometry Type: " + shapeType);
}
addMapShape(geometry);
} else {
MarkerOptions markerOptions = getEditMarkerOptions();
markerOptions.position(point);
Marker marker = map.addMarker(markerOptions);
ShapeMarkers shape = null;
GoogleMapShape mapShape = shapeMarkers.getShape();
switch (mapShape.getShapeType()) {
case POLYLINE_MARKERS:
PolylineMarkers polylineMarkers = (PolylineMarkers) mapShape.getShape();
shape = polylineMarkers;
if (newDrawing) {
polylineMarkers.add(marker);
} else {
polylineMarkers.addNew(marker);
}
break;
case POLYGON_MARKERS:
PolygonMarkers polygonMarkers = (PolygonMarkers) shapeMarkers.getShape().getShape();
shape = polygonMarkers;
if (newDrawing) {
polygonMarkers.add(marker);
} else {
polygonMarkers.addNew(marker);
}
break;
default:
throw new IllegalArgumentException("Unsupported Shape Type: " + mapShape.getShapeType());
}
shapeMarkers.add(marker, shape);
selectShapeMarker(marker);
updateShape(marker);
}
} else if (!shapeMarkersValid() && selectedMarker != null) {
// Allow long click to expand a zero area rectangle
vibrator.vibrate(getResources().getInteger(
R.integer.shape_edit_add_long_click_vibrate));
selectedMarker.setPosition(point);
updateShape(selectedMarker);
updateHint();
}
}
}
示例7: readPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
/**
* Read a Polygon
*
* @param reader
* @param hasZ
* @param hasM
* @return polygon
*/
public static Polygon readPolygon(ByteReader reader, boolean hasZ,
boolean hasM) {
Polygon polygon = new Polygon(hasZ, hasM);
int numRings = reader.readInt();
for (int i = 0; i < numRings; i++) {
LineString ring = readLineString(reader, hasZ, hasM);
polygon.addRing(ring);
}
return polygon;
}
示例8: testCopyMinimizeAndNormalize
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
@Test
public void testCopyMinimizeAndNormalize() {
Polygon polygon = new Polygon();
LineString ring = new LineString();
double random = Math.random();
if (random < .5) {
ring.addPoint(createPoint(90.0, 0.0, 90.0, 90.0));
ring.addPoint(createPoint(90.0, -90.0, 90.0, 90.0));
ring.addPoint(createPoint(-180.0, -90.0, 89.0, 90.0));
ring.addPoint(createPoint(-180.0, 0.0, 89.0, 90.0));
} else {
ring.addPoint(createPoint(-180.0, 0.0, 89.0, 90.0));
ring.addPoint(createPoint(-180.0, -90.0, 89.0, 90.0));
ring.addPoint(createPoint(90.0, -90.0, 90.0, 90.0));
ring.addPoint(createPoint(90.0, 0.0, 90.0, 90.0));
}
polygon.addRing(ring);
Polygon polygon2 = (Polygon) polygon.copy();
GeometryUtils.minimizeGeometry(polygon2, 180.0);
Polygon polygon3 = (Polygon) polygon2.copy();
GeometryUtils.normalizeGeometry(polygon3, 180.0);
List<Point> points = ring.getPoints();
LineString ring2 = polygon2.getRings().get(0);
List<Point> points2 = ring2.getPoints();
LineString ring3 = polygon3.getRings().get(0);
List<Point> points3 = ring3.getPoints();
for (int i = 0; i < points.size(); i++) {
Point point = points.get(i);
Point point2 = points2.get(i);
Point point3 = points3.get(i);
TestCase.assertEquals(point.getY(), point2.getY(), .0000000001);
TestCase.assertEquals(point.getY(), point3.getY(), .0000000001);
TestCase.assertEquals(point.getX(), point3.getX(), .0000000001);
if (i < 2) {
TestCase.assertEquals(point.getX(), point2.getX(), .0000000001);
} else {
double point2Value = point2.getX();
if (random < .5) {
point2Value -= 360.0;
} else {
point2Value += 360.0;
}
TestCase.assertEquals(point.getX(), point2Value, .0000000001);
}
}
}
示例9: createPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
/**
* 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;
}
示例10: createPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
/**
* 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;
}
示例11: createPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
/**
* 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;
}
示例12: createPolygon
import mil.nga.wkb.geom.Polygon; //导入方法依赖的package包/类
/**
* Create a random polygon
*
* @param hasZ
* @param hasM
* @return
*/
public static Polygon createPolygon(boolean hasZ, boolean hasM) {
Polygon polygon = new Polygon(hasZ, hasM);
int num = 1 + ((int) (Math.random() * 5));
for (int i = 0; i < num; i++) {
polygon.addRing(createLineString(hasZ, hasM, true));
}
return polygon;
}