org.locationtech.jts.geom.GeometryFactory.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.locationtech.jts.geom.GeometryFactory.<init>()方法的一些代码示例,展示了GeometryFactory.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryFactory.<init>()方法的具体详情如下:
包路径:org.locationtech.jts.geom.GeometryFactory
类名称:GeometryFactory
方法名:<init>

GeometryFactory.<init>介绍

[英]Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial-reference ID of 0.
[中]构造GeometryFactory,该工厂生成具有浮动精度模型和空间参考ID为0的几何图形。

代码示例

代码示例来源:origin: com.h2database/h2

/**
 * Get or create a geometry value for the given geometry.
 *
 * @param s the WKT representation of the geometry
 * @param srid the srid of the object
 * @return the value
 */
public static ValueGeometry get(String s, int srid) {
  try {
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), srid);
    Geometry g = new WKTReader(geometryFactory).read(s);
    return get(g);
  } catch (ParseException ex) {
    throw DbException.convert(ex);
  }
}

代码示例来源:origin: com.h2database/h2

/**
 * Get the union.
 *
 * @param r the other geometry
 * @return the union of this geometry envelope and another geometry envelope
 */
public Value getEnvelopeUnion(ValueGeometry r) {
  GeometryFactory gf = new GeometryFactory();
  Envelope mergedEnvelope = new Envelope(getGeometryNoCopy().getEnvelopeInternal());
  mergedEnvelope.expandToInclude(r.getGeometryNoCopy().getEnvelopeInternal());
  return get(gf.toGeometry(mergedEnvelope));
}

代码示例来源:origin: graphhopper/graphhopper

GeometryFactory geometryFactory = new GeometryFactory();
QueryGraph queryGraph = new QueryGraph(graphHopperStorage);
final EdgeFilter filter = DefaultEdgeFilter.allEdges(graphHopperStorage.getEncodingManager().getEncoder("foot"));

代码示例来源:origin: geoserver/geoserver

GeometryFactory gf = new GeometryFactory();
SimpleFeatureType featureType =
    DataUtilities.createType(

代码示例来源:origin: graphhopper/graphhopper

public LineString toLineString(boolean includeElevation) {
  GeometryFactory gf = new GeometryFactory();
  Coordinate[] coordinates = new Coordinate[getSize() == 1 ? 2 : getSize()];
  for (int i = 0; i < getSize(); i++) {
    coordinates[i] = includeElevation ?
        new Coordinate(
            round6(getLongitude(i)),
            round6(getLatitude(i)),
            round2(getElevation(i))) :
        new Coordinate(
            round6(getLongitude(i)),
            round6(getLatitude(i)));
  }
  // special case as just 1 point is not supported in the specification #1412
  if (getSize() == 1)
    coordinates[1] = coordinates[0];
  return gf.createLineString(coordinates);
}

代码示例来源:origin: geotools/geotools

@Override
public boolean startObject() throws ParseException, IOException {
  if (properties == NULL_LIST) {
    properties = new ArrayList();
  } else if (properties != null) {
    // start of a new object in properties means a geometry
    delegate = new GeometryHandler(new GeometryFactory());
  }
  return super.startObject();
}

代码示例来源:origin: geotools/geotools

/**
 * Converts an arbitrary Java2D shape into a JTS geometry. The created JTS geometry may be any
 * of {@link LineString}, {@link LinearRing} or {@link MultiLineString}.
 *
 * @param shape the input shape
 * @return A new JTS geometry instance
 * @throws IllegalArgumentException if {@code shape} is {@code null}
 */
public static Geometry toGeometry(final Shape shape) {
  return toGeometry(shape, new GeometryFactory());
}

代码示例来源:origin: geotools/geotools

@Override
protected Geometry getEmpty() {
  if (EMPTY == null) {
    EMPTY = new GeometryFactory().createMultiPolygon(null);
  }
  return EMPTY;
}

代码示例来源:origin: geotools/geotools

private GeometryFactory findGeometryFactory(Hints hints) {
  GeometryFactory geomFactory = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY);
  if (geomFactory == null) {
    CoordinateSequenceFactory seqFac;
    seqFac = (CoordinateSequenceFactory) hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY);
    if (seqFac == null) {
      seqFac = PackedCoordinateSequenceFactory.DOUBLE_FACTORY;
    }
    geomFactory = new GeometryFactory(seqFac);
  }
  return geomFactory;
}

代码示例来源:origin: geotools/geotools

public TestData(int initialFidValue) throws Exception {
  this.initialFidValue = initialFidValue;
  gf = new GeometryFactory();
  ff = CommonFactoryFinder.getFilterFactory(null);
}

代码示例来源:origin: geotools/geotools

public void testIntersectsFilterFunctionUnreferencedGeometry() throws Exception {
  GeometryFactory gf = new GeometryFactory();
  LineString ls =
      gf.createLineString(
          new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)});
  Function intersects = ff.function("intersects", ff.property("geom"), ff.literal(ls));
  Function clone = (Function) intersects.accept(reprojector, null);
  assertNotSame(intersects, clone);
  assertEquals(clone.getParameters().get(0), intersects.getParameters().get(0));
  assertEquals(clone.getParameters().get(1), intersects.getParameters().get(1));
}

代码示例来源:origin: geotools/geotools

/** Tests encoding for X, Y, M ordinates number */
@Test
public void testEncodeXYM() throws Exception {
  GeometryFactory gf = new GeometryFactory();
  Point pointM = gf.createPoint(new CoordinateXYM(1, 1, 4));
  CoordinateSequence seq = pointM.getCoordinateSequence();
  Document doc = encode(seq, GML.pos);
  checkPosOrdinates(doc, 4);
}

代码示例来源:origin: geotools/geotools

public void testEncode3DLineFromLiteCS() throws Exception {
    LineStringEncoder encoder = new LineStringEncoder(gtEncoder, "gml", GML.NAMESPACE);
    LiteCoordinateSequence cs =
        new LiteCoordinateSequence(new double[] {0, 0, 50, 120, 0, 100}, 3);
    LineString geometry = new GeometryFactory().createLineString(cs);
    Document doc = encode(encoder, geometry);
    // print(doc);
    assertEquals("0 0 50 120 0 100", xpath.evaluate("//gml:posList", doc));
  }
}

代码示例来源:origin: geotools/geotools

protected void addFeature(SimpleFeatureType featureType, JDBCFeatureStore features)
    throws Exception {
  SimpleFeatureBuilder b = new SimpleFeatureBuilder(featureType);
  b.add("four");
  b.add(new GeometryFactory().createPoint(new Coordinate(4, 4)));
  SimpleFeature f = b.buildFeature(null);
  features.addFeatures(DataUtilities.collection(f));
  // pattern match to handle the multi primary key case
  assertTrue(
      ((String) f.getUserData().get("fid"))
          .matches(tname(featureType.getTypeName()) + ".4(\\..*)?"));
}

代码示例来源:origin: geotools/geotools

private SimpleFeatureCollection createLineFeatureCollection() throws Exception {
  AttributeDescriptor[] types = new AttributeDescriptor[2];
  GeometryFactory geomFac = new GeometryFactory();
  CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
  MemoryDataStore data = new MemoryDataStore();
  data.addFeature(createLineFeature("LongLabel1", crs, geomFac, 10, 0, 0, 10));
  data.addFeature(createLineFeature("LongLabel2", crs, geomFac, 10, 10, 0, 0));
  //        data.addFeature(createPointFeature(0,2,"LongLabel3",crs, geomFac, types));
  //        data.addFeature(createPointFeature(2,0,"Label4",crs, geomFac, types));
  //        data.addFeature(createPointFeature(0,4,"LongLabel6",crs, geomFac, types));
  return data.getFeatureSource(Rendering2DTest.LINE).getFeatures();
}

代码示例来源:origin: geotools/geotools

public void testEncodePointZMFromLiteCSNoMeasuresEncoded() throws Exception {
    // create a point with M values and encode it in GML
    LiteCoordinateSequence cs = new LiteCoordinateSequence(new double[] {0, 1, 10, -1.5}, 4, 1);
    Point geometry = new GeometryFactory().createPoint(cs);
    PointEncoder encoder = new PointEncoder(gtEncoder, "gml", GML.NAMESPACE);
    Document document = encode(encoder, geometry, false, "line");
    // check that we got the expected result
    XpathEngine xpath = XMLUnit.newXpathEngine();
    // print(document);
    assertEquals("0 1 10", xpath.evaluate("//gml:pos", document));
  }
}

代码示例来源:origin: geotools/geotools

@Test
public void testDWithin() {
  Point geom = new GeometryFactory().createPoint(new Coordinate(0, 0));
  Filter filter = ff.dwithin(ff.property("name"), ff.literal(geom), 100, "metre");
  Envelope env = (Envelope) filter.accept(visitor, null);
  assertEquals(new Envelope(-100, 100, -100, 100), env);
}

代码示例来源:origin: geotools/geotools

@Test
public void testDisjoint() {
  Coordinate[] coords = new Coordinate[] {new Coordinate(0, 0), new Coordinate(10, 10)};
  LineString lineString = new GeometryFactory().createLineString(coords);
  Filter filter = ff.disjoint(ff.property("name"), ff.literal(lineString));
  Envelope env = (Envelope) filter.accept(visitor, null);
  assertEquals(infinity, env);
}

代码示例来源:origin: geotools/geotools

public void testIntersectsUnreferencedGeometry() throws Exception {
  GeometryFactory gf = new GeometryFactory();
  LineString ls =
      gf.createLineString(
          new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)});
  // see if coordinates gets flipped, urn forces lat/lon interpretation
  Intersects original = ff.intersects(ff.property("geom"), ff.literal(ls));
  Filter clone = (Filter) original.accept(reprojector, null);
  assertNotSame(original, clone);
  assertEquals(original, clone);
}

代码示例来源:origin: geotools/geotools

public void testIntersectsRingFilter() throws Exception {
  FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
  // should match only "r1"
  GeometryFactory gf = new GeometryFactory();
  PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
  LineString ls = gf.createLinearRing(sf.create(new double[] {2, 1, 2, 3, 0, 3, 2, 1}, 2));
  Intersects is = ff.intersects(ff.property(aname("geom")), ff.literal(ls));
  FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(is);
  checkSingleResult(features, "r1");
}

相关文章