当前位置: 首页>>代码示例>>Java>>正文


Java Polygon.addRing方法代码示例

本文整理汇总了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;
	}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:20,代码来源:GeometryUtilsTest.java

示例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);
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:14,代码来源:FeatureTileUtils.java

示例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;
}
 
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:18,代码来源:GeometryProjectionTransform.java

示例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);
}
 
开发者ID:ngageoint,项目名称:geopackage-java,代码行数:15,代码来源:FeatureTileUtils.java

示例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());
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:31,代码来源:GeometryUtilsTest.java

示例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();
        }
    }
}
 
开发者ID:ngageoint,项目名称:mage-android,代码行数:76,代码来源:LocationEditActivity.java

示例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;
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:24,代码来源:WkbGeometryReader.java

示例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);
		}
	}

}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:55,代码来源:GeometryUtilsTest.java

示例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;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:20,代码来源:TestUtils.java

示例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;
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:20,代码来源:TestUtils.java

示例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;
}
 
开发者ID:ngageoint,项目名称:geopackage-java,代码行数:20,代码来源:TestUtils.java

示例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;
}
 
开发者ID:ngageoint,项目名称:geopackage-wkb-java,代码行数:20,代码来源:WKBTestUtils.java


注:本文中的mil.nga.wkb.geom.Polygon.addRing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。