/clubMap

comment(s) 

MapPoint .NET (Web Service) and PocketPC (Wireless)

http://www.brains-N-brawn.com/clubMap 3/24/02 casey chesnut

NOTE the live demo will only work up until my MapPoint .NET beta time runs out, which is either April 1st, or a couple weeks afterwards

NOTE a sense of humor is required!

Purpose

Just over a month, Mark Lucovsky (HailStorm Architect) contacted me about /myVoices (VoiceXML + .NET MyServices SDK) dev article. He's been on the .NET show a couple times, but I just watch to see Erica :) Nevermind the unwarranted media beating they are taking, HailStorm is the most insanely cool thing ive worked with. Regardless, they liked it; so check it out: http://www.brains-N-brawn.com/myVoices . Since I had their attention, asked to get in on this beta, since they typically disregard my beta requests ... but not this time! Still waiting to get into the Speech .NET beta, for SALT <insert throat clearing sound here> ... Then, a day after he contacted me, I moved; and my server was down for an entire month, while waiting to get a business DSL hookup. Got it back up, and then my devbox was down for a week, migrating to XP and .NET release, as well as overheating a CPU, which is why my live video feed is not live as I write this. Then today, get a call from MS about the MapPoint .NET beta, saying ive only got 1.5 weeks left, and would I like an extension. I'm like 'hell yes'! And it just so happened that a co-worker came up with a compelling idea for me to work on too. So im later in the game than usual, but here ya go

Install

Downloaded MapPoint .NET SDK and installed. Skimmed through the Help file. Thats all you get, there were no sample code or bits (because it is a web service). Actually, there was sample code embedded as text in the help document, which leads to the next section

Samples (NOTE these are all rehashed from MS MapPoint .NET help file, my stuff is further down)

The samples as text were useless, so had to set them up to run. Made a web form app and added the web reference to MapPoint .NET staging server. Then just went down the list of samples they provided, converting to codebehind model

1) Find | Find.aspx | Find.aspx.cs | ErrorPage.aspx

lat. 40.4442467681959 long. -79.9930539515772

2) Map | Map.aspx | Map.aspx.cs | MapFromSession.aspx | MapFromSession.aspx.cs

if terrorists (aka adult webmasters) want to take down my server, that is where they should drop the bomb

3) Disambiguator | Disambiguator.aspx | Disambiguator.aspx.cs | GlobalPage.cs | web.config.xml

(NOTE: Disambiguator is NOT a word, no matter how many times you have heard it used in anime)

4) RouteMap | RouteMap.aspx | RouteMap.aspx.cs

5) IntPoint | IntPoint.aspx | IntPoint.aspx.cs

6) CenterClick | CenterClick.aspx | CenterClick.aspx.cs

INITIAL THOUGHT this is way too easy so far, any vb monkey could do this. and why are vb samples always 1st now? cause they whined so loudly?

Now that its all color-coded for me, and all the HTML crap is out of the way, I can look at some code and see what is going on; then start building my own

Idea

NOTE: This is where the sense of humor is required ... If you didnt know, I have some of the best, most high tech, free adult sites on the web. (NOTE: I do not link to any of these sites in the demo, NOR in this article, for your protection)  .NET of course, doing stuff my competitors cant in whatever spare environments they use

So im pretty open-minded and like to work with the same. My coworker and ive been joking around, and he knows about my illigetimate sites. So when im whining about having no MapPoint ideas, he throws out strip clubs. Once again, I'm like 'hell yes'! Brand new in PA, from TX, so I know 0 people; therefore its just a matter of time before I buy a strippers friendship. Especially, since im full on downtown and 2 or 3 are within walking distance ... once it warms up, that is :) Strippers and I understand each other too: They get used for their body, and I get used for my mind. Now if I could just find an intelligent one that wanted to get used for their mind, and that would want to use me for my body ... thus brains-N-brawn.com :) Besides, I want something interesting to work on, since im doing this is my spare time; and strippers are definitely more interesting than famous landmarks ... now if I could just get 1 (or more) in front of my live video feed (if I can ever get my dual proc machine working again) ... Coming from the strip club capital of the world though (dallas), ill likely be dissappointed here :( Could integrate with ndecent for v3 as well (images, videos, + clubs), which might give me an excuse to buy PPC 2k+2; ultimatley in preparation for the compact .NET beta relase. Cannot wait! That settles it, if you cannot handle it; now is the time for you to move on

Research

PaStipClubs.txt

From skimming the manual, remember seeing stuff about uploading your own data. e.g. it means if you have a chain of stores, you put them in some format, upload to MapPoint.NET, and then you can search against that collection of stores, to be rendered on the maps when your app calls the service. So with this idea, figure I will need the addresses for the clubs. Couple internet searches later, ive got that list grabbed down. Also remembered some geocoding BS, dealing with lat/long. Had done zipcode stuff in the past for nfamy.com (one of a hundred sites ive coded and killed off cause I dont want to maintain, although this one did not make the B2 conversion due to DataGrid template syntax changing) Go and grab all my old zipcode data, so I can at least guesstimate lat/long based on zipcode. At least I thought I was going to have to do the lat/long stuff, but that ended up not being the case. Oh yeah, could more ad windows have popped up while I was doing my research please!

Geocode

PaStripClubs.mdb | PaStripClubs.xml | PaStripClubs.job

Hooray! Did not have to use my previous lat/long experience. Ends up that this geocoding will take addresses, and then fill in the appropriate lat/long for a location, as well as giving you an idea of how certain it is about that decision. So busted out Access 2002, based on the online instructions they had for the geocoding steps (these were very detailed, and step by step). Since I had no previous data, setup the schema just like what they had outlined. Made sure to add some additional columns (e.g. club name, web site). Then entered in some of the info from the web research. I love the names of strip clubs, stage names of dancers as well. Deleted clubs that did not have zipcodes and such, and added the additional columns for system results. Felt dirty using Access, until exporting to XML.

Downloaded the Output.xml file which now had the lat/longs in it.

NOTE: this would not go to the Data view in VS.NET because of schema silliness, easily fixed by changing the schema namespace 

Upload

PaStripClubs.xml | PaStripClubs.job

Once I geocoded the locations to have lat/long info, they needed to be imported into my MapPoint.NET data source. Made another job file, and repeated the steps. NOTE: my files were picked up immediately and I never had to wait more than a couple minutes, only frustrating part was that IE kept crashing on me when using the web folders. Would have to go and kill a lost IEXPLORE.exe process and repeat. Are you supposed to use 'folder up' or the 'back' button? This took a couple attempts as well.

Icons

You could also make your own icons to be rendered on the maps, but I am too graphically challenged to attempt these. 1 of the stock icons will do nicely, thank you very much; besides the whole upload and wait thing got tiresome

Trial

Cracked open the IntPoint.aspx page to see if the data was there. Changed the DataSource (to 'brainbrawn' - MS assigned) and the Search Set ('strip clubs' - specified in .job file above). Also changed to my apartment address and widened the radius. Changed some code so that it would display the club "Name" property, an additional property added by me. Amazingly, have 2 pushpins showing Chez Kimberly and Club Elite within walking distance. The radius is 3 ??? although the units is not miles, because they are more like .33 to .66 miles

INLINE COMMENT that is day 1, spent about 5 hrs getting this far

Typed DataSets

Access.xsd | Geocode.xsd | Upload.xsd

Woke up and started playing around with Typed DataSets for this. Generated the XML schema from the Geocode/Upload xml files used previosly. Tweaked that a little, and then gen'd a Typed DataSet. Other then schema namespace, it generated and previewed just fine in .NET. Envision a submit page, where people enter in addresses for new/missing clubs, using a typed DataSet for ease of use. Then it would be trivial to serialize and have in the format that MapPoint expects, once those club submissions had been verified and scrubbed, and them uploaded to the MapPoint .NET server to be imported

INLINE COMMENT that is day 2, spent about 1/2 hr getting this much farther. Hey! I had errands to run, workout, ... other excuses!

Architecture

Started building my app the next day. This is real simple:

Presentation

As stated earlier, this had been much easier than expected up to this point, so wanted to trick it up a little. This is when I decided to go ahead and integrate it with my previous PocketPC work. Did not want to waste time on redesigning look and feel, so just reused my aspx/html template from ndecent.com (NOTE: although the template says ndecent.com, you are not actually hitting that site, and are hitting /clubMap exclusively). ndecent.com is a blend of regular ASPX pages along with Mobile .NET controls. The Mobile.NET controls were only necessary for certain situation, since it is targeting PocketPCs exclusively. Made that requirement the same for this (palm sucks), and did not have to use Mobile .NET at all for this app. Real quick use cases, had planned on this functionality: Find Nearest Club, List Clubs, Submit Club. A <<uses>> use case would be Display Map and possibly Map Route; but totally cut almost all of these out from waning interest

Application

mDefault.aspx | findNearest.aspx | findNearest.aspx.cs | viewMap.aspx | renderMap.aspx.cs

Only ended up doing one primary and one secondary use case: Find Nearest Club -> Display Map. Let me explain: I put together the code for that scenario this morning, and it only took 2 hours. Cool, so I might as well finish it off, right ... wrong, my learning curve had leveled off; which was my whole intent for starting this in the 1st place ... to learn. So it became monkey work at this point, which is what I will only do if getting paid for it; and the real cool stuff is what I do for fun in my spare time. But you say this is cool, and I agree. MapPoint .NET is a great WebService, MS nailed it. Could go on and make it zoom, draw routes, tweak the image, etc ... but the time/learning curve does not look promising enough; as this is all detailed in MSs sample code linked above. So let me finish this write up, and mayble I'll revisit if I come up with some more interesting ideas (ideas are hard, code is easy - quoth kc#, circa 2001). Also, since I would ultimately have to pay $$$ to use MapPoint .NET, I cant finish off the site and put out there for free, as all my other sites are. If I had a legit business model, then that is a different scenario

FindNearest is a 3-hit process:

Business Objects

MyFindProxy.cs | MyRenderProxy.cs

While cutting/pasting all the MS sample code, noticed some patterns :) So decided to break out that duplicated code into some base objects. No design went into this part, just grabbed the relevant sections and reorg'd them as to what seemed natural

Web Service

Nothing for me to say here. Its great. An API on the web, so RTFM. I mean that sincerely :) There are 2 Web-Service environments setup (Staging and Production). In the Help documentation, it says explicity that you must use Production for anything public facing. All this required was regen'ing my Web Reference to point to the production server; and then uploading the Geocoded entities to my data source. Geocoding was already done and did not have to be performed again. The Job file <Environment> tag just had to change, and then dropped in the folder to be picked up and imported

Requests

Threw in a TraceExtension so that I could see what was going across the wire for those 3 SOAP requests/responses, and this is the result

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <Find xmlns="http://s.mappoint.net/mappoint-20/">
      <input>15222</input>
      <options>
        <GeoDataSource>
          <Name>MapPoint.NA</Name>
        </GeoDataSource>
        <SearchContext>0</SearchContext>
        <ResultMask/>
      </options>
    </Find>
  </soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <FindResponse xmlns="http://s.mappoint.net/mappoint-20/">
      <FindResult>
        <FindResult>
          <Score>0.88958438128772643</Score>
          <FoundLocation>
            <LatLong Latitude="40.44790411433236" Longitude="-79.994128046498773"/>
            <GeoEntity>
              <EntityID>153929302</EntityID>
              <Name>15222</Name>
              <DisplayName>15222, Pennsylvania, United States</DisplayName>
              <GeoType>
                <Name>Postcode1</Name>
                <ParentName>Postcode</ParentName>
              </GeoType>
            </GeoEntity>
            <BestMapView>
              <CenterPoint Latitude="40.44790411433236" Longitude="-79.994128046498773"/>
              <Height>4</Height>
              <Width>4</Width>
              <BoundingRectangle>
                <SouthWestCoord Latitude="40.429937985815847" Longitude="-80.012094175015278"/>
                <NorthEastCoord Latitude="40.465870242848879" Longitude="-79.976161917982253"/>
              </BoundingRectangle>
            </BestMapView>
            <GeoDataSource>
              <Name>MapPoint.NA</Name>
              <Version>NA.US.0C.0110</Version>
            </GeoDataSource>
          </FoundLocation>
        </FindResult>
      </FindResult>
      <numFound>1</numFound>
    </FindResponse>
  </soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <FindNearby xmlns="http://s.mappoint.net/mappoint-20/">
      <geoDataSource>
        <Name>brainbrawn</Name>
      </geoDataSource>
      <latLong>
        <LatLongCoord Latitude="40.44790411433236" Longitude="-79.994128046498773"/>
      </latLong>
      <distance>3</distance>
      <searchSet>
        <EntityTypePropertySet>
          <GeoType>
            <Name>strip clubs</Name>
          </GeoType>
        </EntityTypePropertySet>
      </searchSet>
      <searchOperator>Or</searchOperator>
    </FindNearby>
  </soap:Body>
</soap:Envelope>

Web-Based Demo

Click the button below to see it working from a popup window. To access it on a web-connected Pocket PC, hit this url:  http://www.mperfect.net/clubMap/mDefault.aspx (NOTE: I told you that you are not actually hitting ndecent.com)

15222 is my zip code (and it correctly renders the 2 clubs within my area). From the PaStripClubs.txt above, some other zips to try are: 15201, 15213, ... remember, I only entered in 12 clubs to the original Access database

Emulator

Somebody asked, so here you go. The emulator pic at the top of the page is the CE .NET emulator. It is available for free here: Microsoft Windows CE .NET Device Emulator  That gives you the emulator runtime with a WebPad (tablet) skin. Check the table of contents to the left, and you can also download a PDA Emulator Sample Project, which is shown above.

Source

As request, here is a zip of the source code:

clubMap C# Source Code

Future

One of these days, wireless will be king, its just taking longer than expected. So most major sites will end up with some interface akin to this, although there specific functional purpose will probably be less in demand :) Admittedly, I dont even own a PPC yet. I did own a Palm, but it was weak, so gave it to my mom. When Compact .NET comes out, then ill get one to make sure this actually works. Hopefully, will be able to get a hold of that beta (HINT HINT). So, in the future, I envision myself on contract X in city Y building application Z. I'll be driving around, bassing my mp3-cd deck, looking for some computer store, because 1 of my computers breaks EVERY time I move (i.e. cpu meltdown noted above). Of course, I'll get lost but will come across a Starbuck's safe haven. Will walk in, and they will have their wireless access point (keep hearing about these, buy have yet to actually experience one), so my PPC becomes instantly connected. Then can look up where the hell I am, and where I need to be going while waiting for my iced caramel macchiatto (spelling? pronounciation?). Or look at some females on ndecent.com :) Now I have to go reward myself for learning MapPoint .NET ... any clue where I'll end up? ... I feel for the stripper that asks, 'so what brings you in?'. That's another reason strippers like me, I somehow manage to surprise them, even after they think they've heard it all ...

Updates

3/27/02 - added the emulator, request, and source sections. Oh yeah, I did try out a club, and was dissappointed i.e. 'who says Dallas is flat?'

4/27/02 - added some more notes, because i'm doing another article about integrating this with the Compact .NET Framework. Also, saw a diff pricing plan which might persuade me to finish this off and charge with a payPal model for usage

7/19/02 - the live demo has stopped working because my MapPoint .NET dev account has expired.