本文整理了Java中org.locationtech.jts.geom.GeometryFactory.createGeometry()
方法的一些代码示例,展示了GeometryFactory.createGeometry()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryFactory.createGeometry()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.GeometryFactory
类名称: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#copy() can also be used to make a deep copy, but it does not allow changing the CoordinateSequence type.
[中]创建输入几何图形的深度副本。为此工厂定义的CoordinateSequenceFactory用于复制输入几何图形的CoordinateSequence。
这是更改用于表示几何图形的坐标序列或更改用于几何图形的工厂的方便方法。
Geometry#copy()也可用于制作深度复制,但它不允许更改CoordinateSequence类型。
代码示例来源:origin: geotools/geotools
public Geometry createGeometry(Geometry g) {
return delegate.createGeometry(g);
}
代码示例来源:origin: geotools/geotools
/**
* 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: geotools/geotools
g = factory.createGeometry(g);
代码示例来源:origin: geotools/geotools
/**
* 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: geotools/geotools
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: locationtech/geogig
public static Geometry clone(Geometry g) {
return gf.createGeometry(g);
}
}
代码示例来源:origin: locationtech/geogig
public @Override Optional<Geometry> get(int index, GeometryFactory gf) {
Geometry g = (Geometry) values[index];
Geometry g2 = null;
if (g != null) {
g2 = gf.createGeometry(g);
}
return Optional.fromNullable(g2);
}
代码示例来源:origin: locationtech/geogig
public @Override Optional<Geometry> get(int index, GeometryFactory gf) {
Geometry g = (Geometry) values[index];
Geometry g2 = null;
if (g != null) {
g2 = gf.createGeometry(g);
}
return Optional.fromNullable(g2);
}
代码示例来源:origin: geotools/geotools
public void testEqualsFilter() throws Exception {
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
// should match only "r3"
GeometryFactory gf = new GeometryFactory();
Geometry g = gf.createGeometry((Geometry) td.roadFeatures[2].getDefaultGeometry());
Equals cs = ff.equal(ff.literal(g), ff.property(aname("geom")));
FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(cs);
checkSingleResult(features, "r3");
}
代码示例来源:origin: locationtech/jts
private Point editPoint(Point geom) {
Point newGeom = (Point) operation.edit(geom, targetFactory);
if (newGeom == null) {
// null return means create an empty one
newGeom = targetFactory.createPoint((CoordinateSequence) null);
}
else if (newGeom == geom) {
// If geometry was not modified, copy it
newGeom = (Point) targetFactory.createGeometry(geom);
}
return newGeom;
}
代码示例来源:origin: locationtech/jts
private LinearRing editLinearRing(LinearRing geom) {
LinearRing newGeom = (LinearRing) operation.edit(geom, targetFactory);
if (newGeom == null) {
// null return means create an empty one
newGeom = targetFactory.createLinearRing((CoordinateSequence) null);
}
else if (newGeom == geom) {
// If geometry was not modified, copy it
newGeom = (LinearRing) targetFactory.createGeometry(geom);
}
return newGeom;
}
代码示例来源:origin: locationtech/jts
private LineString editLineString(LineString geom) {
LineString newGeom = (LineString) operation.edit(geom, targetFactory);
if (newGeom == null) {
// null return means create an empty one
newGeom = targetFactory.createLineString((CoordinateSequence) null);
}
else if (newGeom == geom) {
// If geometry was not modified, copy it
newGeom = (LineString) targetFactory.createGeometry(geom);
}
return newGeom;
}
代码示例来源:origin: locationtech/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.geoserver.extension/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: locationtech/jts
private void checkCreateGeometryExact(String wkt) throws ParseException
{
Geometry g = read(wkt);
Geometry g2 = geometryFactory.createGeometry(g);
assertTrue(g.equalsExact(g2));
}
代码示例来源:origin: locationtech/jts
public void testDeepCopy() throws ParseException
{
Point g = (Point) read("POINT ( 10 10) ");
Geometry g2 = geometryFactory.createGeometry(g);
g.getCoordinateSequence().setOrdinate(0, 0, 99);
assertTrue(! g.equalsExact(g2));
}
代码示例来源:origin: org.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 = theGeom.getGeometry().copy();
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 buildROIGeometry(cloned);
}
代码示例来源:origin: it.geosolutions.jaiext.vectorbin/jt-vectorbin
/**
* 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 buildROIGeometry(cloned);
}
代码示例来源:origin: geosolutions-it/jai-ext
/**
* 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 buildROIGeometry(cloned);
}
代码示例来源:origin: locationtech/jts
/**
* CoordinateArraySequences default their dimension to 3 unless explicitly told otherwise.
* This test ensures that GeometryFactory.createGeometry() recreates the input dimension properly.
*
* @throws ParseException
*/
public void testCopyGeometryWithNonDefaultDimension() throws ParseException
{
GeometryFactory gf = new GeometryFactory(CoordinateArraySequenceFactory.instance());
CoordinateSequence mpSeq = gf.getCoordinateSequenceFactory().create(1, 2);
mpSeq.setOrdinate(0, 0, 50);
mpSeq.setOrdinate(0, 1, -2);
Point g = gf.createPoint(mpSeq);
CoordinateSequence pSeq = ((Point) g.getGeometryN(0)).getCoordinateSequence();
assertEquals(2, pSeq.getDimension());
Point g2 = (Point) geometryFactory.createGeometry(g);
assertEquals(2, g2.getCoordinateSequence().getDimension());
}
内容来源于网络,如有侵权,请联系作者删除!