我跟随GeoTools documentation并发现了这个:
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
Coordinate coord = new Coordinate(45, 15);
Point point = geometryFactory.createPoint(coord);
当我把它放在intellij IDE中时,对于每个类,有几个建议的导入要使用。我需要选择什么导入?
替代方式(同样的问题)是:
GeometryBuilder builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
Point point = builder.createPoint(45, 15);
答案 0 :(得分:3)
如果您有疑问,可以随时阅读文档,例如JTSFactoryFinder返回com.vividsolutions.jts.geom.GeometryFactory
,一旦您知道其他部分就会出现:
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
同时,您的GeometryBuilder为org.geotools.geometry.GeometryBuilder
,导致以下导入:
import org.geotools.geometry.GeometryBuilder;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.geometry.primitive.Point;