public static MgDataPropertyDefinition CreateReverseTextProperty(int length) { MgDataPropertyDefinition textProperty = new MgDataPropertyDefinition("ReverseText"); textProperty.SetDataType(MgPropertyType.String); textProperty.SetLength(length); return textProperty; }
public static MgDataPropertyDefinition CreateTextProperty(int length) { MgDataPropertyDefinition text = new MgDataPropertyDefinition(TEXT_NAME); text.SetDataType(MgPropertyType.String); text.SetLength(length); return text; }
public static MgDataPropertyDefinition CreateTextProperty(int length) { MgDataPropertyDefinition text = new MgDataPropertyDefinition(TEXT_NAME); text.SetDataType(MgPropertyType.String); text.SetLength(length); return(text); }
// 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); }
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); }
private void Ensure() { if (_registryFsId == null) { _registryFsId = new MgResourceIdentifier("Session:" + _sessionID + "//MarkupRegistry.FeatureSource"); if (!_resSvc.ResourceExists(_registryFsId)) { //Markup Registry Feature Source Schema // //Default // MarkupRegistry // ResourceId (String, Identity, Not Null) // LayerDefintion (String, Not Null) // Name (String, Not Null) // FdoProvider (String, Not Null) // GeometryTypes (Int, Not Null) MgFeatureSchema schema = new MgFeatureSchema("Default", ""); MgClassDefinition cls = new MgClassDefinition(); cls.SetName("MarkupRegistry"); MgDataPropertyDefinition regId = new MgDataPropertyDefinition("ResourceId"); regId.SetDataType(MgPropertyType.String); regId.SetLength(1024); regId.SetNullable(false); MgDataPropertyDefinition layerDefId = new MgDataPropertyDefinition("LayerDefinition"); layerDefId.SetDataType(MgPropertyType.String); layerDefId.SetLength(1024); layerDefId.SetNullable(false); MgDataPropertyDefinition name = new MgDataPropertyDefinition("Name"); name.SetDataType(MgPropertyType.String); name.SetLength(512); name.SetNullable(false); MgDataPropertyDefinition provider = new MgDataPropertyDefinition("FdoProvider"); provider.SetDataType(MgPropertyType.String); provider.SetLength(512); provider.SetNullable(false); MgDataPropertyDefinition geomTypes = new MgDataPropertyDefinition("GeometryTypes"); geomTypes.SetDataType(MgPropertyType.Int32); geomTypes.SetNullable(false); MgDataPropertyDefinition styleType = new MgDataPropertyDefinition("StyleType"); styleType.SetDataType(MgPropertyType.Int32); styleType.SetNullable(false); MgPropertyDefinitionCollection dataProps = cls.GetProperties(); dataProps.Add(regId); dataProps.Add(layerDefId); dataProps.Add(name); dataProps.Add(provider); dataProps.Add(geomTypes); dataProps.Add(styleType); MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties(); idProps.Add(regId); MgClassDefinitionCollection classes = schema.GetClasses(); classes.Add(cls); //No coordinate system required here because we're not storing spatial data MgFileFeatureSourceParams createSdf = new MgFileFeatureSourceParams("OSGeo.SDF", "Default", "", schema); _featSvc.CreateFeatureSource(_registryFsId, createSdf); } } }
//--------------------------------------------------------------------------------------- // // ���ܣ�����һ����ΪtempParcel��Ҫ���� // // ���ߣ� // // ���ڣ� 2007.5.23 // // ����ʷ���� // //--------------------------------------------------------------------------------------- private void createTempParcelFeatureSource(MgFeatureService featureService, MgResourceIdentifier resId) { MgClassDefinition parcelClass = null; MgPropertyDefinitionCollection props = null; string ll84Wkt = ""; //����Ҫ���� 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]]"; parcelClass = new MgClassDefinition(); parcelClass.SetName("tempParcel"); props = parcelClass.GetProperties(); //����Ҫ���ඨ��ı�ʶ���� MgDataPropertyDefinition id = new MgDataPropertyDefinition("ID"); id.SetDataType(MgPropertyType.Int32); id.SetReadOnly(true); id.SetNullable(false); id.SetAutoGeneration(true); props.Add(id); MgPropertyDefinitionCollection idProps = parcelClass.GetIdentityProperties(); idProps.Add(id); //����Ҫ���ඨ��ļ������� MgGeometricPropertyDefinition geom = new MgGeometricPropertyDefinition("GEOM"); geom.SetGeometryTypes(MgFeatureGeometricType.Surface); geom.SetHasElevation(false); geom.SetHasMeasure(false); geom.SetSpatialContextAssociation("LL84"); props.Add(geom); parcelClass.SetDefaultGeometryPropertyName("GEOM"); //����Ҫ���ඨ��һ������� MgDataPropertyDefinition acre = new MgDataPropertyDefinition("ACRE"); acre.SetDataType(MgPropertyType.String); acre.SetLength(256); props.Add(acre); MgDataPropertyDefinition billingAddr = new MgDataPropertyDefinition("BILLADDR"); billingAddr.SetDataType(MgPropertyType.String); billingAddr.SetLength(64); props.Add(billingAddr); MgDataPropertyDefinition desc1 = new MgDataPropertyDefinition("DESC1"); desc1.SetDataType(MgPropertyType.String); desc1.SetLength(64); props.Add(desc1); MgDataPropertyDefinition desc2 = new MgDataPropertyDefinition("DESC2"); desc2.SetDataType(MgPropertyType.String); desc2.SetLength(64); props.Add(desc2); MgDataPropertyDefinition desc3 = new MgDataPropertyDefinition("DESC3"); desc3.SetDataType(MgPropertyType.String); desc3.SetLength(64); props.Add(desc3); MgDataPropertyDefinition desc4 = new MgDataPropertyDefinition("DESC4"); desc4.SetDataType(MgPropertyType.String); desc4.SetLength(64); props.Add(desc4); MgDataPropertyDefinition lotDimension = new MgDataPropertyDefinition("LOTDIM"); lotDimension.SetDataType(MgPropertyType.String); lotDimension.SetLength(32); props.Add(lotDimension); MgDataPropertyDefinition sqft = new MgDataPropertyDefinition("SQFT"); sqft.SetDataType(MgPropertyType.Int32); props.Add(sqft); MgDataPropertyDefinition owner = new MgDataPropertyDefinition("OWNER"); owner.SetDataType(MgPropertyType.String); owner.SetLength(64); props.Add(owner); MgDataPropertyDefinition zone = new MgDataPropertyDefinition("ZONE"); zone.SetDataType(MgPropertyType.String); zone.SetLength(32); props.Add(zone); // ����ģʽ MgFeatureSchema schema = new MgFeatureSchema(); schema.SetName("SchemaParcels"); schema.GetClasses().Add(parcelClass); MgCreateSdfParams sdfParams = new MgCreateSdfParams("LL84", ll84Wkt, schema); featureService.CreateFeatureSource(resId, sdfParams); // }
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); }