Java Code Examples for mil.nga.sf.GeometryType#getName()

The following examples show how to use mil.nga.sf.GeometryType#getName() . 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: StyleMappingDao.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Delete by base is and geometry type
 *
 * @param id           base id
 * @param geometryType geometry type
 * @return rows deleted
 */
public int deleteByBaseId(long id, GeometryType geometryType) {

    String geometryTypeName = null;
    if (geometryType != null) {
        geometryTypeName = geometryType.getName();
    }

    StringBuilder where = new StringBuilder();
    where.append(buildWhere(StyleMappingTable.COLUMN_BASE_ID, id));
    where.append(" AND ");
    where.append(buildWhere(StyleMappingTable.COLUMN_GEOMETRY_TYPE_NAME,
            geometryTypeName));

    List<Object> whereArguments = new ArrayList<>();
    whereArguments.add(id);
    if (geometryTypeName != null) {
        whereArguments.add(geometryTypeName);
    }

    String[] whereArgs = buildWhereArgs(whereArguments);

    int deleted = delete(where.toString(), whereArgs);

    return deleted;
}
 
Example 2
Source File: GeometryExtensions.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Get the extension name of a GeoPackage extension Geometry
 * 
 * @param geometryType
 *            geometry type
 * @return extension name
 */
public static String getExtensionName(GeometryType geometryType) {

	if (!isExtension(geometryType)) {
		throw new GeoPackageException(GeometryType.class.getSimpleName()
				+ " is not an extension: " + geometryType.getName());
	}

	if (!isGeoPackageExtension(geometryType)) {
		throw new GeoPackageException(
				GeometryType.class.getSimpleName()
						+ " is not a GeoPackage extension, User-Defined requires an author: "
						+ geometryType.getName());
	}

	String extensionName = GeoPackageConstants.EXTENSION_AUTHOR
			+ Extensions.EXTENSION_NAME_DIVIDER
			+ GeoPackageConstants.GEOMETRY_EXTENSION_PREFIX
			+ Extensions.EXTENSION_NAME_DIVIDER + geometryType.getName();

	return extensionName;
}
 
Example 3
Source File: GeometryExtensions.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Get the extension name of a extension Geometry, either user-defined or
 * GeoPackage extension
 * 
 * @param author
 *            author
 * @param geometryType
 *            geometry type
 * @return extension name
 * @deprecated as of 1.2.1, On August 15, 2016 the GeoPackage SWG voted to
 *             remove this extension from the standard due to
 *             interoperability concerns. (GeoPackage version 1.2)
 */
public static String getExtensionName(String author,
		GeometryType geometryType) {

	if (!isExtension(geometryType)) {
		throw new GeoPackageException(GeometryType.class.getSimpleName()
				+ " is not an extension: " + geometryType.getName());
	}

	String extensionName = (isGeoPackageExtension(geometryType) ? GeoPackageConstants.EXTENSION_AUTHOR
			: author)
			+ Extensions.EXTENSION_NAME_DIVIDER
			+ GeoPackageConstants.GEOMETRY_EXTENSION_PREFIX
			+ Extensions.EXTENSION_NAME_DIVIDER + geometryType.getName();

	return extensionName;
}
 
Example 4
Source File: StyleMappingDao.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Delete by base is and geometry type
 * 
 * @param id
 *            base id
 * @param geometryType
 *            geometry type
 * @return rows deleted
 */
public int deleteByBaseId(long id, GeometryType geometryType) {

	String geometryTypeName = null;
	if (geometryType != null) {
		geometryTypeName = geometryType.getName();
	}

	StringBuilder where = new StringBuilder();
	where.append(buildWhere(StyleMappingTable.COLUMN_BASE_ID, id));
	where.append(" AND ");
	where.append(buildWhere(StyleMappingTable.COLUMN_GEOMETRY_TYPE_NAME,
			geometryTypeName));

	List<Object> whereArguments = new ArrayList<>();
	whereArguments.add(id);
	if (geometryTypeName != null) {
		whereArguments.add(geometryTypeName);
	}

	String[] whereArgs = buildWhereArgs(whereArguments);

	int deleted = delete(where.toString(), whereArgs);

	return deleted;
}
 
Example 5
Source File: StyleMappingRow.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Set the geometry type
 *
 * @param geometryType geometry type
 */
public void setGeometryType(GeometryType geometryType) {
    String geometryTypeName = null;
    if (geometryType != null) {
        geometryTypeName = geometryType.getName();
    }
    setValue(getGeometryTypeNameColumnIndex(), geometryTypeName);
}
 
Example 6
Source File: StyleMappingRow.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Set the geometry type
 * 
 * @param geometryType
 *            geometry type
 */
public void setGeometryType(GeometryType geometryType) {
	String geometryTypeName = null;
	if (geometryType != null) {
		geometryTypeName = geometryType.getName();
	}
	setValue(getGeometryTypeNameColumnIndex(), geometryTypeName);
}
 
Example 7
Source File: GoogleMapShapeConverter.java    From geopackage-android-map with MIT License 4 votes vote down vote up
/**
 * 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) 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;
}
 
Example 8
Source File: GoogleMapShapeConverter.java    From geopackage-android-map with MIT License 4 votes vote down vote up
/**
 * 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) 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;
}
 
Example 9
Source File: GeometryColumnsSqlMm.java    From geopackage-core-java with MIT License 4 votes vote down vote up
public void setGeometryType(GeometryType geometryType) {
	this.geometryTypeName = COLUMN_GEOMETRY_TYPE_NAME_PREFIX
			+ geometryType.getName();
}
 
Example 10
Source File: GeometryExtensionsTest.java    From geopackage-android with MIT License 2 votes vote down vote up
/**
 * Get the expected GeoPackage extension name with no author
 *
 * @param type
 * @return
 */
private String expectedGeoPackageExtensionNameNoAuthor(GeometryType type) {
    return "geom_" + type.getName();
}
 
Example 11
Source File: GeometryExtensionsTest.java    From geopackage-android with MIT License 2 votes vote down vote up
/**
 * Get the expected User-Defined extension name
 *
 * @param author
 * @param type
 * @return
 */
private String expectedUserDefinedExtensionName(String author,
                                                GeometryType type) {
    return author + "_geom_" + type.getName();
}
 
Example 12
Source File: GeometryColumns.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Set the geometry type
 * 
 * @param geometryType
 *            geometry type
 */
public void setGeometryType(GeometryType geometryType) {
	this.geometryTypeName = geometryType.getName();
}
 
Example 13
Source File: GeometryExtensionsTest.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Get the expected GeoPackage extension name with no author
 * 
 * @param type
 * @return
 */
private String expectedGeoPackageExtensionNameNoAuthor(GeometryType type) {
	return "geom_" + type.getName();
}
 
Example 14
Source File: GeometryExtensionsTest.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Get the expected User-Defined extension name
 * 
 * @param author
 * @param type
 * @return
 */
private String expectedUserDefinedExtensionName(String author,
		GeometryType type) {
	return author + "_geom_" + type.getName();
}