geotools

Geotools: bounding box for a buffer in wgs84

社会主义新天地 提交于 2019-12-07 15:41:20
问题 I am need a Java function that will generate a bounding box (rectangle) around a buffer. The buffer is defined by the center point (WGS84 coordinate) and the radius (in meters). Getting a bounding box for a buffer in JTS seems to be quite simple: Point center = .... Geometry boundingBox = center.buffer(...).getEnvelope(); This however is pure planar geometry. Is there a way to do this using a coordinate reference system with the distance given in meters? Optimally with Geotools but other Java

Java API for parsing MapInfo TAB format

女生的网名这么多〃 提交于 2019-12-06 13:46:05
I am working on parsing a MapInfo TAB Format file in Java. It consists of a set of four files viz .TAB, .ID, .MAP and .DAT. After searching on web I came across a parser provided by GeoTools at this repository: https://github.com/geotools/geotools/blob/master/modules/library/main/src/main/java/org/geotools/data/MapInfoFileReader.java When I use this API for parsing the MAPInfo TAB format file bundle, the API throws exception: "Didn't find a minimum of three control points in the .tab file." I am using public MapInfoFileReader(final File tabfile) constructor. I have tried using different

Java: Convert lat/lon from EPSG:4236 to EPSG: 3857

丶灬走出姿态 提交于 2019-12-06 08:19:02
问题 How would I convert my lat lon to EPSG 3857 projection using geotools or another java library? I'm having trouble finding the proper methods to use. I know OpenLayers (javascript) can do it easily, but I don't see a clear path to getting these coordinates transformed. I would like to see this transformation source lon, lat: -71.017942, 42.366662 destination lon, lat: -71 1.25820, 42 22.0932 So I have created my CRS final CoordinateReferenceSystem source = CRS.decode( "EPSG:4236" ); final

Geotools: bounding box for a buffer in wgs84

旧街凉风 提交于 2019-12-06 02:14:21
I am need a Java function that will generate a bounding box (rectangle) around a buffer. The buffer is defined by the center point (WGS84 coordinate) and the radius (in meters). Getting a bounding box for a buffer in JTS seems to be quite simple: Point center = .... Geometry boundingBox = center.buffer(...).getEnvelope(); This however is pure planar geometry. Is there a way to do this using a coordinate reference system with the distance given in meters? Optimally with Geotools but other Java solutions will also work... Although you have approached it in another way, I have another solution

Java.lang.reflect.Proxy returning another proxy from invocation results in ClassCastException on assignment

时光毁灭记忆、已成空白 提交于 2019-12-05 22:26:59
问题 So I'm playing with geotools and I thought I'd proxy one of their data-access classes and trace how it was being used in their code. I coded up a dynamic proxy and wrapped a FeatureSource (interface) in it and off it went happily. Then I wanted to look at some of the transitive objects returned by the featureSource as well, since the main thing a FeatureSource does is return a FeatureCollection (FeatureSource is analogous to a sql DataSource and featurecollection to an sql statement). in my

Geotools distance calculation fails with no convergence exception for several lat lon points

故事扮演 提交于 2019-12-05 12:19:16
I have a number of points which make getOrthodromicDistance method to fail with exception in geotools lib, while these points are valid lat lon points: Point which throws the exception (lat,lon): val p1= (5.318765,-75.786109) val p2= (-6.32907,106.09254) eg exception: No convergence for points 75°47,2'W 06°19,7'S and 106°05,6'E 05°19,1'N. java.lang.ArithmeticException: No convergence for points 75°47,2'W 06°19,7'S and 106°05,6'E 05°19,1'N. at org.geotools.referencing.GeodeticCalculator.computeDirection(GeodeticCalculator.java:1073) Code used in Scala: def latlonDistance(p1:(Double,Double), p2:

How to use GeometricShapeFactory in geoTools to create a Circle on map

不羁的心 提交于 2019-12-04 05:30:58
问题 I am currently using the below code to create a GeoJson Polygon. this gives me a bad circle which is not valid... in this case RADIUS = 1609.34 , which is 1 mile in meters. public GeoJsonPolygon createRadiusPolygon( Point point,double RADIUS) { GeometricShapeFactory shapeFactory = new GeometricShapeFactory(); shapeFactory.setNumPoints(32); shapeFactory.setCentre(new com.vividsolutions.jts.geom.Coordinate(point.getX(), point.getY())); shapeFactory.setSize(RADIUS * 2); com.vividsolutions.jts

Java.lang.reflect.Proxy returning another proxy from invocation results in ClassCastException on assignment

时光怂恿深爱的人放手 提交于 2019-12-04 04:45:26
So I'm playing with geotools and I thought I'd proxy one of their data-access classes and trace how it was being used in their code. I coded up a dynamic proxy and wrapped a FeatureSource (interface) in it and off it went happily. Then I wanted to look at some of the transitive objects returned by the featureSource as well, since the main thing a FeatureSource does is return a FeatureCollection (FeatureSource is analogous to a sql DataSource and featurecollection to an sql statement). in my invocationhandler I just passed the call through to the underlying object, printing out the target class

Reading an ESRI shapefile from a zip-file during Runtime in Java - DataStoreFinder.getDataStore(connectParameters) returns null

痴心易碎 提交于 2019-12-04 03:42:31
We are building a service for uploading zip-files containing an ESRI-shapefile. The service should be able to read the shapefile and do stuff with its content. So I've built a class that unzips the zip-file to temporary folder (subfolder of System.getProperty("java.io.tmpdir")). Another class calls the unzip method from the Unzip-class and it then tries to read the unpacked shapefile using Geotools. It uses the Geotools DataStoreFinder.getDataStore(Map params) method to create a datastore from the unzipped shapefile. Here the problem occurs: the getDataStore-method returns null. I tested the

java.lang.NoClassDefFoundError: Could not initialize class javax.media.jai.JAI

大城市里の小女人 提交于 2019-12-04 03:08:41
问题 I recently started my first program with GeoTools in which i was also using JAI- Java Advanced Imaging 1_1_2_01 with JDK 1_7. It worked fine until I added GeoTiff Jars . I found following error Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class javax.media.jai.JAI at org.geotools.gce.geotiff.GeoTiffReader.read(GeoTiffReader.java:607) at com.rgb.PixelExtractor.extract(PixelExtractor.java:55) at com.rgb.RGBSpliter.main(RGBSpliter.java:136) The Code is as below