1

I've been tasked with writing a web service that can be called from one of our two plant locations that will allow our shipping department to get the most efficient route for a set of deliveries. We've also discussed the possibility of setting up territories and assigning deliveries to territories and territories to drivers.

My question, in its simplest form, is this: MapPoint 2011 allows you to use its object model through COM. I'm not terribly familiar with this type of programming but it seems to create a new instance of the application each time the logic is called. Is this type of usage scalable? What will happen if ten calls are received simultaneously?

I've included some sample code pulled from MSDN below as a point of reference.

//set up application
MapPoint.Application objApp = new Application();
objApp.Visible = false;
objApp.UserControl = false;

MapPoint.Route objRoute;
MapPoint.Map objMap;

objMap = objApp.ActiveMap;
objRoute = objMap.ActiveRoute;

objMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;

//Get locations for route
object item = 1;
objRoute.Waypoints.Add(objMap.FindResults("Redmond, WA").get_Item(ref item), 
    "Redmond, WA");
objRoute.Waypoints.Add(objMap.FindResults("Seattle, WA").get_Item(ref item), 
    "Seattle, WA");
objRoute.Waypoints.Add(objMap.FindResults("Portland, OR").get_Item(ref item), 
    "Portland, OR");

// Calculate the route
objRoute.Calculate();

//Asks if you want to save the map? How would you say no programmatically?
objApp.Quit();
casperOne
  • 73,706
  • 19
  • 184
  • 253
James Hill
  • 60,353
  • 20
  • 145
  • 161
  • With the given code, you'll start 10 instances of MapPoint. Yes, that won't scale well. You can serialize the queries yourself to lessen that blow, slowing down the service but at least not making the machine fall over. Microsoft in general does not recommend using its desktop apps in a server scenario. – Hans Passant Nov 07 '11 at 14:51

3 Answers3

2

No, it is not scaleable and it is a very bad idea. Running any program that relies heavily on a desktop session (such as MapPoint 2011) in a server environment has issues, mainly because a desktop session isn't available.

Additionally, desktop application such as this are not developed for server environments, so they consume resources differently (and usually more aggressively) than you might expect.

In your case, if you receive ten calls at the same time, then you will have ten instances of the application run on your server (and then shut down, but still). This generally is not scaleable for applications of this type.

MapPoint 2011 falls in the same category as Office, in that it should not be run in a server environment, as per Microsoft's own recommendation.

casperOne
  • 73,706
  • 19
  • 184
  • 253
  • I assumed this was the case, but I *hoped* it wasn't. It's difficult to find a programmatic solution in C# that will do everything we need it to do. – James Hill Nov 07 '11 at 14:51
  • @JamesHill: I don't know that's the case and I think you might be asking the wrong question. Instead, you should be asking what server-solutions there are out there that can do what you need. In your example, you seem to want to find routes given waypoints. That said, the [Google Directions API](http://code.google.com/apis/maps/documentation/directions/) does *exactly* that (see ["Using Waypoints in Routes"](http://code.google.com/apis/maps/documentation/directions/#Waypoints]). Finding the other functionality you need should not be difficult. – casperOne Nov 07 '11 at 14:54
  • I should clarify. Finding solution within our budget is difficult. Google Maps API for example starts at $17,500 for enterprise usage on a intranet. – James Hill Nov 07 '11 at 14:56
  • @JamesHill: Just curious, you are going to make more than [2,500 requests per day with more than 10 waypoints per request](http://www.google.com/enterprise/earthmaps/maps-compare.html)? – casperOne Nov 07 '11 at 14:58
  • 2
    No, we don't fail there. We fail here: `Internal deployments` and here `Embedding in software and applications for fee` – James Hill Nov 07 '11 at 14:59
0

@casperOne is right that this is a bad idea. You are talking about 1-2 locations, so here Here are two other approaches:

First, Why not install and run MapPoint locally on the 4-5 machines it sounds like you are using? Do the routing locally.

Secondly, MapPoint has an ActiveX control. This can be embedded in a web app BUT you must have licensed MapPoint applications on each client PC.

otherwise I think you are looking at an online service. Bing Maps is pretty good too; and there's always OpenStreetMaps if their data quality is sufficient in your area of operations.

winwaed
  • 7,645
  • 6
  • 36
  • 81
0

If you want to save the map?

How would you say no programmatically?

 objApp.ActiveMap.saved = true
Jehonathan Thomas
  • 2,110
  • 1
  • 28
  • 34