You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In working on a new user manual section on MongoDB and MsPASS, I ran across a couple issues.
First, we have a mistake in Database.save_inventory. We save the geographical location in site and channel to the attribute "coords" in the "legacy" georefence format for MongoDB. There is a mistake as we have the coordinates reversed. The pair should be lon,lat and we have lat,lon.
In working through this when we fix 1 I think we should change the code to write geoJSON that MongoDB seems to much prefer for at least the past 5 years. Since I seriously doubt we have any users using that feature at this point that should have no impact.
The other side of this is I am having an extremely difficult time getting geographic queries to work. There are some very subtle issues in usage that are not particularly well documented. One I know for sure is that it is very very fussy about indexing. You can't do any geographic query without building an index, AND there are two different versions (2d and 2dsphere) that seem to be incompatible. For MsPASS the only rational choice is 2dsphere, by the way, but that is another reason to ditch legacy coordinates. As I read the documentation you cannot use 2dsphere with legacy coordinate data. The horrible experience I'm having getting any geographic query to work convinces me we really need to put something on our development agenda. That is, I think it will be helpful to write a few simple wrapper functions to make the queries easier. One's I would recommend are:
def select_by_distance(collection,center=[0.0,0.0],radius=1.0,lockey='location'):
"""
Return a cursor selecting documents in collection with geoJSON points linked to lockey using a
circular great circle distance (degrees) radius with center specified as a lon,lat pair.
"""
def select_in_polygon(collection,polydata,lockey='location'):
"""
Does a search within a convex polygon specified by polydata assuming data associated with key
lockey are geoJSON points,
"""
We could do a rectangular lat-lon box function too, but that is pretty trivial. Maybe needed for consistency but it wouldn't wouldn't need the geoJSON points.
The text was updated successfully, but these errors were encountered:
In working on a new user manual section on MongoDB and MsPASS, I ran across a couple issues.
Database.save_inventory
. We save the geographical location in site and channel to the attribute "coords" in the "legacy" georefence format for MongoDB. There is a mistake as we have the coordinates reversed. The pair should be lon,lat and we have lat,lon.The other side of this is I am having an extremely difficult time getting geographic queries to work. There are some very subtle issues in usage that are not particularly well documented. One I know for sure is that it is very very fussy about indexing. You can't do any geographic query without building an index, AND there are two different versions (2d and 2dsphere) that seem to be incompatible. For MsPASS the only rational choice is 2dsphere, by the way, but that is another reason to ditch legacy coordinates. As I read the documentation you cannot use 2dsphere with legacy coordinate data. The horrible experience I'm having getting any geographic query to work convinces me we really need to put something on our development agenda. That is, I think it will be helpful to write a few simple wrapper functions to make the queries easier. One's I would recommend are:
We could do a rectangular lat-lon box function too, but that is pretty trivial. Maybe needed for consistency but it wouldn't wouldn't need the geoJSON points.
The text was updated successfully, but these errors were encountered: