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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Nico777
Sent: Tuesday, July 17, 2007 11:47 AM
To: [email protected]
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

[email protected]

http://lists.osgeo.org/mailman/listinfo/mapguide-users

<<image001.jpg>>

_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to