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; }