neo4j adding spatial wgs84 point to node to calculate distance
i'm trying to add a lon lat point to a node. i was unable to find any doc regarding which java class should be used.
Here is what i have:
@NodeEntity
public class Coordination {
@Id
@GeneratedValue
private Long id;
@Index
private Value point;
private Double lon;
private Double lat;
@Relationship(type = "GEO_LOCATION", direction = Relationship.INCOMING)
private List<GeoLocation> geoLocations;
public Coordination(Double lon, Double lat) {
Value point = new PointValue(new InternalPoint2D(4326, lon, lat));
this.lon = lon;
this.lat = lat;
}
}
Value class is not working for me. what do i miss?
java neo4j spring-data-neo4j neo4j-spatial
add a comment |
i'm trying to add a lon lat point to a node. i was unable to find any doc regarding which java class should be used.
Here is what i have:
@NodeEntity
public class Coordination {
@Id
@GeneratedValue
private Long id;
@Index
private Value point;
private Double lon;
private Double lat;
@Relationship(type = "GEO_LOCATION", direction = Relationship.INCOMING)
private List<GeoLocation> geoLocations;
public Coordination(Double lon, Double lat) {
Value point = new PointValue(new InternalPoint2D(4326, lon, lat));
this.lon = lon;
this.lat = lat;
}
}
Value class is not working for me. what do i miss?
java neo4j spring-data-neo4j neo4j-spatial
add a comment |
i'm trying to add a lon lat point to a node. i was unable to find any doc regarding which java class should be used.
Here is what i have:
@NodeEntity
public class Coordination {
@Id
@GeneratedValue
private Long id;
@Index
private Value point;
private Double lon;
private Double lat;
@Relationship(type = "GEO_LOCATION", direction = Relationship.INCOMING)
private List<GeoLocation> geoLocations;
public Coordination(Double lon, Double lat) {
Value point = new PointValue(new InternalPoint2D(4326, lon, lat));
this.lon = lon;
this.lat = lat;
}
}
Value class is not working for me. what do i miss?
java neo4j spring-data-neo4j neo4j-spatial
i'm trying to add a lon lat point to a node. i was unable to find any doc regarding which java class should be used.
Here is what i have:
@NodeEntity
public class Coordination {
@Id
@GeneratedValue
private Long id;
@Index
private Value point;
private Double lon;
private Double lat;
@Relationship(type = "GEO_LOCATION", direction = Relationship.INCOMING)
private List<GeoLocation> geoLocations;
public Coordination(Double lon, Double lat) {
Value point = new PointValue(new InternalPoint2D(4326, lon, lat));
this.lon = lon;
this.lat = lat;
}
}
Value class is not working for me. what do i miss?
java neo4j spring-data-neo4j neo4j-spatial
java neo4j spring-data-neo4j neo4j-spatial
asked Nov 21 '18 at 10:08
USer22999299USer22999299
1,65932455
1,65932455
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Using a CompositeAttributeConverter
it is possible to define your own class to store lat and lon coordinates. However, you can also use the built-in Point
and corresponding Distance
classes defined in Spring Data Commons.
Here's an example from the test cases in Spring Data Neo4j:
public class Restaurant implements Comparable<Restaurant> {
@Id @GeneratedValue private Long id;
private String name;
@Convert(PointConverter.class) private Point location; //Encapsulates lat/lon
private int zip;
private double score;
private String description;
private boolean halal;
You can then define methods such as:
import org.springframework.data.geo.Point;
import org.springframework.data.neo4j.conversion.PointConverter;
public interface RestaurantRepository extends Neo4jRepository<Restaurant, Long> {
List<Restaurant> findByNameAndLocationNear(String name, Distance distance, Point point);
List<Restaurant> findByLocationNearAndName(Distance distance, Point point, String name);
}
The finder method will generate CYPHER that passes the following arguments to a distance
function:
- The lat and lon properties defined on your node
- The at and lon arguments passed in as an argument to the finder method.
Is this what you were looking for? If yes great! If not, could you please clarify your question.
could you share the import statements of Point? for both classes?
– USer22999299
Nov 21 '18 at 16:14
Coordination findByPoint(@Param("point") Point point); causing the following error : org.neo4j.ogm.exception.core.MappingException: Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 16:24
had no problem to save the objects, but when using findByPoint(Poinit point) i'm getting Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 17:59
I have included the imports. For an example of findBy (read) please clone spring-data-neo4j repository on the master branch and runRestaurantTests
. The version of neo4j-ogm used there appears to be 3.1.4 (latest). . . incidentally, could you also share the versions of spring-data-neo4j, spring-data-commons and neo4j-ogm that you are using?
– Jasper Blues
Nov 21 '18 at 22:06
Thank you!! that absolutely helped! So seems like that the only way to search is by distance, which is working now. the only problem now is that its impossible to search by Point Only, any idea on how it should be handle? or it maybe impossible? this is what im getting when only querying by Point (without distance) Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 22 '18 at 14:27
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409642%2fneo4j-adding-spatial-wgs84-point-to-node-to-calculate-distance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using a CompositeAttributeConverter
it is possible to define your own class to store lat and lon coordinates. However, you can also use the built-in Point
and corresponding Distance
classes defined in Spring Data Commons.
Here's an example from the test cases in Spring Data Neo4j:
public class Restaurant implements Comparable<Restaurant> {
@Id @GeneratedValue private Long id;
private String name;
@Convert(PointConverter.class) private Point location; //Encapsulates lat/lon
private int zip;
private double score;
private String description;
private boolean halal;
You can then define methods such as:
import org.springframework.data.geo.Point;
import org.springframework.data.neo4j.conversion.PointConverter;
public interface RestaurantRepository extends Neo4jRepository<Restaurant, Long> {
List<Restaurant> findByNameAndLocationNear(String name, Distance distance, Point point);
List<Restaurant> findByLocationNearAndName(Distance distance, Point point, String name);
}
The finder method will generate CYPHER that passes the following arguments to a distance
function:
- The lat and lon properties defined on your node
- The at and lon arguments passed in as an argument to the finder method.
Is this what you were looking for? If yes great! If not, could you please clarify your question.
could you share the import statements of Point? for both classes?
– USer22999299
Nov 21 '18 at 16:14
Coordination findByPoint(@Param("point") Point point); causing the following error : org.neo4j.ogm.exception.core.MappingException: Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 16:24
had no problem to save the objects, but when using findByPoint(Poinit point) i'm getting Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 17:59
I have included the imports. For an example of findBy (read) please clone spring-data-neo4j repository on the master branch and runRestaurantTests
. The version of neo4j-ogm used there appears to be 3.1.4 (latest). . . incidentally, could you also share the versions of spring-data-neo4j, spring-data-commons and neo4j-ogm that you are using?
– Jasper Blues
Nov 21 '18 at 22:06
Thank you!! that absolutely helped! So seems like that the only way to search is by distance, which is working now. the only problem now is that its impossible to search by Point Only, any idea on how it should be handle? or it maybe impossible? this is what im getting when only querying by Point (without distance) Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 22 '18 at 14:27
|
show 3 more comments
Using a CompositeAttributeConverter
it is possible to define your own class to store lat and lon coordinates. However, you can also use the built-in Point
and corresponding Distance
classes defined in Spring Data Commons.
Here's an example from the test cases in Spring Data Neo4j:
public class Restaurant implements Comparable<Restaurant> {
@Id @GeneratedValue private Long id;
private String name;
@Convert(PointConverter.class) private Point location; //Encapsulates lat/lon
private int zip;
private double score;
private String description;
private boolean halal;
You can then define methods such as:
import org.springframework.data.geo.Point;
import org.springframework.data.neo4j.conversion.PointConverter;
public interface RestaurantRepository extends Neo4jRepository<Restaurant, Long> {
List<Restaurant> findByNameAndLocationNear(String name, Distance distance, Point point);
List<Restaurant> findByLocationNearAndName(Distance distance, Point point, String name);
}
The finder method will generate CYPHER that passes the following arguments to a distance
function:
- The lat and lon properties defined on your node
- The at and lon arguments passed in as an argument to the finder method.
Is this what you were looking for? If yes great! If not, could you please clarify your question.
could you share the import statements of Point? for both classes?
– USer22999299
Nov 21 '18 at 16:14
Coordination findByPoint(@Param("point") Point point); causing the following error : org.neo4j.ogm.exception.core.MappingException: Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 16:24
had no problem to save the objects, but when using findByPoint(Poinit point) i'm getting Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 17:59
I have included the imports. For an example of findBy (read) please clone spring-data-neo4j repository on the master branch and runRestaurantTests
. The version of neo4j-ogm used there appears to be 3.1.4 (latest). . . incidentally, could you also share the versions of spring-data-neo4j, spring-data-commons and neo4j-ogm that you are using?
– Jasper Blues
Nov 21 '18 at 22:06
Thank you!! that absolutely helped! So seems like that the only way to search is by distance, which is working now. the only problem now is that its impossible to search by Point Only, any idea on how it should be handle? or it maybe impossible? this is what im getting when only querying by Point (without distance) Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 22 '18 at 14:27
|
show 3 more comments
Using a CompositeAttributeConverter
it is possible to define your own class to store lat and lon coordinates. However, you can also use the built-in Point
and corresponding Distance
classes defined in Spring Data Commons.
Here's an example from the test cases in Spring Data Neo4j:
public class Restaurant implements Comparable<Restaurant> {
@Id @GeneratedValue private Long id;
private String name;
@Convert(PointConverter.class) private Point location; //Encapsulates lat/lon
private int zip;
private double score;
private String description;
private boolean halal;
You can then define methods such as:
import org.springframework.data.geo.Point;
import org.springframework.data.neo4j.conversion.PointConverter;
public interface RestaurantRepository extends Neo4jRepository<Restaurant, Long> {
List<Restaurant> findByNameAndLocationNear(String name, Distance distance, Point point);
List<Restaurant> findByLocationNearAndName(Distance distance, Point point, String name);
}
The finder method will generate CYPHER that passes the following arguments to a distance
function:
- The lat and lon properties defined on your node
- The at and lon arguments passed in as an argument to the finder method.
Is this what you were looking for? If yes great! If not, could you please clarify your question.
Using a CompositeAttributeConverter
it is possible to define your own class to store lat and lon coordinates. However, you can also use the built-in Point
and corresponding Distance
classes defined in Spring Data Commons.
Here's an example from the test cases in Spring Data Neo4j:
public class Restaurant implements Comparable<Restaurant> {
@Id @GeneratedValue private Long id;
private String name;
@Convert(PointConverter.class) private Point location; //Encapsulates lat/lon
private int zip;
private double score;
private String description;
private boolean halal;
You can then define methods such as:
import org.springframework.data.geo.Point;
import org.springframework.data.neo4j.conversion.PointConverter;
public interface RestaurantRepository extends Neo4jRepository<Restaurant, Long> {
List<Restaurant> findByNameAndLocationNear(String name, Distance distance, Point point);
List<Restaurant> findByLocationNearAndName(Distance distance, Point point, String name);
}
The finder method will generate CYPHER that passes the following arguments to a distance
function:
- The lat and lon properties defined on your node
- The at and lon arguments passed in as an argument to the finder method.
Is this what you were looking for? If yes great! If not, could you please clarify your question.
edited Nov 21 '18 at 21:55
answered Nov 21 '18 at 12:03
Jasper BluesJasper Blues
18.5k1382152
18.5k1382152
could you share the import statements of Point? for both classes?
– USer22999299
Nov 21 '18 at 16:14
Coordination findByPoint(@Param("point") Point point); causing the following error : org.neo4j.ogm.exception.core.MappingException: Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 16:24
had no problem to save the objects, but when using findByPoint(Poinit point) i'm getting Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 17:59
I have included the imports. For an example of findBy (read) please clone spring-data-neo4j repository on the master branch and runRestaurantTests
. The version of neo4j-ogm used there appears to be 3.1.4 (latest). . . incidentally, could you also share the versions of spring-data-neo4j, spring-data-commons and neo4j-ogm that you are using?
– Jasper Blues
Nov 21 '18 at 22:06
Thank you!! that absolutely helped! So seems like that the only way to search is by distance, which is working now. the only problem now is that its impossible to search by Point Only, any idea on how it should be handle? or it maybe impossible? this is what im getting when only querying by Point (without distance) Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 22 '18 at 14:27
|
show 3 more comments
could you share the import statements of Point? for both classes?
– USer22999299
Nov 21 '18 at 16:14
Coordination findByPoint(@Param("point") Point point); causing the following error : org.neo4j.ogm.exception.core.MappingException: Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 16:24
had no problem to save the objects, but when using findByPoint(Poinit point) i'm getting Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 17:59
I have included the imports. For an example of findBy (read) please clone spring-data-neo4j repository on the master branch and runRestaurantTests
. The version of neo4j-ogm used there appears to be 3.1.4 (latest). . . incidentally, could you also share the versions of spring-data-neo4j, spring-data-commons and neo4j-ogm that you are using?
– Jasper Blues
Nov 21 '18 at 22:06
Thank you!! that absolutely helped! So seems like that the only way to search is by distance, which is working now. the only problem now is that its impossible to search by Point Only, any idea on how it should be handle? or it maybe impossible? this is what im getting when only querying by Point (without distance) Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 22 '18 at 14:27
could you share the import statements of Point? for both classes?
– USer22999299
Nov 21 '18 at 16:14
could you share the import statements of Point? for both classes?
– USer22999299
Nov 21 '18 at 16:14
Coordination findByPoint(@Param("point") Point point); causing the following error : org.neo4j.ogm.exception.core.MappingException: Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 16:24
Coordination findByPoint(@Param("point") Point point); causing the following error : org.neo4j.ogm.exception.core.MappingException: Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 16:24
had no problem to save the objects, but when using findByPoint(Poinit point) i'm getting Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 17:59
had no problem to save the objects, but when using findByPoint(Poinit point) i'm getting Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 21 '18 at 17:59
I have included the imports. For an example of findBy (read) please clone spring-data-neo4j repository on the master branch and run
RestaurantTests
. The version of neo4j-ogm used there appears to be 3.1.4 (latest). . . incidentally, could you also share the versions of spring-data-neo4j, spring-data-commons and neo4j-ogm that you are using?– Jasper Blues
Nov 21 '18 at 22:06
I have included the imports. For an example of findBy (read) please clone spring-data-neo4j repository on the master branch and run
RestaurantTests
. The version of neo4j-ogm used there appears to be 3.1.4 (latest). . . incidentally, could you also share the versions of spring-data-neo4j, spring-data-commons and neo4j-ogm that you are using?– Jasper Blues
Nov 21 '18 at 22:06
Thank you!! that absolutely helped! So seems like that the only way to search is by distance, which is working now. the only problem now is that its impossible to search by Point Only, any idea on how it should be handle? or it maybe impossible? this is what im getting when only querying by Point (without distance) Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 22 '18 at 14:27
Thank you!! that absolutely helped! So seems like that the only way to search is by distance, which is working now. the only problem now is that its impossible to search by Point Only, any idea on how it should be handle? or it maybe impossible? this is what im getting when only querying by Point (without distance) Properties with a CompositeAttributeConverter are not supported by Filters in this version of OGM. Consider implementing a custom FilterFunction.
– USer22999299
Nov 22 '18 at 14:27
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409642%2fneo4j-adding-spatial-wgs84-point-to-node-to-calculate-distance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown