Java Code Examples for mil.nga.sf.CompoundCurve#getLineStrings()

The following examples show how to use mil.nga.sf.CompoundCurve#getLineStrings() . 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: GoogleMapShapeConverterUtils.java    From geopackage-android-map with MIT License 6 votes vote down vote up
/**
 * Test the CompoundCurve conversion
 * 
 * @param converter
 * @param compoundCurve
 */
private static void convertCompoundCurve(GoogleMapShapeConverter converter,
		CompoundCurve compoundCurve) {

	MultiPolylineOptions polylines = converter.toPolylines(compoundCurve);
	TestCase.assertNotNull(polylines);
	TestCase.assertFalse(polylines.getPolylineOptions().isEmpty());

	List<LineString> lineStrings = compoundCurve.getLineStrings();
	compareLineStringsAndPolylines(converter, lineStrings,
			polylines.getPolylineOptions());

	CompoundCurve compoundCurve2 = converter
			.toCompoundCurveWithOptions(polylines);
	compareLineStrings(lineStrings, compoundCurve2.getLineStrings());
}
 
Example 2
Source File: GoogleMapShapeConverter.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Convert a {@link CompoundCurve} to a {@link MultiPolylineOptions}
 *
 * @param compoundCurve compound curve
 * @return multi polyline options
 */
public MultiPolylineOptions toPolylines(CompoundCurve compoundCurve) {

    MultiPolylineOptions polylines = new MultiPolylineOptions();

    for (LineString lineString : compoundCurve.getLineStrings()) {
        PolylineOptions polyline = toPolyline(lineString);
        polylines.add(polyline);
    }

    return polylines;
}
 
Example 3
Source File: DefaultFeatureTiles.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Draw the geometry on the canvas
 *
 * @param simplifyTolerance simplify tolerance in meters
 * @param boundingBox       bounding box
 * @param transform         projection transform
 * @param canvas            feature tile canvas
 * @param featureRow        feature row
 * @param geometry          feature geometry
 * @return true if drawn
 */
private boolean drawShape(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, FeatureTileCanvas canvas, FeatureRow featureRow, Geometry geometry) {

    boolean drawn = false;

    GeometryType geometryType = geometry.getGeometryType();
    FeatureStyle featureStyle = getFeatureStyle(featureRow, geometryType);

    switch (geometryType) {

        case POINT:
            Point point = (Point) geometry;
            drawn = drawPoint(boundingBox, transform, canvas, point, featureStyle);
            break;
        case LINESTRING:
        case CIRCULARSTRING:
            LineString lineString = (LineString) geometry;
            Path linePath = new Path();
            addLineString(simplifyTolerance, boundingBox, transform, linePath, lineString);
            drawn = drawLinePath(canvas, linePath, featureStyle);
            break;
        case POLYGON:
        case TRIANGLE:
            Polygon polygon = (Polygon) geometry;
            Path polygonPath = new Path();
            addPolygon(simplifyTolerance, boundingBox, transform, polygonPath, polygon);
            drawn = drawPolygonPath(canvas, polygonPath, featureStyle);
            break;
        case MULTIPOINT:
            MultiPoint multiPoint = (MultiPoint) geometry;
            for (Point pointFromMulti : multiPoint.getPoints()) {
                drawn = drawPoint(boundingBox, transform, canvas, pointFromMulti, featureStyle) || drawn;
            }
            break;
        case MULTILINESTRING:
            MultiLineString multiLineString = (MultiLineString) geometry;
            Path multiLinePath = new Path();
            for (LineString lineStringFromMulti : multiLineString.getLineStrings()) {
                addLineString(simplifyTolerance, boundingBox, transform, multiLinePath, lineStringFromMulti);
            }
            drawn = drawLinePath(canvas, multiLinePath, featureStyle);
            break;
        case MULTIPOLYGON:
            MultiPolygon multiPolygon = (MultiPolygon) geometry;
            Path multiPolygonPath = new Path();
            for (Polygon polygonFromMulti : multiPolygon.getPolygons()) {
                addPolygon(simplifyTolerance, boundingBox, transform, multiPolygonPath, polygonFromMulti);
            }
            drawn = drawPolygonPath(canvas, multiPolygonPath, featureStyle);
            break;
        case COMPOUNDCURVE:
            CompoundCurve compoundCurve = (CompoundCurve) geometry;
            Path compoundCurvePath = new Path();
            for (LineString lineStringFromCompoundCurve : compoundCurve.getLineStrings()) {
                addLineString(simplifyTolerance, boundingBox, transform, compoundCurvePath, lineStringFromCompoundCurve);
            }
            drawn = drawLinePath(canvas, compoundCurvePath, featureStyle);
            break;
        case POLYHEDRALSURFACE:
        case TIN:
            PolyhedralSurface polyhedralSurface = (PolyhedralSurface) geometry;
            Path polyhedralSurfacePath = new Path();
            for (Polygon polygonFromPolyhedralSurface : polyhedralSurface.getPolygons()) {
                addPolygon(simplifyTolerance, boundingBox, transform, polyhedralSurfacePath, polygonFromPolyhedralSurface);
            }
            drawn = drawPolygonPath(canvas, polyhedralSurfacePath, featureStyle);
            break;
        case GEOMETRYCOLLECTION:
            @SuppressWarnings("unchecked")
            GeometryCollection<Geometry> geometryCollection = (GeometryCollection) geometry;
            List<Geometry> geometries = geometryCollection.getGeometries();
            for (Geometry geometryFromCollection : geometries) {
                drawn = drawShape(simplifyTolerance, boundingBox, transform, canvas, featureRow, geometryFromCollection) || drawn;
            }
            break;
        default:
            throw new GeoPackageException("Unsupported Geometry Type: "
                    + geometry.getGeometryType().getName());
    }

    return drawn;
}