internal static HandleRef getCPtrAndSetReference(projectionObj obj, object parent) { if (obj != null) { obj.swigParentRef = parent; return obj.swigCPtr; } else { return new HandleRef(null, IntPtr.Zero); } }
public int project(projectionObj projin, projectionObj projout) { int ret = mapscriptPINVOKE.rectObj_project(swigCPtr, projectionObj.getCPtr(projin), projectionObj.getCPtr(projout)); if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve(); return ret; }
/// <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 buttonOK_Click(object sender, EventArgs e) { if (checkInput()) { m_mapPropertys.name = textName.Text.Trim(); if (comboStatus.SelectedIndex == 0) m_mapPropertys.status = 1; else m_mapPropertys.status = 0; m_mapPropertys.width = Convert.ToInt32(textSizeW.Text); m_mapPropertys.height = Convert.ToInt32(textSizeH.Text); //get the relative path of the shapepath m_mapPropertys.shapepath = Utility.GetRelativePath(m_mapPropertys.mappath, textShpPath.Text); //myProperty.FontSet = textFontSet.Text; if (comboImgType.SelectedItem.ToString() != m_mapPropertys.outputformat.name) { m_mapPropertys.setOutputFormat (m_mapPropertys.getOutputFormatByName(comboImgType.SelectedItem.ToString())); } m_mapPropertys.imagecolor.red = buttonImgColor.BackColor.R; m_mapPropertys.imagecolor.green = buttonImgColor.BackColor.G; m_mapPropertys.imagecolor.blue = buttonImgColor.BackColor.B; m_mapPropertys.units = (MS_UNITS)comboUnits.SelectedIndex; // m_mapPropertys.resolution = Convert.ToDouble(textResolution.Text); if (m_mapPropertys.getProjection() == "" || textSRID.Text == m_mapPropertys.getProjection()) { m_mapPropertys.extent.maxx = Convert.ToDouble(textExtMaxX.Text); m_mapPropertys.extent.maxy = Convert.ToDouble(textExtMaxY.Text); m_mapPropertys.extent.minx = Convert.ToDouble(textExtMinX.Text); m_mapPropertys.extent.miny = Convert.ToDouble(textExtMinY.Text); if(textSRID.Text != "") { try { m_mapPropertys.setProjection(textSRID.Text); } catch (Exception ex) { MessageBox.Show("����ͶӰ�쳣��" + ex.Message, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { try { rectObj rect = m_mapPropertys.extent; projectionObj proIn = new projectionObj(m_mapPropertys.getProjection()); projectionObj proOut = new projectionObj(textSRID.Text); rect.project(proIn, proOut); m_control.Extents = new Extent(rect.minx, rect.maxx, rect.miny, rect.maxy); //m_control.refreshMap(false); m_mapPropertys.setProjection(textSRID.Text); if (proOut.getUnits() != -1) { m_mapPropertys.units = (MS_UNITS)proOut.getUnits(); } } catch(Exception ex) { MessageBox.Show("����ͶӰ�쳣��" + ex.Message, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } this.DialogResult = DialogResult.OK; } }
internal static HandleRef getCPtr(projectionObj obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
/// <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); } }
/// <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; } }