标签: geotools

使用GeoTools:com.vividsolutions.jts.geom.Coordinate类中的纬度和经度是多少?

我将com.vividsolutions.jts.geom.Coordinate用作我的坐标类.但是找不到任何正确的坐标顺序的文档.它是标准的吗?

这是java doc链接 - > http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Coordinate.html

我的问题是:什么是x?(是纬度还是经度?)什么是y?(是纬度还是经度?)

任何指导表示赞赏.

更新1 让我补充一下.我正在使用GeoTools Java Library.然后,库正在使用该Coordinate类.GeoTools如何处理Coordinate.x和Coordinate.y?

java coordinate geotools

8
推荐指数
1
解决办法
5532
查看次数

java.lang.NoClassDefFoundError:无法初始化类javax.media.jai.JAI

我最近开始使用GeoTools开始我的第一个程序,其中我也使用JAI-Java Advanced Imaging 1_1_2_01和JDK 1_7.它工作正常,直到我添加了GeoTiff Jars.我发现以下错误

线程"main"中的异常java.lang.NoClassDefFoundError:无法在com.rgb.PixelExtractor.extract的org.geotools.gce.geotiff.GeoTiffReader.read(GeoTiffReader.java:607)初始化类javax.media.jai.JAI (PixelExtractor.java:55)at com.rgb.RGBSpliter.main(RGBSpliter.java:136)

守则如下

 public void extract(File f, String name, String date) throws Exception {
 ParameterValue<OverviewPolicy> policy = AbstractGridFormat.OVERVIEW_POLICY
        .createValue();
 policy.setValue(OverviewPolicy.IGNORE);

 // this will basically read 4 tiles worth of data at once from the disk...
 ParameterValue<String> gridsize = AbstractGridFormat.SUGGESTED_TILE_SIZE.createValue();
 //gridsize.setValue(512 * 4 + "," + 512);

 // Setting read type: use JAI ImageRead (true) or ImageReaders read methods (false)
 ParameterValue<Boolean> useJaiRead = AbstractGridFormat.USE_JAI_IMAGEREAD.createValue();
 useJaiRead.setValue(true);

 //reader.read(new GeneralParameterValue[] { policy, gridsize, useJaiRead }); …
Run Code Online (Sandbox Code Playgroud)

java jai geotools

8
推荐指数
1
解决办法
3827
查看次数

从调用返回另一个代理的Java.lang.reflect.Proxy在赋值时导致ClassCastException

所以我正在玩geotools,我想我会代理他们的一个数据访问类,并跟踪它们在代码中的使用方式.

我编写了一个动态代理并在其中包含了一个FeatureSource(接口),并且很高兴.然后我想看看一些由featureSource返回,以及在传递对象,因为FeatureSource做的主要工作是返回的FeatureCollection(FeatureSource类似于一个SQL数据源,并以的FeatureCollection SQL语句).

在我的InvocationHandler我刚刚通过的调用底层对象,打印出目标类/方法/指定参数和结果,我去了,但是对于返回的FeatureCollection(另一个接口)调用,我裹着该对象在我的代理服务器(在相同的类,但一个新的实例,应该不重要吗?)并返回它.BAM!Classcast异常:

java.lang.ClassCastException: $Proxy5 cannot be cast to org.geotools.feature.FeatureCollection  
    at $Proxy4.getFeatures(Unknown Source)  
    at MyClass.myTestMethod(MyClass.java:295)  
Run Code Online (Sandbox Code Playgroud)

调用代码:

FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = ... // create the FS
featureSource = (FeatureSource<SimpleFeatureType, SimpleFeature>) FeatureSourceProxy.newInstance(featureSource, features);
featureSource.getBounds();// ok
featureSource.getSupportedHints();// ok

DefaultQuery query1 = new DefaultQuery(DefaultQuery.ALL);
FeatureCollection<SimpleFeatureType, SimpleFeature> results = featureSource.getFeatures(query1); //<- explosion here
Run Code Online (Sandbox Code Playgroud)

代理人:

public class FeatureSourceProxy  implements java.lang.reflect.InvocationHandler {

private Object target;
private List<SimpleFeature> features;

public static Object newInstance(Object obj, List<SimpleFeature> features) {
return java.lang.reflect.Proxy.newProxyInstance(
    obj.getClass().getClassLoader(), 
    obj.getClass().getInterfaces(), 
    new FeatureSourceProxy(obj, features)
);
}

private …
Run Code Online (Sandbox Code Playgroud)

java reflection proxy classcastexception geotools

7
推荐指数
1
解决办法
2521
查看次数

Java geotools 检查点是否包含在具有公差的多边形中

我正在使用 Java Geotools 库来检查 POINT(...) 是否包含在 POLYGON(...) 中。

我已经做到了:

Geometry sPG = reader.read(wktStartPoint); //startpointgeometry
Geometry sEG = reader.read(wktEndPoint);
if(wktLayerGeo.contains(sPG) || wktLayerGeo.contains(sEG)){
 // do something
}
Run Code Online (Sandbox Code Playgroud)

但现在我必须设置一个容差:例如,我会检查一个点是否包含在容差距离为 50 公里的多边形中。

我可以用 GeoTools 做吗?

谢谢

java contain geotools

7
推荐指数
1
解决办法
2945
查看次数

如何处理 WKT 中的 Circle?

我有一个 json 对象

区域 : CIRCLE (28.625360369528934 77.2227479486792, 3135.6)

如何使用 WKTreader 解析它?

parsing android geotools wkt

7
推荐指数
1
解决办法
4759
查看次数

谷歌地图空间参考系统

当您在地图搜索栏中输入纬度时使用的Google地图的空间参考系统是什么?

我发现它可能是WGS84的提示,但转换到该坐标系后,当我将坐标粘贴到谷歌地图搜索框时,没有任何显示.

我正在转换GDA MGA 56.

样品:

  • 输入MGA56坐标:336301,6253363
  • 预期的WGS86坐标:-33.8473340793201,151.230631835944
  • 我得到:16834916.928327594 -4008321.1020318186

空间坐标系:

  • EPSG:MGA56的28356
  • EPS:900913 for WGS86(谷歌地图)

我正在使用geotools进行转换:

    CoordinateReferenceSystem crsMga56 = CRS.parseWKT(mga56);
    CoordinateReferenceSystem crsGmaps = CRS.parseWKT(gmaps);

    Coordinate coordinate = new Coordinate(336301, 6253363);
    Point point = new GeometryFactory().createPoint(coordinate);

    MathTransform transform = CRS.findMathTransform(crsMga56, crsGmaps);
    Geometry geometry = JTS.transform(point, transform);
Run Code Online (Sandbox Code Playgroud)

我知道变换是不正确的,因为当我使用在线工具时,它给了我正确的坐标.http://www.environment.gov.au/cgi-bin/transform/mga2geo_gda.pl?east=336301&north=6253363&zone=56

google-maps spatial geotools

6
推荐指数
1
解决办法
2万
查看次数

java中的SchemaException

我找到了一个有用的工具,可以使用geotools将 .csv 文件转换为形状文件:

但是我在运行它时遇到问题,出现以下 maven 错误:

无法在项目教程中执行目标 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli):命令执行失败。进程退出并出现错误:1(退出值:1)

这一行有一个错误:

final SimpleFeatureType TYPE = DataUtilities.createType(
                "Location",                   // <- the name for our feature type
                "location:Point:srid=4326," + // <- the geometry attribute: Point type
                "name:String"         // <- a String attribute
        );
Run Code Online (Sandbox Code Playgroud)

错误:

线程“main”org.geotools.feature.SchemaException 中的异常:解码 srs 时出错

我的 POM 文件是这样的:

<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.geotools</groupId>
    <artifactId>tutorial</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>tutorial</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>11-SNAPSHOT</geotools.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-shapefile</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId> …
Run Code Online (Sandbox Code Playgroud)

java maven geotools

6
推荐指数
1
解决办法
1031
查看次数

为什么这段代码如何使用geotools读取shapefile会抛出此异常?

我正在使用geotools 10.1从shapefile中读取属性.我不明白为什么在打印所有要素属性后抛出异常.

这是示例代码:

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.opengis.feature.simple.SimpleFeature;

public class LayerBusinessTest {


public static void main(String[] args) throws IOException {

    File file = new File("../../setup/test/shp/sscc/SSCC2010_WGS84.shp");
    Map<String, Serializable> map = new HashMap<>();
    map.put( "url", file.toURI().toURL() );

    DataStore dataStore = DataStoreFinder.getDataStore( map );
    String typeName = dataStore.getTypeNames()[0];

    FeatureSource source = dataStore.getFeatureSource( typeName );

    FeatureCollection collection =  source.getFeatures();
    FeatureIterator<SimpleFeature> results = collection.features();
    try {
        while (results.hasNext()) …
Run Code Online (Sandbox Code Playgroud)

java geotools

6
推荐指数
1
解决办法
3637
查看次数

如何在Java中对某些形状进行三角测量/镶嵌?

我想从GeoTools镶嵌国家形状,在地球表面上以3D形式显示.GeoTools使用内部功能丰富的JTS拓扑套件.

是否包含镶嵌某些形状的实用程序?我看到有三角测量包,但无法弄清楚,如何将其用于带孔的形状.

另外,我不仅可以像这里一样连接现有的顶点

在此输入图像描述

它应该填充内部有多个顶点的形状.

UPDATE

我发现,JTS包含ConformingDelaunayTriangulationBuilder允许以某种方式制作希望镶嵌的类,但它的工作很糟糕.首先,它只允许约束,这意味着需要额外的代码来从凹陷区域中删除三角形.并且它还试图保留细分的Delaunay性质,这导致创建许多其他部分.

最后,它导致ConstraintEnforcementException复杂的形状像国家和无法使用.

我还发现了"三角形"包,用C语言编写并实现了Chew的第二种算法,效果很好

在此输入图像描述

现在我想知道,它是移植到Java还是包含它?

java jts mesh geotools tessellation

6
推荐指数
1
解决办法
1636
查看次数

如何使用GeoTools创建具有纬度,经度和半径的圆?

现在我有:

Polygon circle = geometryBuilder.circle(
myLong,
myLat, 
radiusInMeters, 10);
Run Code Online (Sandbox Code Playgroud)

它创建(使用lat = 28.456306,long = -16.292034和radius = 500)一个具有巨大纬度和经度的无意义多边形,例如:

POLYGON ((483.678055 28.482505000000003, 388.1865521874737 -265.4101211462366, 138.1865521874737 -447.04575314757676, -170.8304421874737 -447.0457531475768, -420.8304421874737 -265.41012114623663, -516.321945 28.482504999999943, -420.83044218747375 322.3751311462365, -170.8304421874738 504.01076314757677, 138.18655218747358 504.0107631475768, 388.18655218747364 322.3751311462367, 483.678055 28.482505000000003))
Run Code Online (Sandbox Code Playgroud)

我希望在我提供的中心点附近有十对坐标,lat和long.

任何帮助都会有所帮助.提前致谢!

编辑

除了@iant的回答,我还得创建Point一个Feature

//build the type
SimpleFeatureType TYPE = null;
try {
    TYPE = DataUtilities.createType("", "Location", "locations:Point:srid=4326," + "id:Integer" // a
            // number
            // attribute
            );
} catch (Exception e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace(); …
Run Code Online (Sandbox Code Playgroud)

java geotools

6
推荐指数
2
解决办法
5835
查看次数