use of mil.nga.sf.CompoundCurve in project geopackage-android-map by ngageoint.
the class GoogleMapShapeConverter method toCompoundCurveWithOptions.
/**
* Convert a {@link MultiPolylineOptions} to a {@link CompoundCurve}
*
* @param multiPolylineOptions multi polyline options
* @param hasZ has z flag
* @param hasM has m flag
* @return compound curve
*/
public CompoundCurve toCompoundCurveWithOptions(MultiPolylineOptions multiPolylineOptions, boolean hasZ, boolean hasM) {
CompoundCurve compoundCurve = new CompoundCurve(hasZ, hasM);
for (PolylineOptions polyline : multiPolylineOptions.getPolylineOptions()) {
LineString lineString = toLineString(polyline);
compoundCurve.addLineString(lineString);
}
return compoundCurve;
}
use of mil.nga.sf.CompoundCurve in project geopackage-android-map by ngageoint.
the class GoogleMapShapeConverter method toCurvePolygon.
/**
* Convert a {@link CurvePolygon} to a {@link PolygonOptions}
*
* @param curvePolygon curve polygon
* @return polygon options
* @since 1.4.1
*/
public PolygonOptions toCurvePolygon(CurvePolygon<Curve> curvePolygon) {
PolygonOptions polygonOptions = new PolygonOptions();
List<Curve> rings = curvePolygon.getRings();
if (!rings.isEmpty()) {
Double z = null;
// Add the polygon points
Curve curve = rings.get(0);
if (curve instanceof CompoundCurve) {
CompoundCurve compoundCurve = (CompoundCurve) curve;
for (LineString lineString : compoundCurve.getLineStrings()) {
// Try to simplify the number of points in the compound curve
List<Point> points = simplifyPoints(lineString.getPoints());
for (Point point : points) {
LatLng latLng = toLatLng(point);
polygonOptions.add(latLng);
if (point.hasZ()) {
z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
}
}
}
} else if (curve instanceof LineString) {
LineString lineString = (LineString) curve;
// Try to simplify the number of points in the curve
List<Point> points = simplifyPoints(lineString.getPoints());
for (Point point : points) {
LatLng latLng = toLatLng(point);
polygonOptions.add(latLng);
if (point.hasZ()) {
z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
}
}
} else {
throw new GeoPackageException("Unsupported Curve Type: " + curve.getClass().getSimpleName());
}
// Add the holes
for (int i = 1; i < rings.size(); i++) {
Curve hole = rings.get(i);
List<LatLng> holeLatLngs = new ArrayList<>();
if (hole instanceof CompoundCurve) {
CompoundCurve holeCompoundCurve = (CompoundCurve) hole;
for (LineString holeLineString : holeCompoundCurve.getLineStrings()) {
// Try to simplify the number of points in the hole
List<Point> holePoints = simplifyPoints(holeLineString.getPoints());
for (Point point : holePoints) {
LatLng latLng = toLatLng(point);
holeLatLngs.add(latLng);
if (point.hasZ()) {
z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
}
}
}
} else if (hole instanceof LineString) {
LineString holeLineString = (LineString) hole;
// Try to simplify the number of points in the hole
List<Point> holePoints = simplifyPoints(holeLineString.getPoints());
for (Point point : holePoints) {
LatLng latLng = toLatLng(point);
holeLatLngs.add(latLng);
if (point.hasZ()) {
z = (z == null) ? point.getZ() : Math.max(z, point.getZ());
}
}
} else {
throw new GeoPackageException("Unsupported Curve Hole Type: " + hole.getClass().getSimpleName());
}
polygonOptions.addHole(holeLatLngs);
}
if (curvePolygon.hasZ() && z != null) {
polygonOptions.zIndex(z.floatValue());
}
}
return polygonOptions;
}
use of mil.nga.sf.CompoundCurve in project geopackage-android-map by ngageoint.
the class GoogleMapShapeConverter method toCompoundCurve.
/**
* Convert a list of {@link Polyline} to a {@link CompoundCurve}
*
* @param polylineList polyline list
* @param hasZ has z flag
* @param hasM has m flag
* @return compound curve
*/
public CompoundCurve toCompoundCurve(List<Polyline> polylineList, boolean hasZ, boolean hasM) {
CompoundCurve compoundCurve = new CompoundCurve(hasZ, hasM);
for (Polyline polyline : polylineList) {
LineString lineString = toLineString(polyline);
compoundCurve.addLineString(lineString);
}
return compoundCurve;
}
use of mil.nga.sf.CompoundCurve in project geopackage-android-map by ngageoint.
the class GoogleMapShapeConverter method addToMap.
/**
* Convert a {@link Geometry} to a Map shape and add it
*
* @param map google map
* @param geometry geometry
* @return google map shape
*/
@SuppressWarnings("unchecked")
public GoogleMapShape addToMap(GoogleMap map, Geometry geometry) {
GoogleMapShape shape = null;
GeometryType geometryType = geometry.getGeometryType();
switch(geometryType) {
case POINT:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MARKER, addLatLngToMap(map, toLatLng((Point) geometry)));
break;
case LINESTRING:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE, addPolylineToMap(map, toPolyline((LineString) geometry)));
break;
case POLYGON:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toPolygon((Polygon) geometry)));
break;
case MULTIPOINT:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_MARKER, addLatLngsToMap(map, toLatLngs((MultiPoint) geometry)));
break;
case MULTILINESTRING:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE, addPolylinesToMap(map, toPolylines((MultiLineString) geometry)));
break;
case MULTIPOLYGON:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((MultiPolygon) geometry)));
break;
case CIRCULARSTRING:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE, addPolylineToMap(map, toPolyline((CircularString) geometry)));
break;
case COMPOUNDCURVE:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE, addPolylinesToMap(map, toPolylines((CompoundCurve) geometry)));
break;
case CURVEPOLYGON:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toCurvePolygon((CurvePolygon<Curve>) geometry)));
break;
case POLYHEDRALSURFACE:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((PolyhedralSurface) geometry)));
break;
case TIN:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((TIN) geometry)));
break;
case TRIANGLE:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toPolygon((Triangle) geometry)));
break;
case GEOMETRYCOLLECTION:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.COLLECTION, addToMap(map, (GeometryCollection<Geometry>) geometry));
break;
default:
throw new GeoPackageException("Unsupported Geometry Type: " + geometryType.getName());
}
return shape;
}
use of mil.nga.sf.CompoundCurve in project geopackage-android-map by ngageoint.
the class GoogleMapShapeConverterUtils method convertCompoundCurve.
/**
* 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());
}
Aggregations