https://github.com/sobakasu/jpm_geo
Finds points within a distance of a latitude/longitude point using bounding coordinates
https://github.com/sobakasu/jpm_geo
bounding-boxes coordinates gem geospatial ruby
Last synced: 12 months ago
JSON representation
Finds points within a distance of a latitude/longitude point using bounding coordinates
- Host: GitHub
- URL: https://github.com/sobakasu/jpm_geo
- Owner: sobakasu
- License: mit
- Created: 2019-09-29T23:05:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-29T20:34:27.000Z (over 6 years ago)
- Last Synced: 2025-05-27T12:58:43.823Z (about 1 year ago)
- Topics: bounding-boxes, coordinates, gem, geospatial, ruby
- Language: Ruby
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# JpmGeo
Computes the bounding coordinates of all points on the surface of a sphere that have a great circle distance to the given point. This code was ported to ruby directly from http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates, and is owned by Jan Philip Matuschek.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'jpm_geo'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install jpm_geo
## Usage
### Configuration
```
# use miles as a distance unit (default is kilometers)
JpmGeo.units = 'm'
# specify default radius (default is Earth kilometers)
JpmGeo.radius = 3389.5 # Mars radius (km)
```
### Creating points
```
# lonlat is an object that responds to 'lon' and 'lat' methods
point = JpmGeo::Point.from_lonlat(lonlat)
# from degrees
point = JpmGeo::Point.from_degrees(lat: 51.50853, lon: -0.12574) # London
# from radians
point = JpmGeo::Point.from_radians(lat: 0.8990, lon: -0.0022) # London (ish)
# converting to/from radians/degrees
point = point.to_radians
point = point.to_degrees
```
### Finding distance between points
```
# distance is in the same units as radius
distance = point.distance_to(point2)
```
### Finding bounding coordinates
```
bounds = point.bounds(100) # km
p [bounds[0].lat, bounds[0].lon, bounds[1].lat, bounds[1].lon]
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/sobakasu/jpm_geo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the JpmGeo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sobakasu/jpm_geo/blob/master/CODE_OF_CONDUCT.md).