Changeset 8282 in genesis for nodes/make-map.py


Ignore:
Timestamp:
Aug 9, 2010, 9:08:03 PM (14 years ago)
Author:
rick
Message:

Working KML example, much nicer as all other formats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nodes/make-map.py

    r8280 r8282  
    6464
    6565def make_graph():
     66  f = open('kmlfile.kml', 'w')
     67  f.write("""
     68<?xml version="1.0" encoding="UTF-8"?>
     69<kml xmlns="http://earth.google.com/kml/2.0">
     70  <Document>
     71    <name>KML Samples</name>
     72    <open>1</open>
     73    <description>Unleash your creativity with the help of these examples!</description>
     74    <Style id="downArrowIcon">
     75      <IconStyle>
     76        <Icon>
     77          <href>http://maps.google.com/mapfiles/kml/pal4/icon28.png</href>
     78        </Icon>
     79      </IconStyle>
     80    </Style>
     81    <Style id="globeIcon">
     82      <IconStyle>
     83        <Icon>
     84          <href>http://maps.google.com/mapfiles/kml/pal3/icon19.png</href>
     85        </Icon>
     86      </IconStyle>
     87      <LineStyle>
     88        <width>2</width>
     89      </LineStyle>
     90    </Style>
     91    <Style id="transPurpleLineGreenPoly">
     92      <LineStyle>
     93        <color>7fff00ff</color>
     94        <width>4</width>
     95      </LineStyle>
     96      <PolyStyle>
     97        <color>7f00ff00</color>
     98      </PolyStyle>
     99    </Style>
     100    <Style id="yellowLineGreenPoly">
     101      <LineStyle>
     102        <color>7f00ffff</color>
     103        <width>4</width>
     104      </LineStyle>
     105      <PolyStyle>
     106        <color>7f00ff00</color>
     107      </PolyStyle>
     108    </Style>
     109    <Style id="thickBlackLine">
     110      <LineStyle>
     111        <color>87000000</color>
     112        <width>10</width>
     113      </LineStyle>
     114    </Style>
     115    <Style id="redLineBluePoly">
     116      <LineStyle>
     117        <color>ff0000ff</color>
     118      </LineStyle>
     119      <PolyStyle>
     120        <color>ffff0000</color>
     121      </PolyStyle>
     122    </Style>
     123    <Style id="blueLineRedPoly">
     124      <LineStyle>
     125        <color>ffff0000</color>
     126      </LineStyle>
     127      <PolyStyle>
     128        <color>ff0000ff</color>
     129      </PolyStyle>
     130    </Style>
     131    <Style id="transRedPoly">
     132      <LineStyle>
     133        <width>1.5</width>
     134      </LineStyle>
     135      <PolyStyle>
     136        <color>7d0000ff</color>
     137      </PolyStyle>
     138    </Style>
     139    <Style id="transBluePoly">
     140      <LineStyle>
     141        <width>1.5</width>
     142      </LineStyle>
     143      <PolyStyle>
     144        <color>7dff0000</color>
     145      </PolyStyle>
     146    </Style>
     147    <Style id="transGreenPoly">
     148      <LineStyle>
     149        <width>1.5</width>
     150      </LineStyle>
     151      <PolyStyle>
     152        <color>7d00ff00</color>
     153      </PolyStyle>
     154    </Style>
     155    <Style id="transYellowPoly">
     156      <LineStyle>
     157        <width>1.5</width>
     158      </LineStyle>
     159      <PolyStyle>
     160        <color>7d00ffff</color>
     161      </PolyStyle>
     162    </Style>
     163    <Style id="noDrivingDirections">
     164      <BalloonStyle>
     165        <text><![CDATA[
     166          <b>$[name]</b>
     167          <br /><br />
     168          $[description]
     169        ]]></text>
     170      </BalloonStyle>
     171    </Style>
     172    <Folder>
     173      <name>Paths</name>
     174      <visibility>0</visibility>
     175      <description>Examples of paths. Note that the tessellate tag is by default
     176        set to 0. If you want to create tessellated lines, they must be authored
     177        (or edited) directly in KML.</description>
     178    """)
     179
    66180  poel = {}
    67181  link_type = {}
     
    94208      lam, phi = rd2etrs(datadump['rdnap_x'], datadump['rdnap_y'])
    95209      node[host] = (lam, phi)
     210      f.write("""
     211                <Placemark>
     212                        <name>Blue Icon</name>
     213                        <description>Just another blue icon.</description>
     214                        <styleUrl>./styles.kml#blueIcons</styleUrl>
     215                        <Point>
     216                                <coordinates>%s,%s,630</coordinates>
     217                        </Point>
     218                </Placemark>
     219   """ % (lam, phi))
    96220      nodes += [("POINT(%s, %s)" % (lam, phi))]
    97221  except (KeyError, ValueError), e:
     
    113237    for index,lid in enumerate(leden[:-1]):
    114238      for buur in leden[index + 1:]:
    115         links += ["LINESTRING(%s %s,%s %s)" % (node[lid][0], node[lid][1], node[buur][0], node[buur][1])]
    116 
    117   f = open('wktfile.txt', 'w')
    118   f.write("GEOMETRYCOLLECTION(\n")
    119   f.write(",\n".join(nodes))
    120   f.write(",\n".join(links))
    121   f.write(")\n")
     239        f.write("""
     240      <Placemark>
     241        <name>Untessellated</name>
     242        <visibility>0</visibility>
     243        <description><![CDATA[If the <tessellate> tag has a value of 0, the line follow a simple straight-line path from point to point]]></description>
     244        <LineString>
     245          <tessellate>0</tessellate>
     246          <coordinates> %s, %s, 0
     247            %s , %s, 0 </coordinates>
     248        </LineString>
     249      </Placemark>
     250      """ % (node[lid][0], node[lid][1], node[buur][0], node[buur][1]))
     251  f.write("""
     252    </Folder>
     253  </Document>
     254</kml>
     255  """)
    122256  f.close()
    123257
Note: See TracChangeset for help on using the changeset viewer.