📄 default.htm
字号:
<img src="images/tiles2.jpg" /></p>
<ul>
<li>level 1 earth tiles</li>
<li>level 2 earth tiles. see how the image outside of the tiles is low res</li>
</ul>
<h3>
On the 5th day, "let there be boundaries"
</h3>
<p>
so that takes care of working with the BlueMarbleTextures. the next set of data
included Boundaries. WW comes with 5 sets of boundary data for Countries, Canada,
Norway, Sweden, and US States. these boundaries are just rendered as line lists
above the surface of the earth. there are 2 binary files for each type of boundary
: index and data. the index file provides info on how to parse the data file. to
read these files you just use the BinaryReader of .NET. so the first attempt i made
was to read in the boundary data, load that into VertexBuffers, and then render
the lines. but this took way too long, and it barely rendered at all. when zoomed
out the boundaries just disappeared. as you zoomed in, then they would appear. i
think this was because the zoomed out view had alot of lines that had their starting
and end points being the same. WW gets around this by doing a projection of each
line into the viewport and seeing if the start and end points are some distance
a part. if not, it just moves on to the next point. this allows WW to render less
detailed boundaries far away, and more detailed boundaries as you zoom in. i could
not do this on the device because that would require too many calculations during
render. instead, i was going to only load one set of vertices during init, and just
render the same set each time. to come up with that set of vertices i wrote another
desktop app to process the files and shrink them down (e.g. 2.5 megs of boundary
data down to about 25K). then i used that boundary file on the device instead. this
worked great for all the boundaries except for the US. you could see the boundaries
zoomed out, as well as when zoomed in. the US boundaries get messed up for some
reason, so that some of the state boundaries overlap (e.g. the TX panhandle doesnt
look like a panhandle at all).
</p>
<p>
<img src="images/countries.jpg" />
<img src="images/usOut.jpg" />
</p>
<ul>
<li>country boundaries</li>
<li>US and canadian boundaries</li>
</ul>
<p>
<img src="images/usIn.jpg" /> <img src="images/norSwe.jpg" /></p>
<ul>
<li>zoomed in US boundaries. see how the TX panhandle is jacked</li>
<li>boundaries of norway and sweden ... like i care</li>
</ul>
<p>
since i was already working with lines, went ahead and implemented the lat/lon lines,
plus the equator and tropics. this involved just using LineLists, the same as above.
WW had the code to do those calculatins, and i just do those during init for different
levels of altitude. e.g. one level of lat/lon lines has them all spaced 10 degrees
apart, the next is 5, and the most detailed is 2 (WW goes one more level to 1 degree
separation). WW also renders labels on the lat/lon lines and positions each label
based on the view. this requires the calculation to happen during rendering, so
i chose not to render those labels for the sake of speed.
</p>
<p>
<img src="images/latLon.jpg" />
<img src="images/northPole.jpg" /></p>
<ul>
<li>equator and the tropics</li>
<li>latitude and longitude lines</li>
</ul>
<h3>
On the 6th day, "let the places have names"
</h3>
<p>
the previous data accounted for data, so i moved on to working with the placename
data set. from having problems reading in the 10 megs of boundary data, i knew that
i could not read in the 200 megs of placename data. just looking at the file system,
i could see that some of the placename sets had a similar tile row/col setup that
was used for textures. i didnt want to mess with that anymore so i just deleted
those files. getting rid of those took the set down to about 3 megs, and those 3
megs would still provide alot of placenames. the files ended up being really similar
to the boundary files above. they were binary and parsed by using the BinaryReader.
now init just reads those files, and stores them in memory. as you zoom in, the
placenames are rendered accordingly. all i do is a little lat/lon check against
the viewrange to figure out what placenames should be rendered for the current view.
since the placenames were held in memory, i also implemented the 'Find Place' functionality.
so you can search for a place by name, and then if you select it, the view will
be rotated to center on that location. the only other changes i made to this regard
settings. the desktop stores settings in an XML file. to read that data in i used
the new XmlSerializer class for CFv2. first i created the corresponding serialization
classed by using XSD.exe. then, i used the XmlSerializer class with an instance
of that type to deserialize the XML into objects. this worked great but was rather
expensive because the XmlSerializer has to do alot of reflection. to get past this
i just used codegen instead. wrote a quick and dirty XSLT file to transform the
XML into C# code that would create an array that looked just like the collection
of objects that the XmlSerializer would return. this is pretty ugly, but its fast
and cheap; so i used this technique a couple more times later on. and speaking of
collections. was telling a coworker about how much i liked VS 2005 and he asked
if i had used generics yet. i actually had not because i was somewhat scared of
them based on my early C++ experience with templates as a kid. but he guilted me
into trying them ... and they kick ass. it only took like 5 minutes to understand
them in a little test project, and then about 5 more minutes to convert this existing
codebase over. now i just have to retrain myself to not use the ArrayList and Hashtable
unless absolutely necessary.
</p>
<p>
<img src="images/place0.jpg" />
<img src="images/place1.jpg" />
</p>
<ul>
<li>level 0 placenames</li>
<li>level 1 placenames</li>
</ul>
<p>
<img src="images/place2.jpg" />
<img src="images/findPlace.jpg" border="1" /></p>
<ul>
<li>level 2 placenames</li>
<li>placename search form</li>
</ul>
<p>
we'll get to the seventh day later on, but there are more features to add. NOTE
the six days reference was just an attempt at humor. i'm not religious. nor do the
days represent actual days. this took me about a month to do. i was timeboxed from
when i got the device until MEDC happened. i wanted to get this finished before
MEDC so that i could work on something else afterward. all in all, i probably spent
about 100 hours of my spare time. now that the core data sets were being used, i
went ahead and moved on to work with some of the add-on data sets including landmarks
and flags. i did landmarks 1st because it was smaller. all it does is go through
each landmark and render an image at the corresponding spot. i brought the wikipedia
URLS over as well, but am not checking the stylus clicks to spawn the URL or provide
descriptive text. flags of the world ended up being exactly the same. the only problem
with flags is that it was really memory intensive. mitigated this a little by making
the images smaller. regardless, i had to resize the images because the width and
height of the images were not powers of 2 and varied for each flag image. so all
i did was resize them to a size that MD3DM could load and render appropriately.
</p>
<p>
<img src="images/landmarks.jpg" />
<img src="images/flags.jpg" /></p>
<ul>
<li>landmarks</li>
<li>flags of the world. <singing> its a small world ... </singing></li>
</ul>
<h3>
MapPoint WebService</h3>
<p>
landmarks and flags were add-ons to WW, albeit boring ones. i needed to spice it
up just a bit. something that i had been thinking about was the data sources that
WW uses. it gets environmental data from MODIS and satellite images from various
sources including TerraServer. my next thought was that it should also get data
from the MapPoint Web Service. the vision i had involved 3 different scenarios :
Points, Lines, and Maps. MapPoint has the Address service which you can use to get
lat/lon for an address. with the lat/lon, then you can render that spot on the Earth
either as a Placename or an Add-on like Landmarks and Flags. also, the Address service
can return 'areas of interest' around a certain lat/lon. so when you are zoomed
in really close on the map, then it could call it to the MapPoint WS and plot nearby gas stations / coffee shops on the map. they also provide a Route web service for
directions. the directions come back with lat/lon coordinates for when you turn
a corner, so this would allow you to plot the travel course just like boundaries
are rendered. finally, you can get a Map tile back as an image, and then render
that on one of the tiles, instead of using the satellite imagery. as a proof of
concept, i just decided to plot out Placenames for Hooters restaurants</p>
<h3>
Hooters</h3>
<p>
this add the locations of Hooters restaurants as Placenames in WW. it works in both
the desktop version and on the device. first, i went to Hooters website and copied
all the addresses for their US restaurants. then i did some manual labor to work
that into an XML format. next, i wrote a desktop application to submit those addresses
to the MapPoint WS and get back the lat/lon for each restaurant. then i had the
desktop app write that data to the binary Placename format. for the index file,
i just used one of the preexisting ones from US city placenames. finally, i added
extended the Placenames.xml config file to include the new Hooters placename data.
to get it to work on the device i just copied the data file over and added the setting
to include that DataSet. now you can easily see where the Hooters restaurants are
throughout the US. now if somebody would just provide me an XML file with the addresses
to all the strip clubs throughout the world ...</p>
<p>
<img src="images/hooters.jpg" /> <img src="images/hootersTx.jpg" /></p>
<ul>
<li>florida hooters! i've only been to one of those</li>
<li>texas hooters! been to all of those</li>
</ul>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -