[mapguide-users] Re: Uploading Shapefile to Map for Immediate DisplayProblem

GordonL gordon.luckett at arrowgeomatics.com
Sun Nov 13 14:13:04 EST 2011


Hi, this is how I do it (not for the feint of heart).

1. Make sure you have a Unmanaged Resource Alias set up in MapGuide
Administrator that points to the folder on the server where you upload the
file to.
2. Create a data connection in Maestro that points to the ALIAS
3. Create a layer you can use that points to a test SHP file
4. Write .NET or PHP code to upload the SHP file into the folder you pointed
to in (1).
5. After the file is uploaded you have the refresh the Data Connection:
          $OldResourceID = new MgResourceIdentifier($resourceId);
          $resourceContent =
$resourceSrvc->GetResourceContent($OldResourceID);
          $resourceHeader =
$resourceSrvc->GetResourceHeader($OldResourceID);
     
          $resourceSrvc->SetResource($OldResourceID, $resourceContent,
$resourceHeader);

6. Once you have done that you can use the API to explore the file that the
person uploaded to get the Columns, etc. and convert it to XML.
7. Fill out all the properties (including geometry column, fields etc) in
the XML
8. Convert the XML back into a bytesource and then use SetResource.
9 Define the layer based on that new layer definition and add it to the map.
10. SetDisplayInLegend(True) to show it in the legend
11. Save the runtime Map.
12. Use javascript to refresh the map.

So this requires a good knowledge of XML, looping over nodes and populating
information, accessing the MapGuide API etc.

I like to do steps from 1-5 and then push the graphics/attributes into
Oracle or SQL Server myself and scrap the SHP when I am done.

gordon



 

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Uploading-Shapefile-to-Map-for-Immediate-Display-Problem-tp1819294p6990595.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list