本文整理汇总了Java中com.vividsolutions.jts.geom.Point.getCoordinate方法的典型用法代码示例。如果您正苦于以下问题:Java Point.getCoordinate方法的具体用法?Java Point.getCoordinate怎么用?Java Point.getCoordinate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.Point
的用法示例。
在下文中一共展示了Point.getCoordinate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.vividsolutions.jts.geom.Point; //导入方法依赖的package包/类
@Override
public void serialize(Point value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (value == null || value.getCoordinate() == null) {
provider.defaultSerializeNull(jgen);
} else {
jgen.writeStartObject();
jgen.writeObjectField("x", value.getX());
jgen.writeObjectField("y", value.getY());
jgen.writeEndObject();
}
}
示例2: createEnvelopeInMeters
import com.vividsolutions.jts.geom.Point; //导入方法依赖的package包/类
/**
* Calculates Envelope around Point p with sidelength of sideLengthMeters.
*
* Formula
* <pre>
* sideLengthMeters * 180
* ---------------------- = dLon [°]
* meanEarthRadius * cos(point.lat) * Pi
*
*
* sidelengthMeters * 180
* ---------------------- = dLat [°]
* meanEarthRadius * Pi
*
* </pre>
*
* earthRadius is 6371229 which gives best results for latitude around 47°
*
* @param p
* @param sideLengthMeters
* @return
* @throws IllegalArgumentException if SRID != 4326 (WGS84)
*/
public static Envelope createEnvelopeInMeters(Point p, double sideLengthMeters) {
if (p.getSRID() != WGS84) throw new IllegalArgumentException("SRID of Point has to be " + WGS84);
double radius = 6371229;
double lon = p.getCoordinate().x;
double lat = p.getCoordinate().y;
double dLon = sideLengthMeters * 180 / radius / Math.PI / Math.cos(lat / 180 * Math.PI) / 2;
double dLat = sideLengthMeters * 180 / radius / Math.PI / 2;
Envelope env = new Envelope(lon - dLon, lon + dLon, lat - dLat, lat + dLat);
return env;
}
示例3: geometry
import com.vividsolutions.jts.geom.Point; //导入方法依赖的package包/类
@Override
public void geometry(Geometry arg0) {
if (arg0 == null || arg0.getArea() < 80)
return;
// TODO Auto-generated method stub
if (count != 0) {
System.out.println(arg0.getGeometryType());
try {
Point cen = arg0.getCentroid();
Coordinate latLong = new Coordinate();
JTS.transform(cen.getCoordinate(), latLong, transform);
System.out.println(" ************************* " + count + " " + featureName);
System.out.println("in EPSG:27700 " + cen);
System.out.println("lat long " + latLong);
URL url = new URL("https://maps.googleapis.com/maps/api/staticmap?center="+latLong.x+","+latLong.y+"&zoom=20&size=640x640&maptype=satellite&format=png32&key=AIzaSyDYAQH5nMlF0vEfdIg0seTiGUIcRbLNeI4");
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream();
//
BufferedImage image = ImageIO.read(is);// new BufferedImage( 640,640, BufferedImage.TYPE_3BYTE_BGR );
// BufferedImage image = new BufferedImage( 640,640, BufferedImage.TYPE_3BYTE_BGR );
Graphics2D g2 = (Graphics2D) image.getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
double scale = 11f;
int imageCenX = image.getWidth () >> 1,
imageCenY = image.getHeight() >> 1;
g2.setColor(Color.red);
g2.setStroke(new BasicStroke(2f));
for (Pair<Coordinate, Coordinate> pair : new ConsecutivePairs<Coordinate>( Arrays.asList( arg0.getCoordinates() ), true)) {
double
x1 = pair.first().x - cen.getCoordinate().x,
y1 = pair.first().y - cen.getCoordinate().y,
x2 = pair.second().x - cen.getCoordinate().x,
y2 = pair.second().y - cen.getCoordinate().y;
x1 *= scale; x2 *= scale; y1 *= scale; y2 *= scale;
g2.draw( new Line2D.Double(x1 + imageCenX, - y1 + imageCenY, x2 + imageCenX, - y2 +imageCenY) );
}
g2.drawString( HeightsToRedis.getHeight(featureName) +"m below roof", 5, 15 );
g2.drawString( HeightsToRedis.getRoof(featureName) +"m including roof", 5, 30 );
g2.drawString( latLong.x + ", " + latLong.y + " location ", 5, 45 );
g2.dispose();
ImageIO.write(image, "png", new FileOutputStream ( String.format( "/home/twak/data/footprints/center%04d.png", count )) );
is.close();
if (count > 1000)
System.exit(0);
} catch (Throwable e) {
e.printStackTrace();
System.exit(0);
}
}
count++;
featureName = "?";
}