public static MapSpecification PrepareMapFromCenterZoom( int widthPixels, int heightPixels, double centerLatitude, double centerLongitude, double zoom) { // Options MapOptions mapOptions = new MapOptions(); mapOptions.ReturnType = MapReturnType.ReturnImage; mapOptions.Format = new ImageFormat(); mapOptions.Format.Width = widthPixels; mapOptions.Format.Height = heightPixels; mapOptions.Format.MimeType = "image/gif"; mapOptions.Zoom = zoom; // View ViewByScale[] viewByScaleArray = new ViewByScale[1]; viewByScaleArray[0] = new ViewByScale(); viewByScaleArray[0].CenterPoint = new LatLong(); viewByScaleArray[0].CenterPoint.Latitude = centerLatitude; viewByScaleArray[0].CenterPoint.Longitude = centerLongitude; viewByScaleArray[0].MapScale = 1.0; // Specifications MapSpecification mapSpecification = new MapSpecification(); mapSpecification.Options = mapOptions; mapSpecification.Views = viewByScaleArray; mapSpecification.DataSourceName = "MapPoint.NA"; return(mapSpecification); }
public static ImportDocumentMetadataBuilder <TDto> LeadsToProjectStatisticsCalculation <TDto>(this ImportDocumentMetadataBuilder <TDto> builder) where TDto : IBitDto { Func <TDto, IReadOnlyCollection <IOperation> > projector = x => new [] { new RecalculateStatisticsOperation(new StatisticsKey { ProjectId = x.ProjectId }) }; var specification = new MapSpecification <TDto, IReadOnlyCollection <IOperation> >(projector); var feature = new MapSpecificationFeature <TDto, IReadOnlyCollection <IOperation> >(specification); return(builder.WithFeatures(feature)); }
protected override FactMetadata <T> Create() { MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource = specification => new MapSpecification <IQuery, IEnumerable <T> >(q => _sourceMappingSpecification.Map(q).Where(specification)); var targetMappingSpecification = new MapSpecification <IQuery, IQueryable <T> >(q => q.For <T>()); MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget = specification => new MapSpecification <IQuery, IEnumerable <T> >(q => targetMappingSpecification.Map(q).Where(specification)); return(new FactMetadata <T>(mapSpecificationProviderForSource, mapSpecificationProviderForTarget, Specs.Find.ByIds <T>, Features)); }
protected override AggregateMetadata <T, TKey> Create() { MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource = specification => new MapSpecification <IQuery, IEnumerable <T> >(q => _mapToSourceSpec.Map(q).Where(specification)); var targetMappingSpecification = new MapSpecification <IQuery, IQueryable <T> >(q => q.For <T>()); MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget = specification => new MapSpecification <IQuery, IEnumerable <T> >(q => targetMappingSpecification.Map(q).Where(specification)); return(new AggregateMetadata <T, TKey>(mapSpecificationProviderForSource, mapSpecificationProviderForTarget, Features)); }
public AggregateMetadataBuilder <T> HasValueObject <TValueObject>( MapSpecification <IQuery, IQueryable <TValueObject> > sourceMappingSpecification, Func <IReadOnlyCollection <long>, FindSpecification <TValueObject> > findSpecificationProvider) where TValueObject : class { MapToObjectsSpecProvider <TValueObject, TValueObject> mapSpecificationProviderForSource = specification => new MapSpecification <IQuery, IEnumerable <TValueObject> >(q => sourceMappingSpecification.Map(q).Where(specification)); var targetMappingSpecification = new MapSpecification <IQuery, IQueryable <TValueObject> >(q => q.For <TValueObject>()); MapToObjectsSpecProvider <TValueObject, TValueObject> mapSpecificationProviderForTarget = specification => new MapSpecification <IQuery, IEnumerable <TValueObject> >(q => targetMappingSpecification.Map(q).Where(specification)); Childs(new ValueObjectMetadataElement <TValueObject>(mapSpecificationProviderForSource, mapSpecificationProviderForTarget, findSpecificationProvider)); return(this); }
public MergeResult <TCompared> DetectChanges <TCompared>(MapSpecification <IEnumerable <TOutput>, IEnumerable <TCompared> > mapSpec, FindSpecification <TFilter> specification, IEqualityComparer <TCompared> comparer) { using (var scope = new TransactionScope(TransactionScopeOption.Suppress)) { var sourceObjects = _sourceProvider.Invoke(specification).Map(_query); var targetObjects = _targetProvider.Invoke(specification).Map(_query); var result = MergeTool.Merge( mapSpec.Map(sourceObjects).ToArray(), mapSpec.Map(targetObjects).ToArray(), comparer); scope.Complete(); return(result); } }
public static byte[] GetMap(MapSpecification map) { // Declare the map image array and get the map MapImage[] mapImageArray = null; try { mapImageArray = renderService.GetMap(map); } catch (System.Net.WebException) { // Better error handling? return(null); } // Careful return if (null != mapImageArray && null != mapImageArray[0]) { return(mapImageArray[0].MimeData.Bits); } else { return(null); } }
protected void ServeMap() { if (!MapPointNamespace.MapPoint.Initialized) { MapPointNamespace.MapPoint.Initialize(); } bool isSeattle = true; // default to Seattle double centerLat, centerLong, zoom; if ((Request.QueryString["city"] != null) && (Request.QueryString["city"].ToLower().Equals("redmond"))) { isSeattle = false; } byte mask = 0xff; if (Request.QueryString["mask"] != null) { try { mask = Byte.Parse(Request.QueryString["mask"]); } catch (Exception) { /* ignore */ } } if (!isSeattle) { centerLat = redmondCenterLat; centerLong = redmondCenterLong; zoom = redmondZoom; } else { centerLat = seattleCenterLat; centerLong = seattleCenterLong; zoom = seattleZoom; } try { MapSpecification spec = MapPointNamespace.MapPoint.PrepareMapFromCenterZoom( mapWidth, mapHeight, centerLat, centerLong, zoom); // Add pushpins to the map specification! if (isSeattle) { spec.Pushpins = BuildPushPins(SeattlePushPins, mask); } else { spec.Pushpins = BuildPushPins(RedmondPushPins, mask);; } // Fetch the map image; byte[] data = MapPointNamespace.MapPoint.GetMap(spec); if (data == null) { Response.StatusCode = 500; Response.StatusDescription = "Failed to retrieve map data"; } else { Response.ContentType = "image/gif"; Response.BinaryWrite(data); } } catch (Exception ex) { Response.Write(ex); return; } }
public MapSpecificationFeature(MapSpecification <TSource, TTarget> mapSpecificationProvider) { MapSpecificationProvider = mapSpecificationProvider; }
public UpdatesBulkReplicator(IQuery source, DataConnection target, MapSpecification <IQuery, IEnumerable <T> > mapSpecification) { _source = source; _target = target; _mapSpecification = mapSpecification; }
public FactMetadataBuilder <T> HasSource(MapSpecification <IQuery, IQueryable <T> > sourceMappingSpecification) { _sourceMappingSpecification = sourceMappingSpecification; return(this); }
public StatisticsRecalculationMetadataBuilder <TStatisticsObject, TEntityKey> HasTarget(MapSpecification <IQuery, IQueryable <TStatisticsObject> > targetMappingSpecification) { _mapSpecificationProviderForTarget = specification => new MapSpecification <IQuery, IEnumerable <TStatisticsObject> >(q => targetMappingSpecification.Map(q).Where(specification));; return(this); }
/// <summary> /// Return a image representing a map showing the start and ending points and an annotated line for /// the route between those points /// </summary> /// <param name="route">a Route</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> /// <returns>Image</returns> public System.Drawing.Image GetRouteMap(Route route, int imageWidth, int imageHeight) { MapImage[] mapImage; System.Drawing.Bitmap theImage = null; try { if (route == null) { throw new System.ArgumentNullException("Route cannot be null"); } //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"); } // now get a map MapSpecification mapSpec = new MapSpecification(); ViewByHeightWidth[] myViews = new ViewByHeightWidth[1]; myViews[0] = route.Itinerary.View.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; // setup pushpin Pushpin[] ppArray = new Pushpin[2]; // set up start ppArray[0] = new Pushpin(); ppArray[0].IconDataSource = "MapPoint.Icons"; ppArray[0].IconName = "31"; ppArray[0].LatLong = route.Itinerary.Segments[0].Waypoint.Location.LatLong; ppArray[0].Label = "Start"; ppArray[0].ReturnsHotArea = true; // PinID ppArray[0].PinID = "Start"; // set up end ppArray[1] = new Pushpin(); ppArray[1].IconDataSource = "MapPoint.Icons"; ppArray[1].IconName = "29"; ppArray[1].LatLong = route.Itinerary.Segments[route.Itinerary.Segments.GetUpperBound(0)].Waypoint.Location.LatLong; ppArray[1].Label = "End"; ppArray[1].ReturnsHotArea = true; // PinID ppArray[1].PinID = "End"; mapSpec.Pushpins = ppArray; mapSpec.Route = route; 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); }
/// <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); }
public AggregateMetadataBuilder <T> HasSource(MapSpecification <IQuery, IQueryable <T> > mapToSourceSpec) { _mapToSourceSpec = mapToSourceSpec; return(this); }
public StatisticsRecalculationMetadataBuilder <T> HasSource(MapSpecification <IQuery, IQueryable <T> > sourceMappingSpecification) { _mapSpecificationProviderForSource = specification => new MapSpecification <IQuery, IEnumerable <T> >(q => sourceMappingSpecification.Map(q).Where(specification)); return(this); }