@SqlNullable @Description("Returns the cardinality of the collection of interior rings of a polygon") @ScalarFunction("ST_NumInteriorRing") @SqlType(BIGINT) public static Long stNumInteriorRings(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_NumInteriorRing", geometry, EnumSet.of(POLYGON)); if (geometry.isEmpty()) { return null; } return Long.valueOf(((OGCPolygon) geometry).numInteriorRing()); }
@SqlNullable @Description("Returns the interior ring element at the specified index (indices start at 1)") @ScalarFunction("ST_InteriorRingN") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stInteriorRingN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) { OGCGeometry geometry = deserialize(input); validateType("ST_InteriorRingN", geometry, EnumSet.of(POLYGON)); OGCPolygon polygon = (OGCPolygon) geometry; if (index < 1 || index > polygon.numInteriorRing()) { return null; } OGCGeometry interiorRing = polygon.interiorRingN(toIntExact(index) - 1); return serialize(interiorRing); }
@SqlNullable @Description("Returns an array of interior rings of a polygon") @ScalarFunction("ST_InteriorRings") @SqlType("array(" + GEOMETRY_TYPE_NAME + ")") public static Block stInteriorRings(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_InteriorRings", geometry, EnumSet.of(POLYGON)); if (geometry.isEmpty()) { return null; } OGCPolygon polygon = (OGCPolygon) geometry; BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, polygon.numInteriorRing()); for (int i = 0; i < polygon.numInteriorRing(); i++) { GEOMETRY.writeSlice(blockBuilder, serialize(polygon.interiorRingN(i))); } return blockBuilder.build(); }
@Override protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { if (geometry instanceof OGCPolygon) { return ((OGCPolygon) geometry).numInteriorRing(); } else { throw new UnsupportedOperationException( "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); } }
@Override protected Object evaluateOGCGeometry(OGCGeometry geometry) throws HyracksDataException { if (geometry instanceof OGCPolygon) { return ((OGCPolygon) geometry).numInteriorRing() + 1; } else if (geometry instanceof OGCMultiPolygon) { OGCMultiPolygon polygon = (OGCMultiPolygon) geometry; int numGeometries = polygon.numGeometries(); int count = 0; for (int i = 1; i < numGeometries + 1; i++) { if (polygon.geometryN(i) instanceof OGCPolygon) { count += ((OGCPolygon) polygon.geometryN(i)).numInteriorRing() + 1; } } return count; } else { throw new UnsupportedOperationException( "The operation " + getIdentifier() + " is not supported for the type " + geometry.geometryType()); } }
@SqlNullable @Description("Returns the cardinality of the collection of interior rings of a polygon") @ScalarFunction("ST_NumInteriorRing") @SqlType(BIGINT) public static Long stNumInteriorRings(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_NumInteriorRing", geometry, EnumSet.of(POLYGON)); if (geometry.isEmpty()) { return null; } return Long.valueOf(((OGCPolygon) geometry).numInteriorRing()); }
@SqlNullable @Description("Returns the cardinality of the collection of interior rings of a polygon") @ScalarFunction("ST_NumInteriorRing") @SqlType(BIGINT) public static Long stNumInteriorRings(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_NumInteriorRing", geometry, EnumSet.of(POLYGON)); if (geometry.isEmpty()) { return null; } return Long.valueOf(((OGCPolygon) geometry).numInteriorRing()); }
@SqlNullable @Description("Returns the interior ring element at the specified index (indices start at 1)") @ScalarFunction("ST_InteriorRingN") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stInteriorRingN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) { OGCGeometry geometry = deserialize(input); validateType("ST_InteriorRingN", geometry, EnumSet.of(POLYGON)); OGCPolygon polygon = (OGCPolygon) geometry; if (index < 1 || index > polygon.numInteriorRing()) { return null; } OGCGeometry interiorRing = polygon.interiorRingN(toIntExact(index) - 1); return serialize(interiorRing); }
@SqlNullable @Description("Returns the interior ring element at the specified index (indices start at 1)") @ScalarFunction("ST_InteriorRingN") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stInteriorRingN(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(INTEGER) long index) { OGCGeometry geometry = deserialize(input); validateType("ST_InteriorRingN", geometry, EnumSet.of(POLYGON)); OGCPolygon polygon = (OGCPolygon) geometry; if (index < 1 || index > polygon.numInteriorRing()) { return null; } OGCGeometry interiorRing = polygon.interiorRingN(toIntExact(index) - 1); return serialize(interiorRing); }
@SqlNullable @Description("Returns an array of interior rings of a polygon") @ScalarFunction("ST_InteriorRings") @SqlType("array(" + GEOMETRY_TYPE_NAME + ")") public static Block stInteriorRings(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_InteriorRings", geometry, EnumSet.of(POLYGON)); if (geometry.isEmpty()) { return null; } OGCPolygon polygon = (OGCPolygon) geometry; BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, polygon.numInteriorRing()); for (int i = 0; i < polygon.numInteriorRing(); i++) { GEOMETRY.writeSlice(blockBuilder, serialize(polygon.interiorRingN(i))); } return blockBuilder.build(); }
@SqlNullable @Description("Returns an array of interior rings of a polygon") @ScalarFunction("ST_InteriorRings") @SqlType("array(" + GEOMETRY_TYPE_NAME + ")") public static Block stInteriorRings(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_InteriorRings", geometry, EnumSet.of(POLYGON)); if (geometry.isEmpty()) { return null; } OGCPolygon polygon = (OGCPolygon) geometry; BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, polygon.numInteriorRing()); for (int i = 0; i < polygon.numInteriorRing(); i++) { GEOMETRY.writeSlice(blockBuilder, serialize(polygon.interiorRingN(i))); } return blockBuilder.build(); }
public IntWritable 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; } if (GeometryUtils.getType(geomref) == GeometryUtils.OGCType.ST_POLYGON) { try { resultInt.set(((OGCPolygon)(ogcGeometry)).numInteriorRing()); return resultInt; } catch (Exception e) { LogUtils.Log_InternalError(LOG, "ST_NumInteriorRing: " + e); return null; } } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POLYGON, GeometryUtils.getType(geomref)); return null; } }