NetLogo version NetLogo 4.1beta1
Running with NetLogoLite.jar version 411.
NetLogo Version: NetLogo 4.1beta1
;; SUMMARY ;;;; Uses color-processing to reverse-render a google map ;; COPYRIGHT & LICENSE ;;;; Copyright (C) 2005 James P. Steiner ;;;; Some Rights Reserved. ;;;; Creative Commons Attribution-NonCommercial-ShareAlike License v. 2.0. ;;;; Visit http://creativecommons.org/licenses/by-nc-sa/2.0/ for more information. ;; APPLET DIMENSIONS (width x height) ;;;; 500 x 500 ;; GOOGLE MAP DATA Exerpt ;;;; Copyright (C) 2005 Google, Inc. ;; globals [ filename ] to go let side-look-scaling 1 ;; make bigger for higher-res maps every .02 [ ifelse ( [pcolor] of patch-left-and-ahead 45 2 = brown and [pcolor] of patch-right-and-ahead 45 2 != brown ) [ rt 15 ][ ifelse ( [pcolor] of patch-right-and-ahead 45 2 = brown and [pcolor] of patch-left-and-ahead 45 2 != brown ) [ lt 15 ][ set color green ] ] ifelse ( [pcolor] of patch-ahead .5 = brown ) [ set color orange rt one-of [ -135 -90 -45 45 90 135 180 ] ] [ let turns (list patch-left-and-ahead 90 (7 * side-look-scaling) patch-right-and-ahead 90 (7 * side-look-scaling) ) set turns filter [ [pcolor] of ?1 = white ] turns if turns !=  and random 10 = 0 [ set turns one-of turns set heading towards turns ] jump .5 ] ] end to setup ca let known-paths [ "./" "./models/" "./images/" "../models/" "../images/" ] let basename "north40thmap.png" let paths-to-try length known-paths set filename false let index 0 while [ index < paths-to-try ] [ if file-exists? (word (item index known-paths) basename) [ set filename (word (item index known-paths) basename) set index paths-to-try ] set index index + 1 ] if filename = false [ set filename user-file ] if filename = false [ stop ] import-pcolors filename pause ask patches [ ;; set pcolor pcolor - pcolor mod 10 + 5 if pcolor = 7.9 [ set pcolor brown ] ] pause ask patches [ ;; set pcolor pcolor - pcolor mod 10 + 5 if shade-of? pcolor brown [ set pcolor brown ] ] pause ask patches [ ;; set pcolor pcolor - pcolor mod 10 + 5 if not shade-of? pcolor brown [ set pcolor white ] ] pause ask patches [ let c count neighbors with [ pcolor = white] if c >= 5 and c <= 7 [ set pcolor white ] ] pause ask patches with [ pcolor = brown] [ if any? neighbors with [ pcolor = white ] [ let shade count neighbors with [ pcolor = white ] set pcolor brown + (shade / 8) * 5 ] ] pause ask patches with [ (abs pxcor = max-pxcor ) or ( abs pycor = max-pycor ) ] [ set pcolor brown ] pause if load-overlay-with-setup? [ load-overlay ] ask n-of 10 patches with [ pcolor = white ] [ sprout 1 [ set size 4 set color green set shape "circle" set label who set label-color black ] ] end to clear-half-overlay ;; the drawing layer is selectively erased to reveal the underlying patch colors ;; since the drawing pen is 1 pixel, but the patches can be many pixels, ;; and since there is no way for a model to know how many pixels wide the patches are ;; this routine uses a kludge: ;; Theoretically, a turtle draws a series of squares of decending size, ;; erasing a 1 pixel line as it goes. The squares reduce in size by only a fraction of ;; the patch, thus erasing all the pixels of the patch. ;; In Practical terms, things are faster if you draw fewer lines using a fatter pen. ;; So, pixels-per-patch is 3 (for 5 pixel patches) and overdraw is also three. ;; The beauty of this method is that it does not break when the model ;; pixels-per-patch is changed slightly, so it balances flexibility with speed. ;; NOTE: to accomodate diagonal wiping, some overdrawing is required! ;; it ends up missing bits on larger patches, and over-erasing smaller ones. ;; change the local variable "pixels-per-patch" and overdraw to adjust this ;; procedure ;; for different patch sizes. let pixels-per-patch 3 let overdraw 3 let decrement 1 / pixels-per-patch crt 1 [ home set heading 0 let stroke 0 set pen-size overdraw pe repeat 2 [ set stroke max-pycor + (decrement * .5 * (pixels-per-patch - 1)) ;; from 0 to exact edge, must go 1/2 patch more! repeat 3 [ jump stroke rt 90 ] repeat pixels-per-patch * max-pycor [ set stroke stroke - decrement repeat 2 [ jump stroke rt 90 ] ] home set heading 180 ] die ] end to clear-half-overlay-2 crt 1 [ hide-turtle set color black set pen-size 5 setxy max-pxcor max-pycor set heading 180 pe let stroke world-height let decrement 2 * world-width / world-height let way 1 repeat world-width [ jump stroke rt 135 * way jump 1.4 setxy pxcor pycor rt 45 * way set stroke stroke - decrement set way way * -1 ] die ] end to load-overlay import-drawing filename end to clear-overlay clear-drawing end to pause if slow-conversion? [ wait 2 ] end
View or download the complete model file (to download: right-click, save-link-as):
-- Download google-maps-import_2009 --