GeoTools: How to build a point? (imports issue)

╄→гoц情女王★ 提交于 2019-12-13 07:39:37

问题


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);

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);

回答1:


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;

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;


来源:https://stackoverflow.com/questions/32565298/geotools-how-to-build-a-point-imports-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!