Rinsim, load leuven map by dynamicgraph and consider collisionAvoidance. end up with there is too short connection in the graph - rinsim

I am trying to do route planning with Rinsim. And I want to take collisionAvoidance into account, So I load the map by this method (because it seems collisionAvoidance is only supported in dynamicGraph):
private static ListenableGraph<LengthData> loadGrDynamicGraph(String name){
try {
Graph<LengthData> g = DotGraphIO.getLengthGraphIO(Filters.selfCycleFilter())
.read(DDRP.class.getResourceAsStream(name));
return new ListenableGraph<>(g);
}catch (Exception e){
}
return null;
}
and I set the vehicle length as 1d and the distance Unit as SI.METER. And it ends up with the following error.
Exception in thread "main" java.lang.IllegalArgumentException: Invalid graph: the minimum connection length is 1.0, connection (3296724.2131123254,2.5725043247255992E7)->(3296782.7337179,2.5724994399343655E7) defines length data that is too short: 0.8.
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:146)
at com.github.rinde.rinsim.core.model.road.CollisionGraphRoadModelImpl.checkConnectionLength(CollisionGraphRoadModelImpl.java:261)
at com.github.rinde.rinsim.core.model.road.RoadModelBuilders$CollisionGraphRMB.build(RoadModelBuilders.java:702)
at com.github.rinde.rinsim.core.model.road.RoadModelBuilders$CollisionGraphRMB.build(RoadModelBuilders.java:606)
at com.github.rinde.rinsim.core.model.DependencyResolver$Dependency.build(DependencyResolver.java:223)
at com.github.rinde.rinsim.core.model.DependencyResolver$Dependency.(DependencyResolver.java:217)
at com.github.rinde.rinsim.core.model.DependencyResolver.add(DependencyResolver.java:71)
at com.github.rinde.rinsim.core.model.ModelManager$Builder.doAdd(ModelManager.java:231)
at com.github.rinde.rinsim.core.model.ModelManager$Builder.add(ModelManager.java:212)
at com.github.rinde.rinsim.core.Simulator$Builder.addModel(Simulator.java:324)
at com.github.rinde.rinsim.examples.project.DDRP.run(DDRP.java:86)
at com.github.rinde.rinsim.examples.project.DDRP.main(DDRP.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
I tried to change the vehicle length, but the error still exit. Does anyone know how to overcome this error?
Thank you

A graph from OpenStreetMap (such as the map of Leuven) is not meant to be used in combination with the CollisionGraphRoadModel that you are trying to use. The reason is that the CollsionGrahpRoadModel is meant for a warehouse-like environment, not a public street. This model doesn't support multiple parallel lanes which is unrealistic in a city. The WarehouseExample defines two example graphs that can be used in combination with the CollsionGrahpRoadModel.

Related

org.neo4j.ogm.context.GraphEntityMapper throwing IllegalArgumentException: Can not set Double field to java.math.BigDecimal

Upgraded existing API to use Neo4j 4.3.3 and neo4j-ogm-http-driver to 3.2.25. spring-boot-starter-data-neo4j is 2.3.4.Release. Now if I try to create/fetch a relationship with one of the attribute as Double using org.springframework.data.repository CrudRepository.save() and org.springframework.data.neo4j.repository Neo4jRepository.findById(), it throws below error:
Found relationship type: OWNS to map to RelationshipEntity: RelationshipEntityName
2021-08-21 00:25:14.780 ERROR 3556 --- [nio-8303-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Error mapping GraphModel; nested exception is org.neo4j.ogm.exception.core.MappingException: Error mapping GraphModel] with root cause
java.lang.IllegalArgumentException: Can not set java.lang.Double field RelationshipEntityName.percentage to java.math.BigDecimal
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at org.neo4j.ogm.metadata.FieldInfo.lambda$write$0(FieldInfo.java:352)
at java.security.AccessController.doPrivileged(Native Method)
at org.neo4j.ogm.metadata.FieldInfo.write(FieldInfo.java:349)
at org.neo4j.ogm.metadata.FieldInfo.write(FieldInfo.java:383)
at org.neo4j.ogm.context.GraphEntityMapper.writeProperty(GraphEntityMapper.java:305)
at org.neo4j.ogm.context.GraphEntityMapper.setProperties(GraphEntityMapper.java:268)
at org.neo4j.ogm.context.GraphEntityMapper.createRelationshipEntity(GraphEntityMapper.java:409)
at org.neo4j.ogm.context.GraphEntityMapper.mapRelationshipEntity(GraphEntityMapper.java:354)
at org.neo4j.ogm.context.GraphEntityMapper.mapRelationships(GraphEntityMapper.java:330)
at org.neo4j.ogm.context.GraphEntityMapper.mapContentOf(GraphEntityMapper.java:158)
at org.neo4j.ogm.context.GraphEntityMapper.lambda$map$2(GraphEntityMapper.java:115)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.neo4j.ogm.context.GraphEntityMapper.map(GraphEntityMapper.java:117)
at org.neo4j.ogm.context.GraphRowModelMapper.map(GraphRowModelMapper.java:60)
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.lambda$executeAndMap$1(ExecuteQueriesDelegate.java:165)
at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:590)
at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:564)
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.executeAndMap(ExecuteQueriesDelegate.java:150)
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:117)
at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:425)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.lambda$invoke$1(SharedSessionCreator.java:121)
at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.invokeInTransaction(SharedSessionCreator.java:159)
at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.invoke(SharedSessionCreator.java:123)
at com.sun.proxy.$Proxy88.query(Unknown Source)
at org.springframework.data.neo4j.repository.query.GraphQueryExecution$SingleEntityExecution.execute(GraphQueryExecution.java:64)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.doExecute(GraphRepositoryQuery.java:76)
at org.springframework.data.neo4j.repository.query.AbstractGraphRepositoryQuery.execute(AbstractGraphRepositoryQuery.java:57)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy111.findByResource(Unknown Source)
I tried changing the attribute percentage to Number, that does not throw the exception but percentage doesn't get saved.
I do not want to upgrade spring-boot-starter-data-neo4j to any major version at this point.
Upgrading to Spring-Data-Neo4j 6.x will again be big migration effort.
I am stuck now.
I found out the exact place where the error was coming from was neo4j.ogm.core files, I tried various versions of the jar but nothing worked.
Finally I resolved the problem by writing a custom converter as the implicit converter was not able to convert between Double and BigDecimal.
public class PercentageConverter implements AttributeConverter<Double, BigDecimal> {
#Override
public BigDecimal toGraphProperty(Double value) {
if (value == null) {
return null;
}
return new BigDecimal(value);
}
#Override
public Double toEntityAttribute(BigDecimal value) {
return value.doubleValue();
}
}
and annotate the entity attribute to use this converter
#Convert(PercentageConverter.class)
This resolved my error and now I can do all CRUD operations successfully

Received message larger than max on a batch processing pipeline

I have been getting this message on a batch processing pipeline that has been running daily on google's cloud dataflow service. It has started failing with the following message:
(88b342a0e3852af3): java.io.IOException: INVALID_ARGUMENT: Received message larger than max (21824326 vs. 4194304)
dataflow-batch-jetty-11171129-7ea5-harness-waia talking to localhost:12346 at
com.google.cloud.dataflow.sdk.runners.worker.ApplianceShuffleWriter.close(Native Method) at
com.google.cloud.dataflow.sdk.runners.worker.ChunkingShuffleEntryWriter.close(ChunkingShuffleEntryWriter.java:67) at
com.google.cloud.dataflow.sdk.runners.worker.ShuffleSink$ShuffleSinkWriter.close(ShuffleSink.java:286) at
com.google.cloud.dataflow.sdk.util.common.worker.WriteOperation.finish(WriteOperation.java:100) at
com.google.cloud.dataflow.sdk.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:77) at
com.google.cloud.dataflow.sdk.runners.worker.DataflowWorker.executeWork(DataflowWorker.java:264) at
com.google.cloud.dataflow.sdk.runners.worker.DataflowWorker.doWork(DataflowWorker.java:197) at
com.google.cloud.dataflow.sdk.runners.worker.DataflowWorker.getAndPerformWork(DataflowWorker.java:149) at
com.google.cloud.dataflow.sdk.runners.worker.DataflowWorkerHarness$WorkerThread.doWork(DataflowWorkerHarness.java:192) at
com.google.cloud.dataflow.sdk.runners.worker.DataflowWorkerHarness$WorkerThread.call(DataflowWorkerHarness.java:173) at
com.google.cloud.dataflow.sdk.runners.worker.DataflowWorkerHarness$WorkerThread.call(DataflowWorkerHarness.java:160) at
java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at
java.lang.Thread.run(Thread.java:745)
I am still using an old workaround to output a CSV file with headers such as
PCollection<String> output = data.apply(ParDo.of(new DoFn<String, String>() {
String new_line = System.getProperty("line.separator");
String csv_header = "id, stuff_1, stuff_2" + new_line;
StringBuilder csv_body = new StringBuilder().append(csv_header);
#Override
public void processElement(ProcessContext c) {
csv_body.append(c.element()).append(newline);
}
#Override
public void finishBundle(Context c) throws Exception {
c.output(csv_body.toString());
}
})).apply(TextIO.Write.named("WriteData").to(options.getOutput()));
What is causing this? Is the output of this DoFn too big now? The size of the dataset being processed has not increased.
This looks like it might be a bug on our side and we're looking into it, but in general the code is probably not doing what you intend it to do.
As written, you'll end up with an unspecified number of output files, whose names start with the given prefix, each file containing a concatenation of your expected CSV-like output (including headers) for different chunks of the data, in an unspecified order.
In order to properly implement writing to CSV files, simply use TextIO.Write.withHeader() to specify the header, and remove your CSV-constructing ParDo entirely. This will also not trigger the bug.

Neo4j with spatial: NotFoundException: More than one relationship

What is the cause and how to fix this exception:
org.neo4j.graphdb.NotFoundException: More than one relationship[RTREE_CHILD, INCOMING] found for NodeImpl#105
at org.neo4j.kernel.impl.core.NodeImpl.getSingleRelationship(NodeImpl.java:344)
at org.neo4j.kernel.impl.core.NodeProxy.getSingleRelationship(NodeProxy.java:191)
at org.neo4j.collections.rtree.RTreeIndex.getIndexNodeParent(RTreeIndex.java:768)
at org.neo4j.collections.rtree.RTreeIndex.adjustPathBoundingBox(RTreeIndex.java:672)
at org.neo4j.collections.rtree.RTreeIndex.add(RTreeIndex.java:90)
at org.neo4j.gis.spatial.EditableLayerImpl.add(EditableLayerImpl.java:44)
at org.neo4j.gis.spatial.ShapefileImporter.importFile(ShapefileImporter.java:209)
at org.neo4j.gis.spatial.ShapefileImporter.importFile(ShapefileImporter.java:122)
I am using 2.0.0 and spatial jars coming from compiled github project.
The exception is thrown when I try to import Shapefile (this is code in unmanaged extension):
GraphDatabaseService spatialDb = new GraphDatabaseFactory().newEmbeddedDatabase("/home/db/data/spatial.db");
Transaction tx = spatialDb.beginTx();
try {
ShapefileImporter importer = new ShapefileImporter(spatialDb, new NullListener());
importer.importFile("/home/bla/realshp/users_location.shp", "users_location");
tx.success();
} catch (Exception e) {
e.printStackTrace();
} finally {
tx.close();
return Response.status(200).entity("Done. ").build();
}
The shape file is generated from CSV file with ogr2ogr - it seems legit and is read without exceptions. In the original file there was around 30000 points defined as follows (ogr2ogr will pull longitude and latitude):
id,longitude,latitude,gender,updated
3,-122.1171925,37.4343361,1,2013-11-20 05:03:22
304,-122.0919000,37.3094000,1,2013-11-03 00:42:01
311,-122.0919000,37.3094000,1,2013-11-03 00:42:01
How to get around it? I need to load milions of points to the db.
Side question: now I create new graph-spatial datastore - is it correct? Maybe I should load it to existing graph db?
UPDATE:
I tried to input coordinates "manually" using methods from TestSimplePointLayer. I got the same exception around 450th coordinate. Bunch of them are the same as you can see in the sample, but they are valid points. How to get around it?
You are skipping a step here. You create a spatial index and then you add the users to the index.
So for example if you had a shape file of all the states or counties or zip codes in the US, you can create a spatial layer with those shapes and add the users to them.
You can use a simple point layer as well if you want, but they have to be unique, but the user nodes that reside in those locations don't have to be. See http://java.dzone.com/articles/running-along-graph-using-0 and http://www.markhneedham.com/blog/2013/03/10/neo4jcypher-finding-football-stadiums-near-a-city-using-spatial/ for a better idea.
I meet the same error when I try to add node with same lon/lat (0,0) to the layer.
When more than 100 RTREE_CHILD ref node inserted, this exception appears. It's a bug of the source code.
src/main/java/org/neo4j/gis/spatial/rtree/RTreeIndex.java
try this forked plugin:
https://github.com/linkedin-inc/spatial

IllegalArgument exception in custom setter after upgrading to JSF2

After upgrading to JSF2 (probably) one special accessor in an .xhtml file generates IllegalArgumentExceptions but I can't really find out why. Running the app on my local JBoss (4.2.2) does not generate this exception but this can be related to a difference between debug and live data.
Following stack trace is generated that I could extract from the production server log:
Caused by: javax.el.ELException: /xy/xy-subtemplate1.xhtml #131,45 value="#{someClass.someProperty}": java.lang.IllegalArgumentException
at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:101)
at javax.faces.component.UIInput.updateModel(UIInput.java:818)
... 36 more
Caused by: java.lang.IllegalArgumentException
at sun.reflect.GeneratedMethodAccessor1134.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
at com.sun.faces.el.DemuxCompositeELResolver._setValue(DemuxCompositeELResolver.java:255)
at com.sun.faces.el.DemuxCompositeELResolver.setValue(DemuxCompositeELResolver.java:281)
at org.apache.el.parser.AstValue.setValue(AstValue.java:114)
at org.apache.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
... 37 more
someClass is being iterated over in a list and has the following methods to access someProperty:
public int getSomeProperty() {
return this.getSomeRelatedEnum().ordinal();
}
public void setSomeProperty( final int index) {
this.setSomeRelatedEnum( SomeRelatedEnum.fromOrdinal( index) );
}
How can this lead to the IllegalArgumentException mentioned above?
That can happen when the setter method after all expects a different argument type than the one which is provided from EL on.
I guess that it's related to the fact that hardcoded/unconverted numbers in EL are by default treated as long and not as int. Try either changing the int to be long, or providing an explicit integer converter on the input component like so <h:someInput converter="javax.faces.Integer">.
By the way, why don't you just get/set the enum itself directly? Getting/setting the enum by its ordinal is whacky.

JSON converter - stack overflow

I'm trying to convert a domain class into JSON.
def converter = null
try{
converter = events as JSON
} catch(e) {
log.error "error during conversion to JSON"
log.error e
}
return converter.toString()
I always get this error:
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [findEvents] of controller
[com.geoadapta.geodata.DataAccessJsonController] caused exception:
java.lang.StackOverflowError
at java.lang.Thread.run(Thread.java:619)
Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.StackOverflowError
... 1 more
Caused by: java.lang.StackOverflowError
at org.codehaus.groovy.util.AbstractConcurrentMap.getOrPut(AbstractConcurrentMap.java:20)
at grails.converters.JSON.value(JSON.java:188)
at grails.converters.JSON.convertAnother(JSON.java:160)
at grails.converters.JSON.value(JSON.java:192)
// hundreds of times
at grails.converters.JSON.value(JSON.java:192)
at grails.converters.JSON.convertAnother(JSON.java:160)
at grails.converters.JSON.value(JSON.java:192)
at grails.converters.JSON.convertAnother(JSON.java:160)
at grails.converters.JSON.value(JSON.java:192)
at grails.converters.JSON.convertAnother(JSON.java:160)
at grails.converters.JSON.value(JSON.java:192)
at grails.converters.JSON.convertAnother(JSON.java:160)
at grails.converters.JSON.value(JSON.java:192)
at grails.converters.JSON.convertAnother(JSON.java:160)
at grails.converters.JSON.value(JSON.java:192)
2010-06-23 16:21:28,390 [http-8080-1] DEBUG [/GeoAdaptaApp].[grails] - Disabling the response for futher output
This is the domain class: http://www.copypastecode.com/31527
The only problem I can see is the 'context' reference. But even if I set to 'null', I still get the stack overflow.
My converter is not propagating circular references.
I'd like to debug it and find out which property is causing the problem, but no luck so far.
Any hints?
Cheers
Sorry, would prefer to add this as a comment, but do not have the rep to add comments yet.
In your domain class it sounds like there are several classes that extend off this one, how are you populating the 'events' object? Since you say the context is set to null and that is the only relationship that's defined directly, a list of unintended subclasses in your results is one way that springs to mind for how you could get into such a deep recursion scenario.
To work around the immediate problem so you can do some debugging, have you tried calling:
converter.setRenderDomainClassRelations(false)

Resources