קריאת קבצי שפת סימון גיאוגרפית GML בשפה C#
Contents
[
Hide
]
שפת סימון גיאוגרפית (GML)
Aspose.GIS מספקת את היכולת לקרוא תכונות משפת סימון גיאוגרפית (GML). זה מאפשר לך לציין את אפשרות הסכימה במקרה שישנה אחת.
קריאת תכונות מקובץ GML על ידי ציון סכימה
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
GmlOptions options = new GmlOptions | |
{ | |
// In this example we specify custom schemaLocation, since there is no 'schemaLocation' in GML file. | |
SchemaLocation = "http://www.aspose.com schema.xsd", | |
LoadSchemasFromInternet = false, | |
}; | |
Console.WriteLine(""); | |
Console.WriteLine("custom schema location..."); | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "file_without_schema_location.gml", Drivers.Gml, options)) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue<string>("attribute")); | |
} | |
} |
קריאת תכונות מקובץ GML ללא ציון סכימה
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
// Case 1: we try to load schema from Internet. | |
// first, we create an instance of GmlOptions class. | |
GmlOptions options = new GmlOptions | |
{ | |
// In order to read GML layers features description, Aspose.GIS reads XML schema attached to it. | |
// Usually, it is specified in GML files root tag as 'schemaLocation' attribute. If it is not, you need to specify GML schema location | |
// youself. In this examples we don't specify it (keep it null), so Aspose.GIS will try to read schema location from XML file. | |
SchemaLocation = null, | |
// 'schemaLocation' may contain references to schemas located on the Internet. In this case, you need to set this property to 'true' in | |
// order to allow Aspose.GIS to load schemas from internet. | |
// Basically, if you don't mind Aspose.GIS using internet, you can always keep this true. | |
LoadSchemasFromInternet = true, | |
}; | |
// then, we pass it to 'VectorLayer.Open' | |
Console.WriteLine("from internet loading..."); | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "file.gml", Drivers.Gml, options)) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue<string>("attribute")); | |
} | |
} | |
// Case 2: we try to restore the attributes schema by data in file. | |
Console.WriteLine(""); | |
Console.WriteLine("restoration by file data..."); | |
using (VectorLayer layer = VectorLayer.Open(dataDir + "file.gml", Drivers.Gml, new GmlOptions(){RestoreSchema = true})) | |
{ | |
foreach (Feature feature in layer) | |
{ | |
Console.WriteLine(feature.GetValue<string>("attribute")); | |
} | |
} |