Java Code Examples for org.postgis.Geometry#getType()

The following examples show how to use org.postgis.Geometry#getType() . 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: GeometryConverterAdapter.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public GeometryObject getMultiPoint(Object geomObj) throws SQLException {
	GeometryObject multiPoint = null;

	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		if (geometry.getType() == Geometry.MULTIPOINT) {
			multiPoint = getMultiPoint((MultiPoint)geometry);
		}

		else if (geometry.getType() == Geometry.POINT) {
			Point pointObj = (Point)geometry;
			double[][] coordiantes = new double[1][];
			coordiantes[0] = getPointCoordinates(pointObj);

			multiPoint = GeometryObject.createMultiPoint(coordiantes, pointObj.getDimension(), pointObj.getSrid());
		}
	}

	return multiPoint;
}
 
Example 2
Source File: GeometryConverterAdapter.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public GeometryObject getMultiCurve(Object geomObj) throws SQLException {
	GeometryObject multiCurve = null;

	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		if (geometry.getType() == Geometry.MULTILINESTRING) {
			multiCurve = getMultiCurve((MultiLineString)geometry);
		}

		else if (geometry.getType() == Geometry.LINESTRING) {
			LineString lineStringObj = (LineString)geometry;
			double[][] coordiantes = new double[1][];
			coordiantes[0] = getCurveCoordinates(lineStringObj);

			multiCurve = GeometryObject.createMultiPoint(coordiantes, lineStringObj.getDimension(), lineStringObj.getSrid());
		}
	}

	return multiCurve;
}
 
Example 3
Source File: GeometryConverterAdapter.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public GeometryObject getMultiPolygon(Object geomObj) throws SQLException {
	GeometryObject multiPolygon = null;

	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		if (geometry.getType() == Geometry.MULTIPOLYGON) {
			multiPolygon = getMultiPolygon((MultiPolygon)geometry);
		}

		else if (geometry.getType() == Geometry.POLYGON) {
			Polygon polygonObj = (Polygon)geometry;
			double[][] coordinates = getPolygonCoordinates(polygonObj);
			int[] exteriorRings = new int[]{ 0 };

			multiPolygon = GeometryObject.createMultiPolygon(coordinates, exteriorRings, polygonObj.getDimension(), polygonObj.getSrid());
		}
	}

	return multiPolygon;
}
 
Example 4
Source File: GeometryConverterAdapter.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public GeometryObject getGeometry(Object geomObj) throws SQLException {
	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		switch (geometry.getType()) {
		case Geometry.POINT:
			return getPoint((Point)geometry);
		case Geometry.MULTIPOINT:
			return getMultiPoint((MultiPoint)geometry);
		case Geometry.LINESTRING:
			return getCurve((LineString)geometry);
		case Geometry.MULTILINESTRING:
			return getMultiCurve((MultiLineString)geometry);
		case Geometry.POLYGON:
			return getPolygon((Polygon)geometry);
		case Geometry.MULTIPOLYGON:
			return getMultiPolygon((MultiPolygon)geometry);
		default:
			throw new SQLException("Cannot convert PostGIS geometry type '" + geometry.getType() + "' to internal representation: Unsupported type.");
		}
	}

	return null;
}
 
Example 5
Source File: GeometryConverterAdapter.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
@Override
public GeometryObject getPoint(Object geomObj) throws SQLException {
	GeometryObject point = null;

	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		if (geometry.getType() != Geometry.POINT)
			return null;

		point = getPoint((Point)geometry);
	}

	return point;
}
 
Example 6
Source File: GeometryConverterAdapter.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
@Override
public GeometryObject getCurve(Object geomObj) throws SQLException {
	GeometryObject curve = null;

	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		if (geometry.getType() != Geometry.LINESTRING)
			return null;

		curve = getCurve((LineString)geometry);
	}

	return curve;
}
 
Example 7
Source File: GeometryConverterAdapter.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
@Override
public GeometryObject getPolygon(Object geomObj) throws SQLException {
	GeometryObject polygon = null;

	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		if (geometry.getType() != Geometry.POLYGON)
			return null;

		polygon = getPolygon((Polygon)geometry);
	}

	return polygon;
}