Skip to content

Instantly share code, notes, and snippets.

View tormi's full-sized avatar
🇪🇪
Working from home

Tormi Tabor tormi

🇪🇪
Working from home
View GitHub Profile
<?php
/**
* Implements hook_menu().
*/
function example_api_menu() {
$items = array();
$items['api'] = array(
'page callback' => 'example_api_redirect',
'page arguments' => array(1, 2),
@tormi
tormi / Issues.md
Last active August 29, 2015 14:18 — forked from rclark/Issues.md

There are a bunch of reasons why this is convoluted, mostly in building the URL to make the request:

  1. You have to rely on an AJAX request, this example uses jQuery
  2. To make a GetFeatureInfo request, you must provide a BBOX for a image, and the pixel coordinates for the part of the image that you want info from. A couple of squirrely lines of Leaflet code can give you that.
  3. Output formats. The info_format parameter in the request. We don't know a priori which will be supported by a WMS that we might make a request to. See Geoserver's docs for what formats are available from Geoserver. That won't be the same from WMS to WMS, however.
  4. WMS services return XML docs when there's a mistake in the request or in processing. This sends an HTTP 200, which jQuery doesn't think is an error.
<!DOCTYPE html>
<html>
<head>
<link href="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.css" rel="stylesheet" type="text/css" />
<script src="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.js"></script>
<meta charset="utf-8">
<title>Leaflet JS Bin</title>
<style>
#map {
width:600px;
@tormi
tormi / div.html
Last active November 16, 2015 21:25 — forked from mgiraldo/a-web-maps-101.md
A web maps primer
<div id="map"></div>
@tormi
tormi / index.html
Created November 17, 2015 07:13 — forked from phil-pedruco/index.html
Shopping Center Layout
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Shopping Mall Messing</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
@tormi
tormi / summary.js
Created January 6, 2016 14:14 — forked from SamyPesse/summary.js
Summary Generation for Code-Civil
var fs = require("fs");
var path = require("path");
var _ = require("lodash");
var utf8 = require('utf8');
require("natural-compare-lite");
var IGNORE = [
"node_modules",
".git",
"SUMMARY.md",
<?php
/**
* @file
* Default theme implementation to display the basic html structure of a single
* Drupal page.
*
* Variables:
* - $css: An array of CSS files for the current page.
* - $language: (object) The language the site is being displayed in.
@tormi
tormi / leaflet-snippet.js
Created September 20, 2016 08:37 — forked from acdha/leaflet-snippet.js
Quick and dirty script to convert Natural Earth II GeoTIFF from http://www.naturalearthdata.com/ into map tiles for display with LeafletJS
L.tileLayer('natural-earth-ii/{z}/{x}/{y}.png', {
maxZoom: 9,
tms: true
}).addTo(map);
@tormi
tormi / csv-to-geojson.sh
Created October 27, 2016 15:32 — forked from benbalter/csv-to-geojson.sh
Convert CSVs to GeoJSON, in bulk
#!/bin/bash
# Convert CSVs to GeoJSON, in bulk
# Usage: ./csv-to-geojson.sh [URL to list of CSV files]
# Outputs geoJSON files to the `output` folder
# Install csv2geojson if it's not installed
type csv2geojson || npm install -g csv2geojson
# Cleanup
rm -Rf ./tmp
@tormi
tormi / geojson-conversion.sh
Created October 27, 2016 15:32 — forked from benbalter/geojson-conversion.sh
Bulk convert shapefiles to geojson using ogr2ogr
# Bulk convert shapefiles to geojson using ogr2ogr
# For more information, see http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/
# Note: Assumes you're in a folder with one or more zip files containing shape files
# and Outputs as geojson with the crs:84 SRS (for use on GitHub or elsewhere)
#geojson conversion
function shp2geojson() {
ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp"
}