Java 类com.vividsolutions.jts.geom.MultiPoint 实例源码

项目:elasticsearch_my    文件:ElasticsearchGeoAssertions.java   
public static void assertEquals(Geometry s1, Geometry s2) {
    if(s1 instanceof LineString && s2 instanceof LineString) {
        assertEquals((LineString) s1, (LineString) s2);

    } else if (s1 instanceof Polygon && s2 instanceof Polygon) {
        assertEquals((Polygon) s1, (Polygon) s2);

    } else if (s1 instanceof MultiPoint && s2 instanceof MultiPoint) {
        Assert.assertEquals(s1, s2);

    } else if (s1 instanceof MultiPolygon && s2 instanceof MultiPolygon) {
        assertEquals((MultiPolygon) s1, (MultiPolygon) s2);

    } else if (s1 instanceof MultiLineString && s2 instanceof MultiLineString) {
        assertEquals((MultiLineString) s1, (MultiLineString) s2);

    } else {
        throw new RuntimeException("equality of shape types not supported [" + s1.getClass().getName() + " and " + s2.getClass().getName() + "]");
    }
}
项目:vt-support    文件:JtsAdapter.java   
/**
 * Get the MVT type mapping for the provided JTS Geometry.
 *
 * @param geometry JTS Geometry to get MVT type for
 * @return MVT type for the given JTS Geometry, may return
 * {@link uk.os.vt.mvt.VectorTile.Tile.GeomType#UNKNOWN}
 */
public static VectorTile.Tile.GeomType toGeomType(Geometry geometry) {
  VectorTile.Tile.GeomType result = VectorTile.Tile.GeomType.UNKNOWN;

  if (geometry instanceof Point
      || geometry instanceof MultiPoint) {
    result = VectorTile.Tile.GeomType.POINT;

  } else if (geometry instanceof LineString
      || geometry instanceof MultiLineString) {
    result = VectorTile.Tile.GeomType.LINESTRING;

  } else if (geometry instanceof Polygon
      || geometry instanceof MultiPolygon) {
    result = VectorTile.Tile.GeomType.POLYGON;
  }

  return result;
}
项目:Earth    文件:RepeatedPointTester.java   
public boolean hasRepeatedPoint(Geometry g) {
    if (g.isEmpty()) {
        return false;
    }
    if (g instanceof Point) {
        return false;
    } else if (g instanceof MultiPoint) {
        return false;
    }
    // LineString also handles LinearRings
    else if (g instanceof LineString) {
        return this.hasRepeatedPoint(g.getCoordinates());
    } else if (g instanceof Polygon) {
        return this.hasRepeatedPoint((Polygon) g);
    } else if (g instanceof GeometryCollection) {
        return this.hasRepeatedPoint((GeometryCollection) g);
    } else {
        throw new UnsupportedOperationException(g.getClass().getName());
    }
}
项目:Earth    文件:IsSimpleOp.java   
private boolean computeSimple(Geometry geom) {
    this.nonSimpleLocation = null;
    if (geom.isEmpty()) {
        return true;
    }
    if (geom instanceof LineString) {
        return this.isSimpleLinearGeometry(geom);
    }
    if (geom instanceof MultiLineString) {
        return this.isSimpleLinearGeometry(geom);
    }
    if (geom instanceof MultiPoint) {
        return this.isSimpleMultiPoint((MultiPoint) geom);
    }
    if (geom instanceof Polygonal) {
        return this.isSimplePolygonal(geom);
    }
    if (geom instanceof GeometryCollection) {
        return this.isSimpleGeometryCollection(geom);
    }
    // all other geometry types are simple by definition
    return true;
}
项目:Earth    文件:IsSimpleOp.java   
private boolean isSimpleMultiPoint(MultiPoint mp) {
    if (mp.isEmpty()) {
        return true;
    }
    Set points = new TreeSet();
    for (int i = 0; i < mp.getNumGeometries(); i++) {
        Point pt = (Point) mp.getGeometryN(i);
        Coordinate p = pt.getCoordinate();
        if (points.contains(p)) {
            this.nonSimpleLocation = p;
            return false;
        }
        points.add(p);
    }
    return true;
}
项目:Earth    文件:OffsetCurveSetBuilder.java   
private void add(Geometry g) {
    if (g.isEmpty()) {
        return;
    }

    if (g instanceof Polygon) {
        this.addPolygon((Polygon) g);
    }
    // LineString also handles LinearRings
    else if (g instanceof LineString) {
        this.addLineString((LineString) g);
    } else if (g instanceof Point) {
        this.addPoint((Point) g);
    } else if (g instanceof MultiPoint) {
        this.addCollection((MultiPoint) g);
    } else if (g instanceof MultiLineString) {
        this.addCollection((MultiLineString) g);
    } else if (g instanceof MultiPolygon) {
        this.addCollection((MultiPolygon) g);
    } else if (g instanceof GeometryCollection) {
        this.addCollection((GeometryCollection) g);
    } else {
        throw new UnsupportedOperationException(g.getClass().getName());
    }
}
项目:Earth    文件:GMLWriter.java   
private void write(Geometry geom, Writer writer, int level)
        throws IOException {
    this.isRootTag = true;
    if (geom instanceof Point) {
        this.writePoint((Point) geom, writer, level);
    } else if (geom instanceof LineString) {
        this.writeLineString((LineString) geom, writer, level);
    } else if (geom instanceof Polygon) {
        this.writePolygon((Polygon) geom, writer, level);
    } else if (geom instanceof MultiPoint) {
        this.writeMultiPoint((MultiPoint) geom, writer, level);
    } else if (geom instanceof MultiLineString) {
        this.writeMultiLineString((MultiLineString) geom, writer, level);
    } else if (geom instanceof MultiPolygon) {
        this.writeMultiPolygon((MultiPolygon) geom, writer, level);
    } else if (geom instanceof GeometryCollection) {
        this.writeGeometryCollection((GeometryCollection) geom, writer,
                this.startingIndentIndex);
    } else {
        throw new IllegalArgumentException("Unhandled geometry type: "
                + geom.getGeometryType());
    }
    writer.flush();
}
项目:Earth    文件:GMLWriter.java   
private void writeMultiPoint(MultiPoint mp, Writer writer, int level)
        throws IOException {
    this.startLine(level, writer);
    this.startGeomTag(GMLConstants.GML_MULTI_POINT, mp, writer);

    for (int t = 0; t < mp.getNumGeometries(); t++) {
        this.startLine(level + 1, writer);
        this.startGeomTag(GMLConstants.GML_POINT_MEMBER, null, writer);

        this.writePoint((Point) mp.getGeometryN(t), writer, level + 2);

        this.startLine(level + 1, writer);
        this.endGeomTag(GMLConstants.GML_POINT_MEMBER, writer);
    }
    this.startLine(level, writer);
    this.endGeomTag(GMLConstants.GML_MULTI_POINT, writer);
}
项目:Earth    文件:WKBWriter.java   
/**
 * Writes a {@link Geometry} to an {@link OutStream}.
 *
 * @param geom the geometry to write
 * @param os the out stream to write to
 * @throws IOException if an I/O error occurs
 */
public void write(Geometry geom, OutStream os) throws IOException {
    if (geom instanceof Point) {
        this.writePoint((Point) geom, os);
    }
    // LinearRings will be written as LineStrings
    else if (geom instanceof LineString) {
        this.writeLineString((LineString) geom, os);
    } else if (geom instanceof Polygon) {
        this.writePolygon((Polygon) geom, os);
    } else if (geom instanceof MultiPoint) {
        this.writeGeometryCollection(WKBConstants.wkbMultiPoint,
                (MultiPoint) geom, os);
    } else if (geom instanceof MultiLineString) {
        this.writeGeometryCollection(WKBConstants.wkbMultiLineString,
                (MultiLineString) geom, os);
    } else if (geom instanceof MultiPolygon) {
        this.writeGeometryCollection(WKBConstants.wkbMultiPolygon,
                (MultiPolygon) geom, os);
    } else if (geom instanceof GeometryCollection) {
        this.writeGeometryCollection(WKBConstants.wkbGeometryCollection,
                (GeometryCollection) geom, os);
    } else {
        Assert.shouldNeverReachHere("Unknown Geometry type");
    }
}
项目:Earth    文件:WKTWriter.java   
/**
 * Converts a <code>MultiPoint</code> to &lt;MultiPoint Text&gt; format, then
 * appends it to the writer.
 *
 * @param multiPoint the <code>MultiPoint</code> to process
 * @param writer the output writer to append to
 */
private void appendMultiPointText(MultiPoint multiPoint, int level, Writer writer)
        throws IOException {
    if (multiPoint.isEmpty()) {
        writer.write("EMPTY");
    } else {
        writer.write("(");
        for (int i = 0; i < multiPoint.getNumGeometries(); i++) {
            if (i > 0) {
                writer.write(", ");
                this.indentCoords(i, level + 1, writer);
            }
            writer.write("(");
            this.appendCoordinate(multiPoint.getGeometryN(i).getCoordinate(), writer);
            writer.write(")");
        }
        writer.write(")");
    }
}
项目:geoxygene    文件:GeOxygeneGeoToolsTypes.java   
/**
 * @param type
 * @return the class of the given geometry type
 */
private static Class<? extends GM_Object> geometryType(Class<?> type) {
    if (type == null) {
        return GM_Object.class;
    }
    if (Point.class.isAssignableFrom(type)) {
        return GM_Point.class;
    }
    if (MultiPoint.class.isAssignableFrom(type)) {
        return GM_MultiPoint.class;
    }
    if (LineString.class.isAssignableFrom(type)) {
        return GM_LineString.class;
    }
    if (Polygon.class.isAssignableFrom(type)) {
        return GM_Polygon.class;
    }
    return GM_MultiSurface.class;
}
项目:geoxygene    文件:AdapterFactory.java   
/**
 * Traduit un type de géométrie JTS {@link Geometry} et renvoie le type de
 * géométrie GeOxygene {@link IGeometry} équivalent. TODO gérer tous les types
 * de géométrie.
 * @param geometryType type de géométrie JTS
 * @return type de géométrie GeOxygene équivalent
 */
public static Class<? extends IGeometry> toGeometryType(Class<?> geometryType) {
  if (LineString.class.equals(geometryType)) {
    return ILineString.class;
  }
  if (MultiLineString.class.equals(geometryType)) {
    return IMultiCurve.class;
  }
  if (Polygon.class.equals(geometryType)) {
    return IPolygon.class;
  }
  if (MultiPolygon.class.equals(geometryType)) {
    return IMultiSurface.class;
  }
  if (Point.class.equals(geometryType)) {
    return IPoint.class;
  }
  if (MultiPoint.class.equals(geometryType)) {
    return IMultiPoint.class;
  }
  return IGeometry.class;
}
项目:geoxygene    文件:AdapterFactory.java   
/**
 * Traduit un type de géométrie GeOxygene {@link IGeometry} et renvoie le type
 * de géométrie JTS {@link Geometry} équivalent. TODO gérer tous les types de
 * géométrie.
 * @param geometryType type de géométrie GeOxygene
 * @return type de géométrie JTS équivalent
 */
public static Class<? extends Geometry> toJTSGeometryType(
    Class<?> geometryType) {
  if (ILineString.class.isAssignableFrom(geometryType)) {
    return LineString.class;
  }
  if (IMultiCurve.class.isAssignableFrom(geometryType)) {
    return MultiLineString.class;
  }
  if (IPolygon.class.isAssignableFrom(geometryType)) {
    return Polygon.class;
  }
  if (IMultiSurface.class.isAssignableFrom(geometryType)) {
    return MultiPolygon.class;
  }
  if (IPoint.class.isAssignableFrom(geometryType)) {
    return Point.class;
  }
  if (IMultiPoint.class.isAssignableFrom(geometryType)) {
    return MultiPoint.class;
  }
  if (IAggregate.class.isAssignableFrom(geometryType)) {
    return GeometryCollection.class;
  }
  return Geometry.class;
}
项目:sldeditor    文件:AllowedAttributeTypes.java   
/**
 * Initialise.
 */
private static void initialise()
{
    List<Class<?> > doubleList = new ArrayList<Class<?> >(Arrays.asList(Integer.class, Long.class, Double.class, Float.class));
    List<Class<?> > integerList = new ArrayList<Class<?> >(Arrays.asList(Integer.class, Long.class));
    List<Class<?> > stringList = new ArrayList<Class<?> >(Arrays.asList(String.class));
    List<Class<?> > geometryList = new ArrayList<Class<?> >(Arrays.asList(Point.class, LineString.class, Polygon.class, MultiPolygon.class, MultiPoint.class, MultiLineString.class));

    allowedClassTypeMap.put(String.class, stringList);
    allowedClassTypeMap.put(Double.class, doubleList);
    allowedClassTypeMap.put(Float.class, doubleList);
    allowedClassTypeMap.put(Integer.class, integerList);
    allowedClassTypeMap.put(Long.class, integerList);
    allowedClassTypeMap.put(Geometry.class, geometryList);

    List<Class<?> > objectList = new ArrayList<Class<?>>();
    objectList.addAll(doubleList);
    objectList.addAll(integerList);
    objectList.addAll(stringList);
    objectList.addAll(geometryList);
    allowedClassTypeMap.put(Object.class, objectList);
}
项目:StreetComplete    文件:GeoJsonReaderTest.java   
public void testMultiPoint()
{
    Geometry g = read("{\n" +
            "  \"type\": \"MultiPoint\",\n" +
            "  \"coordinates\": [[1,2],[2,4]]\n" +
            "}");
    assertTrue(g instanceof MultiPoint);
    MultiPoint m = (MultiPoint) g;
    assertEquals(2,m.getNumGeometries());
    Point p0 = (Point) m.getGeometryN(0);
    Point p1 = (Point) m.getGeometryN(1);
    assertEquals(1.0,p0.getX());
    assertEquals(2.0,p0.getY());
    assertEquals(2.0,p1.getX());
    assertEquals(4.0,p1.getY());
}
项目:gs-mvt    文件:VectorTileEncoder.java   
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;
    }
    return VectorTile.Tile.GeomType.UNKNOWN;
}
项目:gama    文件:SaveStatement.java   
public String getGeometryType(final List<? extends IShape> agents) {
    String geomType = "";
    for (final IShape be : agents) {
        final IShape geom = be.getGeometry();
        if (geom != null) {
            geomType = geom.getInnerGeometry().getClass().getSimpleName();
            if (geom.getInnerGeometry().getNumGeometries() > 1) {
                if (geom.getInnerGeometry().getGeometryN(0).getClass() == Point.class) {
                    geomType = MultiPoint.class.getSimpleName();
                } else if (geom.getInnerGeometry().getGeometryN(0).getClass() == LineString.class) {
                    geomType = MultiLineString.class.getSimpleName();
                } else if (geom.getInnerGeometry().getGeometryN(0).getClass() == Polygon.class) {
                    geomType = MultiPolygon.class.getSimpleName();
                }
                break;
            }
        }
    }

    if ("DynamicLineString".equals(geomType))
        geomType = LineString.class.getSimpleName();
    return geomType;
}
项目:GeoSpark    文件:VoronoiPartitioning.java   
/**
 * Instantiates a new voronoi partitioning.
 *
 * @param samples the sample list
 * @param partitions the partitions
 * @throws Exception the exception
 */
public VoronoiPartitioning(List<Envelope> samples, int partitions) throws Exception
{
    GeometryFactory fact = new GeometryFactory();
    ArrayList<Point> subSampleList=new ArrayList<Point>();
    MultiPoint mp;

    //Take a subsample accoring to the partitions
    for(int i=0;i<samples.size();i=i+samples.size()/partitions)
    {
        Envelope envelope = samples.get(i);
        Coordinate coordinate = new Coordinate((envelope.getMinX()+envelope.getMaxX())/2.0,(envelope.getMinY()+envelope.getMaxY())/2.0);
        subSampleList.add(fact.createPoint(coordinate));
    }

    mp=fact.createMultiPoint(subSampleList.toArray(new Point[subSampleList.size()]));
    VoronoiDiagramBuilder voronoiBuilder = new VoronoiDiagramBuilder();
    voronoiBuilder.setSites(mp);
    Geometry voronoiDiagram=voronoiBuilder.getDiagram(fact);
    for(int i=0;i<voronoiDiagram.getNumGeometries();i++)
    {
        Polygon poly=(Polygon)voronoiDiagram.getGeometryN(i);
        grids.add(poly.getEnvelopeInternal());
    }
    //grids.add(new EnvelopeWithGrid(boundary,grids.size()));
}
项目:platypus-js    文件:GeometryUtils.java   
public static boolean isValidGeometryData(List<Geometry> aData, Class aGeometryClass) {
    if (Point.class.isAssignableFrom(aGeometryClass)
            || LineString.class.isAssignableFrom(aGeometryClass)
            || Polygon.class.isAssignableFrom(aGeometryClass)) {
        return aData.size() == 1 && isValidGeometryDataSection(aData.get(0).getCoordinates(), aGeometryClass);
    } else if (MultiPoint.class.isAssignableFrom(aGeometryClass)
            || MultiLineString.class.isAssignableFrom(aGeometryClass)
            || MultiPolygon.class.isAssignableFrom(aGeometryClass)) {
        if (aData.size() >= 1) {
            for (int i = 0; i < aData.size(); i++) {
                if (!isValidGeometryDataSection(aData.get(i).getCoordinates(), aGeometryClass)) {
                    return false;
                }
            }
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
项目:platypus-js    文件:GeometryUtils.java   
public static Geometry constructGeometry(Coordinate[] aCoordinates, Class aGeometryClass) {
    Geometry g = null;
    if (isValidGeometryDataSection(aCoordinates, aGeometryClass)) {
        if (Point.class.isAssignableFrom(aGeometryClass)) {
            g = gFactory.createPoint(aCoordinates[0]);
        } else if (LineString.class.isAssignableFrom(aGeometryClass)) {
            g = gFactory.createLineString(aCoordinates);
        } else if (Polygon.class.isAssignableFrom(aGeometryClass)) {
            g = gFactory.createPolygon(aCoordinates);
        } else if (MultiPoint.class.isAssignableFrom(aGeometryClass)) {
            g = gFactory.createMultiPoint(aCoordinates);
        }
        return g;
    }
    return null;
}
项目:modelingcommons    文件:ESRIShapeBuffer.java   
/** */
public MultiPoint getESRIMultiPointRecord (int offset) {
    //Envelope envelope = getBoundingBox(offset);
    offset += 32;
    int nPoints = getInt(offset);
    offset += 4;
    Coordinate[] coords = new Coordinate[nPoints];
    for (int i = 0; i < nPoints; i += 1) {
        double x = _converter.convert(getDouble(offset));
        offset += 8;
        double y = _converter.convert(getDouble(offset));
        offset += 8;
        coords[i] = new Coordinate(x, y);
    }
    return _factory.createMultiPoint(coords);
}
项目:modelingcommons    文件:ESRIShapeBuffer.java   
/** */
public int putESRIMultiPointRecord (int offset, MultiPoint shape, int index) {
    int bytesWritten = 0;
    setByteOrder(ByteOrder.BIG_ENDIAN);
    bytesWritten += putInt(offset + bytesWritten, index);
    int recordLength = 20 + (shape.getNumGeometries() * 8);
    ensureCapacity((recordLength * 2) + 8);
    bytesWritten += putInt(offset + bytesWritten, recordLength);
    setByteOrder(ByteOrder.LITTLE_ENDIAN);
    bytesWritten += putInt(offset + bytesWritten, SHAPE_TYPE_MULTIPOINT);
    bytesWritten += putBoundingBox(offset + bytesWritten, shape.getEnvelopeInternal());
    bytesWritten += putInt(offset + bytesWritten, shape.getNumGeometries());
    for (int i = 0; i < shape.getNumGeometries(); i += 1) {
        Point pt = (Point)shape.getGeometryN(i);
        bytesWritten += putDouble(offset + bytesWritten, _converter.convert(pt.getX()));
        bytesWritten += putDouble(offset + bytesWritten, _converter.convert(pt.getY()));
    }
    return bytesWritten;
}
项目:hortonmachine    文件:GeometryTranslator.java   
/**
 * Builds a point feature from a dwg point.
 */
public SimpleFeature convertDwgPoint( String typeName, String layerName, DwgPoint point, int id ) {
    double[] p = point.getPoint();
    Point2D pto = new Point2D.Double(p[0], p[1]);

    CoordinateList coordList = new CoordinateList();
    Coordinate coord = new Coordinate(pto.getX(), pto.getY(), 0.0);
    coordList.add(coord);

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, MultiPoint.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Geometry points = gF.createMultiPoint(coordList.toCoordinateArray());
    Object[] values = new Object[]{points, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
项目:geokettle-2.0    文件:LayerCollection.java   
public void addGeometryToCollection(Geometry geom, boolean batchMode, int featureIndex){    
    if (geom!=null){
        int type = -1;
        if(geom instanceof Point || geom instanceof MultiPoint){
            type = Layer.POINT_LAYER;
            layers.get(type).addGeometry((Geometry)geom, batchMode);
            featureIndexes.get(type).add(featureIndex);
        }else if(geom instanceof LineString || geom instanceof MultiLineString){
            type = Layer.LINE_LAYER;
            layers.get(type).addGeometry((Geometry)geom, batchMode);
            featureIndexes.get(type).add(featureIndex);
        }else if(geom instanceof Polygon || geom instanceof MultiPolygon){
            type = Layer.POLYGON_LAYER;
            layers.get(type).addGeometry((Geometry)geom, batchMode);
            featureIndexes.get(type).add(featureIndex);
        }else if(geom instanceof GeometryCollection){
            type = Layer.COLLECTION_LAYER;
            layers.get(type).setDisplayCount(layers.get(type).getDisplayCount()+1);
            addGeometryCollection(geom, batchMode, featureIndex);               
        }
    }
}
项目:geodroid_master_update    文件:ShapeWriter.java   
/**
 * 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 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());
}
项目:vdrparser    文件:ParserPolygon.java   
public boolean overlaps(ParserPolygon p)
{

    GeometryFactory gf = new GeometryFactory();
    MultiPoint thisMP = gf.createMultiPoint(this.coords);
    Geometry thisCH = thisMP.convexHull();

    MultiPoint pMP = gf.createMultiPoint(p.coords);
    Geometry pCH = pMP.convexHull();

    Geometry intersection = thisCH.intersection(pCH);
    Geometry union = thisCH.union(pCH);

    if ((intersection.getArea() / union.getArea() - Util.epsilon) > 0.5)
    {
        return true;
    }
    return false;
}
项目:WPS4Aviation    文件:GML32MultiGeometryGenerator.java   
public void encodeAsXmlObject(Object geometry, List<Element> geoms) throws IOException, TransformerException, SAXException {
    this.encoder = new Encoder(config);
    this.encoder.setOmitXMLDeclaration(true);
    if (geometry instanceof MultiPolygon) {
        encodeMultiPolygon((MultiPolygon) geometry, geoms);
    } else if (geometry instanceof Polygon) {
        encodePolygon((Polygon) geometry, geoms);
    } else if (geometry instanceof LinearRing) {
        encodeLinearRing((LinearRing) geometry, geoms);
    } else if (geometry instanceof LineString) {
        encodeLineString((LineString) geometry, geoms);
    } else if (geometry instanceof MultiLineString) {
        encodeMultiLineString((MultiLineString) geometry, geoms);
    } else if (geometry instanceof Point) {
        encodePoint((Point) geometry, geoms);
    } else if (geometry instanceof MultiPoint) {
        encodeMultiPoint((MultiPoint) geometry, geoms);
    }
}
项目:Java-OpenMobility    文件:OGCWKBWriter.java   
/**
 * Writes a {@link Geometry} to an {@link OutStream}.
 *
 * @param geom the geometry to write
 * @param os the out stream to write to
 * @throws IOException if an I/O error occurs
 */
public void write(Geometry geom, OutStream os) throws IOException {
    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");
    }
}
项目:olca-modules    文件:IntersectionsCalculator.java   
Map<String, Double> calculate(KmlFeature feature) {
    if (feature.type == null)
        return Collections.emptyMap();
    Geometry geo = feature.geometry;
    switch (feature.type) {
    case POINT:
        String shapeId = findPointShape(geo);
        return shapeId == null ? Collections.emptyMap()
                : Collections.singletonMap(shapeId, 1d);
    case MULTI_POINT:
        return calculateMultiPoint((MultiPoint) geo);
    case LINE:
    case MULTI_LINE:
        return calculate(geo, new LineStringValueFetch());
    case POLYGON:
    case MULTI_POLYGON:
        return calculate(geo, new PolygonValueFetch());
    default:
        log.warn("cannot calculate shares for type {}", feature.type);
        return Collections.emptyMap();
    }
}
项目:olca-modules    文件:IntersectionsCalculator.java   
private Map<String, Double> calculateMultiPoint(MultiPoint points) {
    Map<String, Double> result = new HashMap<>();
    int count = points.getNumGeometries();
    double total = 0;
    for (int i = 0; i < count; i++) {
        Geometry geo = points.getGeometryN(i);
        String shapeId = findPointShape(geo);
        if (shapeId == null)
            continue;
        Double val = result.get(shapeId);
        if (val == null) {
            result.put(shapeId, 1d);
        } else {
            result.put(shapeId, val + 1d);
        }
        total += 1d;
    }
    return makeRelative(result, total);
}
项目:geomajas-project-server    文件:InternalFeatureCollection.java   
private Class getGeometryBinding(LayerType layerType) {
    switch (layerType) {
        case LINESTRING:
            return Geometry.class;
        case MULTILINESTRING:
            return MultiLineString.class;
        case MULTIPOINT:
            return MultiPoint.class;
        case MULTIPOLYGON:
            return MultiPolygon.class;
        case POINT:
            return Point.class;
        case POLYGON:
            return Polygon.class;
        default:
            return Geometry.class;
    }
}
项目:geomajas-project-server    文件:DtoConverterServiceImpl.java   
/**
 * Convert a layer type to a geometry class.
 * 
 * @param layerType
 *            layer type
 * @return JTS class
 */
public Class<? extends com.vividsolutions.jts.geom.Geometry> toInternal(LayerType layerType) {
    switch (layerType) {
        case GEOMETRY:
            return com.vividsolutions.jts.geom.Geometry.class;
        case LINESTRING:
            return LineString.class;
        case MULTILINESTRING:
            return MultiLineString.class;
        case POINT:
            return Point.class;
        case MULTIPOINT:
            return MultiPoint.class;
        case POLYGON:
            return Polygon.class;
        case MULTIPOLYGON:
            return MultiPolygon.class;
        case RASTER:
            return null;
        default:
            throw new IllegalStateException("Don't know how to handle layer type " + layerType);
    }
}
项目:geomajas-project-server    文件:DtoConverterServiceImpl.java   
/**
 * Convert a geometry class to a layer type.
 * 
 * @param geometryClass
 *            JTS geometry class
 * @return Geomajas layer type
 */
public LayerType toDto(Class<? extends com.vividsolutions.jts.geom.Geometry> geometryClass) {
    if (geometryClass == LineString.class) {
        return LayerType.LINESTRING;
    } else if (geometryClass == MultiLineString.class) {
        return LayerType.MULTILINESTRING;
    } else if (geometryClass == Point.class) {
        return LayerType.POINT;
    } else if (geometryClass == MultiPoint.class) {
        return LayerType.MULTIPOINT;
    } else if (geometryClass == Polygon.class) {
        return LayerType.POLYGON;
    } else if (geometryClass == MultiPolygon.class) {
        return LayerType.MULTIPOLYGON;
    } else {
        return LayerType.GEOMETRY;
    }
}
项目:geomajas-project-server    文件:LayerTypeConverterTest.java   
@Test
public void testConversion() {
    // dto -> internal
    for (LayerType layerType : LayerType.values()) {
        if (layerType != LayerType.RASTER) {
            Class<? extends Geometry> c = converterService.toInternal(layerType);
            Assert.assertEquals(layerType.name(), c.getSimpleName().toUpperCase());
        } else {
            Assert.assertNull(converterService.toInternal(layerType));
        }
    }
    // internal -> dto
    Assert.assertEquals(LayerType.POINT, converterService.toDto(Point.class));
    Assert.assertEquals(LayerType.MULTIPOINT, converterService.toDto(MultiPoint.class));
    Assert.assertEquals(LayerType.LINESTRING, converterService.toDto(LineString.class));
    Assert.assertEquals(LayerType.MULTILINESTRING, converterService.toDto(MultiLineString.class));
    Assert.assertEquals(LayerType.POLYGON, converterService.toDto(Polygon.class));
    Assert.assertEquals(LayerType.MULTIPOLYGON, converterService.toDto(MultiPolygon.class));
    Assert.assertEquals(LayerType.GEOMETRY, converterService.toDto(Geometry.class));
}
项目:geomajas-project-server    文件:GeometryConverterTest.java   
@Test
public void jtsEmptyToDto() throws GeomajasException {
    Geometry p = converter.toDto(createJtsEmpty(Point.class));
    Assert.assertEquals(Geometry.POINT, p.getGeometryType());
    Assert.assertTrue(GeometryService.isEmpty(p));
    Geometry ls = converter.toDto(createJtsEmpty(LineString.class));
    Assert.assertEquals(Geometry.LINE_STRING, ls.getGeometryType());
    Assert.assertTrue(GeometryService.isEmpty(ls));
    Geometry lr = converter.toDto(createJtsEmpty(LinearRing.class));
    Assert.assertEquals(Geometry.LINEAR_RING, lr.getGeometryType());
    Assert.assertTrue(GeometryService.isEmpty(lr));
    Geometry po = converter.toDto(createJtsEmpty(Polygon.class));
    Assert.assertEquals(Geometry.POLYGON, po.getGeometryType());
    Assert.assertTrue(GeometryService.isEmpty(po));
    assertThat(po.getGeometries()).isNull();
    Geometry mp = converter.toDto(createJtsEmpty(MultiPoint.class));
    Assert.assertEquals(Geometry.MULTI_POINT, mp.getGeometryType());
    Assert.assertTrue(GeometryService.isEmpty(mp));
    Geometry mpo = converter.toDto(createJtsEmpty(MultiPolygon.class));
    Assert.assertEquals(Geometry.MULTI_POLYGON, mpo.getGeometryType());
    Assert.assertTrue(GeometryService.isEmpty(mpo));
    Geometry mls = converter.toDto(createJtsEmpty(MultiLineString.class));
    Assert.assertEquals(Geometry.MULTI_LINE_STRING, mls.getGeometryType());
    Assert.assertTrue(GeometryService.isEmpty(mls));
}
项目:geomajas-project-server    文件:GeometryConverterTest.java   
@Test
public void dtoEmptyToJts() throws GeomajasException {
    // Test DTO Point to JTS:
    LineString ls = (LineString) converter.toInternal(createDtoEmpty(Geometry.LINE_STRING));
    Assert.assertTrue(ls.isEmpty());
    LinearRing lr = (LinearRing) converter.toInternal(createDtoEmpty(Geometry.LINEAR_RING));
    Assert.assertTrue(lr.isEmpty());
    MultiLineString mls = (MultiLineString) converter.toInternal(createDtoEmpty(Geometry.MULTI_LINE_STRING));
    Assert.assertTrue(mls.isEmpty());
    MultiPoint mp = (MultiPoint) converter.toInternal(createDtoEmpty(Geometry.MULTI_POINT));
    Assert.assertTrue(mp.isEmpty());
    MultiPolygon mpo = (MultiPolygon) converter.toInternal(createDtoEmpty(Geometry.MULTI_POLYGON));
    Assert.assertTrue(mpo.isEmpty());
    Point p = (Point) converter.toInternal(createDtoEmpty(Geometry.POINT));
    Assert.assertTrue(p.isEmpty());
    Polygon po = (Polygon) converter.toInternal(createDtoEmpty(Geometry.POLYGON));
    Assert.assertTrue(po.isEmpty());
}
项目:geomajas-project-server    文件:GeometryConverterTest.java   
private com.vividsolutions.jts.geom.Geometry createJtsEmpty(Class<?> clazz) {
    if (Point.class.equals(clazz)) {
        return factory.createPoint((com.vividsolutions.jts.geom.Coordinate) null);
    } else if (LineString.class.equals(clazz)) {
        return factory.createLineString((com.vividsolutions.jts.geom.Coordinate[]) null);
    } else if (LinearRing.class.equals(clazz)) {
        return factory.createLinearRing((com.vividsolutions.jts.geom.Coordinate[]) null);
    } else if (Polygon.class.equals(clazz)) {
        return factory.createPolygon(null, null);
    } else if (MultiPoint.class.equals(clazz)) {
        return factory.createMultiPoint((Point[]) null);
    } else if (MultiLineString.class.equals(clazz)) {
        return factory.createMultiLineString((LineString[]) null);
    } else if (MultiPolygon.class.equals(clazz)) {
        return factory.createMultiPolygon((Polygon[]) null);
    } else {
        return null;
    }
}
项目:jts2geojson    文件:GeoJSONWriter.java   
public org.wololo.geojson.Geometry write(Geometry geometry) {
    Class<? extends Geometry> c = geometry.getClass();
    if (c.equals(Point.class)) {
        return convert((Point) geometry);
    } else if (c.equals(LineString.class)) {
        return convert((LineString) geometry);
    } else if (c.equals(Polygon.class)) {
        return convert((Polygon) geometry);
    } else if (c.equals(MultiPoint.class)) {
        return convert((MultiPoint) geometry);
    } else if (c.equals(MultiLineString.class)) {
        return convert((MultiLineString) geometry);
    } else if (c.equals(MultiPolygon.class)) {
        return convert((MultiPolygon) geometry);
    } else if (c.equals(GeometryCollection.class)) {
        return convert((GeometryCollection) geometry);
    } else {
        throw new UnsupportedOperationException();
    }
}
项目:enviroCar-server    文件:GeoBSON.java   
protected BSONObject encodeGeometry(Geometry geometry) throws
        GeometryConverterException {
    Preconditions.checkNotNull(geometry);
    if (geometry.isEmpty()) {
        return null;
    } else if (geometry instanceof Point) {
        return encode((Point) geometry);
    } else if (geometry instanceof LineString) {
        return encode((LineString) geometry);
    } else if (geometry instanceof Polygon) {
        return encode((Polygon) geometry);
    } else if (geometry instanceof MultiPoint) {
        return encode((MultiPoint) geometry);
    } else if (geometry instanceof MultiLineString) {
        return encode((MultiLineString) geometry);
    } else if (geometry instanceof MultiPolygon) {
        return encode((MultiPolygon) geometry);
    } else if (geometry instanceof GeometryCollection) {
        return encode((GeometryCollection) geometry);
    } else {
        throw new GeometryConverterException("unknown geometry type " +
                                             geometry.getGeometryType());
    }
}
项目:enviroCar-server    文件:GeoJSON.java   
protected ObjectNode encodeGeometry(Geometry geometry) throws
        GeometryConverterException {
    Preconditions.checkNotNull(geometry);
    if (geometry.isEmpty()) {
        return null;
    } else if (geometry instanceof Point) {
        return encode((Point) geometry);
    } else if (geometry instanceof LineString) {
        return encode((LineString) geometry);
    } else if (geometry instanceof Polygon) {
        return encode((Polygon) geometry);
    } else if (geometry instanceof MultiPoint) {
        return encode((MultiPoint) geometry);
    } else if (geometry instanceof MultiLineString) {
        return encode((MultiLineString) geometry);
    } else if (geometry instanceof MultiPolygon) {
        return encode((MultiPolygon) geometry);
    } else if (geometry instanceof GeometryCollection) {
        return encode((GeometryCollection) geometry);
    } else {
        throw new GeometryConverterException("unknown geometry type " +
                                             geometry.getGeometryType());
    }
}