use of mil.nga.sf.GeometryType 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.GeometryType in project geopackage-android-map by ngageoint.
the class GoogleMapShapeConverter method toShape.
/**
* Convert a {@link Geometry} to a Map shape
*
* @param geometry geometry
* @return google map shape
*/
@SuppressWarnings("unchecked")
public GoogleMapShape toShape(Geometry geometry) {
GoogleMapShape shape = null;
GeometryType geometryType = geometry.getGeometryType();
switch(geometryType) {
case POINT:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.LAT_LNG, toLatLng((Point) geometry));
break;
case LINESTRING:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE_OPTIONS, toPolyline((LineString) geometry));
break;
case POLYGON:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON_OPTIONS, toPolygon((Polygon) geometry));
break;
case MULTIPOINT:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_LAT_LNG, toLatLngs((MultiPoint) geometry));
break;
case MULTILINESTRING:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE_OPTIONS, toPolylines((MultiLineString) geometry));
break;
case MULTIPOLYGON:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON_OPTIONS, toPolygons((MultiPolygon) geometry));
break;
case CIRCULARSTRING:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE_OPTIONS, toPolyline((CircularString) geometry));
break;
case COMPOUNDCURVE:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE_OPTIONS, toPolylines((CompoundCurve) geometry));
break;
case CURVEPOLYGON:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON_OPTIONS, toCurvePolygon((CurvePolygon<Curve>) geometry));
break;
case POLYHEDRALSURFACE:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON_OPTIONS, toPolygons((PolyhedralSurface) geometry));
break;
case TIN:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON_OPTIONS, toPolygons((TIN) geometry));
break;
case TRIANGLE:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON_OPTIONS, toPolygon((Triangle) geometry));
break;
case GEOMETRYCOLLECTION:
shape = new GoogleMapShape(geometryType, GoogleMapShapeType.COLLECTION, toShapes((GeometryCollection<Geometry>) geometry));
break;
default:
throw new GeoPackageException("Unsupported Geometry Type: " + geometryType.getName());
}
return shape;
}
use of mil.nga.sf.GeometryType in project joa by sebastianfrey.
the class GeoPackageService method getQueryables.
@Override
public Queryables getQueryables(String serviceId, String collectionId) {
try (GeoPackage gpkg = loadService(serviceId)) {
ObjectType schema = JSONSchemaBuilder.objectType().title(collectionId).schema(Schemas.DRAFT_2019_09);
FeatureDao featureDao = loadCollection(gpkg, collectionId);
String geometryColumn = featureDao.getGeometryColumnName();
featureDao.getColumns().stream().forEach((column) -> {
if (column.isGeometry()) {
return;
}
Long max = column.getMax();
Object defaultValue = column.getDefaultValue();
GenericType<?> type = null;
switch(column.getDataType()) {
case BOOLEAN:
type = JSONSchemaBuilder.booleanType();
break;
case BLOB:
case TINYINT:
case TEXT:
type = JSONSchemaBuilder.stringType().maxLength(max);
break;
case DATE:
type = JSONSchemaBuilder.stringType().maxLength(max).format("date");
break;
case DATETIME:
type = JSONSchemaBuilder.stringType().maxLength(max).format("date-time");
break;
case DOUBLE:
case FLOAT:
case REAL:
type = JSONSchemaBuilder.numberType();
break;
case INT:
case INTEGER:
case MEDIUMINT:
case SMALLINT:
type = JSONSchemaBuilder.integerType().maximum(max);
break;
default:
break;
}
if (type == null) {
return;
}
String columnName = column.getName();
type.title(columnName);
if (defaultValue != null) {
type.defaultValue(defaultValue.toString());
}
schema.property(columnName, type);
});
GeometryType geometryType = featureDao.getGeometryType();
JSONSchema geometrySchema = null;
switch(geometryType) {
case GEOMETRY:
geometrySchema = Schemas.GeoJSON.geometry();
break;
case POINT:
geometrySchema = Schemas.GeoJSON.point();
break;
case LINESTRING:
geometrySchema = Schemas.GeoJSON.lineString();
break;
case POLYGON:
geometrySchema = Schemas.GeoJSON.polygon();
break;
case MULTIPOINT:
geometrySchema = Schemas.GeoJSON.multiPoint();
break;
case MULTILINESTRING:
geometrySchema = Schemas.GeoJSON.multiLineString();
break;
case MULTIPOLYGON:
geometrySchema = Schemas.GeoJSON.multiPolygon();
break;
default:
break;
}
if (geometrySchema != null) {
schema.property(geometryColumn, geometrySchema);
}
return new Queryables().serviceId(serviceId).collectionId(collectionId).schema(schema);
}
}
use of mil.nga.sf.GeometryType in project geopackage-android-map by ngageoint.
the class GoogleMapShapeConverterUtils method testShapes.
/**
* Test shapes
*
* @param geoPackage
* @throws SQLException
*/
public static void testShapes(GeoPackage geoPackage) throws SQLException {
GeometryColumnsDao geometryColumnsDao = geoPackage.getGeometryColumnsDao();
if (geometryColumnsDao.isTableExists()) {
List<GeometryColumns> results = geometryColumnsDao.queryForAll();
for (GeometryColumns geometryColumns : results) {
FeatureDao dao = geoPackage.getFeatureDao(geometryColumns);
GoogleMapShapeConverter converter = new GoogleMapShapeConverter(dao.getProjection());
converter.setExteriorOrientation(null);
converter.setHoleOrientation(null);
// Query for all
FeatureCursor cursor = dao.queryForAll();
while (cursor.moveToNext()) {
FeatureRow featureRow = cursor.getRow();
GeoPackageGeometryData geometryData = featureRow.getGeometry();
if (geometryData != null) {
Geometry geometry = geometryData.getGeometry();
GeometryType geometryType = geometry.getGeometryType();
switch(geometryType) {
case POINT:
convertPoint(converter, (Point) geometry);
break;
case LINESTRING:
convertLineString(converter, (LineString) geometry);
break;
case POLYGON:
convertPolygon(converter, (Polygon) geometry);
break;
case MULTIPOINT:
convertMultiPoint(converter, (MultiPoint) geometry);
break;
case MULTILINESTRING:
convertMultiLineString(converter, (MultiLineString) geometry);
break;
case MULTIPOLYGON:
convertMultiPolygon(converter, (MultiPolygon) geometry);
break;
case CIRCULARSTRING:
convertLineString(converter, (CircularString) geometry);
break;
case COMPOUNDCURVE:
convertCompoundCurve(converter, (CompoundCurve) geometry);
break;
case POLYHEDRALSURFACE:
convertMultiPolygon(converter, (PolyhedralSurface) geometry);
break;
case TIN:
convertMultiPolygon(converter, (TIN) geometry);
break;
case TRIANGLE:
convertPolygon(converter, (Triangle) geometry);
break;
default:
}
}
}
cursor.close();
}
}
}
Aggregations