org.locationtech.jts.geom.MultiPolygon Java Examples

The following examples show how to use org.locationtech.jts.geom.MultiPolygon. 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: StyleGenerator.java    From constellation with Apache License 2.0 6 votes vote down vote up
public static Style createStyle(final SimpleFeatureCollection features) {
    if (features.size() == 0) {
        LOGGER.warning("No features available to generate style");
        return null;
    }

    final Class<?> geometryType = features.getSchema().getGeometryDescriptor().getType().getBinding();
    if (Polygon.class.isAssignableFrom(geometryType)
            || MultiPolygon.class.isAssignableFrom(geometryType)) {
        return createPolygonStyle();
    } else if (LineString.class.isAssignableFrom(geometryType)) {
        return createLineStyle();
    } else if (Point.class.isAssignableFrom(geometryType)) {
        return createPointStyle();
    } else {
        LOGGER.log(Level.WARNING, "Style cannot be generated from type: {0}", geometryType);
        return null;
    }
}
 
Example #2
Source File: SimpleFeatureShapeFigure.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private Geometry getGeometryFromShape(Shape shape) {
    AwtGeomToJtsGeomConverter converter = new AwtGeomToJtsGeomConverter();
    Geometry geometry;
    // May need to handle more cases here in the future!  (nf)
    if (Polygon.class.isAssignableFrom(geometryType)) {
        geometry = converter.createPolygon(shape);
    } else if (MultiPolygon.class.isAssignableFrom(geometryType)) {
        geometry = converter.createMultiPolygon(shape);
    } else if (LinearRing.class.isAssignableFrom(geometryType)) {
        geometry = converter.createLinearRingList(shape).get(0);
    } else if (LineString.class.isAssignableFrom(geometryType)) {
        geometry = converter.createLineStringList(shape).get(0);
    } else {
        geometry = converter.createMultiLineString(shape);
    }
    return geometry;
}
 
Example #3
Source File: ShapefileLoader.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private static Style[] createStyle(File shapeFile, FeatureType schema) {
    final Style[] styles = SLDUtils.loadSLD(shapeFile);
    if (styles != null && styles.length > 0) {
        return styles;
    }
    Class<?> type = schema.getGeometryDescriptor().getType().getBinding();
    if (type.isAssignableFrom(Polygon.class)
            || type.isAssignableFrom(MultiPolygon.class)) {
        return new Style[]{createPolygonStyle()};
    } else if (type.isAssignableFrom(LineString.class)
            || type.isAssignableFrom(MultiLineString.class)) {
        return new Style[]{createLineStyle()};
    } else {
        return new Style[]{createPointStyle()};
    }
}
 
Example #4
Source File: GeoUtils.java    From elasticsearch-plugin-geoshape with MIT License 6 votes vote down vote up
public static Geometry removeDuplicateCoordinates(Geometry geom) {
    if (geom.isEmpty()) {
        return geom;
    }

    if (geom instanceof Polygon) {
        return removeDuplicateCoordinates((Polygon) geom);
    }

    if (geom instanceof MultiPolygon) {
        return removeDuplicateCoordinates((MultiPolygon) geom);
    }

    if (geom instanceof GeometryCollection) {
        return removeDuplicateCoordinates((GeometryCollection) geom);
    }

    return geom;
}
 
Example #5
Source File: VectorTileEncoder.java    From java-vector-tile with Apache License 2.0 6 votes vote down vote up
static VectorTile.Tile.GeomType toGeomType(Geometry geometry) {
    if (geometry instanceof Point) {
        return VectorTile.Tile.GeomType.POINT;
    }
    if (geometry instanceof MultiPoint) {
        return VectorTile.Tile.GeomType.POINT;
    }
    if (geometry instanceof LineString) {
        return VectorTile.Tile.GeomType.LINESTRING;
    }
    if (geometry instanceof MultiLineString) {
        return VectorTile.Tile.GeomType.LINESTRING;
    }
    if (geometry instanceof Polygon) {
        return VectorTile.Tile.GeomType.POLYGON;
    }
    if (geometry instanceof MultiPolygon) {
        return VectorTile.Tile.GeomType.POLYGON;
    }
    return VectorTile.Tile.GeomType.UNKNOWN;
}
 
Example #6
Source File: VectorTileEncoderTest.java    From java-vector-tile with Apache License 2.0 6 votes vote down vote up
public void testMultiPolygon() throws IOException {
    Polygon[] polygons = new Polygon[2];
    polygons[0] = (Polygon) gf.createPoint(new Coordinate(13, 16)).buffer(3);
    polygons[1] = (Polygon) gf.createPoint(new Coordinate(24, 25)).buffer(5)
            .symDifference(gf.createPoint(new Coordinate(24, 25)).buffer(1.0));
    MultiPolygon mp = gf.createMultiPolygon(polygons);
    assertTrue(mp.isValid());
    System.out.println(mp.toString());

    Map<String, String> attributes = Collections.singletonMap("key1", "value1");

    VectorTileEncoder vtm = new VectorTileEncoder(256);
    vtm.addFeature("mp", attributes, mp);

    byte[] encoded = vtm.encode();
    assertTrue(encoded.length > 0);

    VectorTileDecoder decoder = new VectorTileDecoder();
    List<Feature> features = decoder.decode(encoded).asList();
    assertEquals(1, features.size());
    MultiPolygon mp2 = (MultiPolygon) features.get(0).getGeometry();
    assertEquals(mp.getNumGeometries(), mp2.getNumGeometries());
}
 
Example #7
Source File: ExtractAttributes.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * (non-Javadoc)
 *
 * @see
 *     org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.PolygonSymbolizer)
 */
@Override
public void visit(PolygonSymbolizer poly) {
    PolygonSymbolizer copy = sf.createPolygonSymbolizer();
    copy.setFill(copy(poly.getFill()));

    copy.setGeometry(copy(MultiPolygon.class, poly.getGeometry()));

    copy.setUnitOfMeasure(poly.getUnitOfMeasure());
    copy.setStroke(copy(poly.getStroke()));
    copy.getOptions().putAll(poly.getOptions());

    if (STRICT && !copy.equals(poly)) {
        throw new IllegalStateException(
                "Was unable to duplicate provided PolygonSymbolizer:" + poly);
    }
    pages.push(copy);
}
 
Example #8
Source File: SpatialiteWKBWriter.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
public void write( Geometry geom, OutStream os ) throws IOException {
    buf[0] = 0x69;
    os.write(buf, 1);
    if (geom instanceof Point)
        writePoint((Point) geom, os);
    // LinearRings will be written as LineStrings
    else if (geom instanceof LineString)
        writeLineString((LineString) geom, os);
    else if (geom instanceof Polygon)
        writePolygon((Polygon) geom, os);
    else if (geom instanceof MultiPoint)
        writeGeometryCollection(WKBConstants.wkbMultiPoint, (MultiPoint) geom, os);
    else if (geom instanceof MultiLineString)
        writeGeometryCollection(WKBConstants.wkbMultiLineString, (MultiLineString) geom, os);
    else if (geom instanceof MultiPolygon)
        writeGeometryCollection(WKBConstants.wkbMultiPolygon, (MultiPolygon) geom, os);
    else if (geom instanceof GeometryCollection)
        writeGeometryCollection(WKBConstants.wkbGeometryCollection, (GeometryCollection) geom, os);
    else {
        Assert.shouldNeverReachHere("Unknown Geometry type");
    }
}
 
Example #9
Source File: CreateInternalDataSource.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds the geometry field.
 *
 * @param b the b
 * @param fieldName the field name
 * @return the attribute descriptor
 */
private AttributeDescriptor addGeometryField(
        ExtendedSimpleFeatureTypeBuilder b, String fieldName) {
    geometryField.setGeometryFieldName(fieldName);
    Class<?> fieldType;
    switch (dsInfo.getGeometryType()) {
        case POLYGON:
            fieldType = MultiPolygon.class;
            break;
        case LINE:
            fieldType = LineString.class;
            break;
        case POINT:
        default:
            fieldType = Point.class;
            break;
    }
    b.setDefaultGeometry(fieldName);
    return b.createAttributeDescriptor(fieldName, fieldType);
}
 
Example #10
Source File: GeoWaveSpatialEncoders.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static void registerUDTs() {
  UDTRegistration.register(
      Geometry.class.getCanonicalName(),
      GeometryUDT.class.getCanonicalName());
  UDTRegistration.register(Point.class.getCanonicalName(), PointUDT.class.getCanonicalName());
  UDTRegistration.register(
      LineString.class.getCanonicalName(),
      LineStringUDT.class.getCanonicalName());
  UDTRegistration.register(Polygon.class.getCanonicalName(), PolygonUDT.class.getCanonicalName());

  UDTRegistration.register(
      MultiLineString.class.getCanonicalName(),
      MultiLineStringUDT.class.getCanonicalName());
  UDTRegistration.register(
      MultiPoint.class.getCanonicalName(),
      MultiPointUDT.class.getCanonicalName());
  UDTRegistration.register(
      MultiPolygon.class.getCanonicalName(),
      MultiPolygonUDT.class.getCanonicalName());
}
 
Example #11
Source File: TWKBWriter.java    From geowave with Apache License 2.0 6 votes vote down vote up
private void writeMultiPolygon(
    final MultiPolygon multiPolygon,
    final PrecisionWriter precision,
    final DataOutput output) throws IOException {
  Varint.writeUnsignedVarInt(multiPolygon.getNumGeometries(), output);
  for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
    final Polygon polygon = (Polygon) multiPolygon.getGeometryN(i);
    if (polygon.isEmpty()) {
      Varint.writeUnsignedVarInt(0, output);
      continue;
    }
    Varint.writeUnsignedVarInt(polygon.getNumInteriorRing() + 1, output);
    precision.writePointArray(polygon.getExteriorRing().getCoordinates(), output);
    for (int j = 0; j < polygon.getNumInteriorRing(); j++) {
      precision.writePointArray(polygon.getInteriorRingN(j).getCoordinates(), output);
    }
  }
}
 
Example #12
Source File: TestSpatialDbsMain.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testContents() throws Exception {
    assertEquals(3, db.getCount(MPOLY_TABLE));

    QueryResult result = db.getTableRecordsMapIn(MPOLY_TABLE, null, 2, 4326, null);
    assertEquals(2, result.data.size());

    result = db.getTableRecordsMapIn(MPOLY_TABLE, null, -1, 4326, null);
    assertEquals(3, result.data.size());

    assertEquals(3, result.geometryIndex);

    Object geomObject = result.data.get(0)[result.geometryIndex];
    assertNotNull(geomObject);

    assertTrue(geomObject instanceof MultiPolygon);
}
 
Example #13
Source File: TWKBWriter.java    From geowave with Apache License 2.0 6 votes vote down vote up
private byte getType(final Geometry geom) {
  if (geom instanceof Point) {
    return TWKBUtils.POINT_TYPE;
  } else if (geom instanceof LineString) {
    return TWKBUtils.LINESTRING_TYPE;
  } else if (geom instanceof Polygon) {
    return TWKBUtils.POLYGON_TYPE;
  } else if (geom instanceof MultiPoint) {
    return TWKBUtils.MULTIPOINT_TYPE;
  } else if (geom instanceof MultiLineString) {
    return TWKBUtils.MULTILINESTRING_TYPE;
  } else if (geom instanceof MultiPolygon) {
    return TWKBUtils.MULTIPOLYGON_TYPE;
  }
  return TWKBUtils.GEOMETRYCOLLECTION_TYPE;
}
 
Example #14
Source File: GeoJSONEncoder.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
protected ObjectNode encodeGeometry(Geometry geometry, int parentSrid)
        throws JSONEncodingException {
    Preconditions.checkNotNull(geometry);
    if (geometry.isEmpty()) {
        return null;
    } else if (geometry instanceof Point) {
        return encode((Point) geometry, parentSrid);
    } else if (geometry instanceof LineString) {
        return encode((LineString) geometry, parentSrid);
    } else if (geometry instanceof Polygon) {
        return encode((Polygon) geometry, parentSrid);
    } else if (geometry instanceof MultiPoint) {
        return encode((MultiPoint) geometry, parentSrid);
    } else if (geometry instanceof MultiLineString) {
        return encode((MultiLineString) geometry, parentSrid);
    } else if (geometry instanceof MultiPolygon) {
        return encode((MultiPolygon) geometry, parentSrid);
    } else if (geometry instanceof GeometryCollection) {
        return encode((GeometryCollection) geometry, parentSrid);
    } else {
        throw new JSONEncodingException("unknown geometry type " + geometry.getGeometryType());
    }
}
 
Example #15
Source File: ShapeWriter.java    From geopaparazzi with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a {@link Shape} representing a {@link Geometry},
 * according to the specified PointTransformation
 * and PointShapeFactory (if relevant).
 * <p>
 * Note that Shapes do not
 * preserve information fragment_about which elements in heterogeneous collections
 * are 1D and which are 2D.
 * For example, a GeometryCollection containing a ring and a
 * disk will render as two disks if Graphics.fill is used,
 * or as two rings if Graphics.draw is used.
 * To avoid this issue use separate shapes for the components.
 *
 * @param geometry the geometry to convert
 * @return a Shape representing the geometry
 */
public DrawableShape toShape(Geometry geometry) {
    if (geometry.isEmpty())
        return new PathShape(new Path());
    else if (geometry instanceof Polygon)
        return toShape((Polygon) geometry);
    else if (geometry instanceof MultiPolygon)
        return toShape((MultiPolygon) geometry);
    else if (geometry instanceof LineString)
        return toShape((LineString) geometry);
    else if (geometry instanceof MultiLineString)
        return toShape((MultiLineString) geometry);
    else if (geometry instanceof Point)
        return toShape((Point) geometry);
    else if (geometry instanceof MultiPoint)
        return toShape((MultiPoint) geometry);
    else if (geometry instanceof GeometryCollection)
        return toShape((GeometryCollection) geometry);

    throw new IllegalArgumentException("Unrecognized Geometry class: " + geometry.getClass());
}
 
Example #16
Source File: MultiPolygons.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
private static Set<MultiPolygon> initializeFrom(File shapeFile) throws IOException {
    URL shapeFileURL = shapeFile.toURI().toURL();
    Map<String, URL> inputMap = new HashMap<>();
    inputMap.put("url", shapeFileURL);

    DataStore dataStore = DataStoreFinder.getDataStore(inputMap);
    SimpleFeatureSource featureSource = dataStore.getFeatureSource(dataStore.getTypeNames()[0]);
    SimpleFeatureCollection collection = DataUtilities.collection(featureSource.getFeatures());
    dataStore.dispose();

    Set<MultiPolygon> polygons = new HashSet<>();
    SimpleFeatureIterator iterator = collection.features();
    while (iterator.hasNext())
        polygons.add((MultiPolygon) iterator.next().getDefaultGeometry());
    return polygons;
}
 
Example #17
Source File: SceneFeatureIterator.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public SimpleFeature apply(final CSVRecord input) {
  if (input == null) {
    return null;
  }
  final String entityId = input.get("entityId");
  final double cloudCover = Double.parseDouble(input.get("cloudCover"));
  final String processingLevel = input.get("processingLevel");
  final int path = Integer.parseInt(input.get("path"));
  final int row = Integer.parseInt(input.get("row"));
  final String downloadUrl = input.get("download_url");

  final MultiPolygon shape = wrs2Geometry.getGeometry(path, row);
  featureBuilder.add(shape);
  featureBuilder.add(entityId);
  Date aquisitionDate;
  final SimpleDateFormat sdf = new SimpleDateFormat(AQUISITION_DATE_FORMAT);
  try {
    aquisitionDate = sdf.parse(input.get("acquisitionDate"));
    featureBuilder.add(aquisitionDate);
  } catch (final ParseException e) {
    LOGGER.warn("Unable to parse aquisition date", e);

    featureBuilder.add(null);
  }

  featureBuilder.add(cloudCover);
  featureBuilder.add(processingLevel);
  featureBuilder.add(path);
  featureBuilder.add(row);
  featureBuilder.add(downloadUrl);
  return featureBuilder.buildFeature(entityId);
}
 
Example #18
Source File: GeoJSONUtils.java    From crate with Apache License 2.0 5 votes vote down vote up
public Map<String, Object> convert(Geometry geometry) {
    HashMap<String, Object> builder = new HashMap<>();

    if (geometry instanceof Point) {
        builder.put(TYPE_FIELD, POINT);
        builder.put(COORDINATES_FIELD, extract((Point) geometry));
    } else if (geometry instanceof MultiPoint) {
        builder.put(TYPE_FIELD, MULTI_POINT);
        builder.put(COORDINATES_FIELD, extract((MultiPoint) geometry));
    } else if (geometry instanceof LineString) {
        builder.put(TYPE_FIELD, LINE_STRING);
        builder.put(COORDINATES_FIELD, extract((LineString) geometry));
    } else if (geometry instanceof MultiLineString) {
        builder.put(TYPE_FIELD, MULTI_LINE_STRING);
        builder.put(COORDINATES_FIELD, extract((MultiLineString) geometry));
    } else if (geometry instanceof Polygon) {
        builder.put(TYPE_FIELD, POLYGON);
        builder.put(COORDINATES_FIELD, extract((Polygon) geometry));
    } else if (geometry instanceof MultiPolygon) {
        builder.put(TYPE_FIELD, MULTI_POLYGON);
        builder.put(COORDINATES_FIELD, extract((MultiPolygon) geometry));
    } else if (geometry instanceof GeometryCollection) {
        GeometryCollection geometryCollection = (GeometryCollection) geometry;
        int size = geometryCollection.getNumGeometries();
        List<Map<String, Object>> geometries = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            geometries.add(convert(geometryCollection.getGeometryN(i)));
        }
        builder.put(TYPE_FIELD, GEOMETRY_COLLECTION);
        builder.put(GEOMETRIES_FIELD, geometries);
    } else {
        throw new IllegalArgumentException(String.format(Locale.ENGLISH,
            "Cannot extract coordinates from geometry %s", geometry.getGeometryType()));
    }
    return Collections.unmodifiableMap(builder);
}
 
Example #19
Source File: GeoJSONUtils.java    From crate with Apache License 2.0 5 votes vote down vote up
private double[][][][] extract(MultiPolygon multiPolygon) {
    int size = multiPolygon.getNumGeometries();
    double[][][][] polygons = new double[size][][][];
    for (int i = 0; i < size; i++) {
        polygons[i] = extract((Polygon) multiPolygon.getGeometryN(i));
    }
    return polygons;
}
 
Example #20
Source File: ShapeWriter.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
private DrawableShape toShape(MultiPolygon mp) {
    GeometryCollectionShape shapes = new GeometryCollectionShape();
    for (int i = 0; i < mp.getNumGeometries(); i++) {
        Polygon polygon = (Polygon) mp.getGeometryN(i);
        DrawableShape shape = toShape(polygon);
        shapes.add(shape);
    }
    return shapes;
}
 
Example #21
Source File: JtsPolygonIterable.java    From geogson with Apache License 2.0 5 votes vote down vote up
public static JtsPolygonIterable of(final MultiPolygon src) {
    return new JtsPolygonIterable(new PolygonProvider() {
        @Override
        public int getNumPolygons() {
            return src.getNumGeometries();
        }

        @Override
        public Polygon getPolygonN(int n) {
            return (Polygon) src.getGeometryN(n);
        }
    });
}
 
Example #22
Source File: GeometryTransform.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Transforms the given geometry. This method delegates to one of the {@code transform(…)} methods
 * based on the type of the given geometry.
 *
 * @param  geom  the geometry to transform.
 * @return the transformed geometry.
 * @throws TransformException if an error occurred while transforming the geometry.
 */
public Geometry transform(final Geometry geom) throws TransformException {
    if (geom instanceof Point)              return transform((Point)              geom);
    if (geom instanceof MultiPoint)         return transform((MultiPoint)         geom);
    if (geom instanceof LinearRing)         return transform((LinearRing)         geom);    // Must be tested before LineString.
    if (geom instanceof LineString)         return transform((LineString)         geom);
    if (geom instanceof MultiLineString)    return transform((MultiLineString)    geom);
    if (geom instanceof Polygon)            return transform((Polygon)            geom);
    if (geom instanceof MultiPolygon)       return transform((MultiPolygon)       geom);
    if (geom instanceof GeometryCollection) return transform((GeometryCollection) geom);
    throw new IllegalArgumentException(Errors.format(Errors.Keys.UnsupportedType_1, Classes.getClass(geom)));
}
 
Example #23
Source File: BaseDAOTest.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
protected MultiPolygon buildMultiPolygon() {
    try {
        WKTReader reader = new WKTReader();
        MultiPolygon mp = (MultiPolygon) reader.read(MULTIPOLYGONWKT);
        mp.setSRID(4326);
        return mp;
    } catch (ParseException ex) {
        throw new RuntimeException("Unexpected exception: " + ex.getMessage(), ex);
    }
}
 
Example #24
Source File: PolygonShape.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * To geometry method
 *
 * @param factory GeometryFactory
 * @return Geometry
 */
@Override
public Geometry toGeometry(GeometryFactory factory) {
    if (this._polygons.size() == 1) {
        return this._polygons.get(0).toGeometry(factory);
    } else {
        org.locationtech.jts.geom.Polygon[] polygons = new org.locationtech.jts.geom.Polygon[this._polygons.size()];
        for (int j = 0; j < polygons.length; j++) {
            polygons[j] = (org.locationtech.jts.geom.Polygon) this._polygons.get(j).toGeometry(factory);
        }
        MultiPolygon mls = factory.createMultiPolygon(polygons);
        return mls;
    }
}
 
Example #25
Source File: XMultiPolygonAdapter.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
@Override
public MultiPolygon unmarshal(String val) throws ParseException {
    WKTReader wktReader = new WKTReader();

    Geometry the_geom = wktReader.read(val);
    if (the_geom.getSRID() == 0)
        the_geom.setSRID(4326);

    try {
        return (MultiPolygon) the_geom;
    } catch (ClassCastException e) {
        throw new ParseException("WKT val is a " + the_geom.getClass().getName());
    }
}
 
Example #26
Source File: RulesManagerServiceImpl.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
public LayerLimitsInfo getLayerLimitsInfo(RuleModel rule) {
    Long ruleId = rule.getId();
    RuleLimits ruleLimits = null;
    LayerLimitsInfo layerLimitsInfo = null;

    try {
        ruleLimits = geofenceRemoteService.getRuleAdminService()
                .get(ruleId).getRuleLimits();

        if (ruleLimits != null) {
            layerLimitsInfo = new LayerLimitsInfo();
            layerLimitsInfo.setRuleId(ruleId);

            MultiPolygon the_geom = ruleLimits.getAllowedArea();

            if (the_geom != null) {
                layerLimitsInfo.setAllowedArea(the_geom.toText());
                layerLimitsInfo.setSrid(String.valueOf(the_geom.getSRID()));
            } else {
                layerLimitsInfo.setAllowedArea(null);
                layerLimitsInfo.setSrid(null);
            }

            ClientCatalogMode ccm = toClientCM(ruleLimits.getCatalogMode());
            layerLimitsInfo.setCatalogMode(ccm);
        }
    } catch (NotFoundServiceEx e) {
        logger.error(e.getMessage(), e);
        throw new ApplicationException(e.getMessage(), e);
    }

    return layerLimitsInfo;
}
 
Example #27
Source File: XMultiPolygonAdapter.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String marshal(MultiPolygon the_geom) throws ParseException {
    if (the_geom != null) {
        WKTWriter wktWriter = new WKTWriter();
        if (the_geom.getSRID() == 0)
            the_geom.setSRID(4326);

        return wktWriter.write(the_geom);
    } else {
        throw new ParseException("Geometry obj is null.");
    }
}
 
Example #28
Source File: GeometryUtility.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the multi polygon.
 *
 * @param pol
 *            the pol
 * @return the multi polygon
 */
public MultiPolygon createMultiPolygon(Polygon[] pol)
{
    MultiPolygon multiPoly = this.factory.createMultiPolygon(pol);
    if (multiPoly.getSRID() == 0)
    {
        multiPoly.setSRID(4326);
    }

    return multiPoly;
}
 
Example #29
Source File: GeometryUtility.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the wkt from multi polygon.
 *
 * @param multiPoly
 *            the multi poly
 * @return the string
 * @throws ParseException
 *             the parse exception
 */
public String createWKTFromMultiPolygon(MultiPolygon multiPoly) throws ParseException
{
    if (multiPoly.getSRID() == 0)
    {
        multiPoly.setSRID(4326);
    }

    return this.multiPolAdapter.marshal(multiPoly);
}
 
Example #30
Source File: GeometryUtility.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the multi polygon.
 *
 * @param wkt
 *            the wkt
 * @return the multi polygon
 * @throws ParseException
 *             the parse exception
 */
public MultiPolygon createMultiPolygon(String wkt) throws ParseException
{
    MultiPolygon multiPoly = this.multiPolAdapter.unmarshal(wkt);
    if (multiPoly.getSRID() == 0)
    {
        multiPoly.setSRID(4326);
    }

    return multiPoly;
}