Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@ThomasG77
ThomasG77 / arc.js
Created May 11, 2018 06:58
Browserifiied version of arc.js
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.arc = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';
var D2R = Math.PI / 180;
var R2D = 180 / Math.PI;
var Coord = function(lon,lat) {
this.lon = lon;
this.lat = lat;
this.x = D2R * lon;
@ThomasG77
ThomasG77 / index.html
Last active April 24, 2024 13:25
Demo to use Overpass JSON API with OpenLayers 3 & 4
<!DOCTYPE>
<html>
<head>
<title>Overpass JSON</title>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
@ThomasG77
ThomasG77 / index.html
Created May 14, 2018 01:46
Demo using native ECMAScript modules in OpenLayers 5.0.0-beta.12
<!DOCTYPE html>
<html>
<head>
<title>Simple Map using native ECMAScript modules</title>
<link rel="stylesheet" href="https://openlayers.org/en/v5.0.0-beta.12/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
</head>
<body>
<div id="map" class="map"></div>
@ThomasG77
ThomasG77 / index.html
Created May 24, 2018 11:53
ol.control.Button without jQuery
<!DOCTYPE html>
<html>
<head>
<!----------------------------------------------------------
Copyright (c) 2015 Jean-Marc VIGLINO,
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
------------------------------------------------------------>
<title>ol-ext: Control button</title>
@ThomasG77
ThomasG77 / snippet-colors-events.js
Last active August 2, 2018 21:07
Colors events snippet
// Open this page http://openlayers.org/en/latest/examples/simple.html, execute in the console
// the following code to see events with same color for each type of event
// Code mainly borrowed from https://paul.kinlan.me/monitoring-all-events-on-an-element/
// with adaptation to manage colors and filter events
const html_colors = [
{'name': 'AliceBlue', 'color': '#F0F8FF'},
{'name': 'AntiqueWhite', 'color': '#FAEBD7'},
{'name': 'Aqua', 'color': '#00FFFF'},
{'name': 'Aquamarine', 'color': '#7FFFD4'},
{'name': 'Azure', 'color': '#F0FFFF'},
@ThomasG77
ThomasG77 / index.html
Created May 28, 2018 12:11
Fetch Adresse.data.gouv when geolocation activated
<!DOCTYPE html>
<html>
<head>
<title>Geolocation</title>
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v4.6.5/build/ol.js"></script>
</head>
<body>
<!DOCTYPE html>
<html>
<head>
<title>Marker Animation</title>
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v4.6.5/build/ol-debug.js"></script>
</head>
<body>
@ThomasG77
ThomasG77 / quick_example.js
Created June 11, 2018 12:16
Docopt in JavaScript
#!/usr/bin/env node
doc = `
Usage:
quick_example.js tcp <host> <port> [--timeout=<seconds>]
quick_example.js serial <port> [--baud=9600] [--timeout=<seconds>]
quick_example.js -h | --help | --version
`;
@ThomasG77
ThomasG77 / README.md
Created July 12, 2018 22:22 — forked from tmcw/README.md
Line Chart
@ThomasG77
ThomasG77 / README.md
Last active July 24, 2018 14:18 — forked from rveciana/README.md
Using JSTS to measure how far a line travels through a polygon

Example to ilustrate this question at gis.stackoverflow.

We choose to replace Turf with JSTS.

If the result is more complex (i.e. the resulting intersection is a polyline), the algorithm should be repeated for each part in the polygon.