Hi Craig

Thank you for replying; I was sick and I couldn't give a look earlier
Anyway I'm little bit confused on how to index my own nodes and/or how to 
create my own adapter
In my scenario I'm parsing an OSM file in order to create my own model 
domain. Basically my model domain will be composed by Nodes and Edges; 
nodes represent points with coordinates X and Y; edges represent OSM ways 
between two points and thhese edges can have OUTOCOMING and/or INCOMING 
direction (from geometry point of view way can coincide with lines so it 
would be great if I can add spatial index to these lines too)
So my node will have the following properties:

   - double x
   - double y
   - long osmId *//File OSM id*
   
My edges will have these properties:

   - node startNode
   - node endNode
   - double cost *//For Dijkstra o A**
   

Now my idea is that when I create a node I can "Spatial Index" it too. I'm 
using the batchInserter in order to create my model (my OSM may coincide 
with the whole Italy, so I'ld like to have good performances during the 
import)
What I can't understand is how I can add a spatial index to my nodes when I 
create them; actually I have this code in my simple java class:

private BatchInserter inserter;

private Label mainNodeLabel;
private Label secondaryNodeLabel;
private void initialize(){
.
.
.

inserter = BatchInserters.inserter(neo4jDbPath, config);

mainNodeLabel = DynamicLabel.label("NodoPrincipale");
inserter.createDeferredSchemaIndex(mainNodeLabel).on("x").create();
inserter.createDeferredSchemaIndex(mainNodeLabel).on("y").create();
secondaryNodeLabel = DynamicLabel.label("NodoSecondario");
inserter.createDeferredSchemaIndex(secondaryNodeLabel).on("x").create();
inserter.createDeferredSchemaIndex(secondaryNodeLabel).on("y").create(); 
}
private void createGraphNode( Node osmFileNode, boolean isMainNode ){
try {

double y = osmFileNode.getLongitude();

double x = osmFileNode.getLatitude();

long osmFileNodeId = osmFileNode.getId();

String giunzioneDbId = "giunzioneDbId_"+osmFileNodeId;

Map<String, Object> nodeProps = new HashMap<String, Object>();

nodeProps.put("x", x);

nodeProps.put("y", y);

nodeProps.put("giunzioneDbId", giunzioneDbId);

long graphNodeId = -100;

if( isMainNode ){


graphNodeId = this.inserter.createNode(nodeProps, mainNodeLabel);

}else{


graphNodeId = this.inserter.createNode(nodeProps, secondaryNodeLabel);
}catch(Excpetion e){
 

logger.fatal("Eccezione",e); 
} 
}

 private void createRelationship(Node startNode, Node endNode, long wayId ){


 RelationshipType roadElementRelation = DynamicRelationshipType.withName( 
"ROAD_ELEMENT" );
 Map<String, Object> relProps = new HashMap<String, Object>();
 String elementoStradaleId = "elementoStradaleDbId_"+wayId; 
 relProps.put("elementoStradaleDbId", elementoStradaleId);
 relProps.put("__type__", PinfRoadElementGraphNodesRelationship.class.
getName());
 relProps.put("lunghezzaArco", 
getDistanzaInMetri(startNodeWrapper,endNodeWrapper
));
 long relationId = inserter.createRelationship(startNodeWrapper.
getGraphNodeId(), endNodeWrapper.getGraphNodeId(), roadElementRelation,relProps
);
 indiceElementoStradaleDbId.add(relationId, MapUtil.map(
"elementoStradaleDbId", elementoStradaleId));
 //Relationship Index flushing
 indiceElementoStradaleDbId.flush();
 }



As you can see now I don't have any spatial index....what should I modify 
in order to add the spatial index? I'm sure that it's something simple that 
I'm missing....but I can't figure it :)

Thank you
Angelo

Il giorno venerdì 10 gennaio 2014 09:34:08 UTC+1, Angelo Immediata ha 
scritto:
>
> Hi there
>
> I'm using this environment:
>
>    - spring 3.2.6
>    - spring-data-neo4j 2.3.3 (I'm thinking to upgrade to the version 3 in 
>    order to have support for neo4j 2.0)
>    - neo4j 1.9.5
>    
>
> I'm thinking to use neo4j in order to store our own graph that will be 
> used in a route planner project. The first question is if this seems to you 
> (sure more experts than me) a good solution in order to build a very good 
> and efficient and performant route planner
> Moreover as far as I know (by reading this link 
> http://docs.neo4j.org/chunked/1.9.5/graph-algo.html ) in neo4j these 
> algorithms are implemented:
>
>    - Shortest paths
>    - all paths
>    - all simple paths
>    - Dijkstra
>    - A*
>    
>
> By reading this link 
> http://docs.neo4j.org/chunked/1.9.5/rest-api-graph-algos.html I saw that 
> REST API allows to call these algorithms:
>
>    - Find all shortest paths
>    - Find one of the shortest paths between nodes
>    - Execute a Dijkstra algorithm with similar weights on relationships
>    - Execute a Dijkstra algorithm with weights on relationships
>    
>
> The second question is: can't I invoke the A* algorithm by REST API? This 
> is related to the fact that I'ld love to have one (ore more) dedicated 
> machine to neo4j and access to them by REST API (is this a good solution?)
>
> The last question regards neo4j performance. In my real scenario i may 
> import an OSM file of an whole italian region (maybe also the full Italy); 
> in the case of one region I can have around 10 millions of nodes (also more 
> than 10 million) and some millions of relationship. In this case...what are 
> performances with the built-in algorithms Dijkstra and/or A* when i want 
> the shortest path (or all paths) between two points located at the end of 
> the graph? 
>
> Thank you
> Angelo
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to