ConnectToSdfFile

Land Desktop Map 3D Samples

 
ConnectToSdfFile
 
 
 

This method takes three arguments: a string containing an aboslute path to a directory containing the SDF file library, a string containing the relative path and filename of the SDF file, and an optional boolean indicating whether the SDF file is read-only. It returns an MgResourceIdentifier identifier, which identifies the SDF file as a resource. This method does the following:

  1. Constructs a full path to the SDF file.
  2. Confirms that the file exists and is an SDF file.
  3. Constructs an OSGeo.MapGuide.Schema.FeatureSource.FeatureSourceType object that contains a field identifying the provider to use (SDF provider) and two key-value pairs identifying the location of the SDF file and whether it is read-only or can be written. The key-value pairs are OSGeo.MapGuide.Schema.FeatureSource.NameValuePairType objects.
  4. Serializes the FeatureSourceType object as an xml-formatted string. Here is an example.
    <?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n
    <FeatureSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n
      <Provider>OSGeo.SDF.3.2</Provider>\r\n
      <Parameter>\r\n
        <Name>File</Name>\r\n
        <Value>c:\\temp\\results3.sdf</Value>\r\n
      </Parameter>\r\n
      <Parameter>\r\n
        <Name>ReadOnly</Name>\r\n
        <Value>False</Value>\r\n
      </Parameter>\r\n
    </FeatureSource>
  5. Converts the xml-formatted string to an array of bytes.
  6. Uses the relative path to the SDF file to create a string identifying the location of the resource in the repository.
  7. Uses the repository resource path string to create an OSGeo.MapGuide.MgResourceIdentifier object.
  8. Uses the OSGeo.MapGuide.MgResourceService to store the byte array containing the FeatureSourceType object in the repository identified by the MgResourceIdentifier object. The byte manipulation involves the use of the OSGeo.MapGuide.MgByteSource and OSGeo.MapGuide.MgByteReader classes.