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

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

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

Geometry.getUserData介绍

[英]Gets the user data object for this geometry, if any.
[中]获取此几何体的用户数据对象(如果有)。

代码示例

代码示例来源:origin: osmandapp/Osmand

/**
 * JTS 1.14 does not support intersection on a {@link GeometryCollection}. This function works around this
 * by performing intersection on a flat list of geometry. The resulting list is pre-filtered for invalid
 * or empty geometry (outside of bounds). Invalid geometry are logged as errors.
 *
 * @param envelope non-list geometry defines bounding area
 * @param dataGeoms geometry pre-passed through {@link #flatFeatureList(Geometry)}
 * @return list of geometry from {@code data} intersecting with {@code envelope}.
 */
private static List<Geometry> flatIntersection(Geometry envelope, List<Geometry> dataGeoms) {
  final List<Geometry> intersectedGeoms = new ArrayList<>(dataGeoms.size());
  Geometry nextIntersected;
  for(Geometry nextGeom : dataGeoms) {
    try {
      // AABB intersection culling
      if(envelope.getEnvelopeInternal().intersects(nextGeom.getEnvelopeInternal())) {
        nextIntersected = envelope.intersection(nextGeom);
        if(!nextIntersected.isEmpty()) {
          nextIntersected.setUserData(nextGeom.getUserData());
          intersectedGeoms.add(nextIntersected);
        }
      }
    } catch (TopologyException e) {
      //LoggerFactory.getLogger(JtsAdapter.class).error(e.getMessage(), e);
    }
  }
  return intersectedGeoms;
}

代码示例来源:origin: osmandapp/Osmand

userDataConverter.addTags(geom.getUserData(), layerProps, featureBuilder);

代码示例来源:origin: osmandapp/Osmand

Object nextUserData;
for(Geometry nextInterGeom : intersectedGeoms) {
  nextUserData = nextInterGeom.getUserData();

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

public void loadSourceGeometries(Collection geoms)
{
  for (Iterator i = geoms.iterator(); i.hasNext(); ) {
    Geometry geom = (Geometry) i.next();
    loadVertices(geom.getCoordinates(), geom.getUserData());
  }
}

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

/**
   * Input is assumed to be a multiGeometry
   * in which every component has its userData
   * set to be a Coordinate which is the key to the output data.
   * The Coordinate is used to determine
   * the output data object to be written back into the component. 
   * 
   * @param targetGeom
   */
  public void transferData(Geometry targetGeom)
  {
    for (int i = 0; i < targetGeom.getNumGeometries(); i++) {
      Geometry geom = targetGeom.getGeometryN(i);
      Coordinate vertexKey = (Coordinate) geom.getUserData();
      if (vertexKey == null) continue;
      geom.setUserData(coordDataMap.get(vertexKey));
    }
  }
}

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

public void loadSourceGeometries(Geometry geomColl)
{
  for (int i = 0; i < geomColl.getNumGeometries(); i++) {
    Geometry geom = geomColl.getGeometryN(i);
    loadVertices(geom.getCoordinates(), geom.getUserData());
  }
}

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

private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv)
  {
    Geometry clipPoly = geom.getFactory().toGeometry(clipEnv);
    List clipped = new ArrayList();
    for (int i = 0; i < geom.getNumGeometries(); i++) {
      Geometry g = geom.getGeometryN(i);
      Geometry result = null;
      // don't clip unless necessary
      if (clipEnv.contains(g.getEnvelopeInternal()))
          result = g;
      else if (clipEnv.intersects(g.getEnvelopeInternal())) {
        result = clipPoly.intersection(g);
        // keep vertex key info
        result.setUserData(g.getUserData());
      }

      if (result != null && ! result.isEmpty()) {
        clipped.add(result);
      }
    }
    return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped));
  }
}

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

public Object getUserData() {
  return geometry.getUserData();
}

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

static String getMetadata(Geometry g, String metadata) {
    if (g.getUserData() instanceof Map) {
      Map userData = (Map) g.getUserData();

      return (String) userData.get(metadata);
    }

    return null;
  }
}

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

public Object getProperty(Object object, QName name)
    throws Exception {
    if ("srsName".equals(name.getLocalPart())) {
      Geometry geometry = (Geometry) object;

      if (geometry.getUserData() instanceof CoordinateReferenceSystem) {
        CoordinateReferenceSystem crs = (CoordinateReferenceSystem) geometry.getUserData();

        return GML3EncodingUtils.crs(crs);
      }
    }

    return null;
  }
}

代码示例来源:origin: DataSystemsLab/GeoSpark

private void writeUserData(Kryo kryo, Output out, Geometry geometry)
{
  out.writeBoolean(geometry.getUserData() != null);
  if (geometry.getUserData() != null) {
    kryo.writeClass(out, geometry.getUserData().getClass());
    kryo.writeObject(out, geometry.getUserData());
  }
}

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

public Object getProperty(Object object, QName name)
    throws Exception {
    if ("srsName".equals(name.getLocalPart())) {
      Geometry geometry = (Geometry) object;

      if (geometry.getUserData() instanceof CoordinateReferenceSystem) {
        return GML2EncodingUtils.crs((CoordinateReferenceSystem) geometry.getUserData());
      }
    }

    return null;
  }
}

代码示例来源:origin: org.datasyslab/geospark

private void writeUserData(Kryo kryo, Output out, Geometry geometry)
{
  out.writeBoolean(geometry.getUserData() != null);
  if (geometry.getUserData() != null) {
    kryo.writeClass(out, geometry.getUserData().getClass());
    kryo.writeObject(out, geometry.getUserData());
  }
}

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

private void initCRS(Geometry g) {
    // see if we have a native CRS in the mix
    if(crs == null && g.getUserData() instanceof CoordinateReferenceSystem) {
      crs = (CoordinateReferenceSystem) g.getUserData();
    }
    if(srid == -1 && g.getSRID() > 0) {
      srid = g.getSRID();
    }
  }
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@SuppressWarnings("rawtypes")
private String getGmlID(Geometry geom, String gmlId) {
  String id;
  if (!Strings.isNullOrEmpty(gmlId)) {
    id = gmlId;
  } else if (geom.getUserData() != null && geom.getUserData() instanceof Map
      && ((Map) geom.getUserData()).containsKey(XmlBeansEncodingFlags.GMLID.name())) {
    id = (String) ((Map) geom.getUserData()).get(XmlBeansEncodingFlags.GMLID.name());
  } else {
    id = JavaHelper.generateID(geom.toText());
  }
  return geom.getGeometryType() + "_" + id;
}

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

public void loadSourceGeometries(Collection geoms)
{
  for (Iterator i = geoms.iterator(); i.hasNext(); ) {
    Geometry geom = (Geometry) i.next();
    loadVertices(geom.getCoordinates(), geom.getUserData());
  }
}

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

@Override
public Envelope decodeGeometryEnvelope(ResultSet rs, int column,
    Connection cx) throws SQLException, IOException {
  String s = rs.getString( column );
  Geometry g = decodeGeometry( s, null );
  if ( g == null ) {
    return null;
  }
  
  return new ReferencedEnvelope( g.getEnvelopeInternal(), (CoordinateReferenceSystem) g.getUserData() );
}

代码示例来源:origin: org.jvnet.ogc/ogc-tools-gml-jts

public void convert(Geometry source, SRSReferenceGroup target) {
 Validate.notNull(source);
 Validate.notNull(target);
 if (source.getUserData() instanceof String) {
  target.setSrsName((String) source.getUserData());
 }
 else if (source.getSRID() != 0) {
  target.setSrsName(MessageFormat.format(this.sridPattern, source.getSRID()));
 }
}

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

public void loadSourceGeometries(Geometry geomColl)
{
  for (int i = 0; i < geomColl.getNumGeometries(); i++) {
    Geometry geom = geomColl.getGeometryN(i);
    loadVertices(geom.getCoordinates(), geom.getUserData());
  }
}

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

相关文章