public SectionInfoCtrl(IDrawingService drawSvc, string drawingSourceId, OSGeo.MapGuide.ObjectModels.Common.DrawingSectionListSection section) : this() { _drawSvc = drawSvc; _drawingSourceId = drawingSourceId; _section = section; }
private static int DoMigrate(OSGeo.MapGuide.MaestroAPI.IServerConnection source, OSGeo.MapGuide.MaestroAPI.IServerConnection target, CopyMoveToServerDialog migrate) { var diag = new ProgressDialog(); diag.CancelAbortsThread = true; var method = new ProgressDialog.DoBackgroundWork((worker, e, args) => { var src = (IServerConnection)args[0]; var dst = (IServerConnection)args[1]; var ids = (string[])args[2]; var folder = (string)args[3]; var overwrite = (bool)args[4]; var act = (MigrationAction)args[5]; var cb = new LengthyOperationProgressCallBack((sender, cbe) => { worker.ReportProgress(cbe.Progress, cbe.StatusMessage); }); var migrator = new ResourceMigrator(source, target); int affected = 0; switch (act) { case MigrationAction.Copy: affected = migrator.CopyResources(ids, folder, overwrite, cb); break; case MigrationAction.Move: affected = migrator.MoveResources(ids, folder, overwrite, cb); break; } return affected; }); return (int)diag.RunOperationAsync(Workbench.Instance, method, source, target, migrate.SourceResourceIds, migrate.TargetFolder, migrate.OverwriteResources, migrate.SelectedAction); }
public bool IsPreviewable(OSGeo.MapGuide.MaestroAPI.Resource.IResource res) { var rt = res.ResourceType; return (rt == ResourceTypes.LayerDefinition || rt == ResourceTypes.MapDefinition || rt == ResourceTypes.WatermarkDefinition); }
public static ESRI.ArcGIS.Geometry.IEnvelope get_extent(OSGeo.OGR.Envelope ogr_envelope, ISpatialReference sr) { IEnvelope env = new EnvelopeClass(); env.PutCoords(ogr_envelope.MinX, ogr_envelope.MinY, ogr_envelope.MaxX, ogr_envelope.MaxY); env.SpatialReference = sr; return env; }
public OGRDataset(OSGeo.OGR.Layer layer) { m_layer = layer; ogr_utils.map_fields(layer, out m_fieldMapping, out m_fields, out m_datasetType, out m_geometryType, out m_geometryFieldIndex, out m_oidFieldIndex, out m_spatialReference); }
private bool IsValid(OSGeo.MapGuide.MaestroAPI.IServerConnection conn) { return conn.Capabilities.SupportsResourceHeaders && conn.Capabilities.SupportsResourceReferences && conn.Capabilities.SupportsResourceSecurity && conn.Capabilities.SupportsWfsPublishing && conn.Capabilities.SupportsWmsPublishing; }
public static void ReadShortBlock(OSGeo.GDAL.Band rasterBand, BandBlock<short> block) { rasterBand.ReadRaster(block.XOffset, block.YOffset, block.UsedPortionXSize, block.UsedPortionYSize, block.Buffer, block.UsedPortionXSize, block.UsedPortionYSize, block.PixelSpace, block.LineSpace); }
/// <summary> /// Constructor /// </summary> /// <param name="gdalDataset">The gdal dataset</param> public GeoTransform(OSGeo.GDAL.Dataset gdalDataset) { if (gdalDataset == null) throw new ArgumentException("GeoTransform constructor invoked with null dataset.", "gdalDataset"); var array = new double[6]; gdalDataset.GetGeoTransform(array); _transform = array; ComputeInverse(); }
public static ESRI.ArcGIS.Geometry.ISpatialReference get_spatialReference(OSGeo.OSR.SpatialReference ogrSR) { ogrSR.MorphToESRI(); string wkt; ogrSR.ExportToWkt(out wkt); ISpatialReferenceFactory4 spatialReferenceFactory = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass(); ISpatialReference sr; int bytesRead; spatialReferenceFactory.CreateESRISpatialReference(wkt, out sr, out bytesRead); return sr; }
public static ISpatialReference GetSpatialReference(OSGeo.OSR.SpatialReference ogrSr) { ogrSr.MorphToESRI(); string wkt; ogrSr.ExportToWkt(out wkt); var type = Type.GetTypeFromCLSID(typeof (SpatialReferenceEnvironmentClass).GUID); ISpatialReferenceFactory4 spatialReferenceFactory = (ISpatialReferenceFactory4) Activator.CreateInstance(type); ISpatialReference sr; int bytesRead; spatialReferenceFactory.CreateESRISpatialReference(wkt, out sr, out bytesRead); return sr; }
/// <summary> /// Converts an FDO Geometry to a SharpMap geometry /// </summary> /// <param name="geom">The FDO geometry</param> /// <returns></returns> public static Sm.Geometry FromFdoGeometry(FdoGeometry geom, OSGeo.FDO.Geometry.FgfGeometryFactory geomFactory) { if (FdoGeometryUtil.Is2D(geom.InternalInstance)) { //Get the WKB form of the geometry byte[] wkb = FdoGeometryFactory.Instance.GetWkb(geom.InternalInstance); return GeometryFromWKB.Parse(wkb); } else { using (OSGeo.FDO.Geometry.IGeometry flattened = FdoGeometryUtil.Flatten(geom.InternalInstance, geomFactory)) { //Get the WKB form of the geometry byte[] wkb = FdoGeometryFactory.Instance.GetWkb(flattened); return GeometryFromWKB.Parse(wkb); } } }
public override OSGeo.MapGuide.MaestroAPI.Resource.IResource CreateItem(string startPoint, OSGeo.MapGuide.MaestroAPI.IServerConnection conn) { using (var picker = new ResourcePicker(conn.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource)) { picker.SetStartingPoint(startPoint); if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var lyr = ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Vector, new Version(1, 1, 0)); var vl = (IVectorLayerDefinition)lyr.SubLayer; vl.ResourceId = picker.ResourceID; //Stub these for now, validation will ensure this never makes it //into the session repository until all validation errors pass vl.FeatureName = string.Empty; vl.Geometry = string.Empty; return lyr; } else { return null; } } }
private static TreeNode CreateOdbcMappingNode(OSGeo.FDO.Providers.Rdbms.Override.ODBC.OvPhysicalSchemaMapping mapping) { var schema = new OdbcPhysicalSchemaMappingItem(mapping); var node = new TreeNode(schema.Name); node.Text = schema.Name; node.Tag = schema; foreach (OdbcClassDefinitionItem cls in schema.Classes) { var clsNode = new TreeNode(cls.Name); clsNode.Text = cls.Name; clsNode.Tag = cls; foreach (object prop in cls.Properties) { if (prop.GetType() == typeof(OdbcDataPropertyDefinitionItem)) { OdbcDataPropertyDefinitionItem p = (OdbcDataPropertyDefinitionItem)prop; var propNode = new TreeNode(p.Name); propNode.Text = p.Name; propNode.Tag = p; clsNode.Nodes.Add(propNode); } else if (prop.GetType() == typeof(OdbcGeometricPropertyDefinitionItem)) { OdbcGeometricPropertyDefinitionItem p = (OdbcGeometricPropertyDefinitionItem)prop; var propNode = new TreeNode(p.Name); propNode.Text = p.Name; propNode.Tag = p; clsNode.Nodes.Add(propNode); } } node.Nodes.Add(clsNode); } return node; }
void OnRequestDispatched(object sender, OSGeo.MapGuide.MaestroAPI.RequestEventArgs e) { string msg = string.Format("[{0}]: {1}", DateTime.Now.ToString("dd MMM yyyy hh:mm:ss"), e.Data); //NOXLATE if (!txtMessages.IsDisposed) { if (txtMessages.InvokeRequired) { txtMessages.Invoke(new MethodInvoker(() => { txtMessages.AppendText(msg + Environment.NewLine); txtMessages.ScrollToCaret(); })); } else { txtMessages.AppendText(msg + Environment.NewLine); txtMessages.ScrollToCaret(); } } }
public int TransformTo(OSGeo.OSR.SpatialReference reference) { int ret = OgrPINVOKE.Geometry_TransformTo(swigCPtr, OSGeo.OSR.SpatialReference.getCPtr(reference)); if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public int Transform(OSGeo.OSR.CoordinateTransformation trans) { int ret = OgrPINVOKE.Geometry_Transform(swigCPtr, OSGeo.OSR.CoordinateTransformation.getCPtr(trans)); if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public void AssignSpatialReference(OSGeo.OSR.SpatialReference reference) { OgrPINVOKE.Geometry_AssignSpatialReference(swigCPtr, OSGeo.OSR.SpatialReference.getCPtr(reference)); if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve(); }
internal FdoMultiClassPicker(string title, string message, OSGeo.FDO.Schema.FeatureSchemaCollection schemas) : this() { _schemas = schemas; _presenter = new FdoMultiClassPickerPresenter(this, title, message); }
private static FeatureDataRow LoadOgrFeatureToFeatureDataRow(FeatureDataTable table, OSGeo.OGR.Feature ogrFeature, GeoAPI.Geometries.IGeometryFactory factory) { var values = new object[ogrFeature.GetFieldCount()]; for (var iField = 0; iField < ogrFeature.GetFieldCount(); iField++) { // No need to get field value if there's no value available... if (!ogrFeature.IsFieldSet(iField)) { continue; } int count; switch (ogrFeature.GetFieldType(iField)) { case OgrFieldType.OFTString: case OgrFieldType.OFTWideString: values[iField] = ogrFeature.GetFieldAsString(iField); break; case OgrFieldType.OFTStringList: case OgrFieldType.OFTWideStringList: values[iField] = ogrFeature.GetFieldAsStringList(iField); break; case OgrFieldType.OFTInteger: values[iField] = ogrFeature.GetFieldAsInteger(iField); break; case OgrFieldType.OFTIntegerList: values[iField] = ogrFeature.GetFieldAsIntegerList(iField, out count); break; case OgrFieldType.OFTReal: values[iField] = ogrFeature.GetFieldAsDouble(iField); break; case OgrFieldType.OFTRealList: values[iField] = ogrFeature.GetFieldAsDoubleList(iField, out count); break; case OgrFieldType.OFTDate: case OgrFieldType.OFTDateTime: case OgrFieldType.OFTTime: Int32 y, m, d, h, mi, s, tz; ogrFeature.GetFieldAsDateTime(iField, out y, out m, out d, out h, out mi, out s, out tz); try { if (y == 0 && m == 0 && d == 0) values[iField] = DateTime.MinValue.AddMinutes(h * 60 + mi); else values[iField] = new DateTime(y, m, d, h, mi, s); } // ReSharper disable once EmptyGeneralCatchClause catch { } break; default: Debug.WriteLine("Cannot handle Ogr DataType '{0}'", ogrFeature.GetFieldType(iField)); break; } } var fdr = (FeatureDataRow)table.LoadDataRow(values, true); using (var gr = ogrFeature.GetGeometryRef()) { fdr.Geometry = ParseOgrGeometry(gr, factory); gr.Dispose(); } return fdr; }
/// <summary> /// Indicates if a specified custom command is supported and can be created /// </summary> /// <param name="cmdType"></param> /// <returns></returns> public bool SupportsCommand(OSGeo.MapGuide.MaestroAPI.Commands.CommandType cmdType) { return Array.IndexOf(_conn.Capabilities.SupportedCommands, (int)cmdType) >= 0; }
private IGeometry ParseOgrGeometry(OSGeo.OGR.Geometry OgrGeometry) { byte[] wkbBuffer = new byte[OgrGeometry.WkbSize()]; int i = OgrGeometry.ExportToWkb(wkbBuffer); return SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse(wkbBuffer); }
/// <summary> /// Reads the field types from the OgrFeatureDefinition -> OgrFieldDefinition /// </summary> /// <param name="fdt">FeatureDatatTable</param> /// <param name="oLayer">OgrLayer</param> private void ReadColumnDefinition(FeatureDataTable fdt, OSGeo.OGR.Layer oLayer) { using (OSGeo.OGR.FeatureDefn _OgrFeatureDefn = oLayer.GetLayerDefn()) { int iField; for (iField = 0; iField < _OgrFeatureDefn.GetFieldCount(); iField++) { using (OSGeo.OGR.FieldDefn _OgrFldDef = _OgrFeatureDefn.GetFieldDefn(iField)) { OSGeo.OGR.FieldType type; switch ((type = _OgrFldDef.GetFieldType())) { case OSGeo.OGR.FieldType.OFTInteger: fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.Int32")); break; case OSGeo.OGR.FieldType.OFTReal: fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.Double")); break; case OSGeo.OGR.FieldType.OFTString: fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.String")); break; case OSGeo.OGR.FieldType.OFTWideString: fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.String")); break; default: { //fdt.Columns.Add(_OgrFldDef.GetName(), System.Type.GetType("System.String")); System.Diagnostics.Debug.WriteLine("Not supported type: " + type + " [" + _OgrFldDef.GetName() + "]"); break; } } } } } }
public string EditExpression(string currentExpr, OSGeo.MapGuide.MaestroAPI.Schema.ClassDefinition schema, string providerName, string featureSourceId, bool attachStylizationFunctions) { return _inner.EditExpression(currentExpr, schema, providerName, featureSourceId, attachStylizationFunctions); }
public object get_mapped_value(OSGeo.OGR.Feature feature, int esriFieldsIndex) { // get the ESRI Field ESRI.ArcGIS.Geodatabase.IField pField = m_fields.get_Field(esriFieldsIndex); if (esriFieldsIndex == m_oidFieldIndex) return feature.GetFID(); if (esriFieldsIndex == m_geometryFieldIndex) { System.Diagnostics.Debug.Assert(false); return null; // this should never be called for geometries } int ogrIndex = (int) m_fieldMapping[esriFieldsIndex]; if (!feature.IsFieldSet(ogrIndex)) return null; switch (feature.GetFieldType(ogrIndex)) { // must be kept in sync with utilities library case OSGeo.OGR.FieldType.OFTInteger: return feature.GetFieldAsInteger(ogrIndex); case OSGeo.OGR.FieldType.OFTReal: return feature.GetFieldAsDouble(ogrIndex); case OSGeo.OGR.FieldType.OFTString: return ogr_utils.ghetto_fix_ogr_string(feature.GetFieldAsString(ogrIndex)); case OSGeo.OGR.FieldType.OFTBinary: // WTF, the C# bindings don't have a blob retrieval until this ticket gets solved // http://trac.osgeo.org/gdal/ticket/4457#comment:2 return null; case OSGeo.OGR.FieldType.OFTDateTime: { int year, month, day, hour, minute, second, flag; feature.GetFieldAsDateTime(ogrIndex, out year, out month, out day, out hour, out minute, out second, out flag); DateTime date = new DateTime(year, month, day, hour, minute, second); return date; } default: return ogr_utils.ghetto_fix_ogr_string(feature.GetFieldAsString(ogrIndex)); //most things coerce as strings } }
/// <summary> /// Create a custom command /// </summary> /// <param name="cmdType"></param> /// <returns></returns> public OSGeo.MapGuide.MaestroAPI.Commands.ICommand CreateCommand(OSGeo.MapGuide.MaestroAPI.Commands.CommandType cmdType) { return _conn.CreateCommand((int)cmdType); }
internal static bool IsPreviewableType(OSGeo.MapGuide.MaestroAPI.ResourceTypes rt) { return Array.IndexOf(PREVIEWABLE_RESOURCE_TYPES, rt) >= 0; }
/// <summary> /// Invokes a prompt to select a resource of the specified type /// </summary> /// <param name="resType"></param> /// <returns></returns> public string SelectResource(OSGeo.MapGuide.MaestroAPI.ResourceTypes resType) { var picker = new ResourcePicker(_conn.ResourceService, resType, ResourcePickerMode.OpenResource); if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return picker.ResourceID; } return string.Empty; }
public Layer CreateLayer(string name, OSGeo.OSR.SpatialReference srs, wkbGeometryType geom_type, string[] options) { IntPtr cPtr = OgrPINVOKE.DataSource_CreateLayer(swigCPtr, name, OSGeo.OSR.SpatialReference.getCPtr(srs), (int)geom_type, (options != null)? new OgrPINVOKE.StringListMarshal(options)._ar : null); Layer ret = (cPtr == IntPtr.Zero) ? null : new Layer(cPtr, false, ThisOwn_false()); if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static Geometry CreateGeometryFromWkt(ref string val, OSGeo.OSR.SpatialReference reference) { IntPtr cPtr = OgrPINVOKE.CreateGeometryFromWkt(ref val, OSGeo.OSR.SpatialReference.getCPtr(reference)); Geometry ret = (cPtr == IntPtr.Zero) ? null : new Geometry(cPtr, true, ThisOwn_true()); if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public override OSGeo.MapGuide.MaestroAPI.Resource.IResource CreateItem(string startPoint, OSGeo.MapGuide.MaestroAPI.IServerConnection conn) { return ObjectFactory.CreateMapDefinition(conn, new Version(2, 4, 0), string.Empty); }