Java Code Examples for mil.nga.sf.LineString#addPoint()

The following examples show how to use mil.nga.sf.LineString#addPoint() . These examples are extracted from open source projects. 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 Project: geopackage-android-map   File: TestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Create a random line string
 *
 * @param hasZ
 * @param hasM
 * @param ring
 * @return
 */
public static LineString createLineString(boolean hasZ, boolean hasM,
                                          boolean ring) {

    LineString lineString = new LineString(hasZ, hasM);

    int numPoints = 2 + ((int) (Math.random() * 9));

    for (int i = 0; i < numPoints; i++) {
        lineString.addPoint(createPoint(hasZ, hasM));
    }

    if (ring) {
        lineString.addPoint(lineString.getPoints().get(0));
    }

    return lineString;
}
 
Example 2
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 3
Source Project: geopackage-android   File: TestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Create a random line string
 *
 * @param hasZ
 * @param hasM
 * @param ring
 * @return
 */
public static LineString createLineString(boolean hasZ, boolean hasM,
                                          boolean ring) {

    LineString lineString = new LineString(hasZ, hasM);

    int numPoints = 2 + ((int) (Math.random() * 9));

    for (int i = 0; i < numPoints; i++) {
        lineString.addPoint(createPoint(hasZ, hasM));
    }

    if (ring) {
        lineString.addPoint(lineString.getPoints().get(0));
    }

    return lineString;
}
 
Example 4
Source Project: geopackage-java   File: GeoPackagePerformance.java    License: MIT License 6 votes vote down vote up
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 5
Source Project: geopackage-java   File: TestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Create a random line string
 * 
 * @param hasZ
 * @param hasM
 * @param ring
 * @return line string
 */
public static LineString createLineString(boolean hasZ, boolean hasM,
		boolean ring) {

	LineString lineString = new LineString(hasZ, hasM);

	int numPoints = 2 + ((int) (Math.random() * 9));

	for (int i = 0; i < numPoints; i++) {
		lineString.addPoint(createPoint(hasZ, hasM));
	}

	if (ring) {
		lineString.addPoint(lineString.getPoints().get(0));
	}

	return lineString;
}
 
Example 6
/**
 * Convert a list of {@link LatLng} to a {@link LineString}
 *
 * @param lineString line string
 * @param latLngs    lat lngs
 */
public void populateLineString(LineString lineString, List<LatLng> latLngs) {

    for (LatLng latLng : latLngs) {
        Point point = toPoint(latLng, lineString.hasZ(), lineString.hasM());
        lineString.addPoint(point);
    }
}
 
Example 7
Source Project: geopackage-android   File: FeatureTileUtils.java    License: MIT License 5 votes vote down vote up
private static LineString getLineString(double[][] points) {
    LineString lineString = new LineString(false, false);
    for (int i = 0; i < points.length; i++) {
        Point point = new Point(false, false, points[i][0], points[i][1]);
        lineString.addPoint(point);
    }
    return lineString;
}
 
Example 8
Source Project: geopackage-java   File: FeatureTileUtils.java    License: MIT License 5 votes vote down vote up
private static LineString getLineString(double[][] points) {
	LineString lineString = new LineString(false, false);
	for (int i = 0; i < points.length; i++) {
		Point point = new Point(false, false, points[i][0], points[i][1]);
		lineString.addPoint(point);
	}
	return lineString;
}
 
Example 9
Source Project: geopackage-android   File: GeoPackageExample.java    License: MIT License 4 votes vote down vote up
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 10
Source Project: geopackage-java   File: GeoPackageExample.java    License: MIT License 4 votes vote down vote up
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);

}