[fusion-commits] r2878 - in branches/fusion-mg26: . widgets/Redline/classes

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Sep 23 23:11:26 PDT 2014


Author: jng
Date: 2014-09-23 23:11:25 -0700 (Tue, 23 Sep 2014)
New Revision: 2878

Modified:
   branches/fusion-mg26/
   branches/fusion-mg26/widgets/Redline/classes/markupmanager.php
Log:
Merged revision(s) 2877 and 2872 from trunk:
#626: Fix KML/KMZ downloads being useless when map CS is not LL84. This fixes the following issues:
 - The bounding box that's passed to MgKmlService::GetFeaturesKml must be in LL84. So if we encounter a non-LL84 bounding box, it must be transformed to LL84 before invoking GetFeaturesKml. The API documentation failed to state this fact and should be updated as well.
 - When creating a SHP feature source, nothing is exported due to a possible bug in CreateFeatureSource() that results in a blank .prj file in the created feature source. This naturally interferes with our need to transform data to LL84 for KML export. We already worked around this for native export (by creating the required .prj file using the map's coordinate system WKT), so we apply the same workaround here.
 - Several deprecated MgMap constructor usages are still being used.
........
#625: A fix for #625(Upload and edit SQLite redline meets an error)
Cause: When upload a SQLite file, the private variable m_bUseMetaData in sltConnection is the default value FALSE. Since can't use meta data, then data type of "ID" is failed to converted from Int64 to Int32 during describing schema.
Solution: Set the UserMetaData to TRUE when uploading the Markup SQLite by appending a xml string <Parameter><Name>UseFdoMetadata</Name><Value>TRUE</Value></Parameter>.

Submit on behalf of Andy Su. 

........




Property changes on: branches/fusion-mg26
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/fusion-mg24:2560
/sandbox/createruntimemap:2699-2708
/sandbox/jxlib-3.0:1957-2248
/sandbox/ol213:2801-2803
/sandbox/robust_error_handling:2818-2825
/trunk:2847,2850,2857,2859,2862-2863
   + /branches/fusion-mg24:2560
/sandbox/createruntimemap:2699-2708
/sandbox/jxlib-3.0:1957-2248
/sandbox/ol213:2801-2803
/sandbox/robust_error_handling:2818-2825
/trunk:2847,2850,2857,2859,2862-2863,2872,2877

Modified: branches/fusion-mg26/widgets/Redline/classes/markupmanager.php
===================================================================
--- branches/fusion-mg26/widgets/Redline/classes/markupmanager.php	2014-09-24 06:08:12 UTC (rev 2877)
+++ branches/fusion-mg26/widgets/Redline/classes/markupmanager.php	2014-09-24 06:11:25 UTC (rev 2878)
@@ -713,6 +713,44 @@
             }
             $fsParams = new MgFileFeatureSourceParams($this->args["MARKUPFDOPROVIDER"], 'Default', $map->GetMapSRS(), $markupSchema);
             $featureService->CreateFeatureSource($markupFsId, $fsParams);
+            //HACK: There must be some defect in MgFeatureService::CreateFeatureSource() for SHP
+            //files or the FDO provider, because even if we plug in a coord sys WKT when we create
+            //it, we get a blank prj file.
+            //
+            //As a workaround, create the required prj file using the map's SRS if we encounter an empty prj file
+            //
+            //That's what we were already doing when we called MgFeatureService::CreateFeatureSource(), but it
+            //or the provider didn't like it.
+            if ($fsParams->GetProviderName() == "OSGeo.SHP")
+            {
+                $dataList = $resourceService->EnumerateResourceData($markupFsId);
+                $doc = new DOMDocument();
+                $doc->loadXML($dataList->ToString());
+                $dataItems = $doc->getElementsByTagName("Name");
+                //Copy out all data files to a temp location
+                for ($i = 0; $i < $dataItems->length; $i++) {
+                    $dataName = $dataItems->item($i)->nodeValue;
+                    $dataNorm = strtolower($dataName);
+                    if ( substr( $dataNorm, strlen( $dataNorm ) - strlen( "prj" ) ) == "prj" ) {
+                        $byteReader = $resourceService->GetResourceData($markupFsId, $dataName);
+                        //Sink to temp file
+                        $tmpSink = new MgByteSink($byteReader);
+                        $fileName = tempnam(sys_get_temp_dir(), $dataName);
+                        $tmpSink->ToFile($fileName);
+                        $content = file_get_contents($fileName);
+                        if (strlen($content) == 0) {
+                            $content = $map->GetMapSRS();
+                            file_put_contents($fileName, $content);
+                            //Put new prj file back into SHP Feature Source
+                            $prjBs = new MgByteSource($fileName);
+                            $prjBr = $prjBs->GetReader();
+                            $resourceService->SetResourceData($markupFsId, $dataName, MgResourceDataType::File, $prjBr);
+                        }
+                        @unlink($fileName);
+                        break;
+                    }
+                }
+            }
             $featureSourceId = $markupFsId->ToString();
         }
         else
@@ -796,8 +834,8 @@
         $kmlService = $this->site->CreateService(MgServiceType::KmlService);
         $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
 
-        $map = new MgMap();
-        $map->Open($resourceService, $this->args['MAPNAME']);
+        $map = new MgMap($this->site);
+        $map->Open($this->args['MAPNAME']);
         $markupLayerResId = new MgResourceIdentifier($this->args['MARKUPLAYER']);
         $downloadName = $markupLayerResId->GetName().".".($kmz ? "kmz" : "kml");
 
@@ -823,10 +861,13 @@
         $geomFact = new MgGeometryFactory();
         $csFactory = new MgCoordinateSystemFactory();
         $metersPerUnit = 1.0;
+        $transform = null;
         if ($map->GetMapSRS() != null)
         {
             $mapCs = $csFactory->Create($map->GetMapSRS());
             $metersPerUnit = $mapCs->ConvertCoordinateSystemUnitsToMeters(1.0);
+            $llCs = $csFactory->CreateFromCode("LL84");
+            $transform = $csFactory->GetTransform($mapCs, $llCs);
         }
         $mapScale = $map->GetViewScale();
         $devW = $map->GetDisplayWidth();
@@ -841,6 +882,12 @@
         $coord0 = $geomFact->CreateCoordinateXY($coord->GetX() - 0.5 * $mcsW, $coord->GetY() - 0.5 * $mcsH);
         $coord1 = $geomFact->CreateCoordinateXY($coord->GetX() + 0.5 * $mcsW, $coord->GetY() + 0.5 * $mcsH);
         $bbox = new MgEnvelope($coord0, $coord1);
+        
+        //The bbox has to be in LL84
+        if ($transform != NULL)
+        {
+            $bbox = $bbox->Transform($transform);
+        }
 
         //Call the service API
         $br = $kmlService->GetFeaturesKml($markupLayer, $bbox, $devW, $devH, $mapDpi, 0, ($kmz ? "KMZ" : "KML"));
@@ -904,8 +951,8 @@
                 if ( substr( $dataNorm, strlen( $dataNorm ) - strlen( "prj" ) ) == "prj" ) {
                     $content = file_get_contents($filePath);
                     if (strlen($content) == 0) {
-                        $map = new MgMap();
-                        $map->Open($resourceService, $this->args['MAPNAME']);
+                        $map = new MgMap($this->site);
+                        $map->Open($this->args['MAPNAME']);
                         $content = $map->GetMapSRS();
                         file_put_contents($filePath, $content);
                     }
@@ -1026,6 +1073,9 @@
         if (strcmp($fdoProvider, "OSGeo.SDF") == 0) { //Need to set ReadOnly = false for SDF
             $extraXml = "<Parameter><Name>ReadOnly</Name><Value>FALSE</Value></Parameter>";
         }
+        else if (strcmp($fdoProvider, "OSGeo.SQLite") == 0) { //Need to set UseFdoMetadata = true for SQLite
+            $extraXml = "<Parameter><Name>UseFdoMetadata</Name><Value>TRUE</Value></Parameter>";
+        }
         $fsXml = sprintf(file_get_contents("templates/markupfeaturesource.xml"), $fdoProvider, $fileParam, $dataName, $extraXml);
         $bs2 = new MgByteSource($fsXml, strlen($fsXml));
         $resourceService->SetResource($markupFsId, $bs2->GetReader(), null);



More information about the fusion-commits mailing list