%!PS % Acme Mark to kml converter % ========================== % by Don Lancaster %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Copyright c 2013 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 2.1 % This is a PostScript format converter that reads the url of a marked Acme Mapper and % converts it into a .kml path command set. % The input file must contain the Acme URL and must be named markurl.txt %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /sourcefilename (markurl.txt) store /targetfilename (kmlpathfrag.txt) store /filenameprefix (C:\\Users\\MrDon\\Desktop\\smooth kml\\) store /inputstring 8000 string store /markcount 0 store % postfix for mark counter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % gonzo excerpts -- full gonzo not used /mt {moveto} store /black {0 setgray} store % timing utilities. use stopwatchon and stopwatchoff for simple % one shot timing. For multiple time totals, use resettimer % starttimer stoptimer ... starttimer stoptimer reporttimer /stopwatchoff {stoptimer reporttimer} def % for single shots /stopwatchon {resettimer starttimer} def % for single shots /reporttimer {mytime 1000 div (\rElapsed time: ) print 20 string cvs print ( seconds.\r) print flush} def % to host /resettimer {/mytime 0 def} def % reset timer /starttimer {usertime /mytimenow exch def} def % add to time so far /stoptimer {usertime mytimenow sub /mytime exch mytime add def} def % for multiple timing intervals % mergestr merges the two top stack strings into one top stack string /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def % [yourarray] makestring converts an array to a string... /makestring {dup length string dup % new string of right size /NullEncode filter % make a file out of string 3 -1 roll {1 index exch write} forall pop } def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % capture markurl to instring.... /infilename filenameprefix sourcefilename mergestr store infilename (r) file /infile2 exch store infile2 4000 string readstring {badreadstring} if /instring exch store infile2 closefile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % open kmlpathfrag text output file /outfilename filenameprefix targetfilename mergestr store outfilename (w+) file /outfile2 exch store outfile2 10 write outfile2 ( ) writestring outfile2 10 write %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12345 % do progressive repeated search, stripping and reversing latlon instring (marker0=) % initial search string 30 { search % repeat search for markcount and breakout not { pop exit } if % no more data pop % previous string pop % markerstring (%2C) search % repeat search for lat lon border not { readerror } if % later error /lat exch store pop % search marker (%2C) search % repeat search for lon end not {readerror } if % later error /lon exch store pop % search marker outfile2 10 write outfile2 lon writestring outfile2 (,) writestring outfile2 lat writestring outfile2 10 write % remainder of string is here /markcount markcount 1 add store (marker) markcount 10 string cvs mergestr (=) mergestr markcount == } repeat % normally done 26 or fewer times %%%%%%%%%%%%%%%%%% % complete text output file outfile2 10 write outfile2 ( ) writestring outfile2 10 write outfile2 closefile % eof