Skip to content

Instantly share code, notes, and snippets.

@vool
Last active October 25, 2018 13:13
Show Gist options
  • Save vool/44d32694f21e5c2c036a6658e7fced5f to your computer and use it in GitHub Desktop.
Save vool/44d32694f21e5c2c036a6658e7fced5f to your computer and use it in GitHub Desktop.
border_osm_vs_osi
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"OBJECTID":1,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.366132499999993,55.03606399911458]}},{"type":"Feature","properties":{"OBJECTID":2,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.403868499999987,54.9773599991139]}},{"type":"Feature","properties":{"OBJECTID":3,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.403164500000003,54.95961749911371]}},{"type":"Feature","properties":{"OBJECTID":4,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.478284000000003,54.83059699911226]}},{"type":"Feature","properties":{"OBJECTID":5,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.544506000000012,54.79232799911183]}},{"type":"Feature","properties":{"OBJECTID":6,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.6084835000000055,54.74271799911128]}},{"type":"Feature","properties":{"OBJECTID":7,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.828498999999993,54.54898449910916]}},{"type":"Feature","properties":{"OBJECTID":8,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.869352499999989,54.533897499109]}},{"type":"Feature","properties":{"OBJECTID":9,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-8.093378,54.478839999108395]}},{"type":"Feature","properties":{"OBJECTID":10,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-8.097008499999987,54.477119499108376]}},{"type":"Feature","properties":{"OBJECTID":11,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-8.09454550000001,54.4767304991084]}},{"type":"Feature","properties":{"OBJECTID":12,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-8.095764000000003,54.40524299910764]}},{"type":"Feature","properties":{"OBJECTID":13,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.976008500000006,54.402774999107585]}},{"type":"Feature","properties":{"OBJECTID":14,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.1072269999999955,54.36851949910723]}},{"type":"Feature","properties":{"OBJECTID":15,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.873554000000014,54.337669499106916]}},{"type":"Feature","properties":{"OBJECTID":16,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.873334000000001,54.29373949910643]}},{"type":"Feature","properties":{"OBJECTID":17,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.864596500000005,54.27499749910626]}},{"type":"Feature","properties":{"OBJECTID":18,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.818514499999992,54.238662499105885]}},{"type":"Feature","properties":{"OBJECTID":19,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.146852999999993,54.23200999910579]}},{"type":"Feature","properties":{"OBJECTID":20,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.703086500000013,54.20771799910553]}},{"type":"Feature","properties":{"OBJECTID":21,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.2432125,54.205920999105516]}},{"type":"Feature","properties":{"OBJECTID":22,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.2467604999999935,54.20021449910545]}},{"type":"Feature","properties":{"OBJECTID":23,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.731109500000002,54.18583699910531]}},{"type":"Feature","properties":{"OBJECTID":24,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.255181999999992,54.17732999910524]}},{"type":"Feature","properties":{"OBJECTID":25,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.2398795,54.173324499105185]}},{"type":"Feature","properties":{"OBJECTID":26,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.6316559999999924,54.16358849910508]}},{"type":"Feature","properties":{"OBJECTID":27,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.2842985000000064,54.15388549910499]}},{"type":"Feature","properties":{"OBJECTID":28,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.327716500000009,54.13782099910482]}},{"type":"Feature","properties":{"OBJECTID":29,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.478100500000011,54.123214499104655]}},{"type":"Feature","properties":{"OBJECTID":30,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.344575499999991,54.12044899910464]}},{"type":"Feature","properties":{"OBJECTID":31,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.35452749999999,54.113372999104556]}},{"type":"Feature","properties":{"OBJECTID":32,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.291635000000013,54.11112199910453]}},{"type":"Feature","properties":{"OBJECTID":33,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.378019999999992,54.068820499104085]}},{"type":"Feature","properties":{"OBJECTID":34,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.663202000000013,54.0688169991041]}},{"type":"Feature","properties":{"OBJECTID":35,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.48335449999999,54.06639849910406]}},{"type":"Feature","properties":{"OBJECTID":36,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-7.286684000000008,55.04910449911471]}},{"type":"Feature","properties":{"OBJECTID":37,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.645479999999991,54.058349499103976]}},{"type":"Feature","properties":{"OBJECTID":38,"FCsubtype":1},"geometry":{"type":"Point","coordinates":[-6.593860500000004,54.04450599910386]}}]}
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Irish Border Crossings - OSM vs OSI data</title>
<link rel="stylesheet" crossorigin="" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js" integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==" crossorigin=""></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin="" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="info">
<div>
<h1>Irish Border Crossings</h1>
<h2>OSM vs OSi data</h2>
<hr>
<table>
<tr>
<td><img src="https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-red.png" /></td>
<td>Ordnance Survey Ireland (<span id="osiCount"></span>)</td>
<td>(<a href="https://data.gov.ie/dataset/border-exits-entrances-osi-national-1m-map-of-ireland" target="_blank">Source</a>)</td>
</tr>
<tr>
<td><img src="https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-green.png" /></td>
<td>Open Street Map (<span id="osmCount"></span>)</td>
<td>(<a href="http://overpass-turbo.eu/s/CRw" target="_blank">Source</a>)</td>
</tr>
</table>
<hr>
<a href="http://www.vool.ie/views-from-the-border" target="_blank"> Background info</a>
</div>
</div>
<div id="map"></div>
<script src="script.js"></script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});
var sat = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
});
var baseMaps = {
"Map": osm,
"Satelite": sat
};
var urlRoots = {
"gmap": 'http://www.google.com/maps/place/',
'osm': 'https://www.openstreetmap.org/#map=18/'
}
var map = L.map('map', {
center: [54.1381228, -6.640066],
zoom: 8,
layers: [osm]
});
var osi = L.featureGroup();
var osm = L.featureGroup();
osm.addTo(map);
osi.addTo(map);
var overlayMaps = {
"OSM": osm,
"OSI": osi
};
L.control.layers(baseMaps, overlayMaps, {
collapsed: false
}).addTo(map);
var greenIcon = new L.Icon({
iconUrl: 'https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-green.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
var redIcon = new L.Icon({
iconUrl: 'https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-red.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
$(function() {
function onEachFeature(feature, layer) {
var gmapLink = urlRoots.gmap + feature.geometry.coordinates[1] + ',' + feature.geometry.coordinates[0];
var osmLink = urlRoots.osm + feature.geometry.coordinates[1] + '/' + feature.geometry.coordinates[0];
layer.bindPopup('<a href="' + osmLink + '" target="_blank"> &#128279; OpenStreetMap </a><br><a href="' + gmapLink + '" target="_blank"> &#128279; Google Maps</a>');
}
$.ajax({
dataType: "json",
url: "ni_ie_osm.geojson",
success: function(data) {
document.getElementById('osmCount').innerHTML= data.features.length;
$(data.features).each(function(key, data) {
L.geoJSON(data, {
pointToLayer: function(feature, latlng) {
return L.marker(latlng, {
icon: greenIcon
});
},
onEachFeature: onEachFeature
}).addTo(osm);
});
}
});
$.ajax({
dataType: "json",
url: "Border_Exits__Entrances__OSi_National_1m_Map_Of_Ireland.geojson",
success: function(data) {
document.getElementById('osiCount').innerHTML= data.features.length;
$(data.features).each(function(key, data) {
L.geoJSON(data, {
pointToLayer: function(feature, latlng) {
return L.marker(latlng, {
icon: redIcon
});
},
onEachFeature: onEachFeature
}).addTo(osi);
});
}
});
});
$(document).ready(function() {
console.log("ready!");
});
body {
padding: 0;
margin: 0;
font-family: Sans-serif;
font-size: 0.8em;
margin: 0;
padding: 0;
-webkit-font-smoothing: antialiased;
}
html, body {
height: 100%;
width: 100%;
}
#info {
width: 25%;
color: #2c3e50;
}
#info div {
margin: 10px;
}
#map {
border-left: 1px solid #fff;
position: absolute;
left: 25%;
width: 75%;
top: 0;
bottom: 0;
}
a {
text-decoration: none;
color: #2980b9;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment