public NavigationHistoryItem(rectObj extent) { minx = extent.minx; miny = extent.miny; maxx = extent.maxx; maxy = extent.maxy; }
internal static HandleRef getCPtrAndSetReference(rectObj obj, object parent) { if (obj != null) { obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
internal static HandleRef getCPtrAndDisown(rectObj obj, object parent) { if (obj != null) { obj.swigCMemOwn = false; obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
/// <summary> /// Click event handler of the buttonOK control. /// </summary> /// <param name="sender">The source object of this event.</param> /// <param name="e">The event parameters.</param> private void buttonOK_Click(object sender, EventArgs e) { if (!ValidateSettings()) { return; } try { // adding the selected layers if (checkBoxSingle.Checked) { // add multiple layers as a single layer (merge attributes) wms_bbox = null; wms_name = ""; wms_title = null; wms_minscaledenom = -1; wms_maxscaledenom = -1; wms_queryable = null; foreach (ListViewItem item in listViewLayers.Items) { GetLayerAttributes((TreeNode)item.Tag); } AddLayerToMap(); } else { foreach (ListViewItem item in listViewLayers.Items) { // add as a separate layer wms_bbox = null; wms_name = ""; wms_title = null; wms_minscaledenom = -1; wms_maxscaledenom = -1; wms_queryable = null; GetLayerAttributes((TreeNode)item.Tag); AddLayerToMap(); } } this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("Unable add layer, " + ex.Message, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); }
public static void QueryByAttribute(string qstring, mapObj map, bool zoomToResults) { Console.WriteLine("\nPerforming QueryByAttribute:"); try { layerObj layer; rectObj query_bounds = null; for (int i = 0; i < map.numlayers; i++) { layer = map.getLayer(i); if (layer.connection != null && IsLayerQueryable(layer)) { Console.WriteLine("Layer [" + i + "] name: " + layer.name); BuildQuery(layer, qstring); // zoom to the query results using (resultCacheObj results = layer.getResults()) { if (results != null && results.numresults > 0) { // calculating the extent of the results if (query_bounds == null) { query_bounds = new rectObj(results.bounds.minx, results.bounds.miny, results.bounds.maxx, results.bounds.maxy, 0); } else { if (results.bounds.minx < query_bounds.minx) { query_bounds.minx = results.bounds.minx; } if (results.bounds.miny < query_bounds.miny) { query_bounds.miny = results.bounds.miny; } if (results.bounds.maxx > query_bounds.maxx) { query_bounds.maxx = results.bounds.maxx; } if (results.bounds.maxy > query_bounds.maxy) { query_bounds.maxy = results.bounds.maxy; } } } } } } // setting the map extent to the result bounds if (query_bounds != null) { if (zoomToResults) { map.setExtent(query_bounds.minx, query_bounds.miny, query_bounds.maxx, query_bounds.maxy); map.scaleExtent(1.2, 0, 0); // increasing the visible area Console.WriteLine("Current map scale: 1:" + (int)map.scaledenom); } } else { Console.WriteLine("The query returned 0 results ..."); } } catch (Exception e) { Console.WriteLine("QueryByAttribute: " + e.Message); } }
public static void QueryByAttribute(string qstring, mapObj map, bool zoomToResults) { Console.WriteLine("\nPerforming QueryByAttribute:"); try { layerObj layer; rectObj query_bounds = null; for (int i = 0; i < map.numlayers; i++) { layer = map.getLayer(i); if (layer.connection != null && IsLayerQueryable(layer)) { Console.WriteLine("Layer [" + i + "] name: " + layer.name); BuildQuery(layer, qstring); // zoom to the query results using (resultCacheObj results = layer.getResults()) { if (results != null && results.numresults > 0) { // calculating the extent of the results if (query_bounds == null) query_bounds = new rectObj(results.bounds.minx, results.bounds.miny, results.bounds.maxx, results.bounds.maxy,0); else { if (results.bounds.minx < query_bounds.minx) query_bounds.minx = results.bounds.minx; if (results.bounds.miny < query_bounds.miny) query_bounds.miny = results.bounds.miny; if (results.bounds.maxx > query_bounds.maxx) query_bounds.maxx = results.bounds.maxx; if (results.bounds.maxy > query_bounds.maxy) query_bounds.maxy = results.bounds.maxy; } } } } } // setting the map extent to the result bounds if (query_bounds != null) { if (zoomToResults) { map.setExtent(query_bounds.minx, query_bounds.miny, query_bounds.maxx, query_bounds.maxy); map.scaleExtent(1.2, 0, 0); // increasing the visible area Console.WriteLine("Current map scale: 1:" + (int)map.scaledenom); } } else Console.WriteLine("The query returned 0 results ..."); } catch (Exception e) { Console.WriteLine("QueryByAttribute: " + e.Message); } }
/// <summary> /// Let the editor to update the modified values to the underlying object. /// </summary> public void UpdateValues() { if (map == null) { return; } if (dirtyFlag) { dirtyFlag = false; // general tab if (map.name != this.textBoxName.Text) { map.name = this.textBoxName.Text; } if (map.shapepath != this.textBoxShapePath.Text) { map.shapepath = this.textBoxShapePath.Text; } if (map.web.imagepath != this.textBoxImagepath.Text) { map.web.imagepath = this.textBoxImagepath.Text; } if (map.fontset.filename != this.textBoxFontset.Text) { if (this.textBoxFontset.Text != "" && File.Exists(this.textBoxFontset.Text)) { map.setFontSet(this.textBoxFontset.Text); } else { map.setFontSet(null); } } if (map.symbolset.filename != this.textBoxSymbolset.Text) { if (this.textBoxSymbolset.Text != "" && File.Exists(this.textBoxSymbolset.Text)) { try { map.setSymbolSet(this.textBoxSymbolset.Text); } catch (Exception ex) { MessageBox.Show("Invalid symbol file, " + ex.Message, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); map.setSymbolSet(null); } } else { map.setSymbolSet(null); } } // image details tab this.colorPickerBackColor.ApplyTo(map.imagecolor); if (map.imagetype != comboBoxImageType.Text) { map.selectOutputFormat(comboBoxImageType.Text); } map.resolution = Convert.ToDouble(this.textBoxResolution.Text); // coordinate space // need to recalculate the extent to point to the same visible area try { // setting up the projection if it have been changed if (map.getProjection() != this.textBoxProjection.Tag.ToString()) { if (map.getProjection() != "" && this.textBoxProjection.Tag.ToString() != "" && map.extent.minx < map.extent.maxx && map.extent.miny < map.extent.maxy) { using (projectionObj oldProj = new projectionObj(map.getProjection())) { using (projectionObj newProj = new projectionObj(this.textBoxProjection.Tag.ToString())) { using (rectObj rect = new rectObj(map.extent.minx, map.extent.miny, map.extent.maxx, map.extent.maxy, 0)) { rect.project(oldProj, newProj); map.units = (MS_UNITS)this.comboBoxUnits.SelectedItem; if (rect.minx < rect.maxx && rect.miny < rect.maxy) { map.setExtent(rect.minx, rect.miny, rect.maxx, rect.maxy); dirtyFlagExtent = true; UpdateExtentValues(); } } } } } if (this.textBoxProjection.Tag.ToString().Trim().StartsWith("+")) { map.setProjection(this.textBoxProjection.Tag.ToString()); map.setMetaData("coordsys_name", this.textBoxProjection.Text); } else { map.setProjection("+AUTO"); } } } catch (Exception ex) { MessageBox.Show("Unable to set projection value, " + ex.Message, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (checkBoxTransparent.Checked) { map.outputformat.transparent = mapscript.MS_TRUE; if (map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGB) { map.outputformat.imagemode = (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA; } } else { map.outputformat.transparent = mapscript.MS_FALSE; if (map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA) { map.outputformat.imagemode = (int)MS_IMAGEMODE.MS_IMAGEMODE_RGB; } } if (target != null && !dirtyFlagExtent) { target.RaisePropertyChanged(this); } SetDirty(false); } if (dirtyFlagExtent) { ApplyExtent(); dirtyFlagExtent = false; } }
private void GetLayerAttributes(TreeNode node) { XmlNode minx = null; XmlNode miny = null; XmlNode maxx = null; XmlNode maxy = null; NumberFormatInfo ni = new NumberFormatInfo(); ni.NumberDecimalSeparator = "."; // minscale - maxscale List<XmlNode> props = GetLayerProp(node, "MaxScaleDenominator", LayerInheritConstants.Replace); if (props.Count > 0) wms_maxscaledenom = Convert.ToDouble(props[0].InnerText, ni); props = GetLayerProp(node, "MinScaleDenominator", LayerInheritConstants.Replace); if (props.Count > 0) wms_minscaledenom = Convert.ToDouble(props[0].InnerText, ni); // Title props = GetLayerProp(node, "Title", LayerInheritConstants.No); if (props.Count > 0) wms_title = props[0].InnerText.Trim(); // Name props = GetLayerProp(node, "Name", LayerInheritConstants.No); if (props.Count > 0) { if (wms_name == "") wms_name = props[0].InnerText.Trim(); else wms_name += "," + props[0].InnerText.Trim(); } // queryable XmlAttribute att = ((XmlNode)node.Tag).Attributes["queryable"]; if (att != null && att.Value.Trim() == "1") wms_queryable = "1"; // bbox props = GetLayerProp(node, "BoundingBox|EX_GeographicBoundingBox|LatLonBoundingBox", LayerInheritConstants.Replace); if (props.Count > 0) { if (props[0].Name == "BoundingBox" || props[0].Name == "LatLonBoundingBox") { minx = props[0].Attributes["minx"]; miny = props[0].Attributes["miny"]; maxx = props[0].Attributes["maxx"]; maxy = props[0].Attributes["maxy"]; } else { minx = props[0].SelectSingleNode("westBoundLongitude"); miny = props[0].SelectSingleNode("southBoundLatitude"); maxx = props[0].SelectSingleNode("eastBoundLongitude"); maxy = props[0].SelectSingleNode("northBoundLatitude"); } } if (minx != null && miny != null && maxx != null && maxy != null) { double fminx = Convert.ToDouble(minx.InnerText, ni); double fminy = Convert.ToDouble(miny.InnerText, ni); double fmaxx = Convert.ToDouble(maxx.InnerText, ni); double fmaxy = Convert.ToDouble(maxy.InnerText, ni); if (wms_bbox == null) wms_bbox = new rectObj(fminx, fminy, fmaxx, fmaxy, 0); else { if (wms_bbox.minx > fminx) wms_bbox.minx = fminx; if (wms_bbox.miny > fminy) wms_bbox.miny = fminy; if (wms_bbox.maxx < fmaxx) wms_bbox.maxx = fmaxx; if (wms_bbox.maxy < fmaxy) wms_bbox.maxy = fmaxy; } } }
/// <summary> /// Click event handler of the buttonOK control. /// </summary> /// <param name="sender">The source object of this event.</param> /// <param name="e">The event parameters.</param> private void buttonOK_Click(object sender, EventArgs e) { if (!ValidateSettings()) return; try { // adding the selected layers if (checkBoxSingle.Checked) { // add multiple layers as a single layer (merge attributes) wms_bbox = null; wms_name = ""; wms_title = null; wms_minscaledenom = -1; wms_maxscaledenom = -1; wms_queryable = null; foreach (ListViewItem item in listViewLayers.Items) GetLayerAttributes((TreeNode)item.Tag); AddLayerToMap(); } else { foreach (ListViewItem item in listViewLayers.Items) { // add as a separate layer wms_bbox = null; wms_name = ""; wms_title = null; wms_minscaledenom = -1; wms_maxscaledenom = -1; wms_queryable = null; GetLayerAttributes((TreeNode)item.Tag); AddLayerToMap(); } } this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("Unable add layer, " + ex.Message, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); }
public void getExtent(int i, rectObj rect) { mapscriptPINVOKE.shapefileObj_getExtent(swigCPtr, i, rectObj.getCPtr(rect)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); }
private void GetLayerAttributes(TreeNode node) { XmlNode minx = null; XmlNode miny = null; XmlNode maxx = null; XmlNode maxy = null; NumberFormatInfo ni = new NumberFormatInfo(); ni.NumberDecimalSeparator = "."; // minscale - maxscale List <XmlNode> props = GetLayerProp(node, "MaxScaleDenominator", LayerInheritConstants.Replace); if (props.Count > 0) { wms_maxscaledenom = Convert.ToDouble(props[0].InnerText, ni); } props = GetLayerProp(node, "MinScaleDenominator", LayerInheritConstants.Replace); if (props.Count > 0) { wms_minscaledenom = Convert.ToDouble(props[0].InnerText, ni); } // Title props = GetLayerProp(node, "Title", LayerInheritConstants.No); if (props.Count > 0) { wms_title = props[0].InnerText.Trim(); } // Name props = GetLayerProp(node, "Name", LayerInheritConstants.No); if (props.Count > 0) { if (wms_name == "") { wms_name = props[0].InnerText.Trim(); } else { wms_name += "," + props[0].InnerText.Trim(); } } // queryable XmlAttribute att = ((XmlNode)node.Tag).Attributes["queryable"]; if (att != null && att.Value.Trim() == "1") { wms_queryable = "1"; } // bbox props = GetLayerProp(node, "BoundingBox|EX_GeographicBoundingBox|LatLonBoundingBox", LayerInheritConstants.Replace); if (props.Count > 0) { if (props[0].Name == "BoundingBox" || props[0].Name == "LatLonBoundingBox") { minx = props[0].Attributes["minx"]; miny = props[0].Attributes["miny"]; maxx = props[0].Attributes["maxx"]; maxy = props[0].Attributes["maxy"]; } else { minx = props[0].SelectSingleNode("westBoundLongitude"); miny = props[0].SelectSingleNode("southBoundLatitude"); maxx = props[0].SelectSingleNode("eastBoundLongitude"); maxy = props[0].SelectSingleNode("northBoundLatitude"); } } if (minx != null && miny != null && maxx != null && maxy != null) { double fminx = Convert.ToDouble(minx.InnerText, ni); double fminy = Convert.ToDouble(miny.InnerText, ni); double fmaxx = Convert.ToDouble(maxx.InnerText, ni); double fmaxy = Convert.ToDouble(maxy.InnerText, ni); if (wms_bbox == null) { wms_bbox = new rectObj(fminx, fminy, fmaxx, fmaxy, 0); } else { if (wms_bbox.minx > fminx) { wms_bbox.minx = fminx; } if (wms_bbox.miny > fminy) { wms_bbox.miny = fminy; } if (wms_bbox.maxx < fmaxx) { wms_bbox.maxx = fmaxx; } if (wms_bbox.maxy < fmaxy) { wms_bbox.maxy = fmaxy; } } } }
/// /// Do a Map Action and send an image stream /// private void Page_Load(object sender, System.EventArgs e) { // add some new environment vars // TODO check if they may already exist - in which case append to //Environment.SetEnvironmentVariable("GDAL_DATA",MY_GDAL_DATA_PATH); //Environment.SetEnvironmentVariable("GDAL_DRIVER_PATH",MY_GDAL_DRIVER_PATH); Environment.SetEnvironmentVariable("PROJ_LIB", "D:\\ms4w\\proj\\nad"); // append to existing PATH variable //string pathVariable = Environment.GetEnvironmentVariable("PATH"; //pathVariable += MY_PATH_VARS //Environment.SetEnvironmentVariable("PATH",MY_PATH_VARS); //read map if existing, otherwhise create a new one from map file try { string pathVariable = Environment.GetEnvironmentVariable("PATH"); pathVariable += @";D:\ms4w\Apache\cgi-bin"; Environment.SetEnvironmentVariable("PATH",pathVariable); map = (mapObj)Session["MAP"]; if (map == null) { map = new mapObj(System.Configuration.ConfigurationSettings.AppSettings["mapFilePath"].ToString()); originalExtent = new rectObj(map.extent.minx, map.extent.miny, map.extent.maxx, map.extent.maxy, 0); Session["ORIGINALEXTENT"] = originalExtent; } originalExtent = (rectObj)Session["ORIGINALEXTENT"]; //read x,y Double x = 0; Double y = 0; if (Request.QueryString["X"] != null && Request.QueryString["Y"] != null) { x = Double.Parse(Request.QueryString["X"].ToString()); y = Double.Parse(Request.QueryString["Y"].ToString()); } //let's see which action is necessary String Action = Request.QueryString["ACTION"].ToString().ToUpper(); switch (Action) { case "ZOOMIN": DoZoom(ZOOMMODE.ZoomIn, x, y); break; case "ZOOMOUT": DoZoom(ZOOMMODE.ZoomOut, x, y); break; case "FULLEXTENT": DoZoomFullExtent(); break; } //refresh RefreshMap(); //store in session Session["MAP"] = map; } catch (Exception ex) { throw; } }
public int queryByRect(rectObj rect) { int ret = mapscriptPINVOKE.mapObj_queryByRect(swigCPtr, rectObj.getCPtr(rect)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
/// <summary> /// Zooming the map to the specified extent. /// </summary> /// <param name="minx">The minx of the extent.</param> /// <param name="miny">The miny of the extent.</param> /// <param name="maxx">The maxx of the extent.</param> /// <param name="maxy">The maxy of the extent.</param> public void ZoomRectangle(double minx, double miny, double maxx, double maxy) { if (map != null && (maxx - minx) > 2 && (maxy-miny) > 2) { using (rectObj imgrect = new rectObj(minx, miny, maxx, maxy, 0)) { // mapscript requires this hack imgrect.miny = maxy; imgrect.maxy = miny; map.zoomRectangle(imgrect, map.width, map.height, map.extent, null); RaiseZoomChanged(); this.RefreshView(); return; } } }
/// <summary> /// Stores the current exten as the initial extent /// </summary> public void StoreInitialExtent() { if (map != null) { if (initial_extent == null) initial_extent = new rectObj(0, 0, 0, 0, 0); initial_extent.maxx = map.extent.maxx; initial_extent.maxy = map.extent.maxy; initial_extent.minx = map.extent.minx; initial_extent.miny = map.extent.miny; } }
/// <summary> /// MouseUp event handler of the Map control. Occurs when a mouse button have been released. /// </summary> /// <param name="sender">The source object of this event.</param> /// <param name="e">The event parameters.</param> private void MapControl_MouseUp(object sender, MouseEventArgs e) { forcePan = false; if (inputMode == InputModes.Select) { //pointObj pt = new pointObj(Pixel2MapX(e.X), Pixel2MapY(e.Y), 0, 0); //TestResult(pt); //return; using (pointObj imgpoint = new pointObj(Pixel2MapX(e.X), Pixel2MapY(e.Y), 0, 0)) { ClearResults(); // clear the previous results map.queryByPoint(imgpoint, mapscript.MS_MULTIPLE, 4); SetSelectionMode(true); this.RefreshView(); this.target.RaiseSelectionChanged(this); } return; } if (magnify != 1) { double offsetX = ((double)1 - (double)1 / magnify) * mouseX; double offsetY = ((double)1 - (double)1 / magnify) * mouseY; if (dragging) { dragging = false; dragRect.Width = e.X - dragRect.X; dragRect.Height = e.Y - dragRect.Y; offsetX -= dragRect.Width; offsetY -= dragRect.Height; } this.ZoomRectangle((double)offsetX, (double)offsetY, (double)offsetX + (double)mapImage.Width / magnify, (double)offsetY + (double)mapImage.Height / magnify); return; } if (dragging) { dragging = false; dragRect.Width = e.X - dragRect.X; dragRect.Height = e.Y - dragRect.Y; if (inputMode == InputModes.Pan || e.Button == MouseButtons.Middle) { if (map != null) PanTo(map.width / 2 - dragRect.Width, map.height / 2 - dragRect.Height); return; } if (inputMode == InputModes.ZoomIn) { ZoomRectangle(Math.Min(dragRect.X, dragRect.X + dragRect.Width), Math.Min(dragRect.Y, dragRect.Y + dragRect.Height), Math.Max(dragRect.X, dragRect.X + dragRect.Width), Math.Max(dragRect.Y, dragRect.Y + dragRect.Height)); return; } if (inputMode == InputModes.ZoomOut) { if (map != null) { //Stephane: change behaviour if small drag of point click to zoom out by a factor of 2, like IntraMaps //if (dragRect.Width <= 2) dragRect.Width = 2; //if (dragRect.Height <= 2) dragRect.Height = 2; if (dragRect.Width <= 2 || dragRect.Height <= 2) { ZoomOut(2); } else { using (pointObj center = new pointObj(dragRect.X + dragRect.Width / 2, dragRect.Y + dragRect.Height / 2, 0, 0)) { double zoomfactor = Math.Min((double)map.width / dragRect.Width, (double)map.height / dragRect.Height); map.zoomScale(zoomfactor * map.scaledenom, center, map.width, map.height, map.extent, null); RaiseZoomChanged(); this.RefreshView(); } } } return; } if (inputMode == InputModes.TrackRectangle) { double x = Pixel2MapX(dragRect.X); double y = Pixel2MapY(dragRect.Y); double x2 = Pixel2MapX(dragRect.X + dragRect.Width); double y2 = Pixel2MapY(dragRect.Y + dragRect.Height); using (rectObj rect = new rectObj(Math.Min(x, x2), Math.Min(y, y2), Math.Max(x, x2), Math.Max(y, y2), 0)) { map.queryByRect(rect); SetSelectionMode(true); this.RefreshView(); this.target.RaiseSelectionChanged(this); return; } } this.Refresh(); } }
internal static HandleRef getCPtr(rectObj obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
/// <summary> /// Let the editor to update the modified values to the underlying object. /// </summary> public void UpdateValues() { if (map == null) return; if (dirtyFlag) { dirtyFlag = false; // general tab if (map.name != this.textBoxName.Text) map.name = this.textBoxName.Text; if (map.shapepath != this.textBoxShapePath.Text) map.shapepath = this.textBoxShapePath.Text; if (map.web.imagepath != this.textBoxImagepath.Text) map.web.imagepath = this.textBoxImagepath.Text; if (map.fontset.filename != this.textBoxFontset.Text) { if (this.textBoxFontset.Text != "" && File.Exists(this.textBoxFontset.Text)) map.setFontSet(this.textBoxFontset.Text); else map.setFontSet(null); } if (map.symbolset.filename != this.textBoxSymbolset.Text) { if (this.textBoxSymbolset.Text != "" && File.Exists(this.textBoxSymbolset.Text)) { try { map.setSymbolSet(this.textBoxSymbolset.Text); } catch (Exception ex) { MessageBox.Show("Invalid symbol file, " + ex.Message, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); map.setSymbolSet(null); } } else map.setSymbolSet(null); } // image details tab this.colorPickerBackColor.ApplyTo(map.imagecolor); if (map.imagetype != comboBoxImageType.Text) map.selectOutputFormat(comboBoxImageType.Text); map.resolution = Convert.ToDouble(this.textBoxResolution.Text); // coordinate space // need to recalculate the extent to point to the same visible area try { // setting up the projection if it have been changed if (map.getProjection() != this.textBoxProjection.Tag.ToString()) { if (map.getProjection() != "" && this.textBoxProjection.Tag.ToString() != "" && map.extent.minx < map.extent.maxx && map.extent.miny < map.extent.maxy) { using (projectionObj oldProj = new projectionObj(map.getProjection())) { using (projectionObj newProj = new projectionObj(this.textBoxProjection.Tag.ToString())) { using (rectObj rect = new rectObj(map.extent.minx, map.extent.miny, map.extent.maxx, map.extent.maxy, 0)) { rect.project(oldProj, newProj); map.units = (MS_UNITS)this.comboBoxUnits.SelectedItem; if (rect.minx < rect.maxx && rect.miny < rect.maxy) { map.setExtent(rect.minx, rect.miny, rect.maxx, rect.maxy); dirtyFlagExtent = true; UpdateExtentValues(); } } } } } if (this.textBoxProjection.Tag.ToString().Trim().StartsWith("+")) { map.setProjection(this.textBoxProjection.Tag.ToString()); map.setMetaData("coordsys_name", this.textBoxProjection.Text); } else map.setProjection("+AUTO"); } } catch (Exception ex) { MessageBox.Show("Unable to set projection value, " + ex.Message, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (checkBoxTransparent.Checked) { map.outputformat.transparent = mapscript.MS_TRUE; if (map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGB) map.outputformat.imagemode = (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA; } else { map.outputformat.transparent = mapscript.MS_FALSE; if (map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA) map.outputformat.imagemode = (int)MS_IMAGEMODE.MS_IMAGEMODE_RGB; } if (target != null && !dirtyFlagExtent) target.RaisePropertyChanged(this); SetDirty(false); } if (dirtyFlagExtent) { ApplyExtent(); dirtyFlagExtent = false; } }
public int zoomRectangle(rectObj poPixRect, int width, int height, rectObj poGeorefExt, rectObj poMaxGeorefExt) { int ret = mapscriptPINVOKE.mapObj_zoomRectangle(swigCPtr, rectObj.getCPtr(poPixRect), width, height, rectObj.getCPtr(poGeorefExt), rectObj.getCPtr(poMaxGeorefExt)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
/// <summary> /// Change the extent of the map according to the extent of the layer. /// Reproject the extent if the layer and the map projection differs. /// </summary> /// <param name="layer">The layer to be used to calculate the extent</param> private void ZoomToLayerExtent(layerObj layer) { try { if (layer.connectiontype == MS_CONNECTION_TYPE.MS_PLUGIN && layer.plugin_library == "msplugin_mssql2008.dll") GetMssqlSpatialLayerExtent(layer); using (rectObj extent = layer.getExtent()) { if (extent.minx < extent.maxx && extent.miny < extent.maxy) { if (map.getProjection() != "" && layer.getProjection() != "") { // need to reproject the extent using (projectionObj oldProj = new projectionObj(layer.getProjection())) { using (projectionObj newProj = new projectionObj(map.getProjection())) { using (rectObj rect = new rectObj(extent.minx, extent.miny, extent.maxx, extent.maxy, 0)) { rect.project(oldProj, newProj); if (rect.minx < rect.maxx && rect.miny < rect.maxy) map.setExtent(rect.minx, rect.miny, rect.maxx, rect.maxy); if (target != null) { target.RaisePropertyChanged(this); RaiseZoomChanged(); } } } } } else { // don't reproject map.setExtent(extent.minx, extent.miny, extent.maxx, extent.maxy); if (target != null) { target.RaisePropertyChanged(this); RaiseZoomChanged(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public int zoomScale(double scale, pointObj poPixPos, int width, int height, rectObj poGeorefExt, rectObj poMaxGeorefExt) { int ret = mapscriptPINVOKE.mapObj_zoomScale(swigCPtr, scale, pointObj.getCPtr(poPixPos), width, height, rectObj.getCPtr(poGeorefExt), rectObj.getCPtr(poMaxGeorefExt)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public int whichShapes(rectObj rect) { int ret = mapscriptPINVOKE.layerObj_whichShapes(swigCPtr, rectObj.getCPtr(rect)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }