Introducing Conrex #3
stephaniewilkinson
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Conrex
The National Association of Independent Schools developed an Elixir implementation of the Paul Bourke's Conrec algorithm to calculate the drive-time to a particular location. The Conrex hex package is now available to developers here on GitHub.
Most map-based apps calculate the distance from a central point outward. That’s helpful if you want to see how long it will take you to fly somewhere else, but not so helpful if you want to calculate how long it will take customers to drive through traffic to get to your location.
Conrex uses a convergent isochrone to calculate real traffic and topographic conditions. An implementation of Paul Bourke's CONREC algorithm in Elixir, Conrex is now available to the open source community.
NAIS developed Conrex for its Market View app. Market View helps schools find children are within a reasonable driving distance of the school. It can also be used to map bus routes, commute times, or to determine a new location for a business.
Installation
Conrex can be installed by adding
conrex
to your list of dependencies inmix.exs
:Usage
The main algorithm outlined by Bourke can be invoked with
Conrex.conrec
:where
values
is a 2D list of samples (heights, travel times, etc),x_coords
and
y_coords
are lists of X and Y coordinates for the sample grid, andcontour_levels
is a list of values at which a contour should be calculated.Conrex.conrec
outputs a list of line segments to match the classic algorithm.If the X and Y values are GPS coordinates, you can use
Conrex.contour_polygons
to generate GeoJSON polygons for each contour level:
The additional parameter,
reference_point
, is a point known to be within thecontour polygon, but outside any polygon holes. When converting the line
segments to GeoJSON
%Geo.Polygon{}
s, Conrex will discard exterior polygonrings, and correct the coordinate winding for the main ring and the polygon
holes to conform to the GeoJSON spec.
Contributing
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.
Some of the tests will write output and sample data to a
contour.js
file,which can be used to visualize the test data and result. The visualization can
be seen by viewing
priv/static/index.html
in a web browser.License
MIT
Beta Was this translation helpful? Give feedback.
All reactions