anthonymartin / geolocation Goto Github PK
View Code? Open in Web Editor NEWRetrieve bounding coordinates and distances with GeoLocation.php
Retrieve bounding coordinates and distances with GeoLocation.php
I've noticed that the longitude bounds for a given point don't appear to contain the origin longitude for a large enough distance. This test below works for the 1 kilometer example but breaks for the 1000 kilometer example.
It appears to break around the 472 kilometers mark, I'm not sure if that is a significant number or not.
<?php
namespace Tests\Unit;
use AnthonyMartin\GeoLocation\GeoPoint;
use PHPUnit\Framework\TestCase;
class BoundingBoxTest extends TestCase
{
public function test_bounding_box_includes_origin()
{
$geoPoint = new GeoPoint(-36.9158, 174.6922);
$smallBoundingBox = $geoPoint->boundingBox(1, 'kilometers');
$this->assertTrue($geoPoint->getLatitude() >= $smallBoundingBox->getMinLatitude());
$this->assertTrue($geoPoint->getLatitude() <= $smallBoundingBox->getMaxLatitude());
$this->assertTrue($geoPoint->getLongitude() >= $smallBoundingBox->getMinLongitude());
$this->assertTrue($geoPoint->getLongitude() <= $smallBoundingBox->getMaxLongitude());
$largeBoundingBox = $geoPoint->boundingBox(1000, 'kilometers');
$this->assertTrue($geoPoint->getLatitude() >= $largeBoundingBox->getMinLatitude());
$this->assertTrue($geoPoint->getLatitude() <= $largeBoundingBox->getMaxLatitude());
$this->assertTrue($geoPoint->getLongitude() >= $largeBoundingBox->getMinLongitude());
$this->assertTrue($geoPoint->getLongitude() <= $largeBoundingBox->getMaxLongitude());
}
}
Hello,
I am trying to create boundingCoordinates from 48.1502228 17.0621223 with distance for example 10km.
Result are next coordinates
48.0602907806 16.9273279672
48.2401548194 17.1969166328
From both points distance is more than 10km (more than 13km).
What causes such a deviation?
Thanks
Hey Anthony,
looking at the source I'm stumbling across the classes GeoLocation and GeoPoint. What's the difference? They seem redundant - am I missing something? Feel free to just update the source documentation and/or readme instead of explaining it here.
Thank you for your efforts :)
Hi,
Can you tag it pls?
We want to add this as a dependency to the one of our projects
Many Thanks
Hi,
this must be a very idiotic question to you but I'm a noob.
What is the code for the composer.json. I mean the "require" code. I tried many things but doesnt seem to work for me.
Thank you.
The thing is i want to generate a fence on a specific location and want to match
if ( inputLocation -> isWithinTheFence) is true/false
use AnthonyMartin\GeoLocation\GeoLocation as GeoLocation;
$location = 'New York City';
$response = GeoLocation::getGeocodeFromGoogle($location);
$latitude = $response->results[0]->geometry->location->lat; <--- lat not lng!!!!!
$longitude = $response->results[0]->geometry->location->lng;
echo $latitude . ', ' . $longitude;
#40.7143528, -74.0059731
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.