OGCLineString linestring = new OGCLineString(multipath, 0, null); return serialize(linestring);
@SqlNullable @Description("Returns the vertex of a linestring at the specified index (indices started with 1) ") @ScalarFunction("ST_PointN") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stPointN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) { OGCGeometry geometry = deserialize(input); validateType("ST_PointN", geometry, EnumSet.of(LINE_STRING)); OGCLineString linestring = (OGCLineString) geometry; if (index < 1 || index > linestring.numPoints()) { return null; } return serialize(linestring.pointN(toIntExact(index) - 1)); }
@SqlNullable @Description("Returns TRUE if and only if the line is closed and simple") @ScalarFunction("ST_IsRing") @SqlType(BOOLEAN) public static Boolean stIsRing(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_IsRing", geometry, EnumSet.of(LINE_STRING)); OGCLineString line = (OGCLineString) geometry; return line.isClosed() && line.isSimple(); }
last_point_id = lastPointId.remove(i); reverse.add(false); sumPoints += linestrings.get(i).numPoints(); connected_lines.add(linestrings.remove(i)); } else if (lastPointId.get(i) == first_point_id) { sumPoints += linestrings.get(i).numPoints(); connected_lines.add(0, linestrings.remove(i)); reverse.add(0, false); sumPoints += linestrings.get(i).numPoints(); connected_lines.add(0, linestrings.remove(i)); reverse.add(0, true); sumPoints += linestrings.get(i).numPoints(); connected_lines.add(linestrings.remove(i)); reverse.add(false); sumPoints += linestrings.get(i).numPoints(); connected_lines.add(linestrings.remove(i)); reverse.add(true); boolean isReverse = reverse.get(i); int last_i = (isPolygon || i < connected_lines.size() - 1)? linestring.numPoints() - 1 : linestring.numPoints(); for (int i_point = 0; i_point < last_i; i_point++) { points[n++] = (Point) linestring.pointN( isReverse? linestring.numPoints() - 1 - i_point : i_point ).getEsriGeometry();
@Override public OGCPoint startPoint() { return pointN(0); }
@Override public OGCPoint startPoint() { return pointN(0); }
return new OGCLineString((Polyline) geometry, 0, null);
@SqlNullable @Description("Returns TRUE if and only if the line is closed and simple") @ScalarFunction("ST_IsRing") @SqlType(BOOLEAN) public static Boolean stIsRing(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_IsRing", geometry, EnumSet.of(LINE_STRING)); OGCLineString line = (OGCLineString) geometry; return line.isClosed() && line.isSimple(); }
@Override protected OGCGeometry evaluateOGCGeometry(OGCGeometry geometry, int n) throws HyracksDataException { if (geometry instanceof OGCLineString) { return ((OGCLineString) geometry).pointN(n); } else { throw new UnsupportedOperationException( "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); } } }
@Override public OGCGeometry geometryN(int n) { OGCLineString ls = new OGCLineString(polyline, n, esriSR); return ls; }
@SqlNullable @Description("Returns TRUE if and only if the line is closed and simple") @ScalarFunction("ST_IsRing") @SqlType(BOOLEAN) public static Boolean stIsRing(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_IsRing", geometry, EnumSet.of(LINE_STRING)); OGCLineString line = (OGCLineString) geometry; return line.isClosed() && line.isSimple(); }
@Override public OGCGeometry geometryN(int n) { OGCLineString ls = new OGCLineString(polyline, n, esriSR); return ls; }
public void drawESRIGeom(Graphics g, OGCGeometry geom, double xscale, double yscale) { if (geom instanceof OGCLineString) { OGCLineString linestring = (OGCLineString) geom; int[] xs = new int[linestring.numPoints()]; int[] ys = new int[linestring.numPoints()]; int n = 0; for (int i = 0; i < n; i++) { OGCPoint point = linestring.pointN(i); xs[n] = (int) Math.floor(point.X() * xscale); ys[n] = (int) Math.floor(point.Y() * yscale); // Increment number of point if this point is different than previous ones if (n == 0 || xs[n] != xs[n-1] || ys[n] != ys[n-1]) n++; } g.drawPolyline(xs, ys, n); } else { throw new RuntimeException("Cannot draw a shape of type "+geom.getClass()); } } }
public BooleanWritable evaluate(BytesWritable geomref) { if (geomref == null || geomref.getLength() == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref); if (ogcGeometry == null){ LogUtils.Log_ArgumentsNull(LOG); return null; } try { switch(GeometryUtils.getType(geomref)) { case ST_LINESTRING: OGCLineString lns = (OGCLineString)ogcGeometry; resultBoolean.set(lns.isClosed() && lns.isSimple()); return resultBoolean; default: // ST_IsRing gives ERROR on Point, Polygon, or MultiLineString - on Postgres LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.getType(geomref)); return null; } } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_IsRing" + e); return null; } }
break; case 2: g = new OGCLineString( (Polyline) lastStructure.m_structures.get(i).m_geometry, 0, sr);
@SqlNullable @Description("Returns the vertex of a linestring at the specified index (indices started with 1) ") @ScalarFunction("ST_PointN") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stPointN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) { OGCGeometry geometry = deserialize(input); validateType("ST_PointN", geometry, EnumSet.of(LINE_STRING)); OGCLineString linestring = (OGCLineString) geometry; if (index < 1 || index > linestring.numPoints()) { return null; } return serialize(linestring.pointN(toIntExact(index) - 1)); }
break; case 2: g = new OGCLineString( (Polyline) lastStructure.m_structures.get(i).m_geometry, 0, sr);
@SqlNullable @Description("Returns the vertex of a linestring at the specified index (indices started with 1) ") @ScalarFunction("ST_PointN") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stPointN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) { OGCGeometry geometry = deserialize(input); validateType("ST_PointN", geometry, EnumSet.of(LINE_STRING)); OGCLineString linestring = (OGCLineString) geometry; if (index < 1 || index > linestring.numPoints()) { return null; } return serialize(linestring.pointN(toIntExact(index) - 1)); }