-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Storing Geodata #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There is no specific support for geodata in this library, but you can still use the original MongoDb methods to do special stuff. |
You just have to save your data in the GeoJSON format (specification here : http://geojson.org/geojson-spec.html). For a simple point, it is just something like that : $event->location = ['type' => 'Point', 'coordinates' => [100.0, 0.0];
$event->save(); If you want to perform geospatial requests you have to create the index in a migration : Schema::collection('events', function ($table) {
$table->index(['location' => '2dsphere']);
}); And then you can do : $query->where('location', 'near', [
'$geometry' => ['type' => 'Point', 'coordinates' => [101.54, 0.43],
'$maxDistance' => 200,
]); |
Thanks a bunch guys. Working great. |
It takes time to find this information. I think it should be in the documentation ;) Thanks for the info 👍 |
But in the migration wich type of data i need to set as column type? |
@anodal88 column type ? That doesn't exist in MongoDB ! |
Since mongodb#371 was raised back in 2014 I’ve wanted a way to improve and simplify adding geospatial indexes.
Since mongodb#371 was raised back in 2014 I’ve wanted a way to improve and simplify adding geospatial indexes.
Since mongodb#371 was raised back in 2014 I’ve wanted a way to improve and simplify adding geospatial indexes.
Since mongodb#371 was raised back in 2014 I’ve wanted a way to improve and simplify adding geospatial indexes.
Since mongodb#371 was raised back in 2014 I’ve wanted a way to improve and simplify adding geospatial indexes.
Tried hunting for this without much success so help me if you can.
I want to store Geodata specifically a geojson point. What's the best way to go about that?
The text was updated successfully, but these errors were encountered: