Menghitung Geolocation Mongo
Untuk mongo db kita menggunakan geo location
bisa pake url ini untuk generate data
https://geojson.io/
1. bikin dokumen dengan nama place lalu insert
formatnya <nama field>: { type: "Point", coordinates: [ long,lat ] },
db.places.insert( {
name: "Central Park",
location: { type: "Point", coordinates: [ -73.97, 40.77 ] },
category: "Parks"
} );
db.places.insert( {
name: "Sara D. Roosevelt Park",
location: { type: "Point", coordinates: [ -73.9928, 40.7193 ] },
category: "Parks"
} );
db.places.insert( {
name: "Polo Grounds",
location: { type: "Point", coordinates: [ -73.9375, 40.8303 ] },
category: "Stadiums"
} );
2. running
db.places.createIndex( { location: "2dsphere" } )
3. contoh pencarian
db.places.find(
{
location:
{ $near:
{
$geometry: { type: "Point", coordinates: [ -73.9667, 40.78 ] },
$minDistance: 1000,
$maxDistance: 5000
}
}
}
)
Sumber : https://docs.mongodb.com/manual/geospatial-queries/#geospatial-data
https://laracasts.com/discuss/channels/forge/php-71-update-broken-memcached
BalasHapus$name = 'def-up.jpg';
BalasHapus$filePath = public_path('/img/'.$name);
$pathImage = 'ticed/images/';
$filePathGCS = $pathImage . $name;
Storage::disk('gcs')->put($filePathGCS, file_get_contents($filePath));
$url = env('GOOGLE_CLOUD_STORAGE_URL').$filePathGCS;
return response()->json([
'message' => 'Gambar berhasil diupload',
'file_name' => $name,
'filePath' =>$url,
]);