diff --git a/osm/dynamic_markers/html/event_map.css b/osm/dynamic_markers/html/event_map.css new file mode 100644 index 0000000..81f34a2 --- /dev/null +++ b/osm/dynamic_markers/html/event_map.css @@ -0,0 +1,33 @@ +/* + * Copyright: 2010 by Lars Kruse + * License: GNU GPL v3 or higher (http://www.gnu.org/licenses/gpl-3.0.txt) + */ + +#event_map { + width: 100%; + height: 100%; + border: 0px; + padding: 0px; +} + +/* positioning the licence information of the map */ +#event_map div.olControlAttribution { + position: relative; + right: 10px; + bottom: 5px; +} + +/* no images within the map (tiles and controls) should have a margin */ +#event_map img { + /* drupal defines 5px margin for img */ + margin: 0; +} + +div.event_map_info h1 { + font-size: small; +} + +div.event_map_info li { + font-size: x-small; +} + diff --git a/osm/dynamic_markers/html/event_map.js b/osm/dynamic_markers/html/event_map.js new file mode 100644 index 0000000..21989d3 --- /dev/null +++ b/osm/dynamic_markers/html/event_map.js @@ -0,0 +1,339 @@ +/* functions for displaying event icons on a map + * Just include this js file in your html code and add an "event_map" div: + * + *
+ * + * Additionally you may want to override some variables, eg: + * + * BEWARE: above overrides MUST be placed before including the "event_map.js" file. + * + * Copyright: 2010 by Lars Kruse + * License: GNU GPL v3 or higher (http://www.gnu.org/licenses/gpl-3.0.txt) + */ + + +var event_map_zoom_default_for_events = 13; +var event_map_zoom_default_for_marker = 15; +var event_map_zoom_default_for_edit = 12; + +// names of fields to be manipulated in "edit" mode +var event_map_fieldname_lat = "edit-field-lat-0-value"; +var event_map_fieldname_lon = "edit-field-long-0-value"; + +// some default startup definitions (can be overwritten in the html file) +// define the base url of local resources - the trailing slash is required! +if (typeof(event_map_base_url) == 'undefined') { + var event_map_base_url = '/event_map/'; +} +// location of our css file - relative to the URL of the main html file +if (typeof(event_map_css_file) == 'undefined') { + var event_map_css_file = event_map_base_url + 'html/event_map.css'; +} +// location of the GML file to be loaded - relative to the URL of the main html file +if (typeof(event_map_gml_file) == 'undefined') { + var event_map_gml_file = event_map_base_url + 'html/events.gml'; +} +// display types: "events" (default), "marker" or "edit" +if (typeof(event_map_display_type) == 'undefined') { + var event_map_display_type = 'events'; +} +// set display_type to default, if the value is unknown +// also set default zoom level for that mode +var event_map_default_zoom; +if (event_map_display_type == 'events') { + event_map_default_zoom = event_map_zoom_default_for_events; +} else if (event_map_display_type == 'marker') { + event_map_default_zoom = event_map_zoom_default_for_marker; +} else if (event_map_display_type == 'edit') { + event_map_default_zoom = event_map_zoom_default_for_edit; +} else { + // unknown display_type + event_map_display_type = 'events'; + event_map_default_zoom = event_map_zoom_default_for_events; +} +// latitude and longitude of the center of the map - set to zero if undefined +// the real default value will be set a little bit later +// note: zero is the magic value for "undefined" +if (typeof(event_map_center_latitude) == 'undefined') { + var event_map_center_latitude = 0; +} +if (typeof(event_map_center_longitude) == 'undefined') { + var event_map_center_longitude = 0; +} +// remember, if the coordinates were not initialized +var event_map_coordinates_unset = false; +// event mode: set default latitude or longitude, if necessary (center of Rostock) +if (event_map_center_latitude == 0) { + event_map_coordinates_unset = true; + event_map_center_latitude = 54.082004; +} +if (event_map_center_longitude == 0) { + event_map_coordinates_unset = true; + event_map_center_longitude = 12.128275; +} +// initial zoom level of the map +if (typeof(event_map_zoom) == 'undefined') { + var event_map_zoom = 0; +} +// this must be done separately from the previous "undefined" check to avoid re-initialization via "var" +if (event_map_zoom == 0) { + event_map_zoom = event_map_default_zoom; +} +// url of the marker icon +if (typeof(event_map_marker_icon) == 'undefined') { + var event_map_marker_icon = event_map_base_url + 'icons/marker.png'; +} + + +// global variables +var event_map; +var event_map_selectControl; +var event_map_marker_layer; +var event_map_marker; + +// run the "event_map_init" function after loading the page +window.onload = event_map_init; + + +function event_map_addJavascript(jsname, pos) { + var th = document.getElementsByTagName(pos)[0]; + var s = document.createElement('script'); + s.setAttribute('type', 'text/javascript'); + s.setAttribute('src', jsname); + th.appendChild(s); +} + + +function event_map_addCSSfile(cssfile, pos) { + var th = document.getElementsByTagName(pos)[0]; + var s = document.createElement('link'); + s.setAttribute('rel', 'stylesheet'); + s.setAttribute('href', cssfile); + th.appendChild(s); +} + + +event_map_addJavascript('http://www.openlayers.org/api/OpenLayers.js', 'head'); +event_map_addJavascript('http://www.openstreetmap.org/openlayers/OpenStreetMap.js', 'head'); +// in case of problems of a browser with loading external ccs files, we could use the local copy +//event_map_addCSSfile(event_map_base_url + 'html/openlayers/style.css', 'head'); +event_map_addCSSfile('http://openlayers.org/api/theme/default/style.css', 'head'); +event_map_addCSSfile(event_map_css_file, 'head'); + + +function event_map_init() { + event_map = new OpenLayers.Map('event_map', { + maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34), + numZoomLevels: 19, + maxResolution: 156543.0399, + units: 'm', + projection: new OpenLayers.Projection("EPSG:900913"), + displayProjection: new OpenLayers.Projection("EPSG:4326") + }); + + // define the public transport map (oepnvkarte.de) + OpenLayers.Layer.OSM.OePNV = OpenLayers.Class(OpenLayers.Layer.OSM, { + initialize: function(name, options) { + var url = [ + "http://tile.xn--pnvkarte-m4a.de/tilegen/${z}/${x}/${y}.png" + ]; + options = OpenLayers.Util.extend({ numZoomLevels: 19 }, options); + var newArguments = [name, url, options]; + OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); + }, + CLASS_NAME: "OpenLayers.Layer.OSM.OePNV" + }); + + + var layerOePNV = new OpenLayers.Layer.OSM.OePNV("ÖPNV-Karte"); + var layerCycle = new OpenLayers.Layer.OSM.CycleMap("Radweg-Karte"); + var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik"); + var layerTah = new OpenLayers.Layer.OSM.Osmarender("Osmarender"); + + event_map.addLayers([layerOePNV, layerCycle, layerMapnik, layerTah]); + // choose default layer + event_map.setBaseLayer(layerMapnik); + + event_map_marker_layer = new OpenLayers.Layer.Markers("Markierung"); + event_map.addLayer(event_map_marker_layer) + + // allow to change the current layer (mapnik/tah/oepnv/cycle) + event_map.addControl(new OpenLayers.Control.LayerSwitcher()); + + var lonLat = new OpenLayers.LonLat(event_map_center_longitude, + event_map_center_latitude).transform(event_map.displayProjection, event_map.projection); + event_map.setCenter(lonLat, event_map_zoom); + + if (event_map_display_type == 'marker') { + event_map_show_marker(lonLat); + } else if (event_map_display_type == 'edit') { + event_map_edit_position(lonLat); + } else { + event_map_show_gml(); + } +} + + +function event_map_get_marker(lonLat) { + var size = new OpenLayers.Size(21, 25); + var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); + var icon = new OpenLayers.Icon(event_map_marker_icon, size, offset) + return new OpenLayers.Marker(lonLat, icon); +} + + +// return false, if no valid coordinate values are found in the form fields +function event_map_get_form_coordinates() { + var lon; + var lat; + var field_lat = document.getElementById(event_map_fieldname_lat); + var field_lon = document.getElementById(event_map_fieldname_lon); + if (field_lat) { lat = field_lat.value; } + if (field_lon) { lon = field_lon.value; } + if ((lat != "") && (lat != 0) && (lon != "") && (lon != 0)) { + return new OpenLayers.LonLat(lon, lat).transform( + event_map.displayProjection, event_map.projection); + } else { + return false; + } +} + + +function event_map_update_edit_marker() { + event_map_marker_layer.clearMarkers(); + var lonLat = event_map_get_form_coordinates(); + if (lonLat) { + event_map_marker = event_map_get_marker(lonLat); + event_map_marker_layer.addMarker(event_map_marker); + // center the map on the item + event_map.setCenter(lonLat, event_map.zoom); + } +} + + +function event_map_edit_position(lonLat) { + event_map_update_edit_marker(); + + // catch click events + OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { + defaultHandlerOptions: { + 'single': true, + 'double': false, + 'pixelTolerance': 0, + 'stopSingle': false, + 'stopDouble': false + }, + initialize: function(options) { + this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions); + OpenLayers.Control.prototype.initialize.apply(this, arguments); + this.handler = new OpenLayers.Handler.Click(this, { 'click': this.trigger }, this.handlerOptions); + } + }); + + var click = new OpenLayers.Control.Click({ trigger: event_map_edit_clicked }); + event_map.addControl(click); + click.activate(); +} + + +function event_map_show_marker(lonLat) { + if (event_map_coordinates_unset) { + // hide the map + document.getElementById('event_map').style.display = "none"; + } else { + // configure and display the map + event_map_marker = event_map_get_marker(lonLat); + event_map_marker_layer.addMarker(event_map_marker); + } +} + + +function event_map_show_gml() { + OpenLayers.Feature.prototype.popupClass = OpenLayers.Popup.FramedCloud; + + var pois = new OpenLayers.Layer.GML("Veranstaltungen", event_map_gml_file, { + format: OpenLayers.Format.Text, + projection: new OpenLayers.Projection("EPSG:4326") + }); + + event_map.addLayer(pois); + + // add the popups + event_map_selectControl = new OpenLayers.Control.SelectFeature(pois, { + onSelect: event_map_onFeatureSelect, + onUnselect: event_map_onFeatureUnselect, + toggle: true + }); + + event_map.addControl(event_map_selectControl); + event_map_selectControl.activate(); +} + + +function event_map_onPopupClose(evnt) { + event_map_selectControl.unselect(selectedFeature); +} + + +function event_map_edit_clicked(evnt) { + var lonLat = event_map.getLonLatFromViewPortPx(evnt.xy).transform( + event_map.projection, event_map.displayProjection); + var field_lat = document.getElementById(event_map_fieldname_lat); + var field_lon = document.getElementById(event_map_fieldname_lon); + // round the numbers to a few digits - otherwise drupal complains about max number of chars + if (field_lat) { field_lat.value = Math.round(lonLat.lat * 10000000) / 10000000; } + if (field_lon) { field_lon.value = Math.round(lonLat.lon * 10000000) / 10000000; } + event_map_update_edit_marker(); +} + + +function event_map_onFeatureSelect(feature) { + selectedFeature = feature; + var content = '
'; + content += '

' + feature.attributes.title + '

'; + /* the description contains six attributes: + * time/date + * place + * address + * organisation + * details + * url + */ + /* we don't do this formatting here - but in the gml file generation script instead + var items = feature.attributes.description.split('#', 6); + content += '
    '; + content += '
  • Wann: ' + items[0] + '
  • '; + content += '
  • Ort: ' + items[1] + '
  • '; + content += '
  • Adresse: ' + items[2] + '
  • '; + content += '
  • Veranstalter: ' + items[3] + '
  • '; + content += '
  • Details: ' + items[4] + '
  • '; + content += '
  • mehr ...
  • '; + content += '
'; + */ + content += feature.attributes.description + content += '' + // do naive protection against Javascript. + if (content.search(" + + + + +
+ + + diff --git a/osm/dynamic_markers/icons/COPYRIGHT b/osm/dynamic_markers/icons/COPYRIGHT new file mode 100644 index 0000000..ee3146d --- /dev/null +++ b/osm/dynamic_markers/icons/COPYRIGHT @@ -0,0 +1,5 @@ +The files below this directory are published under a Creative Commons License. +See the original SVG files below the directory "svg" for the details of +the author and the license. + +http://creativecommons.org diff --git a/osm/dynamic_markers/icons/design/icon_mapping.txt b/osm/dynamic_markers/icons/design/icon_mapping.txt new file mode 100644 index 0000000..39ca620 --- /dev/null +++ b/osm/dynamic_markers/icons/design/icon_mapping.txt @@ -0,0 +1,9 @@ +svg/adriano_Hard_Hat.svg png/workshop +svg/AJ_Party_Balloons.svg png/party +svg/Anonymous_Open_Bible.svg png/lesung +svg/ben_Movie_clapper.svg png/film +svg/liftarn_Raised_fist_1.svg png/demo +svg/pipo_pan.svg png/vokue +svg/ryanlerch_Green_-_Query_Icon.svg png/misc +svg/sheikh_tuhin_Diary.svg png/seminar +svg/valessiobrito_Aquarela_Colors.svg png/kunst diff --git a/osm/dynamic_markers/icons/design/original/AJ_Party_Balloons.svg b/osm/dynamic_markers/icons/design/original/AJ_Party_Balloons.svg new file mode 100644 index 0000000..306a8d9 --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/AJ_Party_Balloons.svg @@ -0,0 +1,452 @@ + + + + + + balloons-aj + + + + + balloons + festive + party + recreation + + + + + AJ Ashton + + + + + AJ Ashton + + + + + AJ Ashton + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/original/Anonymous_Open_Bible.svg b/osm/dynamic_markers/icons/design/original/Anonymous_Open_Bible.svg new file mode 100644 index 0000000..becf928 --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/Anonymous_Open_Bible.svg @@ -0,0 +1,121 @@ + + + + + + + + open bible 01 + + + + hash + + christianity + religion + education + book + + + + + Aaron Johnson + + + + + Aaron Johnson + + + + + Aaron Johnson + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/original/adriano_Hard_Hat.svg b/osm/dynamic_markers/icons/design/original/adriano_Hard_Hat.svg new file mode 100644 index 0000000..796bbfc --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/adriano_Hard_Hat.svg @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/original/ben_Movie_clapper.svg b/osm/dynamic_markers/icons/design/original/ben_Movie_clapper.svg new file mode 100644 index 0000000..0294f2f --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/ben_Movie_clapper.svg @@ -0,0 +1,556 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + Movie clap + + + + + + + + + + + + + + + + + + Inkscape + + diff --git a/osm/dynamic_markers/icons/design/original/liftarn_Raised_fist_1.svg b/osm/dynamic_markers/icons/design/original/liftarn_Raised_fist_1.svg new file mode 100644 index 0000000..17a9f85 --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/liftarn_Raised_fist_1.svg @@ -0,0 +1,62 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/original/pipo_pan.svg b/osm/dynamic_markers/icons/design/original/pipo_pan.svg new file mode 100644 index 0000000..06adc96 --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/pipo_pan.svg @@ -0,0 +1,1757 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/original/ryanlerch_Green_-_Query_Icon.svg b/osm/dynamic_markers/icons/design/original/ryanlerch_Green_-_Query_Icon.svg new file mode 100644 index 0000000..010c231 --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/ryanlerch_Green_-_Query_Icon.svg @@ -0,0 +1,1855 @@ + + + + + + + image/svg+xml + + exclamation icons + 29 11 2006 + + + molumen + + + + + exclamation + icon + series + red + blue + green + yellow + black + triangle + attention + + + a series of exclamation icon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/original/sheikh_tuhin_Diary.svg b/osm/dynamic_markers/icons/design/original/sheikh_tuhin_Diary.svg new file mode 100644 index 0000000..dc37df9 --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/sheikh_tuhin_Diary.svg @@ -0,0 +1,584 @@ + + + + + + + image/svg+xml + + + + Sheikh Tuhin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/original/valessiobrito_Aquarela_Colors.svg b/osm/dynamic_markers/icons/design/original/valessiobrito_Aquarela_Colors.svg new file mode 100644 index 0000000..69a40a8 --- /dev/null +++ b/osm/dynamic_markers/icons/design/original/valessiobrito_Aquarela_Colors.svg @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/design/stadtgestalten_icons_clavdia.svg b/osm/dynamic_markers/icons/design/stadtgestalten_icons_clavdia.svg new file mode 100644 index 0000000..b1106c3 --- /dev/null +++ b/osm/dynamic_markers/icons/design/stadtgestalten_icons_clavdia.svg @@ -0,0 +1,9215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + FILM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/marker.png b/osm/dynamic_markers/icons/marker.png new file mode 100644 index 0000000..ccd1913 Binary files /dev/null and b/osm/dynamic_markers/icons/marker.png differ diff --git a/osm/dynamic_markers/icons/png/demo_12.png b/osm/dynamic_markers/icons/png/demo_12.png new file mode 100644 index 0000000..1843e91 Binary files /dev/null and b/osm/dynamic_markers/icons/png/demo_12.png differ diff --git a/osm/dynamic_markers/icons/png/demo_24.png b/osm/dynamic_markers/icons/png/demo_24.png new file mode 100644 index 0000000..9200f76 Binary files /dev/null and b/osm/dynamic_markers/icons/png/demo_24.png differ diff --git a/osm/dynamic_markers/icons/png/demo_32.png b/osm/dynamic_markers/icons/png/demo_32.png new file mode 100644 index 0000000..5f379d7 Binary files /dev/null and b/osm/dynamic_markers/icons/png/demo_32.png differ diff --git a/osm/dynamic_markers/icons/png/demo_40.png b/osm/dynamic_markers/icons/png/demo_40.png new file mode 100644 index 0000000..debcdd5 Binary files /dev/null and b/osm/dynamic_markers/icons/png/demo_40.png differ diff --git a/osm/dynamic_markers/icons/png/film_12.png b/osm/dynamic_markers/icons/png/film_12.png new file mode 100644 index 0000000..8f1cded Binary files /dev/null and b/osm/dynamic_markers/icons/png/film_12.png differ diff --git a/osm/dynamic_markers/icons/png/film_24.png b/osm/dynamic_markers/icons/png/film_24.png new file mode 100644 index 0000000..999234d Binary files /dev/null and b/osm/dynamic_markers/icons/png/film_24.png differ diff --git a/osm/dynamic_markers/icons/png/film_32.png b/osm/dynamic_markers/icons/png/film_32.png new file mode 100644 index 0000000..70eb9a1 Binary files /dev/null and b/osm/dynamic_markers/icons/png/film_32.png differ diff --git a/osm/dynamic_markers/icons/png/film_40.png b/osm/dynamic_markers/icons/png/film_40.png new file mode 100644 index 0000000..9ae6cfc Binary files /dev/null and b/osm/dynamic_markers/icons/png/film_40.png differ diff --git a/osm/dynamic_markers/icons/png/kunst_12.png b/osm/dynamic_markers/icons/png/kunst_12.png new file mode 100644 index 0000000..8c8aa13 Binary files /dev/null and b/osm/dynamic_markers/icons/png/kunst_12.png differ diff --git a/osm/dynamic_markers/icons/png/kunst_24.png b/osm/dynamic_markers/icons/png/kunst_24.png new file mode 100644 index 0000000..1158b02 Binary files /dev/null and b/osm/dynamic_markers/icons/png/kunst_24.png differ diff --git a/osm/dynamic_markers/icons/png/kunst_32.png b/osm/dynamic_markers/icons/png/kunst_32.png new file mode 100644 index 0000000..f7f78ca Binary files /dev/null and b/osm/dynamic_markers/icons/png/kunst_32.png differ diff --git a/osm/dynamic_markers/icons/png/kunst_40.png b/osm/dynamic_markers/icons/png/kunst_40.png new file mode 100644 index 0000000..d0d808d Binary files /dev/null and b/osm/dynamic_markers/icons/png/kunst_40.png differ diff --git a/osm/dynamic_markers/icons/png/lesung_12.png b/osm/dynamic_markers/icons/png/lesung_12.png new file mode 100644 index 0000000..4c75e12 Binary files /dev/null and b/osm/dynamic_markers/icons/png/lesung_12.png differ diff --git a/osm/dynamic_markers/icons/png/lesung_24.png b/osm/dynamic_markers/icons/png/lesung_24.png new file mode 100644 index 0000000..6e9db62 Binary files /dev/null and b/osm/dynamic_markers/icons/png/lesung_24.png differ diff --git a/osm/dynamic_markers/icons/png/lesung_32.png b/osm/dynamic_markers/icons/png/lesung_32.png new file mode 100644 index 0000000..d7e5534 Binary files /dev/null and b/osm/dynamic_markers/icons/png/lesung_32.png differ diff --git a/osm/dynamic_markers/icons/png/lesung_40.png b/osm/dynamic_markers/icons/png/lesung_40.png new file mode 100644 index 0000000..cdc60a0 Binary files /dev/null and b/osm/dynamic_markers/icons/png/lesung_40.png differ diff --git a/osm/dynamic_markers/icons/png/misc_12.png b/osm/dynamic_markers/icons/png/misc_12.png new file mode 100644 index 0000000..2f9825e Binary files /dev/null and b/osm/dynamic_markers/icons/png/misc_12.png differ diff --git a/osm/dynamic_markers/icons/png/misc_24.png b/osm/dynamic_markers/icons/png/misc_24.png new file mode 100644 index 0000000..7fe684a Binary files /dev/null and b/osm/dynamic_markers/icons/png/misc_24.png differ diff --git a/osm/dynamic_markers/icons/png/misc_32.png b/osm/dynamic_markers/icons/png/misc_32.png new file mode 100644 index 0000000..04c4499 Binary files /dev/null and b/osm/dynamic_markers/icons/png/misc_32.png differ diff --git a/osm/dynamic_markers/icons/png/misc_40.png b/osm/dynamic_markers/icons/png/misc_40.png new file mode 100644 index 0000000..b6da50c Binary files /dev/null and b/osm/dynamic_markers/icons/png/misc_40.png differ diff --git a/osm/dynamic_markers/icons/png/party_12.png b/osm/dynamic_markers/icons/png/party_12.png new file mode 100644 index 0000000..0012a88 Binary files /dev/null and b/osm/dynamic_markers/icons/png/party_12.png differ diff --git a/osm/dynamic_markers/icons/png/party_24.png b/osm/dynamic_markers/icons/png/party_24.png new file mode 100644 index 0000000..2b2c8b0 Binary files /dev/null and b/osm/dynamic_markers/icons/png/party_24.png differ diff --git a/osm/dynamic_markers/icons/png/party_32.png b/osm/dynamic_markers/icons/png/party_32.png new file mode 100644 index 0000000..1b82e2e Binary files /dev/null and b/osm/dynamic_markers/icons/png/party_32.png differ diff --git a/osm/dynamic_markers/icons/png/party_40.png b/osm/dynamic_markers/icons/png/party_40.png new file mode 100644 index 0000000..b8e96a3 Binary files /dev/null and b/osm/dynamic_markers/icons/png/party_40.png differ diff --git a/osm/dynamic_markers/icons/png/seminar_12.png b/osm/dynamic_markers/icons/png/seminar_12.png new file mode 100644 index 0000000..9b70ccb Binary files /dev/null and b/osm/dynamic_markers/icons/png/seminar_12.png differ diff --git a/osm/dynamic_markers/icons/png/seminar_24.png b/osm/dynamic_markers/icons/png/seminar_24.png new file mode 100644 index 0000000..7357511 Binary files /dev/null and b/osm/dynamic_markers/icons/png/seminar_24.png differ diff --git a/osm/dynamic_markers/icons/png/seminar_32.png b/osm/dynamic_markers/icons/png/seminar_32.png new file mode 100644 index 0000000..d72a2f0 Binary files /dev/null and b/osm/dynamic_markers/icons/png/seminar_32.png differ diff --git a/osm/dynamic_markers/icons/png/seminar_40.png b/osm/dynamic_markers/icons/png/seminar_40.png new file mode 100644 index 0000000..ab86c58 Binary files /dev/null and b/osm/dynamic_markers/icons/png/seminar_40.png differ diff --git a/osm/dynamic_markers/icons/png/vokue_12.png b/osm/dynamic_markers/icons/png/vokue_12.png new file mode 100644 index 0000000..95e2bc4 Binary files /dev/null and b/osm/dynamic_markers/icons/png/vokue_12.png differ diff --git a/osm/dynamic_markers/icons/png/vokue_24.png b/osm/dynamic_markers/icons/png/vokue_24.png new file mode 100644 index 0000000..d71f675 Binary files /dev/null and b/osm/dynamic_markers/icons/png/vokue_24.png differ diff --git a/osm/dynamic_markers/icons/png/vokue_32.png b/osm/dynamic_markers/icons/png/vokue_32.png new file mode 100644 index 0000000..ddc4f44 Binary files /dev/null and b/osm/dynamic_markers/icons/png/vokue_32.png differ diff --git a/osm/dynamic_markers/icons/png/vokue_40.png b/osm/dynamic_markers/icons/png/vokue_40.png new file mode 100644 index 0000000..3535775 Binary files /dev/null and b/osm/dynamic_markers/icons/png/vokue_40.png differ diff --git a/osm/dynamic_markers/icons/png/workshop_12.png b/osm/dynamic_markers/icons/png/workshop_12.png new file mode 100644 index 0000000..0d86114 Binary files /dev/null and b/osm/dynamic_markers/icons/png/workshop_12.png differ diff --git a/osm/dynamic_markers/icons/png/workshop_24.png b/osm/dynamic_markers/icons/png/workshop_24.png new file mode 100644 index 0000000..ec9410e Binary files /dev/null and b/osm/dynamic_markers/icons/png/workshop_24.png differ diff --git a/osm/dynamic_markers/icons/png/workshop_32.png b/osm/dynamic_markers/icons/png/workshop_32.png new file mode 100644 index 0000000..2dfdd3b Binary files /dev/null and b/osm/dynamic_markers/icons/png/workshop_32.png differ diff --git a/osm/dynamic_markers/icons/png/workshop_40.png b/osm/dynamic_markers/icons/png/workshop_40.png new file mode 100644 index 0000000..aafedab Binary files /dev/null and b/osm/dynamic_markers/icons/png/workshop_40.png differ diff --git a/osm/dynamic_markers/icons/svg/AJ_Party_Balloons.svg b/osm/dynamic_markers/icons/svg/AJ_Party_Balloons.svg new file mode 100644 index 0000000..c371ddf --- /dev/null +++ b/osm/dynamic_markers/icons/svg/AJ_Party_Balloons.svg @@ -0,0 +1,1516 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/svg/Anonymous_Open_Bible.svg b/osm/dynamic_markers/icons/svg/Anonymous_Open_Bible.svg new file mode 100644 index 0000000..7f4dfeb --- /dev/null +++ b/osm/dynamic_markers/icons/svg/Anonymous_Open_Bible.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/svg/adriano_Hard_Hat.svg b/osm/dynamic_markers/icons/svg/adriano_Hard_Hat.svg new file mode 100644 index 0000000..4a081e0 --- /dev/null +++ b/osm/dynamic_markers/icons/svg/adriano_Hard_Hat.svg @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/svg/ben_Movie_clapper.svg b/osm/dynamic_markers/icons/svg/ben_Movie_clapper.svg new file mode 100644 index 0000000..caa2b83 --- /dev/null +++ b/osm/dynamic_markers/icons/svg/ben_Movie_clapper.svg @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + FILM + + + + diff --git a/osm/dynamic_markers/icons/svg/liftarn_Raised_fist_1.svg b/osm/dynamic_markers/icons/svg/liftarn_Raised_fist_1.svg new file mode 100644 index 0000000..2020a7f --- /dev/null +++ b/osm/dynamic_markers/icons/svg/liftarn_Raised_fist_1.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/svg/pipo_pan.svg b/osm/dynamic_markers/icons/svg/pipo_pan.svg new file mode 100644 index 0000000..6722dd9 --- /dev/null +++ b/osm/dynamic_markers/icons/svg/pipo_pan.svg @@ -0,0 +1,1015 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/svg/ryanlerch_Green_-_Query_Icon.svg b/osm/dynamic_markers/icons/svg/ryanlerch_Green_-_Query_Icon.svg new file mode 100644 index 0000000..8dd463b --- /dev/null +++ b/osm/dynamic_markers/icons/svg/ryanlerch_Green_-_Query_Icon.svg @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/svg/sheikh_tuhin_Diary.svg b/osm/dynamic_markers/icons/svg/sheikh_tuhin_Diary.svg new file mode 100644 index 0000000..8e7a43b --- /dev/null +++ b/osm/dynamic_markers/icons/svg/sheikh_tuhin_Diary.svg @@ -0,0 +1,459 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/icons/svg/valessiobrito_Aquarela_Colors.svg b/osm/dynamic_markers/icons/svg/valessiobrito_Aquarela_Colors.svg new file mode 100644 index 0000000..bfcef0e --- /dev/null +++ b/osm/dynamic_markers/icons/svg/valessiobrito_Aquarela_Colors.svg @@ -0,0 +1,367 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osm/dynamic_markers/pictures/link_map.png b/osm/dynamic_markers/pictures/link_map.png new file mode 100644 index 0000000..93161a5 Binary files /dev/null and b/osm/dynamic_markers/pictures/link_map.png differ diff --git a/osm/dynamic_markers/pictures/link_map_bubble.png b/osm/dynamic_markers/pictures/link_map_bubble.png new file mode 100644 index 0000000..873ee12 Binary files /dev/null and b/osm/dynamic_markers/pictures/link_map_bubble.png differ diff --git a/osm/dynamic_markers/pictures/link_map_bubble.xcf b/osm/dynamic_markers/pictures/link_map_bubble.xcf new file mode 100644 index 0000000..fe98645 Binary files /dev/null and b/osm/dynamic_markers/pictures/link_map_bubble.xcf differ diff --git a/osm/dynamic_markers/scripts/convert_raw2gml.py b/osm/dynamic_markers/scripts/convert_raw2gml.py new file mode 100755 index 0000000..ca42025 --- /dev/null +++ b/osm/dynamic_markers/scripts/convert_raw2gml.py @@ -0,0 +1,457 @@ +#!/usr/bin/env python +# -*- coding: iso-8859-15 -*- +# +# Syntax: convert_html2gml [[HTML_URL] OUTPUT_FILE] +# +# reasonable defaults are used, if zero or one arguments are given +# +# BEWARE: you _MUST_ adapt both the input parser "EventParser") and the output +# formatting ("get_gml_from_data") to your specific implementation +# +# Copyright: 2010 by Lars Kruse +# License: GNU GPL v3 or higher (http://www.gnu.org/licenses/gpl-3.0.txt) +# + +""" +Popup: + * aktuelle Veranstaltung: + * Veranstaltungsname + * Termin + * Ort ("Frieda 23") + * "Details" -> Link + * evt.: Liste weiterer Veranstaltungen am selben Ort (naechste Tage) + * Datum und Veranstaltungsname als gemeinsamer Link fuer "mehr" +""" + + +import sys +import HTMLParser +import urllib +import htmlentitydefs +import time +import re +import locale + +IMPORT_URL = "http://stadtgestalten.org/?q=termin-roh" +EXPORT_FILE = "events.gml" +ICON_URL_PREFIX = "http://stadtgestalten.org/event_map/icons/png" +INPUT_ENCODING = 'utf-8' +# number of additional events to be displayed for the same location +MAX_EXTRA_EVENTS = 3 + + +# as given to "locale.setlocale" +LOCALE = "de_DE" + +COLUMNS = { + 'title': 0, + 'time': 1, + 'category': 2, + 'place': 3, + 'latitude': 4, + 'longitude': 5, + 'organizer': 6, + } + + +# mapping of categories (as defined in drupal) to filename prefixes +ICONS = { + 'Sonstiges': 'misc', + 'Party': 'party', + 'Lesung': 'lesung', + 'Demo': 'demo', + 'Seminar': 'seminar', + 'Workshop': 'workshop', + 'Film': 'film', + 'Kunst': 'kunst', + 'Vokue': 'vokue', + 'default': 'misc', + } + + +# mapping of time "importance" (today, tomorrow, ...) to sizes +ICON_SIZES = { + 'tiny': 12, + 'small': 24, + 'medium': 32, + 'big': 40, + } + + +# used for "html_escape" below +HTML_ESCAPE_TABLE = { + "&": "&", + '"': """, + "'": "'", + ">": ">", + "<": "<", + } + + +""" how to display different events according to their date +events before "today" and after "future" are ignored +""" +TIME_OFFSET_HOURS = { + "today": -8, + "soon": 1.5 * 24, + "coming": 4 * 24, + "future": 30 * 24, + } + + +class EventParser(HTMLParser.HTMLParser, object): + """ This parser extracts the input from the the event page generated by drupal. + BEWARE: the drupal page MUST be configured as a table layout with the above order + of columns (see 'COLUMNS') + """ + + def __init__(self): + super(EventParser, self).__init__() + self.in_data = False + self.div_view_depth = 0 + self.in_event = False + self.in_attribute = False + self.current_attribute = -1 + self.events = [] + + def handle_starttag(self, tag, attrs): + attrs_dict = dict(attrs) + if (tag == "div"): + if attrs_dict.has_key("class") and (attrs_dict["class"] == "view-content"): + self.in_data = True + self.div_view_depth = 0 + elif self.in_data: + # count the levels of sub-divs + self.div_view_depth += 1 + elif self.in_data and (tag == "tr"): + # a new event item + self.in_event = True + self.current_attribute = -1 + self.events.append({}) + elif self.in_event and (tag == "td"): + self.in_attribute = True + self.current_attribute += 1 + elif self.in_attribute and (tag == "a"): + event = self.events[-1] + if self.current_attribute == COLUMNS['title']: + event['event_url'] = attrs_dict["href"] + elif self.current_attribute == COLUMNS['place']: + event['place_url'] = attrs_dict["href"] + elif self.current_attribute == COLUMNS['organizer']: + event['organizer_url'] = attrs_dict["href"] + + def handle_endtag(self, tag): + if self.in_data: + if (tag == "div"): + if self.div_view_depth > 0: + self.div_view_depth -= 1 + elif self.div_view_depth == 0: + self.in_event = False + else: + # event_depth is never below zero + pass + elif (tag == "tr"): + self.in_event = False + # remove empty entries + if not self.events[-1]: + del self.events[-1] + elif (tag == "td"): + self.in_attribute = False + else: + pass + + def handle_data(self, data): + """ BEWARE: the "handle_data" function does not really work well + for strings, that contain an ampersand entity (e.g. &). + In this case, it splits the string before and after the special + character. This results (e.g.) in a splitted title string and + thus only the last part of it is correctly stored. + Example: "foo & bar" -> "bar" + Solution: the strings, that may contain ampersand entities/refs + (title, place, organizer) are joined with potential special + characters. + See "handle_charref" and "handle_entityref" below + """ + if self.in_attribute: + data = data.decode(INPUT_ENCODING) + event = self.events[-1] + if not data.strip(): + # ignore empty strings + pass + elif self.current_attribute == COLUMNS['title']: + # maybe the title is splitted by an ampersand entity + event['title'] = event.get('title', '') + data + elif self.current_attribute == COLUMNS['time']: + if event.has_key("time"): + # the first "time" field is the start + # the next ones should be ignored + pass + else: + timestamp = re.match("[0-9]*", data).group().strip() + if timestamp: + # non-empty string + try: + event['time'] = int(timestamp) + except ValueError: + # give a warning - the event will be ignored during the check later + system.stderr.write("Invalid time format: %s\n" % (timestamp, )) + else: + # empty string - this event will be ignore during the check later + pass + elif self.current_attribute == COLUMNS['category']: + event['category'] = data.strip() + elif self.current_attribute == COLUMNS['place']: + event['place'] = event.get('place', '') + data + elif self.current_attribute == COLUMNS['latitude']: + event['latitude'] = data.strip() + elif self.current_attribute == COLUMNS['longitude']: + event['longitude'] = data.strip() + elif self.current_attribute == COLUMNS['organizer']: + event['organizer'] = event.get('organizer', '') + data + else: + sys.stderr.write("UNKNOWN ATTRIBUTE: %d (%s)\n" % (self.current_attribute, data.encode(INPUT_ENCODING))) + + + def handle_charref(self, num): + """ add the encoded character (e.g. ) to the current string """ + # decode before passing it to "handle_data" + self.handle_data(unichr(int(num))) + + def handle_entityref(self, name): + """ add the encoded entity (e.g. &) to the current string """ + # decode before passing it to "handle_data" + self.handle_data(unichr(htmlentitydefs.name2codepoint[name])) + + +def read_from_url(url): + try: + con = urllib.urlopen(url) + except IOError, errmsg: + sys.stderr.write("Failed to open input (%s): %s\n" % (url, errmsg)) + sys.exit(1) + try: + data = con.read() + except IOError, errmsg: + sys.stderr.write("Failed to read from input (%s): %s\n" % (url, errmsg)) + sys.exit(2) + con.close() + return data + + +def get_date_string(timestamp): + # use locale encoding + try: + locale.setlocale(locale.LC_ALL, LOCALE) + except locale.Error, err_msg: + sys.stderr.write("Locales (%s) not found: %s\n" % (LOCALE, err_msg) \ + + " Maybe you should run 'aptitude install locales-all' on debian.\n") + localtime = time.localtime(timestamp) + return time.strftime(locale.nl_langinfo(locale.D_T_FMT), localtime) + + +def html_escape(text): + """Produce entities within text.""" + chars = [] + for c in text: + chars.append(HTML_ESCAPE_TABLE.get(c, c)) + return "".join(chars) + + +def get_data_from_html(html): + parser = EventParser() + # parse the html input + parser.feed(html) + return filtered_events(parser.events) + + +def filtered_events(events): + """ remove old or incomplete events """ + result = [] + for event in events: + # add an empty 'category', if it is not set + if not event.has_key('category'): + event['category'] = None + if not event.has_key('title'): + sys.stderr.write("Skipping event without a title\n"); + elif not (event.has_key('longitude') and event.has_key('latitude')): + sys.stderr.write(("Skipping event without long/lat: %(title)s\n" \ + % event).encode(INPUT_ENCODING)) + elif not event.has_key('time'): + sys.stderr.write(("Skipping event without date/time: %(title)s\n" \ + % event).encode(INPUT_ENCODING)) + elif not is_event_current(event["time"]): + # skipping events, that are too old or too far in the future + pass + else: + # the event is valid + result.append(event) + return result + + +# icon sizes depend on the current date and the date of the event +# use the timestamp "None" for the smallest icon +def get_icon_size(timestamp): + now = time.time() + if timestamp is None: + return ICON_SIZES["tiny"] + if timestamp >= now + 3600 * TIME_OFFSET_HOURS["coming"]: + return ICON_SIZES["small"] + elif timestamp >= now + 3600 * TIME_OFFSET_HOURS["soon"]: + return ICON_SIZES["medium"] + else: + return ICON_SIZES["big"] + + +def is_event_current(timestamp): + now = time.time() + if timestamp < now + 3600 * TIME_OFFSET_HOURS["today"]: + return False + elif timestamp >= now + 3600 * TIME_OFFSET_HOURS["future"]: + return False + else: + return True + + +def get_icon_url(category, timestamp): + if category in ICONS.keys(): + filename = ICONS[category] + else: + filename = ICONS["default"] + size = get_icon_size(timestamp) + return "%s/%s_%d.png" % (ICON_URL_PREFIX, filename, size) + + +def get_gml_from_data(data): + result = [] + # first line: the header for gml + result.append(['point', 'title', 'description', 'icon', 'iconSize', 'iconOffset']) + # add one line for each event + for place in group_sorted_events_by_location(data): + result.append([]) + event = place[0] + # escape some html entities + for item in ["title", "place", "organizer"]: + if event.has_key(item): + event[item] = html_escape(event[item]) + items = result[-1] + # the 'point' + items.append('%(latitude)s,%(longitude)s' % event) + # the 'title' + items.append('%(title)s' % event) + # the 'description' + description = '
    ' + # maybe only a date without time is given + description += "
  • Termin: %s
  • " % get_date_string(event["time"]) + description += '
  • Ort: %(place)s
  • ' % event + if event.has_key('organizer'): + description += '
  • Veranstalter: %(organizer)s
  • ' % event + description += '
  • ... mehr Infos
  • ' % event + if len(place) > 1: + # other events will take place here ... + description += '
  • Weitere Veranstaltungen:
      ' + # we add not more than three more events + num_events = min(MAX_EXTRA_EVENTS, len(place)-1) + for index in range(1, num_events+1): + other_event = place[index] + # show a small icon for each other event + description += '
    • ' \ + % get_icon_url(other_event["category"], None) + description += '%s: %s
    • ' \ + % (get_date_string(other_event["time"]), other_event["event_url"], html_escape(other_event["title"])) + description += '
  • ' + description += '
' + items.append(description) + # the 'icon' + items.append(get_icon_url(event['category'], event['time'])) + # 'iconSize' and 'iconOffset' + size = get_icon_size(event['time']) + # size of the icon + items.append('%d,%d' % (size, size)) + # offset of the middle of the icon + items.append('%d,%d' % (-size/2, -size/2)) + # turn the array into a string + return '\n'.join(['\t'.join(event) for event in result]) + + +def unicode2htmlentities(text): + result = "" + for c in text: + if ord(c) < 128: + result += c + else: + result += '&%s;' % htmlentitydefs.codepoint2name[ord(c)] + return result + + +def write_to_file(output_file, data): + try: + con = open(output_file, 'w') + except IOError, errmsg: + sys.stderr.write("Failed to open output file for writing (%s): %s" % (output_file, errmsg)) + sys.stderr.exit(3) + try: + con.write(unicode2htmlentities(data)) + # a final linebreak is necessary - otherwise openlayers ignores the last line + con.write("\n") + except IOError, errmsg: + sys.stderr.write("Failed to write to output file(%s): %s" % (output_file, errmsg)) + sys.stderr.exit(4) + con.close() + + +def is_same_location(event_a, event_b): + """ check if two events are located at the same place + beware: for now it does not take the name of the place into account. + It only compares latitude and longitude. + """ + if (event_a["longitude"] == event_b["longitude"]) \ + and (event_a["latitude"] == event_b["latitude"]): + return True + else: + return False + + +def group_sorted_events_by_location(events): + """ convert a list of events into a list of places - each being a list + of events happening at this location. + """ + places = [] + for event in events: + # we use this variable to store a (possibly) matching place + already_defined_place = None + for place in places: + if is_same_location(event, place[0]): + already_defined_place = place + if already_defined_place is None: + # create a new place (starting with the current event) + places.append([event]) + else: + # add it to the existing place + already_defined_place.append(event) + # sort the events of each place by time + def cmp_event(x, y): + if x["time"] < y["time"]: + return -1 + elif x["time"] == y["time"]: + return 0 + else: + return 1 + for place in places: + place.sort(cmp=cmp_event) + return places + + +if __name__ == '__main__': + if len(sys.argv) > 1: + input_file = sys.argv[1] + else: + input_file = IMPORT_URL + if len(sys.argv) > 2: + output_file = sys.argv[2] + else: + output_file = EXPORT_FILE + html_data = read_from_url(input_file) + data = get_data_from_html(html_data) + gml_data = get_gml_from_data(data) + write_to_file(output_file, gml_data) + diff --git a/osm/dynamic_markers/scripts/svg2png.sh b/osm/dynamic_markers/scripts/svg2png.sh new file mode 100755 index 0000000..6556fb0 --- /dev/null +++ b/osm/dynamic_markers/scripts/svg2png.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# +# convert an svg file into the useful png icon sizes: 12, 16 and 24px +# +# Parameter: input_file.svg output_prefix +# +# Copyright: 2010 by Lars Kruse +# License: GNU GPL v3 or higher (http://www.gnu.org/licenses/gpl-3.0.txt) +# + +set -eu + +CONVERTER=inkscape +SIZES="12 24 32 40" + + +test $# -ne 2 && echo >&2 "Invalid number of arguments: I expected exactly two" && exit 1 + +in_file="$1" +out_prefix="$2" + +test ! -e "$1" && echo >&2 "File not found: $1" && exit 2 + +# conversion +for size in $SIZES + do inkscape --without-gui --export-area-drawing \ + --export-height="$size" --export-width="$size" \ + --export-png="${out_prefix}_${size}.png" "$in_file" + done +