@SuppressWarnings("unchecked") public Geoshape.Type getType(Shape shape) { final Geoshape.Type type; if (JtsGeometry.class.isAssignableFrom(shape.getClass()) && "LineString".equals(((JtsGeometry) shape).getGeom().getGeometryType())) { type = Geoshape.Type.LINE; } else if (JtsGeometry.class.isAssignableFrom(shape.getClass())) { try { type = Geoshape.Type.fromGson((((JtsGeometry) shape).getGeom().getGeometryType())); } catch (IllegalArgumentException e) { throw new IllegalStateException("Unrecognized shape type");
private static void writeGeometry(Geometry geometry, DynamicSliceOutput output) { switch (geometry.getGeometryType()) { case "Point": writePoint((Point) geometry, output); break; case "MultiPoint": writeMultiPoint((MultiPoint) geometry, output); break; case "LineString": writePolyline(geometry, output, false); break; case "MultiLineString": writePolyline(geometry, output, true); break; case "Polygon": writePolygon(geometry, output, false); break; case "MultiPolygon": writePolygon(geometry, output, true); break; case "GeometryCollection": writeGeometryCollection(geometry, output); break; default: throw new IllegalArgumentException("Unsupported geometry type : " + geometry.getGeometryType()); } }
@SqlNullable @Description("Returns a float between 0 and 1 representing the location of the closest point on the LineString to the given Point, as a fraction of total 2d line length.") @ScalarFunction("line_locate_point") @SqlType(DOUBLE) public static Double lineLocatePoint(@SqlType(GEOMETRY_TYPE_NAME) Slice lineSlice, @SqlType(GEOMETRY_TYPE_NAME) Slice pointSlice) { Geometry line = JtsGeometrySerde.deserialize(lineSlice); Geometry point = JtsGeometrySerde.deserialize(pointSlice); if (line.isEmpty() || point.isEmpty()) { return null; } GeometryType lineType = GeometryType.getForJtsGeometryType(line.getGeometryType()); if (lineType != GeometryType.LINE_STRING && lineType != GeometryType.MULTI_LINE_STRING) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("First argument to line_locate_point must be a LineString or a MultiLineString. Got: %s", line.getGeometryType())); } GeometryType pointType = GeometryType.getForJtsGeometryType(point.getGeometryType()); if (pointType != GeometryType.POINT) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Second argument to line_locate_point must be a Point. Got: %s", point.getGeometryType())); } return new LengthIndexedLine(line).indexOf(point.getCoordinate()) / line.getLength(); }
protected boolean testTypeAndVertexEquality(Geometry geom1, Geometry geom2) { if ( !geom1.getGeometryType().equals( geom2.getGeometryType() ) ) { return false; } if ( geom1.getNumGeometries() != geom2.getNumGeometries() ) { return false; } if ( geom1.getNumPoints() != geom2.getNumPoints() ) { return false; } Coordinate[] coordinates1 = geom1.getCoordinates(); Coordinate[] coordinates2 = geom2.getCoordinates(); for ( int i = 0; i < coordinates1.length; i++ ) { Coordinate c1 = coordinates1[i]; Coordinate c2 = coordinates2[i]; if ( !testCoordinateEquality( c1, c2 ) ) { return false; } } return true; }
public static String geometryType(Geometry arg0) { if (arg0 == null) return null; Geometry _this = arg0; return _this.getGeometryType(); }
public String getGeometryType() { return geometry.getGeometryType(); }
/** * Returns the type of the geometry as a string. Eg: 'LINESTRING', 'POLYGON', 'MULTIPOINT', etc. * * <p>This method returns <code>null</code> when <tt>wkb</tt> is <code>null</code>. * * @param wkb The geometry. */ public static String GeometryType(byte[] wkb) { if (wkb == null) { return null; } Geometry g = fromWKB(wkb); return g != null ? g.getGeometryType().toUpperCase() : null; }
+ geom.getGeometryType() + " as SDO_GTYPE " + "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"
@Override public void filter(Geometry gmtr) { if (MultiPolygon.class.isAssignableFrom(binding)) { if (gmtr.getArea() != 0.0d && gmtr.getGeometryType().equals("Polygon")) { collection.add(gmtr); } } if (MultiLineString.class.isAssignableFrom(binding)) { if (gmtr.getLength() != 0.0d && gmtr.getGeometryType().equals("LineString")) { collection.add(gmtr); } } if (MultiPoint.class.isAssignableFrom(binding)) { if (gmtr.getNumGeometries() > 0 && gmtr.getGeometryType().equals("Point")) { collection.add(gmtr); } } if (Point.class.isAssignableFrom(binding)) { if (gmtr.getGeometryType().equals("Point")) { collection.add(gmtr); } } }
static Object[] distanceBufferOpProperty(Expression e) { if (e instanceof PropertyName) { return new Object[] {FES.ValueReference, e}; } else if (e instanceof Literal) { Literal l = (Literal) e; if (l.getValue() instanceof Geometry) { Geometry g = (Geometry) l.getValue(); return new Object[] {new QName(GML.NAMESPACE, g.getGeometryType()), g}; } return new Object[] {FES.Literal, e}; } else if (e instanceof Function) { return new Object[] {FES.Function, e}; } else { return new Object[] {FES.expression, e}; } }
/** * Construct a geometry from the WKT representation of a geometry * * @param geom the constructor for the geometry. */ public String db2Geom(Geometry geom) { String geomType = geom.getGeometryType(); String g1 = geom.toText(); String g2 = "db2gse.ST_" + geomType + "('" + g1 + "'," + getSRID() + ")"; return g2; }
@DescribeProcess( title = "Geometry Type", description = "Returns the name of a geometry's type. Values are one of POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION." ) @DescribeResult(description = "The name of the geometry type") public static String geometryType( @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) { return geom.getGeometryType(); }
+ geom.getGeometryType() + " as " + "SDO_ORDINATRES (Limitied to Point, Line, Polygon, "
if (geo.getGeometryType().equals(geometryType)) { geoms.add(geo);
private static Geometry smooth( final Geometry geom, final double fit, final GeometryFactory factory, GeometrySmoother smoother) { switch (Geometries.get(geom)) { case POINT: case MULTIPOINT: // For points, just return the input geometry return geom; case LINESTRING: // This handles open and closed lines (LinearRings) return smoothLineString(factory, smoother, geom, fit); case MULTILINESTRING: return smoothMultiLineString(factory, smoother, geom, fit); case POLYGON: return smoother.smooth((Polygon) geom, fit); case MULTIPOLYGON: return smoothMultiPolygon(factory, smoother, geom, fit); case GEOMETRYCOLLECTION: return smoothGeometryCollection(factory, smoother, geom, fit); default: throw new UnsupportedOperationException( "No smoothing method available for " + geom.getGeometryType()); } }
+ geom.getGeometryType() + " as SDO_ELEM_INFO " + "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"
+ geom.getGeometryType() + " as " + "SDO_ORDINATRES (Limitied to Point, Line, Polygon, "
} else if (shape instanceof Point == false) { throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a " + ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
@Test public void testDecimateCollection() throws Exception { WKTReader2 reader = new WKTReader2(); MultiLineString origin = (MultiLineString) reader.read("MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))"); Decimator d = new Decimator(0.1, 0.1); MultiLineString simplified = (MultiLineString) d.decimateTransformGeneralize(origin, identity); assertEquals(origin.getGeometryN(0), simplified.getGeometryN(0)); assertNotEquals(origin.getGeometryN(1), simplified.getGeometryN(1)); assertEquals("CircularString", origin.getGeometryN(1).getGeometryType()); assertEquals("LineString", simplified.getGeometryN(1).getGeometryType()); } }
throw new IllegalArgumentException("Unknown geometry type: " + geom.getGeometryType());