[mapguide-users] RE: Insert point feature .NET

Nico777 nicolas.leclerc at dessausoprin.com
Fri Jul 20 12:22:58 EDT 2007


Hello Mark

Well i checked all your advices and I’m still having the same « BUG » (I
probably have done something wrong, since its the first time I work with
MapGuide OS).

1 – The feature was read only ! I changed the xml file and set it to FALSE.
Still having the problem

2 – Class name is ok

3 – Case sensitive ok

4 – The shapefile is point and converted as a point geometry

5 – Looked into mapagent/index.html, Schemas and settings seemed correct

I included the files from my project and my settings in case it my be part
of the problem.

-	MapGuide OS is installed on the F : drive (using a dual boot for dev on
different windows setup)
-	IIS is on F : drive too

Here are the files i use :

91045.zip : Web site so far installed on [F:\Inetpub\wwwroot]
	AjouterProjet.aspx.vb : Contains the code i posted

Projets.sdf : the download from the ressource from the studio
SHP.zip : The shapefile created to hold the points the user should create
(in case)

Thanks alot for your time and advices

-Nicolas





Mark Pendergraft wrote:
> 
> Well, at a glance everything looks fine to me....
> 
> I have had problems with inserting data into feature sources too... so
> here is what I would suggest:
> 
>  
> 
> 1)  Make sure the feature source isn't read only (if you created the
> feature source, this could be an issue)
> 
> To do this: goto http://localhost/mapguide/mapagent/index.html
> 
> Under Resource, selected GetResourceContent.... in resource ID specify
> the resource you are trying to access.  Hit, submit... and it will
> return some XML.  The resource should have a tag "ReadOnly" and it
> should be set to false obviously...
> 
>  
> 
> 2)  Make a page in your program, and have it list all of the layers and
> their featureclassname... make sure you are accessing the correct
> featureclass when you are creating the insert command...
> 
> It's confusing because the PHP example shows the variable layerName when
> inserting a command... but that isn't necessarily the name of your
> feature class.
> 
> So, find out what the class name is (usually "Default:(layerName)") and
> just use anything after the semicolon (case sensitive).
> 
> Dim cmd As New OSGeo.MapGuide.MgInsertFeatures(LayerName ---- not always
> the layer name!!!---, propColl)
> 
>  
> 
> 3)  Make sure you schema's properties match the properties you are
> creating in the batchpropertycollection
> 
> These are case sensitive, so you have to be exact.  "NoProjet" and
> "NomProjet" and "SHPGEOM" 
> 
>  
> 
> 4)  Make sure SHPGEOM is set to accept points... I had a problem with
> the developer's guide PHP example "draw_line.php"  I never got it to
> actually draw a line for me...  I did get it to work when I drew a
> polygon though... don't know why, but I suspect that when I created the
> featuresource (which I copied from the example) the geometry type was
> set to surface not Point.
> 
>  
> 
> 5)  finally, if you feel confident that all of these things are
> correct... I would then recommend checking to see if your layer for the
> feature source is setup correctly.. maybe it's there and you just can't
> see it..  And if that doesn't work, I would try creating your own
> temporary feature source, and writing to it to see if it will show up...
> examples of which are in the developer's guide...
> 
> 
> If you post the SDF file you are accessing, as well as the pages
> involved in writing to it.. I would be happy to troubleshoot it for you.
> 
>  
> 
> -Mark Pendergraft
> 
>  
> 
>  
> 
> Ph: (425) 486-1252  Fx: (425) 486-6108  www.meadgilman.com
> <http://www.meadgilman.com/> 
> 
>  
> 
>  
> 
>  
> 
>  
> 
> -----Original Message-----
> From: mapguide-users-bounces at lists.osgeo.org
> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Nico777
> Sent: Tuesday, July 17, 2007 11:47 AM
> To: mapguide-users at lists.osgeo.org
> Subject: [mapguide-users] Insert point feature .NET
> 
>  
> 
>  
> 
> Hi all
> 
>  
> 
> I'm trying to let the user insert a point feature in VB.NET along with
> some
> 
> string attributes. The feature source is an SHP file and the code was
> 
> translated/modified from the PHP example (draw_line). The user can get
> the
> 
> X, Y coordinates from another button (works fine).
> 
>  
> 
> Everything compiles fine and execute well but no feature is added to the
> 
> feature source. I tried with a converted SDF feature source (didnt
> change a
> 
> thing). 
> 
>  
> 
> Did I miss something ? Did I do something wrong :)
> 
>  
> 
> Any help would be appreciated 
> 
>  
> 
> here's the code :
> 
>  
> 
> Protected Sub bntCreateProjet_Click(ByVal sender As Object, ByVal e As
> 
> System.EventArgs) Handles bntCreateProjet.Click
> 
>         'Add the feature
> 
>  
> 
>         Try
> 
>             'Get the session ID
> 
>             Dim sessionID As String
> 
>             sessionID = Me.Session("SessionID")
> 
>  
> 
>             'Initialize the Web Tier
> 
>             InitializeWebTier()
> 
>  
> 
>             'Get 'User info' from the sessionID, connect to the site
> server
> 
>             Dim UserInfo As New
> OSGeo.MapGuide.MgUserInformation(sessionID)
> 
>             Dim mySiteConn As New OSGeo.MapGuide.MgSiteConnection()
> 
>             mySiteConn.Open(UserInfo)
> 
>  
> 
>             'Get the ressource and feature services
> 
>             Dim ressourceService As OSGeo.MapGuide.MgService
> 
>             ressourceService =
> 
> mySiteConn.CreateService(OSGeo.MapGuide.MgServiceType.ResourceService)
> 
>             Dim featureService As OSGeo.MapGuide.MgFeatureService
> 
>             featureService =
> 
> mySiteConn.CreateService(OSGeo.MapGuide.MgServiceType.FeatureService)
> 
>  
> 
>             'Create a point feature and add it to the feature source
> 
>             'Create the point properties
> 
>             Dim batchPropColl As New
> 
> OSGeo.MapGuide.MgBatchPropertyCollection()
> 
>             Dim propColl As New OSGeo.MapGuide.MgPropertyCollection()
> 
>  
> 
>             'Set some informations (string values)
> 
>             Dim NoProp As New
> OSGeo.MapGuide.MgStringProperty("NoProjet",
> 
> Me.txtNo.Value)
> 
>             Dim NomProp As New
> OSGeo.MapGuide.MgStringProperty("NomProjet",
> 
> Me.txtNom.Value)
> 
>  
> 
>             'Set geometry
> 
>             Dim wtkReaderWriter As New
> OSGeo.MapGuide.MgWktReaderWriter()
> 
>             Dim agfReaderWriter As New
> OSGeo.MapGuide.MgAgfReaderWriter()
> 
>  
> 
>             Dim geo As OSGeo.MapGuide.MgGeometry
> 
>             geo = wtkReaderWriter.Read("POINT XY (" & Me.txtX2.Value & "
> " &
> 
> Me.txtY2.Value & ")")
> 
>             Dim geoByteReader As OSGeo.MapGuide.MgByteReader
> 
>             geoByteReader = agfReaderWriter.Write(geo)
> 
>             Dim geoProp As New
> OSGeo.MapGuide.MgGeometryProperty("SHPGEOM",
> 
> geoByteReader)
> 
>  
> 
>             'Fill the properties collection
> 
>             propColl.Add(geoProp)
> 
>             propColl.Add(NoProp)
> 
>             propColl.Add(NomProp)
> 
>  
> 
>             'Create an insert feature command
> 
>             Dim cmd As New OSGeo.MapGuide.MgInsertFeatures(LayerName,
> 
> propColl)
> 
>             Dim featCmdColl As New
> 
> OSGeo.MapGuide.MgFeatureCommandCollection()
> 
>             featCmdColl.Add(cmd)
> 
>  
> 
>             Dim resID As New
> 
> OSGeo.MapGuide.MgResourceIdentifier("Library://91045/Data/Projets.Featur
> eSource")
> 
>  
> 
>             'Execute the update
> 
>             featureService.UpdateFeatures(resID, featCmdColl, False)
> 
>  
> 
>  
> 
>         Catch ex As OSGeo.MapGuide.MgException
> 
>             Response.Write(ex.GetMessage)
> 
>             Response.Write(ex.GetDetails)
> 
>         End Try
> 
>  
> 
>     End Sub
> 
>  
> 
>     Private Sub InitializeWebTier()
> 
>         Dim sAppPath As String =
> 
> Request.ServerVariables("APPL_PHYSICAL_PATH")
> 
>         Dim sConfigPath As String = sAppPath & "webconfig.ini"
> 
>         MapGuideApi.MgInitializeWebTier(sConfigPath)
> 
>     End Sub
> 
>  
> 
> -- 
> 
> View this message in context:
> http://www.nabble.com/Insert-point-feature-.NET-tf4098806s16610.html#a11
> 655548
> 
> Sent from the MapGuide Users mailing list archive at Nabble.com.
> 
>  
> 
> _______________________________________________
> 
> mapguide-users mailing list
> 
> mapguide-users at lists.osgeo.org
> 
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 
>  
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 
http://www.nabble.com/file/p11711046/Projets.sdf Projets.sdf 
http://www.nabble.com/file/p11711046/SHP.zip SHP.zip 
http://www.nabble.com/file/p11711046/91045.zip 91045.zip 
-- 
View this message in context: http://www.nabble.com/Insert-point-feature-.NET-tf4098806s16610.html#a11711046
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list