public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } System.Drawing.Point[] points = this.ExtractPoints(this.DataString); double x = points[0].X / 10000; double y = points[0].Y / 10000; double zoom = Double.Parse(HttpContext.Current.Request["Zoom"]); if (zoom == -1) { zoom = map.Zoom.Value; } UserMap.Center(map, x, y, zoom); MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); return; }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); //get map object from map model MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map.Legends.Count == 0) { return; } Legend legend = map.Legends[0]; LegendExport legendExp = new LegendExport(map, legend); legendExp.Format = (MapInfo.Mapping.ExportFormat)MapInfo.Mapping.ExportFormat.Parse(typeof(ExportFormat), LegendExportFormat, true); //export Legend to memorystream MemoryStream stream = new MemoryStream(); legendExp.Export(stream); stream.Position = 0; legendExp.Dispose(); //stream legend image back to client StreamImageToClient(stream); }
/// <summary> /// This method gets the map object out of the mapfactory with given mapalias and /// Adds a point feature into a temp layer, exports it to memory stream and streams it back to client. /// </summary> /// <remarks>None</remarks> public override void Process() { // Extract points from the string System.Drawing.Point [] points = this.ExtractPoints(this.DataString); MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } // There will be only one point, convert it to spatial MapInfo.Geometry.DPoint point; map.DisplayTransform.FromDisplay(points[0], out point); IMapLayer lyr = map.Layers[SampleConstants.TempLayerAlias]; if (lyr == null) { TableInfoMemTable ti = new TableInfoMemTable(SampleConstants.TempTableAlias); // Make the table mappable ti.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(map.GetDisplayCoordSys())); ti.Columns.Add(ColumnFactory.CreateStyleColumn()); Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti); map.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias)); } lyr = map.Layers[SampleConstants.TempLayerAlias]; if (lyr == null) { return; } FeatureLayer fLyr = lyr as FeatureLayer; MapInfo.Geometry.Point geoPoint = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), point); // Create a Point style which is a red pin point. SimpleVectorPointStyle vs = new SimpleVectorPointStyle(); vs.Code = 67; vs.Color = Color.Red; vs.PointSize = Convert.ToInt16(24); vs.Attributes = StyleAttributes.PointAttributes.BaseAll; vs.SetApplyAll(); // Create a Feature which contains a Point geometry and insert it into temp table. Feature pntFeature = new Feature(geoPoint, vs); MapInfo.Data.Key key = fLyr.Table.InsertFeature(pntFeature); // Send contents back to client. MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); //get map object from map model MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); string zoomStr = map.Zoom.ToString(); HttpContext.Current.Response.Output.Write(zoomStr); }
/// <summary> /// This method gets the map object out of the mapfactory with given mapalias and /// This method searches all features within a given point and a radius in all visible and selectable layers /// except the features picked up by the given point /// and then updates the default selection and streams the image back to client. /// </summary> /// <remarks>None</remarks> public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); System.Drawing.Point[] points = ExtractPoints(DataString); Map myMap = model.GetMapObj(MapAlias); RadiusSelection(myMap, points); MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); }
/// <summary> /// Get a MultiFeatureCollection containing features in all layers falling into the tolerance of the point. /// </summary> /// <param name="points">points array</param> /// <param name="pixelTolerance">pixel tolerance used when searching</param> /// <returns>Returns a MultiResultSetFeatureCollection object</returns> protected MultiResultSetFeatureCollection RetrieveInfo(Point[] points, int pixelTolerance) { if (points.Length != 1) { return(null); } MapControlModel model = MapControlModel.GetModelFromSession(); //get map object from map model MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return(null); } //creat a layer filter to include normal visible layers for searching IMapLayerFilter layerFilter = MapLayerFilterFactory.FilterForTools( map, MapLayerFilterFactory.FilterByLayerType(LayerType.Normal), MapLayerFilterFactory.FilterVisibleLayers(true), "MapInfo.Tools.MapToolsDefault.SelectLayers", null); ITableEnumerator tableEnum = map.Layers.GetTableEnumerator(layerFilter); //return if there is no valid layer to search if (tableEnum == null) { return(null); } System.Drawing.Point center = points[0]; //create a SearchInfo with a point and tolerance SearchInfo si = MapInfo.Mapping.SearchInfoFactory.SearchNearest(map, center, pixelTolerance); (si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch; //retrieve all columns si.QueryDefinition.Columns = null; MapInfo.Geometry.Distance d = MapInfo.Mapping.SearchInfoFactory.ScreenToMapDistance(map, pixelTolerance); (si.SearchResultProcessor as ClosestSearchResultProcessor).DistanceUnit = d.Unit; (si.SearchResultProcessor as ClosestSearchResultProcessor).MaxDistance = d.Value; //do search MultiResultSetFeatureCollection mrfc = MapInfo.Engine.Session.Current.Catalog.Search(tableEnum, si); return(mrfc); }
/// <summary> /// This method gets the map object out of the mapfactory with given mapalias /// and This method delete the pin point features added by AddPinPointCommand in a given point /// and then streams the image back to client. /// </summary> /// <remarks>None</remarks> public override void Process() { System.Drawing.Point[] points = ExtractPoints(DataString); MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } PointDeletion(map, points[0]); MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); //get map object from map model MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); FeatureLayer fLyr = map.Layers[ProjectConstants.ThemeLayerAlias] as FeatureLayer; fLyr.Modifiers.Clear(); map.Legends.Clear(); //create theme IndividualValueTheme iTheme = new IndividualValueTheme(fLyr, ProjectConstants.IndColumnName, ProjectConstants.ThemeAlias); fLyr.Modifiers.Insert(0, iTheme); //create legend based on the individual value theme Legend lg = map.Legends.CreateLegend(new Size(236, 282)); //create legend frame ThemeLegendFrame lgFrame = LegendFrameFactory.CreateThemeLegendFrame(iTheme); lg.Frames.Append(lgFrame); //modify legend frame style lgFrame.BackgroundBrush = new SolidBrush(Color.AliceBlue); lgFrame.Title = "World Country Legend"; lgFrame.SubTitle = " "; MapInfo.Styles.Font titleFont = new MapInfo.Styles.Font("Arial", 10); titleFont.ForeColor = Color.DarkBlue; titleFont.FontWeight = FontWeight.Bold; lgFrame.TitleStyle = titleFont; MapInfo.Styles.Font rowTextStyle = new Font("Arial", 8); rowTextStyle.FontWeight = FontWeight.Bold; lgFrame.RowTextStyle = rowTextStyle; //stream map image back to client MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } UserMap.ZoomAll(map); MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); return; }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); //get map object from map model MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); FeatureLayer fLyr = map.Layers[ProjectConstants.ThemeLayerAlias] as FeatureLayer; fLyr.Modifiers.Clear(); map.Legends.Clear(); MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } MapInfo.Geometry.Distance savezoom = map.Zoom; map.Zoom = new MapInfo.Geometry.Distance(savezoom.Value * 4, savezoom.Unit); if (ExportFormat == "undefined") { ExportFormat = "Gif"; } System.IO.MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); map.Zoom = savezoom; /* * MapControlModel model = MapControlModel.GetModelFromSession(); * Map oMap = model.GetMapObj(MapAlias); * if (oMap == null) * { * return; * } * * MapInfo.Geometry.Distance zoom = oMap.Zoom; * zoom = new MapInfo.Geometry.Distance(zoom.Value * 4, zoom.Unit ); * oMap.Zoom = zoom; * if (ExportFormat == "undefined" ) * { * ExportFormat = "Gif"; * } * System.IO.MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); * StreamImageToClient(ms); * zoom = new MapInfo.Geometry.Distance(zoom.Value / 4, zoom.Unit); * oMap.Zoom = zoom; */ }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } string strUID = HttpContext.Current.Request["uid"]; UserMap.DeleteFeature(map, Constants.TempLayerAlias, strUID); MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); return; }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } int wheelvalue = int.Parse(System.Convert.ToString(HttpContext.Current.Request["wheelvalue"])); try { double db; if (wheelvalue > 0) { db = map.Zoom.Value * 0.5; } else { db = map.Zoom.Value * 2; } if (db > Constants.MINZOOMVALUE) { db = Constants.MINZOOMVALUE; } else if (db < Constants.MAXZOOMVALUE) { db = Constants.MAXZOOMVALUE; } map.Zoom = new MapInfo.Geometry.Distance(db, map.Zoom.Unit); } finally { System.IO.MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); } }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } string strUID = HttpContext.Current.Request["uid"]; string strText = HttpContext.Current.Request["Name"]; System.Drawing.Point[] points = this.ExtractPoints(this.DataString); System.Drawing.Color clr = UserMap.stringToColor(HttpContext.Current.Request["Color"]); int lineWidth = Int32.Parse(HttpContext.Current.Request["LineWidth"]); if (lineWidth <= 0) { lineWidth = 2; } int cnt = 0; int len = points.Length; double x = 0; double y = 0; MapInfo.Geometry.DPoint[] dPoints = new MapInfo.Geometry.DPoint[len]; for (cnt = 0; cnt < len; cnt++) { x = (double)points[cnt].X / 10000; y = (double)points[cnt].Y / 10000; dPoints[cnt] = new MapInfo.Geometry.DPoint(x, y); } UserMap.DeleteFeature(map, Constants.TempLayerAlias, strUID); UserMap.AddLine(map, Constants.TempLayerAlias, strUID, strText, dPoints, clr, lineWidth); /* * FeatureLayer layer = map.Layers[Constants.TempLayerAlias] as FeatureLayer; * if (layer == null) * { * return; * } * * int cnt = 0; * int len = points.Length; * double x =0; * double y = 0; * * MapInfo.Geometry.DPoint[] dPoints = new MapInfo.Geometry.DPoint[len]; * * for (cnt = 0; cnt < len; cnt++) * { * x = points[cnt].X/10000; * y = points[cnt].Y/10000; * dPoints[cnt] = new MapInfo.Geometry.DPoint(x, y); * } * * * //创建线图元及其样式 * FeatureGeometry fg = new MultiCurve(layer.CoordSys, CurveSegmentType.Linear, dPoints); * CompositeStyle cs = new MapInfo.Styles.CompositeStyle( * new SimpleLineStyle(new LineWidth(linewidth, LineWidthUnit.Pixel), 2, Color.Red) * ); * * MapInfo.Data.Feature feature = new MapInfo.Data.Feature(layer.Table.TableInfo.Columns); * * feature.Geometry = fg; * feature.Style = cs; * feature["name"] = name; * * //将线图元加入图层 * layer.Table.InsertFeature(feature); */ MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); return; }
public override void Process() { MapControlModel model = MapControlModel.GetModelFromSession(); model.SetMapSize(MapAlias, MapWidth, MapHeight); MapInfo.Mapping.Map map = model.GetMapObj(MapAlias); if (map == null) { return; } string strUID = HttpContext.Current.Request["uid"]; string strText = HttpContext.Current.Request["Name"]; System.Drawing.Point[] points = this.ExtractPoints(this.DataString); System.Drawing.Color clr = UserMap.stringToColor(HttpContext.Current.Request["Color"]); double x = (double)points[0].X / 10000; double y = (double)points[0].Y / 10000; UserMap.DeleteFeature(map, Constants.TempLayerAlias, strUID); UserMap.AddMarker(map, Constants.TempLayerAlias, strUID, strText, new DPoint(x, y), Constants.BMPFILENAME, Constants.POINT_SIZE, clr); /* * //获取图层和表 * FeatureLayer layer = (FeatureLayer)map.Layers[Constants.TempLayerAlias]; * if (layer == null) * { * return; * } * * double x = points[0].X/10000; * double y = points[0].Y/10000; * * * //创建点图元及其样式 * FeatureGeometry fg = new MapInfo.Geometry.Point( map.GetDisplayCoordSys(), x, y); * CompositeStyle cs = new CompositeStyle( * new BitmapPointStyle(Constants.BMPFILENAME, BitmapStyles.None, Color.Red, Constants.POINT_SIZE) * ); * * * Feature feature = new Feature(layer.Table.TableInfo.Columns); * feature.Geometry = fg; * feature.Style = cs; * feature["name"] = name; * * //fg.GetGeometryEditor().Rotate(dPoint, 90); * //fg.EditingComplete(); * * * //MapInfo.Geometry.IGeometryEdit edit = feature.Geometry.GetGeometryEditor(); * //edit.OffsetByAngle(90, 500, MapInfo.Geometry.DistanceUnit.Meter, MapInfo.Geometry.DistanceType.Spherical); * //edit.Geometry.EditingComplete(); * * layer.Table.InsertFeature(feature);*/ MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat); StreamImageToClient(ms); return; }