org.deegree.geometry.Geometry.getCoordinateSystem()方法的使用及代码示例

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

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

Geometry.getCoordinateSystem介绍

[英]Returns the associated spatial reference system.
[中]返回关联的空间参照系。

代码示例

代码示例来源: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

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

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

private void evaluateSrsNameForFeature( Feature feature, List<ICRS> queryCRS, String handle )
            throws OWSException {
  Set<Geometry> geometries = new LinkedHashSet<Geometry>();
  findFeaturesAndGeometries( feature, geometries, new LinkedHashSet<Feature>(), new LinkedHashSet<String>(),
                new LinkedHashSet<String>() );
  for ( Geometry geometry : geometries ) {
    ICRS crs = geometry.getCoordinateSystem();
    evaluateSrsName( crs, queryCRS, handle );
    evaluateValidDomain( crs, geometry, handle );
  }
}

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

private static void exportGeometry( Geometry geometry, GMLStreamWriter gmlWriter )
            throws XMLStreamException, UnknownCRSException, TransformationException {
  if ( geometry != null ) {
    gmlWriter.setOutputCrs( geometry.getCoordinateSystem() );
    gmlWriter.write( geometry );
  }
}

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

/**
 * Creates a deep copy of the given {@link Geometry} object.
 * 
 * @param geom
 * @return
 */
public static Geometry copyDeep( Geometry geom ) {
  // TODO implement this without JTS
  com.vividsolutions.jts.geom.Geometry jtsGeom = ( (AbstractDefaultGeometry) geom ).getJTSGeometry();
  return ( (AbstractDefaultGeometry) geom ).createFromJTS( jtsGeom, geom.getCoordinateSystem() );
}

代码示例来源: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

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

Geometry inSource = geom;
ICRS sourceCRS = validDomain.getCoordinateSystem();
if ( sourceCRS != null && geom.getCoordinateSystem() != null
   && !sourceCRS.equals( geom.getCoordinateSystem() ) ) {
  try {
    GeometryTransformer trans = new GeometryTransformer( sourceCRS );

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

private Geometry getCompatibleGeometry( Geometry literal )
            throws SQLException {
  if ( crs == null ) {
    return literal;
  }
  Geometry transformedLiteral = literal;
  if ( literal != null ) {
    ICRS literalCRS = literal.getCoordinateSystem();
    if ( literalCRS != null && !( crs.equals( literalCRS ) ) ) {
      LOG.debug( "Need transformed literal geometry for evaluation: " + literalCRS.getAlias() + " -> "
            + crs.getAlias() );
      try {
        GeometryTransformer transformer = new GeometryTransformer( crs );
        transformedLiteral = transformer.transform( literal );
      } catch ( Throwable e ) {
        throw new SQLException( e.getMessage() );
      }
    }
  }
  return transformedLiteral;
}

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

private Geometry getCompatibleGeometry( Geometry literal )
            throws SQLException {
  if ( crs == null ) {
    return literal;
  }
  Geometry transformedLiteral = literal;
  if ( literal != null ) {
    ICRS literalCRS = literal.getCoordinateSystem();
    if ( literalCRS != null && !( crs.equals( literalCRS ) ) ) {
      LOG.debug( "Need transformed literal geometry for evaluation: " + literalCRS.getAlias() + " -> "
            + crs.getAlias() );
      try {
        GeometryTransformer transformer = new GeometryTransformer( crs );
        transformedLiteral = transformer.transform( literal );
      } catch ( Exception e ) {
        throw new SQLException( e.getMessage(), e );
      }
    }
  }
  return transformedLiteral;
}

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

@Override
public Geometry getIntersection( Geometry geometry ) {
  JTSGeometryPair jtsGeoms = JTSGeometryPair.createCompatiblePair( this, geometry );
  ICRS crs = this.crs;
  if ( crs == null ) {
    crs = geometry.getCoordinateSystem();
  }
  com.vividsolutions.jts.geom.Geometry jtsGeom = jtsGeoms.first.intersection( jtsGeoms.second );
  return createFromJTS( jtsGeom, crs );
}

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

throws FilterEvaluationException {
Geometry transformedLiteral = literal;
ICRS paramCRS = param.getCoordinateSystem();
ICRS literalCRS = literal.getCoordinateSystem();
if ( literalCRS != null && !( paramCRS.equals( literalCRS ) ) ) {
  LOG.debug( "Need transformed literal geometry for evaluation: " + literalCRS.getAlias() + " -> "

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

/**
 * Returns a transformed version of the given {@link Geometry} in the specified CRS.
 *
 * @param literal
 * @param crs
 * @return transformed version of the geometry, never <code>null</code>
 * @throws FilterEvaluationException
 */
public static Geometry getCompatibleGeometry( Geometry literal, ICRS crs )
            throws FilterEvaluationException {
  if ( crs == null ) {
    return literal;
  }
  Geometry transformedLiteral = literal;
  if ( literal != null ) {
    ICRS literalCRS = literal.getCoordinateSystem();
    if ( literalCRS != null && !( crs.equals( literalCRS ) ) ) {
      LOG.debug( "Need transformed literal geometry for evaluation: " + literalCRS.getAlias() + " -> "
            + crs.getAlias() );
      try {
        GeometryTransformer transformer = new GeometryTransformer( crs );
        transformedLiteral = transformer.transform( literal );
      } catch ( Exception e ) {
        throw new FilterEvaluationException( e.getMessage() );
      }
    }
  }
  return transformedLiteral;
}

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

/**
 * Calculates the points inside the geometry and inside the view port. First the passed geometry is clipped
 * by the view port. A multipolygon may result. For each of the polygon in this multipolygon one interior point
 * is created
 *
 * @param geom to create labels for, must not be <code>null</code> and in the same CRS as the viewPort
 * @return a MultiPoint with all calculated labels
 */
MultiPoint calculateInteriorPoints( final Geometry geom ) {
  if ( geom == null )
    return null;
  Geometry clippedGeometry = clipGeometry( geom, viewPort );
  List<Point> points = new ArrayList<Point>();
  if ( clippedGeometry != null && clippedGeometry instanceof DefaultSurface ) {
    points.add( ( (DefaultSurface) clippedGeometry ).getInteriorPoint() );
  }
  if ( clippedGeometry != null && clippedGeometry instanceof MultiPolygon ) {
    for ( Polygon p : ( (MultiPolygon) clippedGeometry ) ) {
      if ( p instanceof DefaultSurface ) {
        points.add( ( (DefaultSurface) p ).getInteriorPoint() );
      }
    }
  }
  return new GeometryFactory().createMultiPoint( null, geom.getCoordinateSystem(), points );
}

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

ICRS source = sourceCRS;
if ( source == null ) {
  source = geom.getCoordinateSystem();

代码示例来源: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;
}

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

@Override
public Geometry inspect( Geometry geom )
            throws GeometryInspectionException {
  ICRS crs = geom.getCoordinateSystem();
  if ( crs != null ) {
    ICRS cs = crs;
    int csDim = cs.getDimension();
    int coordDim = geom.getCoordinateDimension();
    if ( csDim != coordDim ) {
      String msg = "Geometry is invalid. Dimensionality of coordinates (=" + coordDim
             + ") does not match dimensionality of CRS '" + crs.getAlias() + "' (=" + csDim + ").";
      throw new GeometryInspectionException( msg );
    }
  }
  return geom;
}

代码示例来源: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

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;
}

相关文章