org.deegree.geometry.Geometry类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(193)

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

Geometry介绍

[英]Base interface for all vector geometry types.

Root of deegree's ISO 19107/GML 3.1.1/GML 3.2.1 compliant geometry type hierarchy. All geometries inherit methods for the common topological predicates (e.g. #intersects(Geometry) and #touches(Geometry) as well as the usual geometry creation methods (e.g #getIntersection(Geometry) and #getBuffer(Measure)).

Topological predicates

These are the methods for evaluating the common topological predicates:

  • #contains(Geometry)
  • #crosses(Geometry)
  • #equals(Geometry)
  • #intersects(Geometry)
  • #isDisjoint(Geometry)
  • #isWithin(Geometry)
  • #isWithinDistance(Geometry,Measure)
  • #touches(Geometry)
Set-theoretic methods

Methods for deriving geometries that aid spatial analysis tasks:

  • #getBuffer(Measure)

  • #getCentroid()

  • #getConvexHull()

  • #getDifference(Geometry)

  • #getEnvelope()

  • #getIntersection(Geometry)

  • #getUnion(Geometry)
    Distance calculation:

  • #getDistance(Geometry,Unit)

Simple Feature Specification (SFS) compliance

TODO: check with specification
As the expressiveness of the ISO 19107 model is much more powerful than the Simple Feature Specification (SFS), a deegree Geometryis not automatically a compliant SFS geometry. #isSFSCompliant() can be used to check if this is the case, it returns true for the following subtypes / configurations:

  • Point
  • LineString
  • Polygon (with LinearRing boundaries)
  • MultiPoint
  • MultiLineString
  • MultiPolygon (if the members are SFS-compliant)
  • MultiGeometry (if the members are SFS-compliant)
    If the geometry is not SFS-compliant, SFSProfiler can be used to simplify it into an SFS geometry.
Notes on GML properties

GML geometries allow for non-geometric properties, such as the ones from the gml:StandardObjectProperties attribute group. Additionally, extensions of core GML geometry elements (e.g. aixm:ElevatedPoint from the AIXM 5.1 application schema) may define even more properties which don't actually add to the geometric semantics of the element. The properties of GML geometry can hence be divided like this:

  • Standard GML properties (e.g. gml:name)
  • Properties with a geometric semantics (e.g. gml:pos/code>)
  • Additional properties (for application-schema defined geometry elements)
    Note that the methods operating on properties ( #getProperties(), #getProperties(javax.xml.namespace.QName), #setProperties(List)) currently only deal with the standard and additional properties.
    [中]所有矢量几何图形类型的基本接口。
    deegree符合ISO 19107/GML 3.1.1/GML 3.2.1的几何类型层次结构的根。所有几何体继承常用拓扑谓词的方法(例如相交(几何体)和接触(几何体)以及常用的几何体创建方法(例如getIntersection(几何体)和getBuffer(度量))。
    #####拓扑谓词
    以下是评估常用拓扑谓词的方法:
    *#包含(几何体)
    *#交叉(几何)
    *#等于(几何)
    *#相交(几何)
    *#isDisjoint(几何)
    *#在(几何)范围内
    *#无距离(几何、测量)
    *#接触(几何)
    #####集合论方法
    用于导出有助于空间分析任务的几何图形的方法:
    *#getBuffer(测量)
    *#getCentroid()
    *#getConvexHull()
    *#getDifference(几何)
    *#getEnvelope()
    *#获取交叉点(几何)
    *#getUnion(几何)
    距离计算:
    *#getDistance(几何体,单位)
    #####简单功能规范(SFS)合规性
    TODO:检查规格
    由于ISO 19107模型的表达能力比Simple Feature Specification (SFS)模型强大得多,因此deegree几何不自动符合SFS几何#isSFSCompliant()可用于检查是否存在这种情况,对于以下子类型/配置,它返回true
    *点
    *线绳
    *多边形(具有线性化边界)
    *多点
    *多重限制
    *多多边形(如果成员符合SFS)
    *多重几何体(如果成员符合SFS)
    如果几何图形不符合SFS,可以使用SFSProfiler将其简化为SFS几何图形。
    #####关于GML性质的注记
    GML几何允许非几何特性,例如gml:StandardObjectProperties属性组中的特性。此外,核心GML几何元素的扩展(例如来自AIXM 5.1应用程序模式的[2$])可能会定义更多实际上不会添加到元素几何语义的属性。因此,GML几何体的属性可以如下划分:
    *标准GML属性(例如:gml:name
    *具有几何语义的属性(例如gml:pos/code>)
    *其他属性(用于应用程序架构定义的几何图元)
    请注意,对属性(#getProperties()、#getProperties(javax.xml.namespace.QName)、#setProperties(List))进行操作的方法目前只处理标准属性和附加属性。

代码示例

代码示例来源:origin: deegree/deegree3

@Override
public ICRS getCoordinateSystem() {
  return getReferencedObject().getCoordinateSystem();
}

代码示例来源:origin: deegree/deegree3

@Override
public Envelope getEnvelope() {
  return getReferencedObject().getEnvelope();
}

代码示例来源:origin: deegree/deegree3

private void startGeometry( String localName, Geometry geometry )
            throws XMLStreamException {
  writeStartElementWithNS( GML21NS, localName );
  if ( geometry.getId() != null ) {
    referenceExportStrategy.addExportedId( geometry.getId() );
    writer.writeAttribute( "gid", geometry.getId() );
  }
  if ( outputCRS != null ) {
    writer.writeAttribute( "srsName", outputCRS.getAlias() );
  } else if ( geometry.getCoordinateSystem() != null ) {
    ICRS coordinateSystem = geometry.getCoordinateSystem();
    writer.writeAttribute( "srsName", coordinateSystem.getAlias() );
  }
}

代码示例来源:origin: deegree/deegree3

@Override
public boolean visitGeometry( Geometry geom ) {
  if ( geom.getCoordinateSystem() != null && geom.getCoordinateDimension() != 1 ) {
    try {
      geom.getCoordinateSystem();
    } catch ( Exception e ) {
      throw new IllegalArgumentException( e.getMessage() );
    }
  }
  return true;
}

代码示例来源:origin: deegree/deegree3

/**
 * Sets the {@link CRS} for all geometries contained in the given {@link Filter} that do not have crs information.
 * 
 * @param filter
 *            filter to process, must not be <code>null</code>
 * @param crs
 *            crs to set, must not be <code>null</code>
 */
public static void setDefaultCRS( Filter filter, ICRS crs ) {
  for ( Geometry geom : getGeometries( filter ) ) {
    if ( geom.getCoordinateSystem() == null ) {
      // TODO propagate to deeper levels / change behavior of setCoordinateSystem()
      geom.setCoordinateSystem( crs );
    }
  }
}

代码示例来源:origin: deegree/deegree3

private Geometry transformGeometry( Geometry value, GeometryTransformer transformer )
            throws IllegalArgumentException, TransformationException {
  Geometry transformed = value;
  if ( transformed.getCoordinateSystem() == null ) {
    transformed.setCoordinateSystem( transformer.getTargetCRS() );
  } else {
    transformed = linearizer.linearize( value, crit );
    if ( !( transformed instanceof Point && transformed.getCoordinateDimension() == 1 ) ) {
      transformed = transformer.transform( transformed, transformed.getCoordinateSystem() );
    }
  }
  return transformed;
}

代码示例来源:origin: deegree/deegree3

List<SurfacePatch> patches = new ArrayList<SurfacePatch>();
  patches.add( geomFac.createPolygonPatch( p.getExteriorRing(), p.getInteriorRings() ) );
  geom = geomFac.createSurface( geom.getId(), patches, geom.getCoordinateSystem() );
} else if ( hierarchy.getCurveSubstitutions().contains( particle.getName() ) && geom instanceof LineString ) {
  CurveSegment[] segments = new CurveSegment[1];
  segments[0] = geomFac.createLineStringSegment( p.getControlPoints() );
  geom = geomFac.createCurve( geom.getId(), geom.getCoordinateSystem(), segments );
geom.setType( fs.getSchema().getGeometryType( particle.getName() ) );
geom.setProperties( props );

代码示例来源:origin: deegree/deegree3

Geometry clipGeometry( final Geometry geom, Geometry clippingArea ) {
  if ( clippingArea != null && !clippingArea.contains( geom ) ) {
    try {
      Geometry clippedGeometry = clippingArea.getIntersection( geom );
      if ( clippedGeometry == null ) {
        return null;
      }
      com.vividsolutions.jts.geom.Geometry jtsOrig = ( (AbstractDefaultGeometry) geom ).getJTSGeometry();
      com.vividsolutions.jts.geom.Geometry jtsClipped = ( (AbstractDefaultGeometry) clippedGeometry ).getJTSGeometry();
      if ( jtsOrig == jtsClipped ) {
        return geom;
      }
      if ( isInvertedOrientation( jtsOrig ) ) {
        return clippedGeometry;
      }
      return fixOrientation( clippedGeometry, clippedGeometry.getCoordinateSystem() );
    } catch ( UnsupportedOperationException e ) {
      // use original geometry if intersection not supported by JTS
      return geom;
    }
  }
  return geom;
}

代码示例来源:origin: deegree/deegree3

if ( !insideValidDomain( domainOfValidity, geo ) ) {
    throw new OutsideCRSDomainException( "Geometry (gml:id="
                       + ( isSet( geo.getId() ) ? geo.getId() : "not set" )
                       + ")is outside the area of validity of the source CRS." );
GeometryType geometryType = geo.getGeometryType();
try {
  switch ( geometryType ) {
                              geo.getCoordinateSystem().getAlias(),
                              getTargetCRS().getCodes(), ge.getMessage() ), ge );

代码示例来源:origin: deegree/deegree3

private void startGeometry( String localName, Geometry geometry )
            throws XMLStreamException, UnknownCRSException, TransformationException {
  GMLObjectType gmlType = geometry.getType();
  if ( gmlType == null ) {
    writeStartElementWithNS( gmlNs, localName );
  } else {
    QName elName = gmlType.getName();
    writeStartElementWithNS( elName.getNamespaceURI(), elName.getLocalPart() );
  }
  if ( geometry.getId() != null ) {
    referenceExportStrategy.addExportedId( geometry.getId() );
    writeAttributeWithNS( gmlNs, "id", geometry.getId() );
  } else if ( version == GML_32 && geometry.getId() == null ) {
    // in GML 3.2, a gml:id is required for every geometry
    writeAttributeWithNS( gmlNs, "id", "GEOMETRY_" + generateNewId() );
  }
  if ( outputCRS != null ) {
    writer.writeAttribute( "srsName", outputCRS.getAlias() );
  } else if ( geometry.getCoordinateSystem() != null ) {
    writer.writeAttribute( "srsName", geometry.getCoordinateSystem().getAlias() );
  }
  exportStandardProps( geometry );
}

代码示例来源:origin: deegree/deegree3

@Override
public boolean visitGeometry( Geometry geom ) {
  idToObject.put( geom.getId(), geom );
  return true;
}

代码示例来源:origin: deegree/deegree3

private Geometry simplify( Geometry geometry ) {
  if ( simplifier == null ) {
    return geometry;
  }
  GeometryType type = geometry.getGeometryType();
  if ( type == ENVELOPE || type == COMPOSITE_GEOMETRY ) {
    return geometry;
  }
  return simplifier.simplify( geometry );
}

代码示例来源:origin: deegree/deegree3

@Override
public Geometry process( Geometry inputGeometry, Map<String, Object> params ) {
  return inputGeometry.getCentroid();
}

代码示例来源:origin: deegree/deegree3

String oldGid = geometry.getId();
if ( oldGid != null ) {
  gids.remove( oldGid );
geometry.setId( newGid );
if ( geometry.getId() == null ) {
  String newGid = "GEOMETRY_" + generateNewId();
  geometry.setId( newGid );
  gids.add( newGid );

代码示例来源:origin: deegree/deegree3

@Override
public boolean contains( Geometry geometry ) {
  return getReferencedObject().contains( geometry );
}

代码示例来源:origin: deegree/deegree3

@Override
public int getCoordinateDimension() {
  return members.get( 0 ).getCoordinateDimension();
}

代码示例来源:origin: deegree/deegree3

@Override
public void setCoordinateSystem( ICRS crs ) {
  getReferencedObject().setCoordinateSystem( crs );
}

代码示例来源:origin: deegree/deegree3

@Override
public boolean equals( Geometry geometry ) {
  return getReferencedObject().equals( geometry );
}

代码示例来源:origin: deegree/deegree3

@Override
public boolean crosses( Geometry geometry ) {
  return getReferencedObject().crosses( geometry );
}

代码示例来源:origin: deegree/deegree3

private <T extends Geometry> T transformLinearized( T g ) {
  if ( g instanceof Surface ) {
    @SuppressWarnings("unchecked")
    T g2 = (T) transform( linearizer.linearize( (Surface) g, new NumPointsCriterion( 100 ) ) );
    g2.setCoordinateSystem( g.getCoordinateSystem() );
    return g2;
  }
  if ( g instanceof Curve ) {
    @SuppressWarnings("unchecked")
    T g2 = (T) transform( linearizer.linearize( (Curve) g, new NumPointsCriterion( 100 ) ) );
    g2.setCoordinateSystem( g.getCoordinateSystem() );
    return g2;
  }
  return null;
}

相关文章