Hi There,

You can change the ReadOnly attribute by MapAgent index.html page or programmatically

a) Changing by MapAgent web page.

Go to http://servername:port/mapguide[2008]/mapagent/index.html

Go to GetResourceContent Link, and perform a query using the ResourceID like Library://Samples/Sheboygan/Data/Parcels.FeatureSource

You will get an XML file like this.

<Provider>OSGeo.SDF</Provider>

<Parameter>

<Name>File</Name>

<Value>%MG_DATA_FILE_PATH%Road.sdf</Value>

</Parameter>

<Parameter>

<Name>ReadOnly</Name>

<Value>TRUE</Value>

</Parameter>


You will see a tag <ReadOnly> if that tag value is TRUE change you must save the XML file as ParcelsContent.XML, then modify with Notepad changing the TRUE value to FALSE.

Then go to http://servername:port/mapguide[2008]/mapagent/index.html, go to SetResource, and provide the ResourceID and the Content XML File by upload your modified ParcelsContent.XML, for the HEADER field leave it empty, click on submit and the SDF file will be read/write now.

b) Changing Programmatically

Use the next routines and examples :

// This routine makes a resource writable

private void set_ResourceWriteAble(MgResourceIdentifier resoureId, MgResourceService resourceService)
    {//by knife114
        //-----------------------------------------------------------------------------
        String buffer;
        MgByteReader reader = resourceService.GetResourceContent(resoureId);
        buffer = reader.ToString();
        if (buffer.Contains("<Value>TRUE</Value>"))
        {
            buffer = buffer.Replace("<Value>TRUE</Value>", "<Value>FALSE</Value>");
            Byte[] buf_Byte = System.Text.Encoding.Default.GetBytes(buffer);
            MgByteSource byteSource = new MgByteSource(buf_Byte, buf_Byte.Length);

            resourceService.SetResource(resoureId, byteSource.GetReader(), null);
        }      
        //-----------------------------------------------------------------------------
    }

This is an example code using the code above:

             MgGeometryFactory geoFac = new MgGeometryFactory();
             MgLinearRingCollection LinearRingCollection = new MgLinearRingCollection();
             MgCoordinateCollection CoordinateCollection = new MgCoordinateCollection();


             String[] coods = this.TextBox1.Text.Split(',');
             for (int i = 1; i <= Convert.ToInt16(coods[0])*2 ; i+=2)
             {
                 double x = Convert.ToDouble(coods[i]);
                 double y = Convert.ToDouble(coods[i+1]);
                 MgCoordinate coordinate = geoFac.CreateCoordinateXY(x, y);
                 CoordinateCollection.Add(coordinate);
                 //MgPoint point = new MgGeometryFactory().CreatePoint(coordinate);
             }
           
             MgLinearRing LinearRing = geoFac.CreateLinearRing(CoordinateCollection);
             CoordinateCollection.Clear();
             LinearRingCollection.Add(LinearRing);
             MgPolygon Polygon = geoFac.CreatePolygon(LinearRing, null);


             //propertyCol.Add(new MgInt32Property("Autogenerated_SDF_ID", 11));
             propertyCol.Add(new MgStringProperty("Name", "it's me"));
             propertyCol.Add(new MgInt32Property("Key", 11));
             propertyCol.Add(new MgStringProperty("Url", "me,too"));

             //Polygon.
             propertyCol.Add(new MgGeometryProperty("Data", geometryReaderWriter.Write(Polygon)));
          
             ftrCmdCol.Add(new MgInsertFeatures(lyrClass, propertyCol));

             set_ResourceWriteAble(resoureId, resourceService); // set sdf readonly=false
           
             if (ftrCmdCol.Count >= 1)
             {
                 ReleaseReader(ftrService.UpdateFeatures(resoureId, ftrCmdCol, false), ftrCmdCol);

                 layerToSave.ForceRefresh();
                 map.Save(resourceService);
              }

Regards

Francisco J Rojas D


<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">Pascal Coulon wrote:</div>
<div class="quote-message">
Hi There,

When creating a layer (SDF) in Studio. It is created in ReadOnly mode. You need to enable read/write by using the mapagent. Let me know if you need any further details.

Regards,

pascal


<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">Jackie Ng wrote:</div>
<div class="quote-message">
Open two browser windows/tabs, one to your web application that adds the points. Another to the schemareport page (usually at http://servername:port/mapguide/schemareport/main.php )

Run your add point routine, then check if the schemareport for that feature source has included the point you have just added.

If the point is there, then i suspect it is something to do with the layer that's based off of the feature source.

Otherwise, your php script is clearly failing to insert the new point feature.

- Jackie

<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">gaku wrote:</div>
<div class="quote-message">
Yes,I have created site resources by use Administrator username.



-gaku

<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">Jackie Ng wrote:</div>
<div class="quote-message">
Oh I see, I thought you were adding points to a session-based feature source.

In that case, did you create a mapguide session via a username that has permissions to modify site resources?

- Jackie

<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">gaku wrote:</div>
<div class="quote-message">
Yes, I have created the feature source by using Mapguide Studio. 

<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">Jackie Ng wrote:</div>
<div class="quote-message">
Have you actually created the feature source pointed to by $featureSourceId ? (ie. Have you called $featureService->CreateFeatureSource() ?)

- Jackie

<blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">gaku wrote:</div>
<div class="quote-message">
Hi all 

I'm trying to let the user insert a point feature in PHP along with some attributes. The feature source is an SDF 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 : 

------------------------------------------------------------

try
        {
                MgInitializeWebTier($webconfigFilePath);

                // Get the session information passed from the viewer.
            $sessionId = ($_SERVER['REQUEST_METHOD'] == "POST")?$_POST['SESSION']: $_GET['SESSION'];
            
            // Get the user information using the session id,
            // and set up a connection to the site server.     
            $userInfo = new MgUserInformation($sessionId);
            $siteConnection = new MgSiteConnection();
            $siteConnection->Open($userInfo);
    
            
                $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
                $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);                
                $featureSourceId = new MgResourceIdentifier('Library://Sample/Data/020101Markup.FeatureSource');
                
                
                $map = new MgMap();
                $map->Open($resourceService, $mgMapName);
                
                //$geometryFactory = new MgGeometryFactory();
                $wktReaderWriter = new MgWktReaderWriter();
                $agfReaderWriter = new MgAgfReaderWriter();
                
                $geo = $wktReaderWrite->Read("POINT XY ( $x, $y )");
                
                $geoByteReader = new MgByteReader();
                $geoByteReader = $agfReaderWriter->Write($geo);
                
                $idid = 500;
                
                $propertyValues = new MgPropertyCollection();
                $propertyValues->Add(new MgInt32Property("ID", $idid )); 
                $propertyValues->Add(new MgStringProperty(name, 'test'));
                $propertyValues->Add(new MgGeometryProperty('Geometry', $geoByteReader));        
                
                $commands = new MgFeatureCommandCollection();
                $commands->Add(new MgInsertFeatures('020101Markup', $propertyValues));
                $featureService->UpdateFeatures($featureSourceId, $commands, false);
        
                
        }
        catch (MgException $e)
        {
                $errorMsg = $e->GetMessage();
                $errorDetail = $e->GetDetails();
        }


-------------------------------end of code -------------

--Thanks, 


</div>
</div></blockquote>


</div>
</div></blockquote>


</div>
</div></blockquote>


</div>
</div></blockquote>


</div>
</div></blockquote>


</div>
</div></blockquote>


</div>
</div></blockquote>


<br><hr align="left" width="300">
View this message in context: <a href="http://www.nabble.com/Add-Point-to-Existing-Layer-tp15136337s16610p15269590.html">Re: Add Point to Existing Layer</a><br>
Sent from the <a href="http://www.nabble.com/MapGuide-Users-f14845.html">MapGuide Users mailing list archive</a> at Nabble.com.<br>