Exemplo n.º 1
0
        /// <summary>
        /// This method returns the direction (itinerary) between a starting and ending location
        /// </summary>
        /// <param name="startLocation">Starting location</param>
        /// <param name="endLocation">Ending location</param>
        /// <param name="segPref">specify the shortest or quickest route</param>
        /// <returns>a RouteItinerary - just the directions portion of a route</returns>
        public RouteItinerary GetRouteDirections(Location startLocation, Location endLocation, SegmentPreference segPref)
        {
            Route myRoute;

            try
            {
                if (startLocation == null)
                {
                    throw new System.ArgumentNullException("Start location cannot be null");
                }
                if (endLocation == null)
                {
                    throw new System.ArgumentNullException("End location cannot be null");
                }

                SegmentSpecification[] routeSegmentsSpec = new SegmentSpecification[2];
                routeSegmentsSpec[0] = new SegmentSpecification();
                routeSegmentsSpec[0].Waypoint = new Waypoint();
                routeSegmentsSpec[0].Waypoint.Name = startLocation.Entity.Name;
                routeSegmentsSpec[0].Waypoint.Location = startLocation;
                routeSegmentsSpec[0].Options = new SegmentOptions();
                routeSegmentsSpec[0].Options.Preference = segPref;
                routeSegmentsSpec[1] = new SegmentSpecification();
                routeSegmentsSpec[1].Waypoint = new Waypoint();
                routeSegmentsSpec[1].Waypoint.Name = endLocation.Entity.Name;
                routeSegmentsSpec[1].Waypoint.Location = endLocation;
                routeSegmentsSpec[1].Options = new SegmentOptions();
                routeSegmentsSpec[1].Options.Preference = segPref;

                RouteSpecification routeSpec = new RouteSpecification();
                routeSpec.DataSourceName = "MapPoint.NA";
                routeSpec.ResultMask = RouteResultMask.Itinerary;
                routeSpec.Segments = routeSegmentsSpec;

                myRoute = theMapPointRouteService.CalculateRoute(routeSpec);

            }
            catch (ArgumentNullException e)
            {
                throw e;  // rethrow for app to handle
            }
            catch (Exception e)
            {
                throw e;  // rethrow for app to handle

            }

            return myRoute.Itinerary;
        }
Exemplo n.º 2
0
 /// <summary>
 /// This method returns the direction (itinerary) between a starting and ending location
 /// </summary>
 /// <param name="startLocation">Starting location</param>
 /// <param name="endLocation">Ending location</param>
 /// <returns>a RouteItinerary - just the directions portion of a route</returns>
 public RouteItinerary GetRouteDirections(Location startLocation, Location endLocation)
 {
     return this.GetRouteDirections(startLocation, endLocation, SegmentPreference.Quickest);
 }
Exemplo n.º 3
0
        /// <summary>
        /// This method will return a image representing a map
        /// </summary>
        /// <param name="location">result from the FindLocation method</param>
        /// <param name="imageWidth">width of image used to display the map</param>
        /// <param name="imageHeight">height of the image used to display the map</param>
        /// <param name="zoom">floating point number > 0 respresent amount of zoom on the returned map</param>
        /// <returns>Address</returns>
        public System.Drawing.Image GetMap(Location location, int imageWidth, int imageHeight, double zoom)
        {
            MapImage[] mapImage;
            System.Drawing.Bitmap theImage = null;

            try
            {

                if (location == null)
                {
                    throw new System.ArgumentNullException("Location cannot be null");
                }

                if (imageWidth <= 0)
                {
                    throw new System.ArgumentNullException("Image width should be > then 0");
                }

                if (imageHeight <= 0)
                {
                    throw new System.ArgumentNullException("Image Height should be > then 0");
                }
                if (zoom <= 0)
                {
                    throw new System.ArgumentNullException("Zoom should be great then 0");
                }

                // now get a map
                MapSpecification mapSpec = new MapSpecification();

                //ViewByScale[] myViews = new ViewByScale[1];
                MapView[] myViews = new MapView[1];
                myViews[0] = location.BestMapView.ByHeightWidth;

                mapSpec.Views = myViews;
                mapSpec.DataSourceName = "MapPoint.NA";
                mapSpec.Options = new MapOptions();
                mapSpec.Options.Format = new ImageFormat();
                mapSpec.Options.Format.Height = imageHeight;
                mapSpec.Options.Format.Width = imageWidth;
                mapSpec.Options.Zoom = zoom;

                //	setup pushpin
                Pushpin[] ppArray = new Pushpin[1];

                // set up a sample push pin
                ppArray[0] = new Pushpin();
                ppArray[0].IconDataSource = "MapPoint.Icons";
                ppArray[0].IconName = "168";
                ppArray[0].LatLong = location.LatLong;
                ppArray[0].Label = "You are here";
                ppArray[0].ReturnsHotArea = true;
                // PinID contains the db key and the ADE NAME seperated by a tilde
                ppArray[0].PinID = "where I am now";

                mapSpec.Pushpins = ppArray;

                mapImage = theMapPointRenderService.GetMap(mapSpec);

                // let sure an MapImage was returned
                if (mapImage != null && mapImage.Length > 0)
                {
                    theImage = new System.Drawing.Bitmap(new System.IO.MemoryStream(mapImage[0].MimeData.Bits));
                }
                else
                    throw new System.Exception("Unable to build a map for this route");

            }
            catch (ArgumentNullException e)
            {
                throw e;  // rethrow for app to handle
            }
            catch (Exception e)
            {
                throw e;  // rethrow for app to handle
            }

            return theImage;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Return a Route given a start and end location.
 /// </summary>
 /// 
 /// <param name="startLocation">result from the FindLocation method</param>
 /// <param name="endLocation">result from the FindLocation method</param>
 /// <returns>Route</returns>
 public Route GetRoute(Location startLocation, Location endLocation)
 {
     return this.GetRoute(startLocation, endLocation, SegmentPreference.Quickest);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Methods for looking up points of interest based on a location.  Points of interest could 
 /// be things like gas, food and lodging.  Standard Industry Codes (SIC) are used to identify the type
 /// of point of interest you are interested in.  Some example sic codes are SICInd554 for Gas, SIC5800 for 
 /// Food and SICInd701 for lodging.
 /// 
 /// Search radius is assumed to be 50 miles.
 /// 
 /// The data source is NavTech.NA
 /// 
 /// <param name="location">result from the FindLocation method</param>
 /// <param name="POI">Entity code - like the SIC example above</param>
 /// <param name="searchRadius">float allowing of specify the search radius</param>
 /// <returns>FindResults</returns>
 public FindResults FindNearByPlaces(Location location, string POI, double searchRadius)
 {
     return this.FindNearByPlaces(location, POI, "Navtech.NA", searchRadius);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Methods for looking up points of interest based on a location.  Points of interest could 
        /// be things like gas, food and lodging.  Standard Industry Codes (SIC) are used to identify the type
        /// of point of interest you are interested in.  Some example sic codes are SICInd554 for Gas, SIC5800 for 
        /// Food and SICInd701 for lodging.
        /// 
        /// You must specify the datasource like NavTech.NA
        /// 
        /// </summary>
        /// <param name="location">result from the FindLocation method</param>
        /// <param name="POI">Entity code - like the SIC example above</param>
        /// <param name="dataSource"></param>
        /// <param name="searchRadius">float allowing of specify the search radius</param>
        /// <returns>FindResults</returns>
        public FindResults FindNearByPlaces(Location location, string POI,string dataSource, double searchRadius)
        {
            FindResults foundResults = null;

            try
            {

                if (location == null)
                {
                    throw new System.ArgumentNullException("Location cannot be null");
                }

                if (POI == null)
                {
                    throw new System.ArgumentNullException("POI cannot be null");
                }

                if (dataSource == null)
                {
                    throw new System.ArgumentNullException("dataSource cannot be null");
                }

                string POIDatasourceName = dataSource;
                //string POIEntityTypeName = PointsOfInterest.GetInstance().GetPointOfInterestSICCODE(POI);

                FindNearbySpecification findNearbySpec = new FindNearbySpecification();
                findNearbySpec.DataSourceName = POIDatasourceName;
                findNearbySpec.Distance = searchRadius;  // (myViews(0).Width / 2) * 1.2
                findNearbySpec.LatLong = location.LatLong;
                findNearbySpec.Filter = new FindFilter();
                findNearbySpec.Filter.EntityTypeName = POI;
                findNearbySpec.Options = new FindOptions();
                findNearbySpec.Options.Range = new FindRange();
                findNearbySpec.Options.Range.Count = 99;

                foundResults = theMapPointFindService.FindNearby(findNearbySpec);

                // make sure NumberFound and size of results array are the same
                foundResults.NumberFound = foundResults.Results.GetLength(0);
            }
            catch (ArgumentNullException e)
            {
                throw e;  // rethrow for app to handle
            }
            catch (Exception e)
            {
                throw e;  // rethrow for app to handle
            }

            return foundResults;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Methods for looking up points of interest based on a location.  Points of interest could 
 /// be things like gas, food and lodging.  Standard Industry Codes (SIC) are used to identify the type
 /// of point of interest you are interested in.  Some example sic codes are SICInd554 for Gas, SIC5800 for 
 /// Food and SICInd701 for lodging.
 /// 
 /// The data source is NavTech.NA
 /// 
 /// </summary>
 /// <param name="location">result from the FindLocation method</param>
 /// <param name="POI">Entity code - like the SIC example above</param>
 /// <returns>FindResults</returns>
 public FindResults FindNearByPlaces(Location location, string POI)
 {
     return this.FindNearByPlaces(location, POI, 50.0);
 }
Exemplo n.º 8
0
 /// <remarks/>
 public void GetBestMapViewAsync(Location[] locations, string dataSourceName, object userState) {
     if ((this.GetBestMapViewOperationCompleted == null)) {
         this.GetBestMapViewOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetBestMapViewOperationCompleted);
     }
     this.InvokeAsync("GetBestMapView", new object[] {
                 locations,
                 dataSourceName}, this.GetBestMapViewOperationCompleted, userState);
 }
Exemplo n.º 9
0
 /// <remarks/>
 public void GetBestMapViewAsync(Location[] locations, string dataSourceName) {
     this.GetBestMapViewAsync(locations, dataSourceName, null);
 }
Exemplo n.º 10
0
 /// <remarks/>
 public System.IAsyncResult BeginGetBestMapView(Location[] locations, string dataSourceName, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("GetBestMapView", new object[] {
                 locations,
                 dataSourceName}, callback, asyncState);
 }
Exemplo n.º 11
0
 public MapViewRepresentations GetBestMapView(Location[] locations, string dataSourceName) {
     object[] results = this.Invoke("GetBestMapView", new object[] {
                 locations,
                 dataSourceName});
     return ((MapViewRepresentations)(results[0]));
 }