Если я компилирую проект с помощью maven, все работает нормально, но когда я выполняю это с помощью Eclipse, когда я пытаюсь создать фабрику геометрии:
Код: Выделить всё
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
Код: Выделить всё
Caused by: java.lang.ClassNotFoundException: org.geotools.geometry.jts.JTSFactoryFinder from [Module "deployment.famaWebApp.war" from Service Module Loader]
Код: Выделить всё
GeometryFactory geometryFactory = new GeometryFactory();;
Код: Выделить всё
Caused by: java.lang.ClassNotFoundException: org.locationtech.jts.geom.GeometryFactory from [Module "deployment.famaWebApp.war" from Service Module Loader]
Код: Выделить всё
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
Код: Выделить всё
// Patrón de expresión regular para encontrar pares de números entre corchetes
Matcher matcher;
// GeometryFactory geometryFactory = new GeometryFactory();
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
if ("Point".equals(geometryType))
{
Pattern patternPoint = Pattern.compile("\\[([\\d.]+),\\s*([\\d.]+),\\s*([\\d.]+)\\]");
matcher = patternPoint.matcher(coordinates);
if (matcher.find())
{
double x = Double.parseDouble(matcher.group(1));
double y = Double.parseDouble(matcher.group(2));
Point point = geometryFactory.createPoint(new Coordinate(x, y));
geometryFeature.put("coordinates", point);
}
}
else
{
Pattern patternPolyline = Pattern.compile("\\[\\s*([-+]?\\d+\\.\\d+),\\s*([-+]?\\d+\\.\\d+)\\s*\\]");
matcher = patternPolyline.matcher(coordinates);
// Buscar y crear objetos Point/Polygon
int i = 0;
Coordinate[] coords = new Coordinate[] {};
while (matcher.find())
{
double x = Double.parseDouble(matcher.group(1));
double y = Double.parseDouble(matcher.group(2));
coords[i] = new Coordinate(x, y);
}
Polygon polygon = geometryFactory.createPolygon(coords);
geometryFeature.put("coordinates", polygon);
}
Код: Выделить всё
org.locationtech.jts
jts-core
1.18.2
org.geotools
gt-main
28.5
org.geotools
gt-metadata
28.5
Я пытался добавить зависимости gt-main, но все равно не работает. Как вы думаете, что я делаю не так?
Большое спасибо.
Подробнее здесь: https://stackoverflow.com/questions/772 ... rror-org-g