Ejemplo n.º 1
0
        public void CreateBufferFeatureSource(MgFeatureService featureService, String wkt, MgResourceIdentifier bufferFeatureResId)
        {
            MgClassDefinition bufferClass = new MgClassDefinition();
            bufferClass.SetName("BufferClass");
            MgPropertyDefinitionCollection properties = bufferClass.GetProperties();

            MgDataPropertyDefinition idProperty = new MgDataPropertyDefinition("ID");
            idProperty.SetDataType(MgPropertyType.Int32);
            idProperty.SetReadOnly(true);
            idProperty.SetNullable(false);
            idProperty.SetAutoGeneration(true);
            properties.Add(idProperty);

            MgGeometricPropertyDefinition polygonProperty = new MgGeometricPropertyDefinition("BufferGeometry");
            polygonProperty.SetGeometryTypes(MgFeatureGeometricType.Surface);
            polygonProperty.SetHasElevation(false);
            polygonProperty.SetHasMeasure(false);
            polygonProperty.SetReadOnly(false);
            polygonProperty.SetSpatialContextAssociation("defaultSrs");
            properties.Add(polygonProperty);

            MgPropertyDefinitionCollection idProperties = bufferClass.GetIdentityProperties();
            idProperties.Add(idProperty);

            bufferClass.SetDefaultGeometryPropertyName("BufferGeometry");

            MgFeatureSchema bufferSchema = new MgFeatureSchema("BufferLayerSchema", "temporary schema to hold a buffer");
            bufferSchema.GetClasses().Add(bufferClass);

            MgCreateSdfParams sdfParams = new MgCreateSdfParams("defaultSrs", wkt, bufferSchema);

            featureService.CreateFeatureSource(bufferFeatureResId, sdfParams);
        }
Ejemplo n.º 2
0
        public static MgGeometricPropertyDefinition CreateGeometryProperty(int geomType)
        {
            MgGeometricPropertyDefinition geometryProperty = new MgGeometricPropertyDefinition("Geometry");
            geometryProperty.SetGeometryTypes(geomType);
            geometryProperty.SetHasElevation(false);
            geometryProperty.SetHasMeasure(false);
            geometryProperty.SetReadOnly(false);
            geometryProperty.SetSpatialContextAssociation("LL84");

            return geometryProperty;
        }
Ejemplo n.º 3
0
        public static MgGeometricPropertyDefinition CreateGeometryProperty(int geomType)
        {
            MgGeometricPropertyDefinition geom = new MgGeometricPropertyDefinition(GEOM_NAME);
            geom.SetGeometryTypes(geomType);
            geom.SetHasElevation(false);
            geom.SetHasMeasure(false);
            geom.SetReadOnly(false);
            geom.SetSpatialContextAssociation(SPATIAL_CONTEXT);

            return geom;
        }
Ejemplo n.º 4
0
        public static MgGeometricPropertyDefinition CreateGeometryProperty(int geomType)
        {
            MgGeometricPropertyDefinition geom = new MgGeometricPropertyDefinition(GEOM_NAME);

            geom.SetGeometryTypes(geomType);
            geom.SetHasElevation(false);
            geom.SetHasMeasure(false);
            geom.SetReadOnly(false);
            geom.SetSpatialContextAssociation(SPATIAL_CONTEXT);

            return(geom);
        }
Ejemplo n.º 5
0
    // Create a temporary Feature Source to store geocode results.
    public void CreateLocationMarkerFeatureSource(MgFeatureService featureService, MgResourceIdentifier locationMarkerDataResId, MgMap map)
    {
        //String ll84Wkt = "GEOGCS[\"LL84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.25722293287],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degrees\",1]]";
        //string ll84Wkt = "LOCAL_CS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]] ";
        MgCoordinateSystemFactory sysCoordsFactory = new MgCoordinateSystemFactory();
        string srsDefMap = map.GetMapSRS();
        string mapSrsUnits = string.Empty;

        srsDefMap = !string.IsNullOrEmpty(srsDefMap) ? srsDefMap : "LOCAL_CS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]] ";

        MgCoordinateSystem srsMap = sysCoordsFactory.Create(srsDefMap);
        MgClassDefinition locationClass = new MgClassDefinition();
        locationClass.SetName("LocationMarker");
        MgPropertyDefinitionCollection properties = locationClass.GetProperties();

        MgDataPropertyDefinition idProperty = new MgDataPropertyDefinition("ID");
        idProperty.SetDataType(MgPropertyType.Int32);
        idProperty.SetReadOnly(true);
        idProperty.SetNullable(false);
        idProperty.SetAutoGeneration(true);
        properties.Add(idProperty);

        MgDataPropertyDefinition addressProperty = new MgDataPropertyDefinition("Address");
        addressProperty.SetDataType(MgPropertyType.String);
        addressProperty.SetLength(512);
        properties.Add(addressProperty);

        MgGeometricPropertyDefinition locationProperty = new MgGeometricPropertyDefinition("Location");
        locationProperty.SetGeometryTypes(MgGeometryType.Point);
        locationProperty.SetHasElevation(false);
        locationProperty.SetHasMeasure(false);
        locationProperty.SetReadOnly(false);
        locationProperty.SetSpatialContextAssociation(srsMap.GetCsCode());
        properties.Add(locationProperty);

        MgPropertyDefinitionCollection idProperties = locationClass.GetIdentityProperties();
        idProperties.Add(idProperty);

        locationClass.SetDefaultGeometryPropertyName("Location");

        MgFeatureSchema locationSchema = new MgFeatureSchema();
        locationSchema.SetName("LocationMarkerSchema");
        locationSchema.GetClasses().Add(locationClass);

        MgCreateSdfParams sdfParams = new MgCreateSdfParams(srsMap.GetCsCode(), srsDefMap, locationSchema);

        featureService.CreateFeatureSource(locationMarkerDataResId, sdfParams);
    }
Ejemplo n.º 6
0
        public void CreateBufferFeatureSource(MgFeatureService featureService, String wkt, MgResourceIdentifier bufferFeatureResId)
        {
            MgClassDefinition bufferClass = new MgClassDefinition();

            bufferClass.SetName("BufferClass");
            MgPropertyDefinitionCollection properties = bufferClass.GetProperties();

            MgDataPropertyDefinition idProperty = new MgDataPropertyDefinition("ID");

            idProperty.SetDataType(MgPropertyType.Int32);
            idProperty.SetReadOnly(true);
            idProperty.SetNullable(false);
            idProperty.SetAutoGeneration(true);
            properties.Add(idProperty);

            MgGeometricPropertyDefinition polygonProperty = new MgGeometricPropertyDefinition("BufferGeometry");

            polygonProperty.SetGeometryTypes(MgFeatureGeometricType.Surface);
            polygonProperty.SetHasElevation(false);
            polygonProperty.SetHasMeasure(false);
            polygonProperty.SetReadOnly(false);
            polygonProperty.SetSpatialContextAssociation("defaultSrs");
            properties.Add(polygonProperty);

            MgPropertyDefinitionCollection idProperties = bufferClass.GetIdentityProperties();

            idProperties.Add(idProperty);

            bufferClass.SetDefaultGeometryPropertyName("BufferGeometry");

            MgFeatureSchema bufferSchema = new MgFeatureSchema("BufferLayerSchema", "temporary schema to hold a buffer");

            bufferSchema.GetClasses().Add(bufferClass);

            MgFileFeatureSourceParams sdfParams = new MgFileFeatureSourceParams("OSGeo.SDF", "defaultSrs", wkt, bufferSchema);

            featureService.CreateFeatureSource(bufferFeatureResId, sdfParams);
        }
Ejemplo n.º 7
0
        public void CreateParcelMarkerFeatureSource(MgFeatureService featureService, String wkt, MgResourceIdentifier parcelMarkerDataResId)
        {
            MgClassDefinition parcelClass = new MgClassDefinition();

            parcelClass.SetName("ParcelMarkerClass");
            MgPropertyDefinitionCollection properties = parcelClass.GetProperties();

            MgDataPropertyDefinition idProperty = new MgDataPropertyDefinition("ID");

            idProperty.SetDataType(MgPropertyType.Int32);
            idProperty.SetReadOnly(true);
            idProperty.SetNullable(false);
            idProperty.SetAutoGeneration(true);
            properties.Add(idProperty);

            MgGeometricPropertyDefinition pointProperty = new MgGeometricPropertyDefinition("ParcelLocation");

            pointProperty.SetGeometryTypes(MgGeometryType.Point);
            pointProperty.SetHasElevation(false);
            pointProperty.SetHasMeasure(false);
            pointProperty.SetReadOnly(false);
            pointProperty.SetSpatialContextAssociation("defaultSrs");
            properties.Add(pointProperty);

            MgPropertyDefinitionCollection idProperties = parcelClass.GetIdentityProperties();

            idProperties.Add(idProperty);

            parcelClass.SetDefaultGeometryPropertyName("ParcelLocation");

            MgFeatureSchema parcelSchema = new MgFeatureSchema("ParcelLayerSchema", "temporary schema to hold parcel markers");

            parcelSchema.GetClasses().Add(parcelClass);

            MgFileFeatureSourceParams sdfParams = new MgFileFeatureSourceParams("OSGeo.SDF", "defaultSrs", wkt, parcelSchema);

            featureService.CreateFeatureSource(parcelMarkerDataResId, sdfParams);
        }
Ejemplo n.º 8
0
        internal static MgFeatureSchema ConvertSchema(FeatureSchema source)
        {
            MgFeatureSchema             fs      = new MgFeatureSchema(source.Name, source.Description);
            MgClassDefinitionCollection classes = fs.GetClasses();

            foreach (ClassDefinition cls in source.Classes)
            {
                MgClassDefinition clsDef = new MgClassDefinition();
                clsDef.SetName(cls.Name);
                clsDef.SetDescription(cls.Description);
                clsDef.SetDefaultGeometryPropertyName(cls.DefaultGeometryPropertyName);
                var clsProps = clsDef.GetProperties();
                var idProps  = clsDef.GetIdentityProperties();

                foreach (PropertyDefinition prop in cls.Properties)
                {
                    switch (prop.Type)
                    {
                    case PropertyDefinitionType.Data:
                    {
                        var dp    = new MgDataPropertyDefinition(prop.Name);
                        var srcDp = (DataPropertyDefinition)prop;
                        dp.SetAutoGeneration(srcDp.IsAutoGenerated);
                        dp.SetDataType((int)srcDp.DataType);
                        if (srcDp.DefaultValue != null)
                        {
                            dp.SetDefaultValue(srcDp.DefaultValue);
                        }
                        if (srcDp.Description != null)
                        {
                            dp.SetDescription(srcDp.Description);
                        }
                        dp.SetLength(srcDp.Length);
                        dp.SetNullable(srcDp.IsNullable);
                        dp.SetPrecision(srcDp.Precision);
                        dp.SetReadOnly(srcDp.IsReadOnly);
                        dp.SetScale(srcDp.Scale);

                        clsProps.Add(dp);

                        if (cls.IdentityProperties.Contains(srcDp))
                        {
                            idProps.Add(dp);
                        }
                    }
                    break;

                    case PropertyDefinitionType.Geometry:
                    {
                        var gp    = new MgGeometricPropertyDefinition(prop.Name);
                        var srcGp = (GeometricPropertyDefinition)prop;
                        if (srcGp.Description != null)
                        {
                            gp.SetDescription(srcGp.Description);
                        }
                        gp.SetGeometryTypes((int)srcGp.GeometricTypes);
                        gp.SetHasElevation(srcGp.HasElevation);
                        gp.SetHasMeasure(srcGp.HasMeasure);
                        gp.SetReadOnly(srcGp.IsReadOnly);
                        if (srcGp.SpatialContextAssociation != null)
                        {
                            gp.SetSpatialContextAssociation(srcGp.SpatialContextAssociation);
                        }

                        clsProps.Add(gp);
                    }
                    break;

                    case PropertyDefinitionType.Raster:
                    {
                        var rp    = new MgRasterPropertyDefinition(prop.Name);
                        var srcRp = (RasterPropertyDefinition)prop;
                        rp.SetDefaultImageXSize(srcRp.DefaultImageYSize);
                        rp.SetDefaultImageYSize(srcRp.DefaultImageYSize);
                        if (srcRp.Description != null)
                        {
                            rp.SetDescription(srcRp.Description);
                        }
                        rp.SetNullable(srcRp.IsNullable);
                        rp.SetReadOnly(srcRp.IsReadOnly);
                        if (srcRp.SpatialContextAssociation != null)
                        {
                            rp.SetSpatialContextAssociation(srcRp.SpatialContextAssociation);
                        }

                        clsProps.Add(rp);
                    }
                    break;

                    default:
                        throw new NotSupportedException();
                    }
                }

                classes.Add(clsDef);
            }

            return(fs);
        }
Ejemplo n.º 9
0
    private MgFeatureSchema CreateFilterSchema()
    {
        MgFeatureSchema filterSchema = new MgFeatureSchema();
        filterSchema.SetName("FilterSchema");

        MgClassDefinition filterClass = new MgClassDefinition();
        filterClass.SetName("Filter");
        MgPropertyDefinitionCollection properties = filterClass.GetProperties();

        MgDataPropertyDefinition idProperty = new MgDataPropertyDefinition("ID");
        idProperty.SetDataType(MgPropertyType.Int32);
        idProperty.SetReadOnly(true);
        idProperty.SetNullable(false);
        idProperty.SetAutoGeneration(true);
        properties.Add(idProperty);

        MgGeometricPropertyDefinition geometryProperty = new MgGeometricPropertyDefinition("Geometry");
        geometryProperty.SetGeometryTypes(MgFeatureGeometricType.Surface);
        geometryProperty.SetHasElevation(false);
        geometryProperty.SetHasMeasure(true);
        geometryProperty.SetReadOnly(false);
        geometryProperty.SetSpatialContextAssociation("MAPCS");
        properties.Add(geometryProperty);

        filterClass.GetIdentityProperties().Add(idProperty);
        filterClass.SetDefaultGeometryPropertyName("Geometry");

        filterSchema.GetClasses().Add(filterClass);

        return filterSchema;
    }
Ejemplo n.º 10
0
        public void CreateParcelMarkerFeatureSource(MgFeatureService featureService, String wkt, MgResourceIdentifier parcelMarkerDataResId)
        {
            MgClassDefinition parcelClass = new MgClassDefinition();
            parcelClass.SetName("ParcelMarkerClass");
            MgPropertyDefinitionCollection properties = parcelClass.GetProperties();

            MgDataPropertyDefinition idProperty = new MgDataPropertyDefinition("ID");
            idProperty.SetDataType(MgPropertyType.Int32);
            idProperty.SetReadOnly(true);
            idProperty.SetNullable(false);
            idProperty.SetAutoGeneration(true);
            properties.Add(idProperty);

            MgGeometricPropertyDefinition pointProperty = new MgGeometricPropertyDefinition("ParcelLocation");
            pointProperty.SetGeometryTypes(MgGeometryType.Point);
            pointProperty.SetHasElevation(false);
            pointProperty.SetHasMeasure(false);
            pointProperty.SetReadOnly(false);
            pointProperty.SetSpatialContextAssociation("defaultSrs");
            properties.Add(pointProperty);

            MgPropertyDefinitionCollection idProperties = parcelClass.GetIdentityProperties();
            idProperties.Add(idProperty);

            parcelClass.SetDefaultGeometryPropertyName("ParcelLocation");

            MgFeatureSchema parcelSchema = new MgFeatureSchema("ParcelLayerSchema", "temporary schema to hold parcel markers");
            parcelSchema.GetClasses().Add(parcelClass);

            MgCreateSdfParams sdfParams = new MgCreateSdfParams("defaultSrs", wkt, parcelSchema);

            featureService.CreateFeatureSource(parcelMarkerDataResId, sdfParams);
        }
Ejemplo n.º 11
0
        void CreateLocationMarkerFeatureSource(MgFeatureService featureService, MgResourceIdentifier locationMarkerDataResId)
        {
            String ll84Wkt = "GEOGCS[\"LL84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.25722293287],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degrees\",1]]";

            MgClassDefinition locationClass = new MgClassDefinition();
            locationClass.SetName("LocationMarker");
            MgPropertyDefinitionCollection properties = locationClass.GetProperties();

            MgDataPropertyDefinition idProperty = new MgDataPropertyDefinition("ID");
            idProperty.SetDataType(MgPropertyType.Int32);
            idProperty.SetReadOnly(true);
            idProperty.SetNullable(false);
            idProperty.SetAutoGeneration(true);
            properties.Add(idProperty);

            MgDataPropertyDefinition addressProperty = new MgDataPropertyDefinition("Address");
            addressProperty.SetDataType(MgPropertyType.String);
            addressProperty.SetLength(512);
            properties.Add(addressProperty);

            MgGeometricPropertyDefinition locationProperty = new MgGeometricPropertyDefinition("Location");
            locationProperty.SetGeometryTypes(MgGeometryType.Point);
            locationProperty.SetHasElevation(false);
            locationProperty.SetHasMeasure(false);
            locationProperty.SetReadOnly(false);
            locationProperty.SetSpatialContextAssociation("LL84");
            properties.Add(locationProperty);

            MgPropertyDefinitionCollection idProperties = locationClass.GetIdentityProperties();
            idProperties.Add(idProperty);

            locationClass.SetDefaultGeometryPropertyName("Location");

            MgFeatureSchema locationSchema = new MgFeatureSchema();
            locationSchema.SetName("LocationMarkerSchema");
            locationSchema.GetClasses().Add(locationClass);

            MgCreateSdfParams sdfParams = new MgCreateSdfParams("LL84", ll84Wkt, locationSchema);

            featureService.CreateFeatureSource(locationMarkerDataResId, sdfParams);
        }