Skip to content

Instantly share code, notes, and snippets.

View bhousel's full-sized avatar

Bryan Housel bhousel

View GitHub Profile
@bhousel
bhousel / change_tags.js
Last active August 29, 2015 14:21
Hotkey to change some tags on all selected entities in #iD
context = id;
addTags = { building: 'yes' };
removeTags = ['area','natural','landuse'];
function changeTags() {
var actions = [],
entities = _.filter(_.map(context.selectedIDs(), context.entity),
function(entity) { return entity.geometry(context.graph()) === 'area'; });
_.each(entities, function(entity) {
@bhousel
bhousel / latlng.js
Created April 19, 2015 02:54
Show lat/lng of mouse cursor in #iD
id.surface().on('mousemove.custom', function() {
function wrap(x, min, max) { var d = max - min; return ((x - min) % d + d) % d + min; }
var ll = d3.select('#content')
.selectAll('#latLng')
.data([0]);
ll.enter()
.append('div')
.attr('id', 'latLng')
@bhousel
bhousel / whereami.js
Created March 15, 2015 19:29
Where am I (Nominatim lookup) #iD
// https://github.com/twain47/Nominatim/blob/master/lib/ReverseGeocode.php
function whereami(z) {
var endpoint = 'https://nominatim.openstreetmap.org/reverse?',
loc = id.map().center();
d3.json(endpoint +
iD.util.qsString({format: 'json', addressdetails: 1, lat: loc[1], lon: loc[0], zoom: z }),
function(err, result) { console.info(result); }
);
}
@bhousel
bhousel / history transplant.md
Last active August 29, 2015 14:16
Browser History Transplant for #iD

##iD history transplant

###Browser 1

  • Open "Help" and start walkthrough
  • Open developer console
  • Change "main frame/top frame" to "id-embed" if necessary, eg. running from openstreetmap.org
  • Run this:

(function getHistory() {

@bhousel
bhousel / string_search_microsoft.sql
Created February 25, 2015 15:32
string search in Microsoft #SQL
DECLARE @search VARCHAR(255)
SET @search = '[10.10.100.50]'
SELECT DISTINCT
o.name AS Object_Name,
o.type_desc
FROM
sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id = o.object_id
WHERE
@bhousel
bhousel / debug_entity_ids.js
Last active August 29, 2015 14:15
#iD debug mode - show ids instead of names
iD.util.displayName = function(entity) { return entity.id; }
@bhousel
bhousel / load_custom_iD_preset.js
Last active August 29, 2015 14:15
Load custom preset into #iD on the fly
obj = {
presets: {
'aerialway/zip_line': {
geometry: ["line"],
fields: ["incline"],
tags: { "aerialway": "zip_line" },
name: "Zipline"
}
}
};