Add license, reduce underscore dep, update readme

This commit is contained in:
Tom MacWright
2012-10-26 11:42:40 -04:00
parent af4e048a30
commit 33ddd283a8
6 changed files with 54 additions and 97 deletions

13
LICENSE Normal file
View File

@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Richard Fairhurst <richard@systemeD.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

View File

@@ -3,13 +3,24 @@ iD - friendly JavaScript editor for OpenStreetMap
Basics
------
* iD is a JavaScript-based OpenStreetMap editor with MapCSS rendering.
* iD is written with the Dojo framework.
* It's intentionally simple. iD is not a 90% editor. It's not even a 70% editor. It should let you do the most basic tasks while not breaking other people's data. Nothing more. (Same goes for the code, so go easy on the abstraction. :) )
* iD is a JavaScript-based [OpenStreetMap](http://www.openstreetmap.us/) editor.
* It's intentionally simple. This is not a 90% editor -
not even a 70% editor. It should let you do the most basic tasks while
not breaking other people's data. Nothing more. (Same goes for the code,
so go easy on the abstraction. :) )
* Speaking of percentages, it's about 1% complete.
* We're initially targeting WebKit-based browsers and Firefox, using SVG. IE and non-SVG can come later!
* The licence of iD is WTFPL, though obviously, if you want to dual-license any contributions that's cool.
* The licence of iD is [WTFPL](http://sam.zoy.org/wtfpl/), though obviously, if you want to dual-license
any contributions that's cool.
Architecture
------------
* iD uses [d3js](http://d3js.org/) for graphics & managing databindings to the
map. There's a tiny tiled-map core, but the majority of the action is in
dynamic rendering of the editable map data.
* This project aims to create a usable object model of [OpenStreetMap data](http://wiki.openstreetmap.org/wiki/Tags)
in Javascript that can be transformed by actions and serialized back into
[changesets](http://wiki.openstreetmap.org/wiki/Changeset)
Getting started
---------------
@@ -20,34 +31,39 @@ Getting started
How it works
------------
The code works similarly to Potlatch 2, but with a bit less abstraction. So, we have:
The code works similarly to [Potlatch 2](http://wiki.openstreetmap.org/wiki/Potlatch_2),
but with a bit less abstraction. So, we have:
* Connection: stores, fetches and saves data. (iD/Connection.js)
* Entity (Node, Way, Relation): the data objects. (iD/Entity.js)
* EntityUI (NodeUI, WayUI): the rendered graphic elements. (iD/renderer/...)
* Map: the displayed map on which EntityUIs are rendered. (iD/renderer/Map.js)
* Controller: the heart of the app, which does its work via...
* ControllerState: the current UI mode. ControllerStates decide what to do in response to mouse/keyboard events. (iD/controller/...)
* UndoableAction: the code to actually change the data, as fired by ControllerStates. (iD/actions/...)
* ControllerState: the current UI mode. ControllerStates decide what to do in
response to mouse/keyboard events. (iD/controller/...)
* UndoableAction: the code to actually change the data, as fired by
ControllerStates. (iD/actions/...)
The UI is much more modal than Potlatch 2. In particular there's a "draw shape" mode (the "Add road or shape" button) and an "edit object" mode. The directory structure of iD/controller reflects this.
The UI is much more modal than Potlatch 2. In particular there's a "draw shape"
mode (the "Add road or shape" button) and an "edit object" mode. The directory
structure of iD/controller reflects this.
Other relevant code includes the MapCSS parser in styleparser/ and custom widgets in ui/ .
As well as the [live docs](http://www.geowiki.com/docs/), you'll find various notes and comments in the docs/ folder. Feel free to add to these.
As well as the [live docs](http://www.geowiki.com/docs/), you'll find
various notes and comments in the docs/ folder. Feel free to add to these.
Getting started
---------------
Most of the interesting code is in the ControllerStates, which live in iD/controller/. Each one corresponds to a UI mode (e.g. "drawing a way"). Its EntityMouseEvent method takes the user's mouse event (e.g. "clicked on a node"), carries out any actions, and returns the new ControllerState (which might just be 'this', i.e. carry on with the current state).
Most of the interesting code is in the ControllerStates, which live in
iD/controller/. Each one corresponds to a UI mode (e.g. "drawing a way").
Its EntityMouseEvent method takes the user's mouse event (e.g. "clicked on
a node"), carries out any actions, and returns the new ControllerState
(which might just be 'this', i.e. carry on with the current state).
Coding tips
-----------
Scoping in JavaScript is famously broken: Dojo's lang.hitch method will save your life. Make sure you include dojo/_base/lang (in the 'declare' statement). Then, when you're passing an instance method as a function parameter, use lang.hitch(instance, instance.method) instead, and Dojo will magically set the right scope. You'll see lots of examples of this throughout the code.
Instance methods and variables _always_ need to be accessed with 'this.'. This is a fairly frequent gotcha if you're coming from another language.
The [Dojo site](http://dojotoolkit.org/) has lots of documentation. iD currently uses Dojo 1.8 - this has a much better module architecture (AMD) than previously.
Come on in, the water's lovely. More help? Ping RichardF on IRC (irc.oftc.net, in #osm-dev or #osm), on the OSM mailing lists or at richard@systemeD.net.
Come on in, the water's lovely. More help? Ping RichardF on IRC
(irc.oftc.net, in #osm-dev or #osm), on the OSM mailing lists or at
richard@systemeD.net.

View File

@@ -18,7 +18,6 @@
<script type="text/javascript" src="js/iD/controller/controller.js"></script>
<script type="text/javascript" src="js/iD/controller/edit/edit.js"></script>
<script type="text/javascript" src="js/iD/controller/edit/EditBaseState.js"></script>
<script type="text/javascript" src="js/iD/controller/edit/NoSelection.js"></script>
<script type="text/javascript" src="js/iD/controller/edit/SelectedPOINode.js"></script>
<script type="text/javascript" src="js/iD/controller/edit/SelectedWay.js"></script>

View File

@@ -9,9 +9,9 @@ iD.Relation = function(connection, id, members, tags, loaded) {
this.tags = tags;
this.modified = this.id < 0;
this.loaded = (loaded === undefined) ? true : loaded;
_.each(members, _.bind(function(member) {
member.entity.entity.addParent(this);
}, this));
for (var i = 0; i < members.length; i++) {
members[i].entity.entity.addParent(this);
}
};
iD.RelationMember = function(entity, role) {

View File

@@ -13,9 +13,9 @@ iD.Way = function(connection, id, nodes, tags, loaded) {
this.modified = this.id < 0;
this.nodes = nodes || [];
this.extent = {};
_.each(nodes, _.bind(function(node) {
node.entity.addParent(this);
}, this));
for (var i = 0; i < nodes.length; i++) {
nodes[i].entity.addParent(this);
}
};
iD.Way.prototype = {

View File

@@ -1,71 +0,0 @@
// ----------------------------------------------------------------------
// EditBaseState class - provides shared UI functions to edit mode states
iD.controller.edit.EditBaseState = function() {};
iD.controller.edit.EditBaseState.prototype = {
editortooltip: null,
constructor: function() {
// summary: Base state for the 'Edit object' states - where an
// object is selected and the user is making changes to it.
},
openEditorTooltip: function(entity) {
// summary: Open the initial 'Edit tags/Edit shape' tooltip.
// entity: iD.Entity The entity to be edited.
$('.edit-pane h2').text(iD.Util.friendlyName(entity));
$('.edit-pane').show().addClass('active');
/*
var $presets = $('.edit-pane .presets');
// Build presets panel
iD.Util.presets(entity.entityType, function(presets) {
$presets.empty();
_.each(presets, function(pre, category) {
$('<h3></h3>')
.text(category)
.appendTo($presets);
_.each(pre, function(set) {
var a = $('<a></a>')
.text(set.name)
.attr({
'class': 'preset-option',
'href': '#'
})
.appendTo($presets);
$('<span></span>')
.text(set.description)
.appendTo(a);
});
});
});
*/
// Build tag panel
$('.edit-pane .tags tbody').empty();
_.each(entity.tags, function(value, key) {
var tr = $('<tr></tr>').appendTo(
$('.edit-pane .tags tbody'));
var keyfield = $('<input></input>')
.attr({
type: 'text'
})
.val(key);
var valuefield = $('<input></input>')
.attr({
type: 'text'
})
.val(value);
$('<td></td>').append(keyfield).appendTo(tr);
$('<td></td>').append(valuefield).appendTo(tr);
});
$('.edit-pane a[href=#close]').click(this.closeEditorTooltip);
},
closeEditorTooltip: function(e) {
if (e) e.preventDefault();
// summary: Close the tooltip.
$('.edit-pane').removeClass('active').hide();
}
};