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

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

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

GeometryFactory.createPoint介绍

[英]Creates a Point using the given Coordinate. A null Coordinate creates an empty Geometry.
[中]使用给定坐标创建点。空坐标将创建空几何体。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

@Override
public boolean filter(Individual individual) {
  Coordinate coord = new Coordinate(individual.lon, individual.lat);
  Point pt = gf.createPoint(coord);
  boolean accept = hull.contains(pt);
  //LOG.debug("label {} accept {}", individual.label, accept);
  return accept;
}

代码示例来源:origin: stackoverflow.com

points.add(new Coordinate(-10, -10));
points.add(new Coordinate(-10, 10));
points.add(new Coordinate(10, 10));
points.add(new Coordinate(10, -10));
points.add(new Coordinate(-10, -10));
final Coordinate coord = new Coordinate(0, 0);
final Point point = gf.createPoint(coord);

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Compute an (approximated) distance between a point and a linestring expressed in standard geographical
 * coordinates (lon, lat in degrees).
 * @param point The coordinates of the point (longitude, latitude degrees).
 * @param lineString The set of points representing the polyline, in the same coordinate system.
 * @return The (approximated) distance, in meters, between the point and the linestring.
 */
public static final double fastDistance(Coordinate point, LineString lineString) {
  // Transform in equirectangular projection on sphere of radius 1,
  // centered at point
  double lat = Math.toRadians(point.y);
  double cosLat = FastMath.cos(lat);
  double lon = Math.toRadians(point.x) * cosLat;
  Point point2 = GeometryUtils.getGeometryFactory().createPoint(new Coordinate(lon, lat));
  LineString lineString2 = equirectangularProject(lineString, cosLat);
  return lineString2.distance(point2) * RADIUS_OF_EARTH_IN_M;
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

/** projected distance from stop to edge, in latitude degrees */
private static double distance (Vertex tstop, StreetEdge edge, double xscale) {
  // Despite the fact that we want to use a fast somewhat inaccurate projection, still use JTS library tools
  // for the actual distance calculations.
  LineString transformed = equirectangularProject(edge.getGeometry(), xscale);
  return transformed.distance(geometryFactory.createPoint(new Coordinate(tstop.getLon() * xscale, tstop.getLat())));
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

@Override
public String resolve(double x, double y) {
  System.out.println("x="+x+", y="+y);
  FeatureIterator<Feature> iterator = collection.features();
  while( iterator.hasNext() ){
     SimpleFeature feature = (SimpleFeature) iterator.next();
     Geometry geom = (Geometry) feature.getDefaultGeometry();
          GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();             
     Coordinate coord = new Coordinate(x, y);
     Point point = geometryFactory.createPoint(coord);
          //System.out.println("checking "+point.toString());
     if(geom.contains(point)) {
       return feature.getAttribute(this.nameField).toString();
     }
  }
  return null;
      
  
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

vvAttrs.color = null;
vvAttrs.label = null;
Point point = geomFactory.createPoint(new Coordinate(vertex.getLon(), vertex.getLat()));
boolean render = evRenderer.renderVertex(vertex, vvAttrs);
if (!render)

代码示例来源:origin: opentripplanner/OpenTripPlanner

Coordinate dropPoint = new Coordinate(lon, lat);
        geomsArray = new Geometry[coords.length];
        for (int j = 0; j < geomsArray.length; j++) {
          geomsArray[j] = gf.createPoint(coords[j]);

代码示例来源:origin: opentripplanner/OpenTripPlanner

private final void generateDebugGeometry(TZ z0) {
  debug = false;
  for (DelaunayEdge<TZ> e : triangulation.edges()) {
    Coordinate cA = e.getA().getCoordinates();
    Coordinate cB = e.getB().getCoordinates();
    debugGeom.add(geometryFactory.createLineString(new Coordinate[] { cA, cB }));
    if (zMetric.cut(e.getA().getZ(), e.getB().getZ(), z0) != 0) {
      double k = zMetric.interpolate(e.getA().getZ(), e.getB().getZ(), z0);
      Coordinate cC = new Coordinate(cA.x * (1.0 - k) + cB.x * k, cA.y * (1.0 - k) + cB.y
          * k);
      debugGeom.add(geometryFactory.createPoint(cC));
    }
  }
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

if (geoJsonGeom instanceof org.geojson.Point) {
  org.geojson.Point geoJsonPoint = (org.geojson.Point) geoJsonGeom;
  return gf.createPoint(new Coordinate(geoJsonPoint.getCoordinates().getLongitude(), geoJsonPoint
      .getCoordinates().getLatitude()));

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

static Point createRandomPoint()
 {
   return geomFact.createPoint(new Coordinate(Math.random(), Math.random()));
 }
}

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

static Point createRandomPoint()
{
  return geomFact.createPoint(new Coordinate(Math.random(), Math.random()));
}

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

public static void main(String[] args)
   throws Exception
 {
  // create a factory using default values (e.g. floating precision)
  GeometryFactory fact = new GeometryFactory();

  Point p1 = fact.createPoint(new Coordinate(0,0));
  System.out.println(p1);

  Point p2 = fact.createPoint(new Coordinate(1,1));
  System.out.println(p2);

  MultiPoint mpt = fact.createMultiPoint(new Coordinate[] { new Coordinate(0,0), new Coordinate(1,1) } );
  System.out.println(mpt);

 }
}

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

static Geometry createCircle()
{
  Geometry centrePt = geomFact.createPoint(new Coordinate(0.5, 0.5));
  return centrePt.buffer(0.5, 20);
}

代码示例来源:origin: komoot/photon

@Override
  public Point apply(Request webRequest) throws BadRequestException {
    Point location;
    String lonParam = webRequest.queryParams("lon");
    String latParam = webRequest.queryParams("lat");
    if (!mandatory && lonParam == null && latParam == null) {
      return null;
    }
    
    try {
      Double lon = Double.valueOf(lonParam);
      if (lon > 180.0 || lon < -180.00) {
        throw new BadRequestException(400, "invalid search term 'lon', expected number >= -180.0 and <= 180.0");
      }
      Double lat = Double.valueOf(latParam);
      if (lat > 90.0 || lat < -90.00) {
        throw new BadRequestException(400, "invalid search term 'lat', expected number >= -90.0 and <= 90.0");
      }
      location = geometryFactory.createPoint(new Coordinate(lon, lat));
    } catch (NullPointerException | NumberFormatException e) {
      throw new BadRequestException(400, "invalid search term 'lat' and/or 'lon', try instead lat=51.5&lon=8.0");
    }
    return location;
  }
}

代码示例来源:origin: stackoverflow.com

File f = new File ( "world.shp" );
 ShapefileDataStore dataStore = new ShapefileDataStore ( f.toURI ().toURL () );
 FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = 
   dataStore.getFeatureSource ();
 String geomAttrName = featureSource.getSchema ()
   .getGeometryDescriptor ().getLocalName ();
 ResourceInfo resourceInfo = featureSource.getInfo ();
 CoordinateReferenceSystem crs = resourceInfo.getCRS ();
 Hints hints = GeoTools.getDefaultHints ();
 hints.put ( Hints.JTS_SRID, 4326 );
 hints.put ( Hints.CRS, crs );
 FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2 ( hints );
 GeometryFactory gf = JTSFactoryFinder.getGeometryFactory ( hints );
 Coordinate land = new Coordinate ( -122.0087, 47.54650 );
 Point pointLand = gf.createPoint ( land );
 Coordinate water = new Coordinate ( 0, 0 );
 Point pointWater = gf.createPoint ( water );
 Intersects filter = ff.intersects ( ff.property ( geomAttrName ), 
   ff.literal ( pointLand ) );
 FeatureCollection<SimpleFeatureType, SimpleFeature> features = featureSource
     .getFeatures ( filter );
 filter = ff.intersects ( ff.property ( geomAttrName ), 
   ff.literal ( pointWater ) );
 features = featureSource.getFeatures ( filter );

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

public Geometry toGeometry(GeometryFactory geomFactory)
  return geomFactory.createPoint((CoordinateSequence)null);
 Coordinate px00 = new Coordinate(minX, minA - minX);
 Coordinate px01 = new Coordinate(minX, minX - minB);
 Coordinate px10 = new Coordinate(maxX, maxX - maxB);
 Coordinate px11 = new Coordinate(maxX, maxA - maxX);
  return geomFactory.createPoint(px00);

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

return createPoint((CoordinateSequence)null);
return createPoint(new Coordinate(envelope.getMinX(), envelope.getMinY()));
   || envelope.getMinY() == envelope.getMaxY()) {
 return createLineString(new Coordinate[]{
  new Coordinate(envelope.getMinX(), envelope.getMinY()),
  new Coordinate(envelope.getMaxX(), envelope.getMaxY())
  });

代码示例来源:origin: org.orbisgis/h2gis

/**
 * Compute the point of the cell
 *
 * @return Center point of the cell
 */
private Point getCellPoint() {
  double x1 = (minX + cellI * deltaX) + (deltaX / 2d);
  double y1 = (minY + cellJ * deltaY) + (deltaY / 2d);
  cellI++;
  return GF.createPoint(new Coordinate(x1, y1));
}

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

/**
 * Generate Point from two dimensional ordinates
 *
 * @param x
 * @param y
 * @return Point
 */
public Point point( int x, int y ){
  return gf.createPoint( new Coordinate( x, y ) );
}
/**

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

@Override
  protected Geometry newGeometry(final double[][][] coords,
      final GeometryFactory geometryFactory) throws DataSourceException {
    final double x = coords[0][0][0];
    final double y = coords[0][0][1];
    return geometryFactory.createPoint(new Coordinate(x, y));
  }
}

相关文章