Migrating com.vividsolutions.jts to org.locationtech.jts still complaining about lack of com.vividsolutions package

1.8k Views Asked by At

I'm trying to upgrade dependencies for a java application that uses com.vividsolutions.jts. I have removed all the references to this library from pom.xml and replaced them by the ones from org.locationtech.jts.

I have updated all the imports to use org.locationtech version. However, in my function I'm still getting an error related to com.vividsolutions object not being imported.

import org.locationtech.spatial4j.context.jts.JtsSpatialContext;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.LinearRing;

import org.locationtech.spatial4j.shape.jts.JtsGeometry;


// ... other stuff

public static myFunc() {
    GeometryFactory gf = new GeometryFactory();
    LinearRing linear = gf.createLinearRing(coordinates);
    JtsGeometry poly = new JtsGeometry(fact.createPolygon(linear), JtsSpatialContext.GEO, true, true);
}

Here's the error that I get for the last line of the above code: [ERROR] cannot access com.vividsolutions.jts.geom.Geometry [ERROR] class file for com.vividsolutions.jts.geom.Geometry not found

I'm clearly importing JtsGeometry from the new library at org.locationtech, however, it's still thinking the old library should be used.

The old library isn't in the dependency tree or the code anymore, as the followings don't return anything:

mvn dependency:tree | grep vivid
rg vivid

Any idea what I'm missing here or how I should troubleshoot this?

1

There are 1 best solutions below

1
mohi666 On

I'm not too sure what was wrong with the vividsolutions library inclusion. However, I was able to resolve my issue by including both of these in pom.xml:

    <dependency>
        <groupId>org.locationtech.jts</groupId>
        <artifactId>jts-core</artifactId>
        <version>1.18.2</version>
    </dependency>
    <dependency>
        <groupId>org.locationtech.spatial4j</groupId>
        <artifactId>spatial4j</artifactId>
        <version>0.8</version>
    </dependency>

Initially I didn't have the second dependency in the pom.xml file.