org.locationtech.jts.geom.Point.getUserData()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(156)

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

Point.getUserData介绍

暂无

代码示例

代码示例来源:origin: geotools/geotools

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

代码示例来源:origin: geotools/geotools

/**
 * @param point
 * @throws TransformException
 */
public Point transformPoint(Point point, GeometryFactory gf) throws TransformException {
  // if required, init csTransformer using geometry's CSFactory
  init(gf);
  CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence());
  Point transformed = gf.createPoint(cs);
  transformed.setUserData(point.getUserData());
  return transformed;
}

代码示例来源:origin: geotools/geotools

/**
 * Parse an srsName from a gml:Point.
 *
 * @param srsName the srsName attribute on the gml:Point
 * @return the parsed CoordinateReferenceSystem
 */
private static CoordinateReferenceSystem parsePointSrsname(String srsName) {
  Parser parser = new Parser(new GMLConfiguration());
  String text =
      "<gml:Point " //
          + "xmlns:gml=\"http://www.opengis.net/gml/3.2\" " //
          + "srsName=\""
          + srsName
          + "\">" //
          + "<gml:pos>1 2</gml:pos>" //
          + "</gml:Point>";
  try {
    Point point = (Point) parser.parse(new StringReader(text));
    return (CoordinateReferenceSystem) point.getUserData();
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: geotools/geotools

public void testPos() throws Exception {
  GML3MockData.point(document, document);
  Point p = (Point) parse();
  assertNotNull(p);
  assertEquals(new Coordinate(1d, 2d), p.getCoordinate());
  assertTrue(p.getUserData() instanceof CoordinateReferenceSystem);
}

代码示例来源:origin: geotools/geotools

public void testNormal() throws Exception {
  Iterator reproject = new ReprojectFeatureResults(delegate, target).iterator();
  Iterator reader = delegate.iterator();
  while (reader.hasNext()) {
    SimpleFeature normal = (SimpleFeature) reader.next();
    SimpleFeature reprojected = (SimpleFeature) reproject.next();
    Point p1 = (Point) normal.getAttribute("defaultGeom");
    Point p2 = (Point) reprojected.getAttribute("defaultGeom");
    if (p1 != null) {
      assertEquals(crs, p1.getUserData());
      assertEquals(target, p2.getUserData());
      p1 = (Point) transformer.transform(p1);
      assertTrue(p1.equalsExact(p2));
    } else {
      assertNull(p2);
    }
    LineString l1 = (LineString) normal.getAttribute("otherGeom");
    LineString l2 = (LineString) reprojected.getAttribute("otherGeom");
    if (l1 != null) {
      l1 = (LineString) transformer.transform(l1);
      assertTrue(l1.equalsExact(l2));
    } else {
      assertNull(l2);
    }
  }
}

代码示例来源:origin: geotools/geotools

public void testPos3D() throws Exception {
  GML3MockData.point3D(document, document);
  Point p = (Point) parse();
  assertNotNull(p);
  assertTrue(new Coordinate(1d, 2d, 10d).equals3D(p.getCoordinate()));
  assertTrue(p.getUserData() instanceof CoordinateReferenceSystem);
}

代码示例来源:origin: geotools/geotools

assertEquals(pt.getCoordinate().x, 5.0, 0);
assertEquals(pt.getCoordinate().y, 2.5, 0);
Map<Object, Object> userData = (Map<Object, Object>) pt.getUserData();
assertEquals(userData.get("gml:id"), "1");
assertEquals(userData.get(CoordinateReferenceSystem.class), CRS.decode("EPSG:4283"));
assertEquals(pt.getCoordinate().x, 5.0, 0);
assertEquals(pt.getCoordinate().y, 2.5, 0);
assertNull(pt.getUserData());

代码示例来源:origin: Geomatys/geotoolkit

/**
 * @param point
 *
 * @throws TransformException
 */
public Point transformPoint(final Point point, final GeometryFactory gf)
  throws TransformException {
  final CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence());
  final Point transformed = gf.createPoint(cs);
  transformed.setUserData( point.getUserData() );
  return transformed;
}

代码示例来源:origin: Geomatys/geotoolkit

@Override
public MultiPoint apply(Point object) throws UnconvertibleObjectException {
  final MultiPoint geom = object.getFactory().createMultiPoint(new Point[]{object});
  geom.setSRID(object.getSRID());
  geom.setUserData(object.getUserData());
  return geom;
}

代码示例来源:origin: Geomatys/geotoolkit

@Test
public void testSetCRS(){
  //empty user data test
  final Point geom = GF.createPoint(new Coordinate(50, 27));
  final CoordinateReferenceSystem crs = CommonCRS.WGS84.normalizedGeographic();
  JTS.setCRS(geom, crs);
  final Object userData = geom.getUserData();
  assertEquals(crs, userData);
  //user data contained another CRS
  final Point geom2 = GF.createPoint(new Coordinate(50, 27));
  geom2.setUserData(CommonCRS.SPHERE.normalizedGeographic());
  JTS.setCRS(geom2, crs);
  final Object userData2 = geom2.getUserData();
  assertEquals(crs, userData2);
  //user data contained a Map with another CRS
  final Point geom3 = GF.createPoint(new Coordinate(50, 27));
  Map<String,CoordinateReferenceSystem> dataMap = new HashMap<String,CoordinateReferenceSystem>();
  dataMap.put(HintsPending.JTS_GEOMETRY_CRS, CommonCRS.SPHERE.normalizedGeographic());
  geom3.setUserData(dataMap);
  JTS.setCRS(geom3, crs);
  final Object userData3 = geom3.getUserData();
  Map values = (Map) userData3;
  assertEquals(crs, values.get(HintsPending.JTS_GEOMETRY_CRS));
}

相关文章