Maps
And Drupal
Artem Sylchuk
One of the five
A map. What is it?
Mercator projection & Google Web Mercator
Some math and EPSG:3857
Ellipsoid:
x=a×λ
y=a×ln[tan(π/4+φ/2)×((1-e×sinφ)/(1+e×sinφ))^(e/2)]
Sphere:
x=a×λ
y=a×ln[tan(π/4+φ/2)]
λ — lon, rad; φ — lat, rad. a - semimajor axis of the ellipsoid. e - the value of the eccentricity of the ellipsoid (the ratio of the major and minor semi-axes).
http://imgs.xkcd.com/comics/map_projections.png
We need a canvas. Map tiles
x/y/z
Zoom levels are related to each other by powers of four:
Because of this exponential relationship the amount of detail increases at every zoom level, but so does the amount of bandwidth and storage required to serve up tiles.
For example, a map at z15, about when city building footprints first become visible, requires about 1.1 billion tiles to cover the entire world. At z17, just two zoom levels greater, the world requires 17 billion
http://maps.stamen.com/
Put a point. And one more. And more
Well Known
GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))�POINT ZM (1 1 5 60)�POINT M (1 1 80)�POINT EMPTY�MULTIPOLYGON EMPTY�CIRCULARSTRING(1 5, 6 2, 7 3)�COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))�CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))�MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))�TRIANGLE((0 0 0,0 1 0,1 1 0,0 0 0))�TIN (((0 0 0, 0 0 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 0 0 0)))�POLYHEDRALSURFACE Z (� ((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),� ((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)),� ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),� ((1 1 1, 1 0 1, 0 0 1, 0 1 1, 1 1 1)),� ((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)),� ((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1))� )
GeoJSON
{ "type": "FeatureCollection",� "features": [� { "type": "Feature",� "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},� "properties": {"prop0": "value0"}� },� { "type": "Feature",� "geometry": {� "type": "LineString",� "coordinates": [� [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]� ]� },� "properties": {� "prop0": "value0",� "prop1": 0.0� }� },� { "type": "Feature",� "geometry": {� "type": "Polygon",� "coordinates": [� [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],� [100.0, 1.0], [100.0, 0.0] ]� ]� },� "properties": {� "prop0": "value0",� "prop1": {"this": "that"}� }� }� ]� }
Stop. Show me something .
Google. Yandex. Bing.
OpenStreetMap. Data Providers .
OpenLayers, Leaflet
Mapbox .
How to ?
PostGIS
SELECT� neighborhoods.name AS neighborhood_name,� Sum(census.popn_total) AS population,� 100.0 * Sum(census.popn_white) / Sum(census.popn_total) AS white_pct,� 100.0 * Sum(census.popn_black) / Sum(census.popn_total) AS black_pct�FROM nyc_neighborhoods AS neighborhoods�JOIN nyc_census_blocks AS census�ON ST_Intersects(neighborhoods.geom, census.geom)�WHERE neighborhoods.boroname = 'Manhattan'�GROUP BY neighborhoods.name�ORDER BY white_pct DESC;
GeoPHP
Solr
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
spatialContextFactory="org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory"
autoIndex="true"
validationRule="repairBuffer0"
distErrPct="0.025"
maxDistErr="0.001"
distanceUnits="kilometers" />
&q=*:*&sfield=store&pt=45.15,-93.85&facet.query={!frange l=0 u=5}geodist()&facet.query={!frange l=5.001 u=3000}geodist()
This is the end.