问题描述
我正在跟踪 GeoTools文档,并发现了这一点:
I'm following the GeoTools documentation and found this:
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
Coordinate coord = new Coordinate(45, 15);
Point point = geometryFactory.createPoint(coord);
当我将它放在intellij IDE中时,对于每个类,都有几个建议使用的导入.我需要选择什么导入?
When I put it in intellij IDE, for each class there are several suggested imports to use. What import I need to select?
(具有相同问题)的替代方法是:
Alternative way (with same issue) is:
GeometryBuilder builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
Point point = builder.createPoint(45, 15);
推荐答案
如有疑问,您可以随时阅读文档,例如 JTSFactoryFinder 返回com.vividsolutions.jts.geom.GeometryFactory
,一旦您知道其他部分落入位置:
When in doubt you can always read the documentation, for example JTSFactoryFinder returns a com.vividsolutions.jts.geom.GeometryFactory
, once you know that the other pieces fall into place as:
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
与此同时,您的 GeometryBuilder 是org.geotools.geometry.GeometryBuilder
导致以下导入:
Meanwhile your GeometryBuilder is an org.geotools.geometry.GeometryBuilder
which leads to the following imports:
import org.geotools.geometry.GeometryBuilder;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.geometry.primitive.Point;
这篇关于GeoTools:如何建立一个点? (进口问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!