[mapguide-commits] r9493 - in sandbox/jng/tiling_v2/Common: Foundation/Data Foundation/System MapGuideCommon/MapLayer MapGuideCommon/Resources MapGuideCommon/Services Renderers

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Apr 22 21:05:11 PDT 2019


Author: jng
Date: 2019-04-22 21:05:11 -0700 (Mon, 22 Apr 2019)
New Revision: 9493

Modified:
   sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.cpp
   sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.h
   sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.cpp
   sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.h
   sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.cpp
   sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.h
   sandbox/jng/tiling_v2/Common/MapGuideCommon/Resources/mapguide_en.res
   sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.cpp
   sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.h
   sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.cpp
   sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.h
   sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/RenderingService.h
   sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.cpp
   sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.h
Log:
Port across the core metatile rendering primitives from RFC90 sandbox. This is the common parts I left out in the previous commit

Modified: sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.cpp
===================================================================
--- sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.cpp	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.cpp	2019-04-23 04:05:11 UTC (rev 9493)
@@ -36,4 +36,4 @@
 const STRING MgMimeType::Json            = L"application/json";
 const STRING MgMimeType::Kml             = L"application/vnd.google-earth.kml+xml";
 const STRING MgMimeType::Kmz             = L"application/vnd.google-earth.kmz";
-
+const STRING MgMimeType::Meta            = L"application/metatile";

Modified: sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.h
===================================================================
--- sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.h	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/Foundation/Data/MimeType.h	2019-04-23 04:05:11 UTC (rev 9493)
@@ -83,6 +83,10 @@
     /// \brief
     /// application/vnd.google-earth.kmz
     static const STRING Kmz;      ///\if INTERNAL value("application/vnd.google-earth.kmz") \endif
+
+    /// \brief
+    /// application/metatile
+    static const STRING Meta;      ///\if INTERNAL value("application/metatile") \endif
 };
 /// \}
 

Modified: sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.cpp
===================================================================
--- sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.cpp	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.cpp	2019-04-23 04:05:11 UTC (rev 9493)
@@ -99,3 +99,8 @@
 {
     return (SAFE_ADDREF((MgByte*)m_data));
 }
+
+MgByte* ByteSourceMemoryImpl::BytesNoAddRef()
+{
+    return (MgByte*)m_data;
+}
\ No newline at end of file

Modified: sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.h
===================================================================
--- sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.h	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/Foundation/System/ByteSourceMemoryImpl.h	2019-04-23 04:05:11 UTC (rev 9493)
@@ -112,6 +112,16 @@
     ///
     MgByte* Bytes();
 
+    ////////////////////////////////////////////////////////////////
+    /// \brief
+    /// Gets the pojnter the to internal MgByte object. The reference count
+    /// is not incremented
+    ///
+    /// \return
+    /// Internal MgByte
+    ///
+    MG_FOUNDATION_API MgByte* BytesNoAddRef();
+
 protected:
     Ptr<MgByte> m_data;
     INT32   m_pos;

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.cpp
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.cpp	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.cpp	2019-04-23 04:05:11 UTC (rev 9493)
@@ -20,6 +20,12 @@
 #include "SAX2Parser.h"
 #include <map>
 
+/// rfc90 instead of a dependency on Common/Stylization/Bounds.h
+#define rs_max(a,b)     (((a) > (b)) ? (a) : (b))
+#define rs_min(a,b)     (((a) < (b)) ? (a) : (b))
+/// rfc90 instead of a dependency on Common/Stylization/StylizationDefs.h
+#define _METERS_PER_INCH 0.0254
+
 using namespace std;
 
 MG_IMPL_DYNCREATE(MgMap)
@@ -1574,6 +1580,32 @@
     m_watermarkUsage = watermarkUsage;
 }
 
+/////////////////////////////////////////////////////////////////////
+// compute the tile coordinates from the x y index of the tiles and the meta tiling factor
+void MgMap::GetTileCoords(int metaTileFactor, int tileColumn, int tileRow,
+    int dpi, int tileWidth, int tileHeight,
+    double &tileMinX, double &tileMaxX, double &tileMinY, double & tileMaxY)
+{
+    Ptr<MgEnvelope> mapExtent = this->GetMapExtent();
+    Ptr<MgCoordinate> pt00 = mapExtent->GetLowerLeftCoordinate();
+    Ptr<MgCoordinate> pt11 = mapExtent->GetUpperRightCoordinate();
+    double mapMinX = rs_min(pt00->GetX(), pt11->GetX());
+    double mapMaxX = rs_max(pt00->GetX(), pt11->GetX());
+    double mapMinY = rs_min(pt00->GetY(), pt11->GetY());
+    double mapMaxY = rs_max(pt00->GetY(), pt11->GetY());
+
+    double scale = this->GetViewScale();
+    double metersPerUnit = this->GetMetersPerUnit();
+    double metersPerPixel = _METERS_PER_INCH / dpi;
+    double tileWidthMCS = (double)tileWidth  * metersPerPixel * scale / metersPerUnit;
+    double tileHeightMCS = (double)tileHeight * metersPerPixel * scale / metersPerUnit;
+
+    tileMinX = mapMinX + (double)(tileColumn)* tileWidthMCS;  // left edge
+    tileMaxX = mapMinX + (double)(tileColumn + metaTileFactor) * tileWidthMCS;  // right edge
+    tileMinY = mapMaxY - (double)(tileRow + metaTileFactor) * tileHeightMCS; // bottom edge
+    tileMaxY = mapMaxY - (double)(tileRow)* tileHeightMCS; // top edge
+}
+
 //////////////////////////////////////////////////////////////////
 // Returns the resource id of the Tile Set Definition that this group originates from.
 //

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.h
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.h	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/MapLayer/Map.h	2019-04-23 04:05:11 UTC (rev 9493)
@@ -715,6 +715,17 @@
 
     virtual void Create(MgResourceService* resourceService, MgResourceIdentifier* mapDefinition, CREFSTRING mapName, bool strict);
 
+    /// \brief
+    /// compute the coordinates of a tile, increase size by meta tiling Factor sm_useMetaTiles
+    ///
+    /// \param in metaTileFactor, tileColumn, tileRow, dpi, tileWidth, tileHeight,
+    /// \param out tileMinX,tileMinY. tileMaxX , tileMaxY
+    /// min,max corners of the tile
+    ///
+    virtual void GetTileCoords(int metaTileFactor, int tileColumn, int tileRow,
+        int dpi, int tileWidth, int tileHeight,
+        double &tileMinX, double &tileMaxX, double &tileMinY, double & tileMaxY);
+
 protected:
 
     //////////////////////////////////////////////////////////////////

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/Resources/mapguide_en.res	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/Resources/mapguide_en.res	2019-04-23 04:05:11 UTC (rev 9493)
@@ -333,9 +333,6 @@
 MgStringEmpty                                         = The string cannot be empty.
 MgStringTooLong                                       = The string is too long.
 MgTagFieldNotFound                                    = The tag contained no fields.
-MgUnableToLockTileFile                                = Unable to lock the tile file.
-MgUnableToOpenLockFile                                = Unable to open the tile lock file.
-MgUnableToOpenTileFile                                = Unable to open the tile file.
 MgUnsupportedService                                  = The site/resource services cannot be enabled/disabled.
 MgUserAndGroupNotEmpty                                = Both the user and group are not empty.
 MgUserAndRoleNotEmpty                                 = Both the user and role are not empty.
@@ -431,6 +428,16 @@
 # T I L E  S E R V I C E
 # *****************************************************************************
 [TileService]
+MgFoundBlockingLockFile                                = Found a lock file for the current tile.
+MgGetTileWithOutMapSpecified                           = Calling GetTile without a valid mapdefinition or baselayer name.
+MgPermissionDeniedForResource                          = No permission to access the resource service for the current mapDefinition.
+MgNoMapSpecified                                       = Clearcache has been called with an empty map reference.
+MgTooLargeMetaTilingFactor                             = The specified metatiling Factor is too big, change serverconfig.ini.
+MgUnableToLockMetaTileFile                             = Unable to lock the current metatile file.
+MgUnableToLockTileFile                                 = Unable to lock the tile file.
+MgUnableToOpenLockFile                                 = Unable to open the tile lock file.
+MgUnableToOpenTileFile                                 = Unable to open the tile file.
+MgWrongSizeOfMetaTile                                  = Metatile has wrong size.
 MgTileProvider_Default_DisplayName                     = Default Tile Provider
 MgTileProvider_Default_Description                     = Default tile access provided by MapGuide. Supports MapGuide-managed tile path or user-defined path
 MgTileProvider_XYZ_DisplayName                         = XYZ Tile Provider

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.cpp
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.cpp	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.cpp	2019-04-23 04:05:11 UTC (rev 9493)
@@ -30,3 +30,4 @@
 const STRING MgImageFormats::Png8   = L"PNG8";
 const STRING MgImageFormats::Tiff   = L"TIF";
 const STRING MgImageFormats::Raw    = L"RAW";
+const STRING MgImageFormats::Meta   = L"META";
\ No newline at end of file

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.h
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.h	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ImageFormats.h	2019-04-23 04:05:11 UTC (rev 9493)
@@ -53,6 +53,10 @@
     /// \brief
     /// Raw format
     static const STRING Raw;    /// \if INTERNAL value("RAW") \endif
+
+    /// \brief
+    /// Meta format for rfc90 meta tiling
+    static const STRING Meta;   /// \if INTERNAL value("META") \endif
 };
 
 #endif

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.cpp
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.cpp	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.cpp	2019-04-23 04:05:11 UTC (rev 9493)
@@ -148,13 +148,14 @@
     INT32 tileHeight,
     INT32 tileDpi,
     CREFSTRING tileImageFormat,
-    double tileExtentOffset)
+    double tileExtentOffset,
+    INT32 metaTileFactor)
 {
     MgCommand cmd;
     cmd.ExecuteCommand(m_connProp,                                      // Connection
         MgCommand::knObject,                            // Return type expected
         MgRenderingServiceOpId::RenderTile2,            // Command Code
-        9,                                              // No of arguments
+        10,                                              // No of arguments
         Rendering_Service,                              // Service Id
         BUILD_VERSION(3, 3, 0),                         // Operation version
         MgCommand::knObject, map,                       // Argument#1
@@ -166,6 +167,7 @@
         MgCommand::knInt32, tileDpi,                    // Argument#7
         MgCommand::knString, &tileImageFormat,          // Argument#8
         MgCommand::knDouble, tileExtentOffset,          // Argument#9
+        MgCommand::knInt32, metaTileFactor,             // Argument#10
         MgCommand::knNone);                             // End of arguments
 
     SetWarning(cmd.GetWarningObject());

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.h
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.h	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/ProxyRenderingService.h	2019-04-23 04:05:11 UTC (rev 9493)
@@ -157,7 +157,8 @@
         INT32 tileHeight,
         INT32 tileDpi,
         CREFSTRING tileImageFormat,
-        double tileExtentOffset);
+        double tileExtentOffset,
+        INT32 metaTileFactor);
 
     /////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/RenderingService.h
===================================================================
--- sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/RenderingService.h	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/MapGuideCommon/Services/RenderingService.h	2019-04-23 04:05:11 UTC (rev 9493)
@@ -171,7 +171,8 @@
         INT32 tileHeight,
         INT32 tileDpi,
         CREFSTRING tileImageFormat,
-        double tileExtentOffset) = 0;
+        double tileExtentOffset,
+        INT32 metaTileFactor) = 0;
 
     /////////////////////////////////////////////////////////////////
     /// \brief

Modified: sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.cpp
===================================================================
--- sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.cpp	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.cpp	2019-04-23 04:05:11 UTC (rev 9493)
@@ -65,6 +65,8 @@
 #include "SE_SymbolDefProxies.h"
 
 #include "RenderUtil.h"
+// simple define to avoid dependency cycles
+#define MgImageFormats_Meta L"META"
 
 using namespace DWFToolkit;
 using namespace DWFCore;
@@ -257,12 +259,25 @@
 
 //////////////////////////////////////////////////////////////////////////////
 // Return the rendered image passed in via the imagebuffer (m_rows) as
-// a bytestream in the given image format using the provided colorPalette
-// if given.
+// a bytestream in the given image format using the optional provided colorPalette.
+// In MetaTileing mode return the imagebuffer copied in a new  RS_ByteData object.
 RS_ByteData* AGGRenderer::Save(const RS_String& format, int width, int height,
-                               RS_ColorVector* baseColorPalette)
+                               RS_ColorVector* baseColorPalette, unsigned int* imagebuffer)
 {
-    return AGGImageIO::Save(format, m_rows, m_width, m_height, width, height, m_bgcolor, baseColorPalette);
+    if (format == MgImageFormats_Meta)
+    {
+        //        if (imagebuffer == NULL)  // this musnt happen
+        //            return NULL;
+        int imagebufferByteSize = width * height * 4; // multiply 32 bit pixel by 4 bytes
+        return new RS_ByteData((unsigned char*)m_rows, imagebufferByteSize);
+    }
+    else 
+    {
+        if (imagebuffer)       // use imagebuffer from previous meta tiling pass
+            return AGGImageIO::Save(format, imagebuffer, m_width, m_height, width, height, m_bgcolor, baseColorPalette);
+        else
+            return AGGImageIO::Save(format, m_rows, m_width, m_height, width, height, m_bgcolor, baseColorPalette);
+    }
 }
 
 

Modified: sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.h
===================================================================
--- sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.h	2019-04-23 04:04:25 UTC (rev 9492)
+++ sandbox/jng/tiling_v2/Common/Renderers/AGGRenderer.h	2019-04-23 04:05:11 UTC (rev 9493)
@@ -152,7 +152,7 @@
     RENDERERS_API void Save(const RS_String& filename, const RS_String& format);
     RENDERERS_API void Save(const RS_String& filename, const RS_String& format, int width, int height);
     RENDERERS_API RS_ByteData* Save(const RS_String& format, int width, int height,
-                                    RS_ColorVector* baseColorPalette = NULL);
+                                    RS_ColorVector* baseColorPalette = NULL, unsigned int* imagebuffer = NULL);
 
     RENDERERS_API void Combine(const RS_String& fileIn1, const RS_String& fileIn2, const RS_String& fileOut);
     RENDERERS_API void SetWorldToScreenTransform(SE_Matrix& xform);



More information about the mapguide-commits mailing list