How to run Neo4j with OSM and Neo4jSpatial?

61 views
Skip to first unread message

amhg

unread,
Jul 20, 2015, 11:03:10 PM7/20/15
to ne...@googlegroups.com

Hello i'm new in neo4j and i would like to use OSM + Neo4j Spatial. I have a maven project and my Neo4j version is 2.3.0-M01


I have a simple code just for importing an OSM file but it displays some errors in the import files: GraphDatabaseService, EmbeddedGraphDatabase and BatchInserter.


package testOSM;

import java.nio.charset.Charset;
import org.neo4j.gis.spatial.osm.OSMImporter;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.kernel.impl.batchinsert.BatchInserter;

public class TestOsm {

    private static final String DB_PATH = "/community/data/graph.db";

    public static void main(final String[] args){

        OSMImporter importer = new OSMImporter("clz_map.osm");
        importer.setCharset(Charset.forName("UTF-8"));
        BatchInserter batchInserter = BatchInserter.inserter(DB_PATH);

        try{
            importer.importFile(batchInserter, "clz_map.osm", false);
            GraphDatabaseService db = new EmbeddedGraphDatabase(DB_PATH);
            importer.reIndex(db);
            db.shutdown();
            }

        catch(Exception e){
            System.out.println(e.getMessage());
            }

        batchInserter.shutdown();    
    }  
}

May be my problem is with the versions, because i'm using Neo4j 2.3-M01, but i don't know exactly how should i set the versions e.g. here

<dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-graph-collections</artifactId> <version>0.7.1-neo4j-2.0.2-SNAPSHOT</version> <type>jar</type> </dependency>


My pom.xml is based on https://github.com/neo4j-contrib/spatial/blob/master/pom.xml

Plus
<repository> <id>neo4j</id> <url>http://m2.neo4j.org/content/repositories/releases/</url> <releases> <enabled>true</enabled> </releases> </repository> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j</artifactId> <version>2.3.0-M01</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-kernel</artifactId> <version>2.3.0-M01</version> </dependency>

You can have a look into my git repository https://github.com/amhg/OSM


I hope you can help me, thank you in advance!



Craig Taverner

unread,
Jul 21, 2015, 10:54:00 AM7/21/15
to ne...@googlegroups.com
Hi Andrea,

We have not tried Neo4j Spatial on 2.3 yet, but it should be possible to get it working. One thing I can see is that you are referring to graph-collections which was deprecated a year ago, and should not be a dependency at all any more. The RTree code was ported into a newer version of Neo4j.

I'll try get time to try it out on 2.3 sometime next week, and then I could upload a version for that then.

Good luck.

Regards, Craig

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Craig Taverner

unread,
Jul 29, 2015, 3:44:42 PM7/29/15
to ne...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages