[mapguide-users] DWGLoadProcedure

Greenhough, Jamie JamieGreenhough at sierrasystems.com
Fri Oct 24 15:31:18 EDT 2008


Thanks Kenneth(!!),

 

I've implemented your code snippet, and it now looks like this:

 

            string username = "Author1";

            string password = "Author1";

            string locale = "EN";

            string url = "http://mapguideserver/MapGuide";

            System.Uri uri = new System.Uri(url);            

 

ServerConnectionI con = new HttpServerConnection(uri, username,
password, locale, false);

            FeatureSource fs = new FeatureSource();

            fs.Provider = "OSGeo.SHP.3.3";

            fs.Parameter = new NameValuePairTypeCollection();

            fs.Parameter["DefaultFileLocation"] =
"%MG_DATA_FILE_PATH%ShapeFile.SHP";

            string resId = "Library://MYNEWTESTSHAPE.FeatureSource";

            con.SaveResourceAs(fs, resId);

            using (System.IO.FileStream fss =
System.IO.File.OpenRead("C:\\Hydrant.shp"))

                con.SetResourceData(resId, "ShapeFile.SHP",
ResourceDataType.File, fss);

 

... and that works. 

 

Now I'm looking at and thinking about how to:

o   Convert to SDF feature source.

o   Set the coordinate system.

o   Import/save the attribute data from *.dbf file.


So I'm looking for more direction/information on uploading shp files to
a managed mapguide server. Anyone?

 

Thanks

 

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Kenneth
Skovhede, GEOGRAF A/S
Sent: Friday, October 17, 2008 1:00 AM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] DWGLoadProcedure

 

As DWG is a proprietary format, I belive it will be difficult to do this
with only open-source software.
Supposedly, you can use FME to do it, and I think there is some
organisation that has a 'open-source' like library for reading DWG data.

There are no methods for dealing with DWG in Maestro or the Maestro API,
for the above reasons.

As for SHP, it is fairly easy to do this:
IServerConnection con = new HttpServerConnection(url, username,
password, locale, false);
FeatureSource fs = new FeatureSource();
fs.Provider = "OSGeo.SHP.3.3"; //Adjust if you are not using FDO 3.3
fs.Parameter = new NameValueCollection();
fs.Parameter["DefaultFileLocation"] =
"%MG_DATA_FILE_PATH%ShapeFile.SHP"; //Can use absolute path here
string resId = "Library://MyShpFile.FeatureSource";
con.SaveResourceAs(fs, resId);
using(System.IO.FileStream fs =
System.IO.File.OpenRead("C:\\myshapefile.shp"))
    con.SetResourceData(resId, "ShapeFile.SHP", ResourceDataType.File,
fs);

The above code will create a managed copy of your shape data.
If you want an unmanaged copy, just change "DefaultFileLocation" to the
absolute path, and remove the "SetResourceData" call.




Regards, Kenneth Skovhede, GEOGRAF A/S



Greenhough, Jamie skrev: 

Hello again MapGuide coders ;)

 

I want to programmatically load .dwg/.shp files to a managed MapGuide
environment. 

 

I think this can be accomplished with the MapGuide Studio API... but are
there any other ways to get this data into the MapGuide server? I'm
trying to stay open source. Are there any methods in the Maestro API to
accomplish this?

----Notice Regarding Confidentiality----
This email, including any and all attachments, (this "Email") is
intended only for the party to whom it is addressed and may contain
information that is confidential or privileged. Sierra Systems Group
Inc. and its affiliates accept no responsibility for any loss or damage
suffered by any person resulting from any unauthorized use of or
reliance upon this Email. If you are not the intended recipient, you are
hereby notified that any dissemination, copying or other use of this
Email is prohibited. Please notify us of the error in communication by
return email and destroy all copies of this Email. Thank you.

 


________________________________



 
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
  


----Notice Regarding Confidentiality----
This email, including any and all attachments, (this "Email") is intended only for the party to whom it is addressed and may contain information that is confidential or privileged.  Sierra Systems Group Inc. and its affiliates accept no responsibility for any loss or damage suffered by any person resulting from any unauthorized use of or reliance upon this Email.  If you are not the intended recipient, you are hereby notified that any dissemination, copying or other use of this Email is prohibited.  Please notify us of the error in communication by return email and destroy all copies of this Email.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20081024/9627c5b4/attachment.html


More information about the mapguide-users mailing list