Have you actually created the feature source pointed to by $featureSourceId ?
(ie. Have you called $featureService->CreateFeatureSource() ?)

- Jackie


gaku wrote:
> 
> 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, 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Add-Point-to-Existing-Layer-tp15136337s16610p15152993.html
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

Reply via email to