本文整理汇总了C#中MgResourceIdentifier类的典型用法代码示例。如果您正苦于以下问题:C# MgResourceIdentifier类的具体用法?C# MgResourceIdentifier怎么用?C# MgResourceIdentifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MgResourceIdentifier类属于命名空间,在下文中一共展示了MgResourceIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearSpatialFilter
public bool ClearSpatialFilter()
{
bool result = true;
MgUserInformation userInfo = new MgUserInformation(Request["SESSION"]);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgResourceIdentifier sdfResId = new MgResourceIdentifier("Session:" + Request["SESSION"] + "//Filter.FeatureSource");
MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService;
MgMap map = new MgMap();
map.Open(resourceService, Request["MAPNAME"]);
MgFeatureCommandCollection updateCommands = new MgFeatureCommandCollection();
MgLayer layer = null;
MgLayerCollection layers = map.GetLayers();
if (layers.Contains("_QuerySpatialFilter"))
{
layer = (MgLayer)layers.GetItem("_QuerySpatialFilter");
updateCommands.Add(new MgDeleteFeatures("Filter", "ID > 0"));
featureService.UpdateFeatures(sdfResId, updateCommands, false);
layers.Remove(layer);
map.Save(resourceService);
}
return result;
}
示例2: Invoke
public override void Invoke()
{
var provider = this.Viewer.GetProvider();
var mdfId = new MgResourceIdentifier(this.MapDefinition);
var map = provider.CreateMap(mdfId, mdfId.GetName());
provider.LoadMap(map);
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
try
{
var fact = new MgdServiceFactory();
MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
MgFeatureQueryOptions query = new MgFeatureQueryOptions();
string[] propNames = txtProps.Text.Split(',');
foreach (var p in propNames)
{
if (string.IsNullOrEmpty(p))
continue;
query.AddFeatureProperty(p);
}
foreach (Pair p in lstComputed.Items)
{
query.AddComputedProperty(p.Name, p.Expr);
}
if (!string.IsNullOrEmpty(txtFilter.Text.Trim()))
query.SetFilter(txtFilter.Text.Trim());
MgResourceIdentifier fsId = new MgResourceIdentifier(txtFeatureSource.Text);
MgFeatureReader reader = featSvc.SelectFeatures(fsId, txtClass.Text, query);
new ReaderResponseDialog(reader).ShowDialog();
}
catch (MgException ex)
{
MessageBox.Show(ex.ToString(), "Error from MapGuide");
}
}
示例4: createMuniMarker
//----------------------------------------------------------------------------------------
// �� �ܣ� ��Mapguide���ص�����ת��ΪKML
//
// �� �ߣ�
//
//
// �� �ڣ�2007.05.#
//
//-----------------------------------------------------------------------------------------
public String createMuniMarker()
{
StringBuilder outString = new StringBuilder();
MgGeometryFactory geoFactory = new MgGeometryFactory();
outString.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
MgResourceIdentifier resId = new MgResourceIdentifier("Library://MgTutorial/Data/WheatonMunicipalities.FeatureSource");
MgFeatureReader featureReader = featureService.SelectFeatures(resId, "WheatonMunicipalities", null);
outString.Append("<markers>");
MgAgfReaderWriter geoReader = new MgAgfReaderWriter();
while (featureReader.ReadNext())
{
String muniName = featureReader.GetString("MUNINAME");
MgByteReader byteReader = featureReader.GetGeometry("Geometry");
MgGeometry geo = geoReader.Read(byteReader);
MgPoint pt = geo.GetCentroid();
double x = pt.GetCoordinate().GetX();
double y = pt.GetCoordinate().GetY();
outString.Append("<marker lat=\"" + y + "\" lng=\"" + x + "\" info=\"" + muniName + "\" />");
}
featureReader.Close();
outString.Append("</markers>");
return outString.ToString();
}
示例5: Plot
private MgByteReader Plot(MapGuideViewerInputModel input, bool useLayout, double? scale)
{
MgSiteConnection conn = CreateConnection(input);
MgMap map = new MgMap(conn);
map.Open(input.MapName);
MgPoint center = map.ViewCenter;
MgCoordinate coord = center.Coordinate;
MgMappingService mappingService = (MgMappingService)conn.CreateService(MgServiceType.MappingService);
MgDwfVersion dwfVersion = new MgDwfVersion("6.01", "1.2");
MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f);
plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f);
MgLayout layout = null;
if (useLayout)
{
MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout");
layout = new MgLayout(layoutRes, "City of Sheboygan", MgPageUnitsType.Inches);
}
if (!scale.HasValue)
{
return mappingService.GeneratePlot(map, plotSpec, layout, dwfVersion);
}
else
{
MgCoordinate mapCenter = map.GetViewCenter().GetCoordinate();
return mappingService.GeneratePlot(map, mapCenter, scale.Value, plotSpec, layout, dwfVersion);
}
}
示例6: GetAllFeatures
public IEnumerable<RedlineObject> GetAllFeatures()
{
MgMapBase map = _viewer.GetMap();
MgLayerCollection layers = map.GetLayers();
MgLayerBase redlineLayer = layers.GetItem(_layer.SystemName);
MgResourceIdentifier resId = new MgResourceIdentifier(redlineLayer.GetFeatureSourceId());
MgFeatureReader reader = null;
try
{
reader = _featSvc.SelectFeatures(resId, RedlineSchemaFactory.CLASS_NAME, null);
//HACK: Another leaky abstraction. SHP will always choose FeatId, so once again
//use the class definition to determine the identity property name
MgClassDefinition cls = reader.GetClassDefinition();
MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties();
MgPropertyDefinition keyProp = idProps.GetItem(0);
string idName = keyProp.GetName();
while (reader.ReadNext())
{
int id = reader.GetInt32(idName);
string text = reader.IsNull(RedlineSchemaFactory.TEXT_NAME) ? string.Empty : reader.GetString(RedlineSchemaFactory.TEXT_NAME);
yield return new RedlineObject(id, text);
}
}
finally
{
if (reader != null)
reader.Close();
}
}
示例7: CreateBufferFeatureSource
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);
}
示例8: Index
// GET: Home
public ActionResult Index()
{
MgUserInformation user = new MgUserInformation("Anonymous", "");
MgSiteConnection conn = new MgSiteConnection();
conn.Open(user);
MgResourceService resSvc = (MgResourceService)conn.CreateService(MgServiceType.ResourceService);
var vm = new HomeViewModel()
{
HasSampleResources = true,
AjaxLayout = AJAX_LAYOUT,
FlexLayout = FLEX_LAYOUT
};
MgResourceIdentifier mdfId = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
MgResourceIdentifier sample1 = new MgResourceIdentifier(vm.AjaxLayout);
MgResourceIdentifier sample2 = new MgResourceIdentifier(vm.FlexLayout);
vm.HasSampleResources = resSvc.ResourceExists(mdfId) &&
resSvc.ResourceExists(sample1) &&
resSvc.ResourceExists(sample2);
return View(vm);
}
示例9: btnCreateFile_Click
private void btnCreateFile_Click(object sender, EventArgs e)
{
try
{
var fact = new MgdServiceFactory();
var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
var param = new MgFileFeatureSourceParams();
param.CoordinateSystemWkt = txtCoordinateSystemWkt.Text;
param.FileName = txtFileName.Text;
var schemas = featureSvc.XmlToSchema(File.ReadAllText(txtSchemaXml.Text));
param.FeatureSchema = schemas.GetItem(0);
param.ProviderName = txtProvider.Text;
param.SpatialContextDescription = "Created from MgFileFeatureSourceParams";
param.SpatialContextName = txtCoordinateSystemName.Text;
param.XYTolerance = double.Parse(txtXYTolerance.Text);
param.ZTolerance = double.Parse(txtZTolerance.Text);
var fsId = new MgResourceIdentifier(txtResourceId.Text);
featureSvc.CreateFeatureSource(fsId, param);
MessageBox.Show("Success");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
示例10: TestEnd
public void TestEnd()
{
try
{
var fact = new MgdServiceFactory();
MgdResourceService service = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService);
MgResourceIdentifier mapres1 = new MgResourceIdentifier("Library://UnitTests/Data/Shuttle.DrawingSource");
service.DeleteResource(mapres1);
if (service.ResourceExists(resourceIdentifier))
service.DeleteResource(resourceIdentifier);
if (service.ResourceExists(resourceIdentifier2))
service.DeleteResource(resourceIdentifier2);
if (service.ResourceExists(resourceIdentifier3))
service.DeleteResource(resourceIdentifier3);
if (service.ResourceExists(resourceIdentifier4))
service.DeleteResource(resourceIdentifier4);
}
catch (MgException ex)
{
ex.Dispose();
}
}
示例11: button1_Click
private void button1_Click(object sender, EventArgs e)
{
try
{
var fact = new MgdServiceFactory();
MgdRenderingService renSvc = (MgdRenderingService)fact.CreateService(MgServiceType.RenderingService);
MgResourceIdentifier mdfId = new MgResourceIdentifier(txtMapDefinition.Text);
var sw = new Stopwatch();
sw.Start();
MgdMap map = new MgdMap(mdfId);
sw.Stop();
Trace.TraceInformation("Runtime map created in {0}ms", sw.ElapsedMilliseconds);
map.SetViewScale(Convert.ToDouble(txtScale.Text));
sw.Reset();
sw.Start();
MgByteReader response = renSvc.RenderTile(map, txtBaseGroup.Text, Convert.ToInt32(txtCol.Text), Convert.ToInt32(txtRow.Text));
sw.Stop();
Trace.TraceInformation("RenderTile executed in {0}ms", sw.ElapsedMilliseconds);
new ImageResponseDialog(response).ShowDialog();
}
catch (MgException ex)
{
MessageBox.Show(ex.ToString(), "Error from MapGuide");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
}
}
示例12: SetResourceFromXml
public static void SetResourceFromXml(HtzMgHelper helper, MgResourceIdentifier resourceId, XmlDocument doc)
{
byte[] layerDef = new UTF8Encoding().GetBytes(doc.InnerXml);
MgByteSource byteSource = new MgByteSource(layerDef, layerDef.Length);
byteSource.SetMimeType("text/xml");
helper.ResourceService.SetResource(resourceId, byteSource.GetReader(), null);
}
示例13: btnReload_Click
private void btnReload_Click(object sender, EventArgs e)
{
_viewer.ClearSelection();
MgResourceIdentifier mdfId = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
MgdMap map = new MgdMap(mdfId);
MgDesktopMapViewerProvider provider = new MgDesktopMapViewerProvider(map);
Shell.Instance.ReloadViewer(provider);
}
示例14: GetResourceXml
// Methods
public static XmlDocument GetResourceXml(HtzMgHelper helper, MgResourceIdentifier resourceId)
{
XmlDocument result = new XmlDocument();
if (resourceId != null)
{
result.LoadXml(helper.ResourceService.GetResourceContent(resourceId).ToString());
}
return result;
}
示例15: AddPointFeature
public static void AddPointFeature(string FeatureName, MgPropertyCollection featureProps, MgPoint geom, MgFeatureService featureSrvc, MgResourceIdentifier dataSourceId)
{
MgByteReader geomReader = new MgAgfReaderWriter().Write(geom);
MgGeometryProperty geometryProp = new MgGeometryProperty("GEOM", geomReader);
featureProps.Add(geometryProp);
MgInsertFeatures cmd = new MgInsertFeatures(FeatureName, featureProps);
MgFeatureCommandCollection commands = new MgFeatureCommandCollection();
commands.Add(cmd);
ReleaseReader(featureSrvc.UpdateFeatures(dataSourceId, commands, false));
}