com.vividsolutions.jts.geom.GeometryFactory.createGeometry()方法的使用及代码示例

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

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

GeometryFactory.createGeometry介绍

[英]Creates a deep copy of the input Geometry. The CoordinateSequenceFactory defined for this factory is used to copy the CoordinateSequences of the input geometry.

This is a convenient way to change the CoordinateSequence used to represent a geometry, or to change the factory used for a geometry.

Geometry#clone() can also be used to make a deep copy, but it does not allow changing the CoordinateSequence type.
[中]创建输入几何图形的深度副本。为此工厂定义的CoordinateSequenceFactory用于复制输入几何图形的CoordinateSequence。
这是更改用于表示几何图形的坐标序列或更改用于几何图形的工厂的方便方法。
Geometry#clone()也可用于制作深度副本,但它不允许更改CoordinateSequence类型。

代码示例

代码示例来源:origin: com.vividsolutions/jts

private Geometry fixPolygonalTopology(Geometry geom)
{
  /**
   * If precision model was *not* changed, need to flip
   * geometry to targetPM, buffer in that model, then flip back
   */
  Geometry geomToBuffer = geom;
  if (! changePrecisionModel) {
    geomToBuffer = changePM(geom, targetPM);
  }
  
  Geometry bufGeom = geomToBuffer.buffer(0);
  
  Geometry finalGeom = bufGeom;
  if (! changePrecisionModel) {
   // a slick way to copy the geometry with the original precision factory
    finalGeom = geom.getFactory().createGeometry(bufGeom);
  }
  return finalGeom;
}

代码示例来源:origin: org.geomajas.extension/geomajas-extension-command

public void execute(SplitPolygonRequest request, SplitPolygonResponse response) throws Exception {
  // convert to most accurate precision model
  Polygon polygon = null;
  try {
    polygon = (Polygon) converter.toJts(request.getPolygon());
  } catch (Exception e) {
    // throw new GeomajasException();
  }
  GeometryFactory factory = new GeometryFactory(new PrecisionModel(), polygon.getFactory().getSRID());
  Polygon p = (Polygon) factory.createGeometry(polygon);
  LineString l = (LineString) factory.createGeometry(converter.toJts(request.getLineString()));
  int precision = 11;
  com.vividsolutions.jts.geom.Geometry buffered = factory.createGeometryCollection(null);
  while (buffered.isEmpty()) {
    buffered = l.buffer(Math.pow(10.0, -(precision--)));
  }
  com.vividsolutions.jts.geom.Geometry diff = p.difference(buffered);
  if (diff instanceof Polygon) {
    response.setPolygons(new Geometry[] {converter.toDto(diff)});
  } else if (diff instanceof MultiPolygon) {
    Geometry[] polygons = new Geometry[diff.getNumGeometries()];
    for (int i = 0; i < diff.getNumGeometries(); i++) {
      polygons[i] = converter.toDto(diff.getGeometryN(i));
      // makePrecise(polygon.getPrecisionModel(), polygons[i]);
    }
    response.setPolygons(polygons);
  }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-gis

public Geometry createGeometry(final Geometry _g) {
 return super.createGeometry(_g);
}
/**

代码示例来源:origin: org.locationtech.geogig/geogig-core

@Override
public Optional<Geometry> get(int index, GeometryFactory gf) {
  Geometry g = (Geometry) values.get(index);
  Geometry g2 = null;
  if (g != null) {
    g2 = gf.createGeometry(g);
  }
  return Optional.fromNullable(g2);
}

代码示例来源:origin: org.geotools/gt-main

/**
 * Sets the geometry contained in this lite shape. Convenient to reuse this
 * object instead of creating it again and again during rendering
 * 
 * @param g
 * @throws TransformException
 * @throws FactoryException
 */
public void setGeometry(Geometry g) throws TransformException,
    FactoryException {
  if (g != null) {
    this.geometry = getGeometryFactory().createGeometry(g);
    transformGeometry(geometry);
  }
}

代码示例来源:origin: org.geotools/gt2-main

/**
 * Sets the geometry contained in this lite shape. Convenient to reuse this
 * object instead of creating it again and again during rendering
 * 
 * @param g
 * @throws TransformException
 * @throws FactoryException
 */
public void setGeometry(Geometry g) throws TransformException,
    FactoryException {
  if (g != null) {
    this.geometry = getGeometryFactory().createGeometry(g);
    transformGeometry(geometry);
  }
}

代码示例来源:origin: com.vividsolutions/jts-core

private Geometry fixPolygonalTopology(Geometry geom)
{
  /**
   * If precision model was *not* changed, need to flip
   * geometry to targetPM, buffer in that model, then flip back
   */
  Geometry geomToBuffer = geom;
  if (! changePrecisionModel) {
    geomToBuffer = changePM(geom, targetPM);
  }
  
  Geometry bufGeom = geomToBuffer.buffer(0);
  
  Geometry finalGeom = bufGeom;
  if (! changePrecisionModel) {
   // a slick way to copy the geometry with the original precision factory
    finalGeom = geom.getFactory().createGeometry(bufGeom);
  }
  return finalGeom;
}

代码示例来源:origin: org.geotools/gt-main

g = factory.createGeometry(g);

代码示例来源:origin: org.geoserver.community/gs-vectortiles

@Nullable
private TopoGeom createObject(String featureId, Geometry geom, Map<String, Object> properties)
    throws MismatchedDimensionException, TransformException {
  // // snap to pixel
  geom = fixedGeometryFactory.createGeometry(geom);
  if (geom.isEmpty()) {
    return null;
  }
  if (geom instanceof GeometryCollection && geom.getNumGeometries() == 1) {
    geom = geom.getGeometryN(0);
  }
  TopoGeom geometry = createGeometry(geom);
  geometry.setProperties(properties);
  geometry.setId(featureId);
  return geometry;
}

代码示例来源:origin: com.googlecode.jaitools/jt-utils

if (useFixedPrecision){
  geomFactory = PRECISE_FACTORY;
  cloned = geomFactory.createGeometry(geom);
  Coordinate[] coords = cloned.getCoordinates();
  for (Coordinate coord : coords) {

代码示例来源:origin: org.geotools/gt-main

/**
 * Creates a new LiteShape object.
 *
 * @param geom - the wrapped geometry
 * @param at - the transformation applied to the geometry in order to get to the shape points
 * @param generalize - set to true if the geometry need to be generalized
 *        during rendering
 * 
 */
public LiteShape(Geometry geom, AffineTransform at, boolean generalize) {
  if( geom!=null)
    this.geometry =getGeometryFactory().createGeometry(geom);
  this.affineTransform = at;
  this.generalize = generalize;
  if (at==null){
    yScale=xScale=1;
    return;
  }
  xScale = (float) Math.sqrt(
      (at.getScaleX() * at.getScaleX())
      + (at.getShearX() * at.getShearX()));
  yScale = (float) Math.sqrt(
      (at.getScaleY() * at.getScaleY())
      + (at.getShearY() * at.getShearY()));
}

代码示例来源:origin: org.geotools/gt2-main

/**
 * Creates a new LiteShape object.
 *
 * @param geom - the wrapped geometry
 * @param at - the transformation applied to the geometry in order to get to the shape points
 * @param generalize - set to true if the geometry need to be generalized
 *        during rendering
 * 
 */
public LiteShape(Geometry geom, AffineTransform at, boolean generalize) {
  if( geom!=null)
    this.geometry =getGeometryFactory().createGeometry(geom);
  this.affineTransform = at;
  this.generalize = generalize;
  if (at==null){
    yScale=xScale=1;
    return;
  }
  xScale = (float) Math.sqrt(
      (at.getScaleX() * at.getScaleX())
      + (at.getShearX() * at.getShearX()));
  yScale = (float) Math.sqrt(
      (at.getScaleY() * at.getScaleY())
      + (at.getShearY() * at.getShearY()));
}

代码示例来源:origin: org.geotools/gt-main

public Object visit(Literal expression, Object extraData) {
    if (!(expression.getValue() instanceof Geometry))
      return super.visit(expression, extraData);

    // check if reprojection is needed
    Geometry geom = (Geometry) expression.getValue();
    if(geom.getUserData() != null && geom.getUserData() instanceof CoordinateReferenceSystem)
      return super.visit(expression, extraData);
    
    // clone the geometry and assign the new crs
    Geometry clone = geom.getFactory().createGeometry(geom);
    clone.setUserData(defaultCrs);

    // clone
    return ff.literal(clone);
  }
}

代码示例来源:origin: com.googlecode.jaitools/jt-utils

/**
 * Returns a new ROI created by applying the given transform to 
 * this ROI.
 * 
 * @param at the transform
 * 
 * @return the new ROI
 */
@Override
public ROI transform(AffineTransform at) {
  Geometry cloned = (Geometry) theGeom.getGeometry().clone();
  cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(), 
      at.getShearY(), at.getScaleY(), at.getTranslateY()));
  if (useFixedPrecision){
    Geometry fixed = PRECISE_FACTORY.createGeometry(cloned);
    Coordinate[] coords = fixed.getCoordinates();
    for (Coordinate coord : coords) {
      Coordinate precise = coord;
      PRECISION.makePrecise(precise);
    }
    cloned = fixed;
  }
  return new ROIGeometry(cloned);
}

相关文章