Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

POI stuff

  • Loading branch information...
commit b79c9d08112a0af8f797f48ffe683f08f390fbca 1 parent b6de890
@systemed authored
Showing with 116 additions and 77 deletions.
  1. +13 −0 LICENCE.txt
  2. +8 −3 README.txt
  3. +3 −3 halcyon.mxml
  4. +21 −31 halcyon.tmproj
  5. BIN  icons/airport.png
  6. BIN  icons/atm.png
  7. BIN  icons/bar.png
  8. BIN  icons/bus_stop.png
  9. BIN  icons/cafe.png
  10. BIN  icons/convenience.png
  11. BIN  icons/fast_food.png
  12. BIN  icons/fire_station.png
  13. BIN  icons/hospital.png
  14. BIN  icons/hotel.png
  15. BIN  icons/icons_grid.png
  16. BIN  icons/parking.png
  17. BIN  icons/pharmacy.png
  18. BIN  icons/pharmacy_dispensing.png
  19. BIN  icons/police.png
  20. BIN  icons/post_box.png
  21. BIN  icons/pub.png
  22. BIN  icons/recycling.png
  23. BIN  icons/restaurant.png
  24. BIN  icons/school.png
  25. BIN  icons/station.png
  26. BIN  icons/taxi.png
  27. BIN  icons/telephone.png
  28. +8 −10 net/systemeD/halcyon/Map.as
  29. +33 −20 net/systemeD/halcyon/POI.as
  30. +9 −5 net/systemeD/halcyon/connection/AMFConnection.as
  31. +1 −1  net/systemeD/halcyon/connection/Connection.as
  32. +8 −0 net/systemeD/halcyon/styleparser/ImageLoader.as
  33. +12 −4 net/systemeD/halcyon/styleparser/RuleSet.as
View
13 LICENCE.txt
@@ -0,0 +1,13 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar
+ 14 rue de Plaisance, 75014 Paris, France
+ 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
11 README.txt
@@ -2,7 +2,7 @@
Here's some embryonic unfinished stuff to play with.
-This is a live OSM renderer written in AS3 which will one day grow into a beautiful map editor.
+This is a live OSM renderer written in AS3 which will one day grow into a beautiful map editor. It's rules-based (like, say, Mapnik) and does dotted lines, text on a path, casing, icons for POIs, all of that.
=== What you'll need ===
@@ -15,10 +15,15 @@ This is a live OSM renderer written in AS3 which will one day grow into a beauti
=== How to compile and run ===
Compiling:
-mxmlc -managers=flash.fonts.AFEFontManager -output=/path/to/halcyon.swf /path/to/halcyon.mxml
+* fcsh
+ - launches the Flex Compiler SHell
+* mxmlc -managers=flash.fonts.AFEFontManager -output=/path/to/halcyon.swf /path/to/halcyon.mxml
+ - compile for the first time
+* compile 1
+ - compile each subsequent time (_much_ faster than using mxmlc every time)
Running:
-* Make sure test.yaml is in the same directory as halcyon.swf
+* Make sure test.yaml and icons/ are in the same directory as halcyon.swf
* Open halcyon.swf in your browser
=== Some other stuff you might need to know ===
View
6 halcyon.mxml
@@ -79,9 +79,9 @@
// add debug field
var t:TextField=new TextField();
- //t.width=400; t.height=100; t.border=true;
- //t.multiline=true;
- //_root.addChild(t);
+ t.width=400; t.height=100; t.border=true;
+ t.multiline=true;
+ _root.addChild(t);
Globals.vars.debug=t;
}
View
52 halcyon.tmproj
@@ -6,45 +6,33 @@
<array>
<dict>
<key>filename</key>
- <string>net/systemeD/halcyon/AMFConnection.as</string>
- <key>lastUsed</key>
- <date>2009-05-30T13:59:09Z</date>
- </dict>
- <dict>
- <key>filename</key>
- <string>net/systemeD/halcyon/Connection.as</string>
- <key>lastUsed</key>
- <date>2009-05-30T13:59:04Z</date>
- </dict>
- <dict>
- <key>filename</key>
- <string>net/systemeD/halcyon/Globals.as</string>
- <key>lastUsed</key>
- <date>2009-05-30T15:21:19Z</date>
- </dict>
- <dict>
- <key>filename</key>
<string>net/systemeD/halcyon/Map.as</string>
<key>lastUsed</key>
- <date>2009-05-30T15:21:19Z</date>
+ <date>2009-06-01T11:58:41Z</date>
</dict>
<dict>
<key>filename</key>
- <string>net/systemeD/halcyon/Node.as</string>
+ <string>net/systemeD/halcyon/POI.as</string>
<key>lastUsed</key>
- <date>2009-05-30T13:59:07Z</date>
+ <date>2009-06-01T12:11:15Z</date>
+ <key>selected</key>
+ <true/>
</dict>
<dict>
<key>filename</key>
- <string>net/systemeD/halcyon/POI.as</string>
+ <string>net/systemeD/halcyon/WayUI.as</string>
<key>lastUsed</key>
- <date>2009-05-30T15:09:53Z</date>
+ <date>2009-06-01T11:58:42Z</date>
</dict>
<dict>
- <key>filename</key>
- <string>net/systemeD/halcyon/Way.as</string>
- <key>lastUsed</key>
- <date>2009-05-30T15:16:50Z</date>
+ <key>expanded</key>
+ <true/>
+ <key>name</key>
+ <string>connection</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string>net/systemeD/halcyon/connection</string>
</dict>
<dict>
<key>expanded</key>
@@ -58,11 +46,13 @@
</dict>
<dict>
<key>filename</key>
+ <string>net/systemeD/halcyon/Globals.as</string>
+ </dict>
+ <dict>
+ <key>filename</key>
<string>halcyon.mxml</string>
<key>lastUsed</key>
- <date>2009-05-30T15:21:19Z</date>
- <key>selected</key>
- <true/>
+ <date>2009-06-01T11:49:17Z</date>
</dict>
</array>
<key>fileHierarchyDrawerWidth</key>
@@ -72,6 +62,6 @@
<key>showFileHierarchyDrawer</key>
<true/>
<key>windowFrame</key>
- <string>{{272, 182}, {710, 564}}</string>
+ <string>{{268, 182}, {710, 564}}</string>
</dict>
</plist>
View
BIN  icons/airport.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/atm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/bar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/bus_stop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/cafe.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/convenience.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/fast_food.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/fire_station.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/hospital.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/hotel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/icons_grid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/parking.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/pharmacy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/pharmacy_dispensing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/police.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/post_box.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/pub.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/recycling.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/restaurant.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/school.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/station.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/taxi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  icons/telephone.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
18 net/systemeD/halcyon/Map.as
@@ -19,7 +19,7 @@ package net.systemeD.halcyon {
public const MINSCALE:uint=13; // don't zoom out past this
public const MAXSCALE:uint=19; // don't zoom in past this
- public var ruleset:RuleSet=new RuleSet(); // rules
+ public var ruleset:RuleSet=new RuleSet(redrawPOIs); // rules
public var ways:Object=new Object(); // geodata
public var nodes:Object=new Object(); // |
@@ -84,7 +84,7 @@ package net.systemeD.halcyon {
}
public function gotEnvironment(r:Object):void {
- init(51.45889,-0.21476);
+ init(52.022,-1.2745);
}
// ------------------------------------------------------------------------------------------
@@ -205,14 +205,12 @@ package net.systemeD.halcyon {
// Redraw all items, zoom in and out
public function redraw():void {
-// addDebug("redrawing");
-// var s:String='';
- for each (var w:WayUI in ways) {
- w.redraw();
-// s+=w.id+",";
- }
-// addDebug(s);
- // ** do POIs, etc.
+ for each (var w:WayUI in ways) { w.redraw(); }
+ for each (var p:POI in pois) { p.redraw(); }
+ }
+
+ public function redrawPOIs():void {
+ for each (var p:POI in pois) { p.redraw(); }
}
public function zoomIn():void {
View
53 net/systemeD/halcyon/POI.as
@@ -12,8 +12,9 @@ package net.systemeD.halcyon {
private var node:Node;
public var map:Map; // reference to parent map
- public var icon:Sprite; // instance in display list
+ public var icon:Bitmap; // instance in display list
public var name:Sprite; // |
+ private var iconname:String=''; // name of icon
[Embed(source="fonts/DejaVuSans.ttf", fontFamily="DejaVu", fontWeight="normal", mimeType="application/x-font-truetype")]
public static var DejaVu:Class;
@@ -22,34 +23,46 @@ package net.systemeD.halcyon {
public function POI(node:Node, map:Map) {
this.map = map;
this.node = node;
-
-map.addDebug("POI "+node.id);
-
- // place icon on map
- var tags:Object = node.getTagsCopy();
+ redraw();
+ }
+
+ public function redraw():void {
+ var tags:Object = node.getTagsCopy();
var styles:Array=map.ruleset.getStyle(true,tags,map.scale);
var ps:PointStyle=styles[1];
- if (ps) {
-map.addDebug("pointstyle found");
- if (ps.icon && ps.icon!='') {
-map.addDebug("placing "+ps.icon);
- var loader:Loader = new Loader();
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedIcon);
- loader.loadBytes(map.ruleset.images[ps.icon]);
+ if (ps && ps.icon && ps.icon!='') {
+ if (ps.icon!=iconname) {
+ // 'load' icon (actually just from library)
+ if (map.ruleset.images[ps.icon]) {
+ var loader:Loader = new Loader();
+ loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedIcon);
+ loader.loadBytes(map.ruleset.images[ps.icon]);
+ iconname=ps.icon;
+ }
+ } else {
+ // already loaded, so just reposition
+ updatePosition();
+ iconname=ps.icon;
}
+ } else if (iconname!='') {
+ // not rendered any more, so remove
+ var l:DisplayObject=map.getChildAt(11);
+ Sprite(l).removeChild(icon);
+ iconname='';
}
}
private function loadedIcon(event:Event):void {
-map.addDebug("loadedIcon");
- var bitmap:Bitmap = Bitmap(event.target.content);
+ icon = Bitmap(event.target.content);
var l:DisplayObject=map.getChildAt(11);
- bitmap.x=map.lon2coord(node.lon);
- bitmap.y=map.latp2coord(node.latp);
- Sprite(l).addChild(bitmap);
+ Sprite(l).addChild(icon);
+ updatePosition();
+ }
+
+ private function updatePosition():void {
+ icon.x=map.lon2coord(node.lon);
+ icon.y=map.latp2coord(node.latp);
}
-
- // redraw
}
}
View
14 net/systemeD/halcyon/connection/AMFConnection.as
@@ -53,6 +53,8 @@ package net.systemeD.halcyon.connection {
var relationlist:Array=r[2];
var id:Number, version:uint;
+ // Load ways
+
for each (var w:Array in waylist) {
id=Number(w[0]);
version=uint(w[1]);
@@ -63,15 +65,17 @@ package net.systemeD.halcyon.connection {
}
}
+ // Create POIs
+
for each (var p:Array in pointlist) {
- id = Number(w[0]);
- version = uint(w[4]);
+ id = Number(p[0]);
+ version = uint(p[4]);
var node:Node = getNode(id);
if ( node == null ) {
- var lat:Number = Number(w[2]);
- var lon:Number = Number(w[1]);
- var tags:Object = w[3];
+ var lat:Number = Number(p[2]);
+ var lon:Number = Number(p[1]);
+ var tags:Object = p[3];
node = new Node(id, version, tags, lat, lon);
setNode(node);
}
View
2  net/systemeD/halcyon/connection/Connection.as
@@ -65,7 +65,7 @@ package net.systemeD.halcyon.connection {
}
protected function unregisterPOI(node:Node):void {
- var index:uint = pois.indexOf(node)
+ var index:uint = pois.indexOf(node);
if ( index >= 0 ) {
pois.splice(index,1);
}
View
8 net/systemeD/halcyon/styleparser/ImageLoader.as
@@ -1,5 +1,13 @@
package net.systemeD.halcyon.styleparser {
+ /*
+ === ImageLoader ===
+
+ This simply allows us to store a filename in the URLLoader object,
+ so that the responder knows which image has just been loaded.
+
+ */
+
import flash.events.*;
import flash.net.*;
View
16 net/systemeD/halcyon/styleparser/RuleSet.as
@@ -9,9 +9,15 @@ package net.systemeD.halcyon.styleparser {
public var rules:Array=new Array(); // list of rules
public var images:Object=new Object(); // loaded images
+ private var iconCallback:Function=null; // function to call when all icons loaded
+ private var iconsToLoad:uint=0; // number of icons left to load (fire callback when ==0)
// variables for name, author etc.
+ public function RuleSet(f:Function=null):void {
+ iconCallback=f;
+ }
+
// returns array of ShapeStyle,PointStyle,TextStyle,ShieldStyle
public function getStyle(isPoint:Boolean,tags:Object,scale:uint):Array {
var ss:ShapeStyle;
@@ -21,8 +27,8 @@ package net.systemeD.halcyon.styleparser {
for each (var rule:* in rules) {
if ( isPoint && rule is ShapeRule) { continue; }
if (!isPoint && rule is PointRule) { continue; }
- if (scale>rule.minScale && !isPoint) { continue; }
- if (scale<rule.maxScale && !isPoint) { continue; }
+ if (scale>rule.minScale) { continue; }
+ if (scale<rule.maxScale) { continue; }
if (rule.test(tags)) {
if (rule is ShapeRule && rule.shapeStyle) { ss=rule.shapeStyle; }
if (rule is PointRule && rule.pointStyle) { ps=rule.pointStyle; }
@@ -96,11 +102,13 @@ package net.systemeD.halcyon.styleparser {
public function loadImages():void {
var ps:PointStyle;
+
for each (var rule:* in rules) {
if (!(rule is PointRule)) { continue; }
if (!(rule.pointStyle)) { continue; }
if (!(rule.pointStyle.icon)) { continue; }
+ iconsToLoad++;
var request:URLRequest=new URLRequest(rule.pointStyle.icon);
var loader:ImageLoader=new ImageLoader();
loader.dataFormat=URLLoaderDataFormat.BINARY;
@@ -116,9 +124,9 @@ package net.systemeD.halcyon.styleparser {
// data handler
private function loadedImage(event:Event):void {
- Globals.vars.debug.appendText("Target is "+event.target+", name"+event.target.filename+"\n");
images[event.target.filename]=event.target.data;
+ iconsToLoad--;
+ if (iconsToLoad==0 && iconCallback!=null) { iconCallback(); }
}
-
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.