[mapguide-commits] r7103 - in trunk/MgDev/Desktop: MgDesktop/Services MgDesktop/Services/Rendering UnitTest
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Oct 10 04:02:22 PDT 2012
Author: jng
Date: 2012-10-10 04:02:21 -0700 (Wed, 10 Oct 2012)
New Revision: 7103
Modified:
trunk/MgDev/Desktop/MgDesktop/Services/Rendering/RenderingOptions.h
trunk/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp
trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp
trunk/MgDev/Desktop/UnitTest/TestRenderingService.h
trunk/MgDev/Desktop/UnitTest/main.cpp
Log:
mg-desktop: This submission adds an extra behavior flag (RenderBaseLayers) allowing for RenderDynamicOverlay to incorporate base map layers into the rendered image. A new test case has been added to exercise this behavior flag. In addition, the rendering service test suite has been parameterized (like its server counterpart) to exercise all supported image formats
Modified: trunk/MgDev/Desktop/MgDesktop/Services/Rendering/RenderingOptions.h
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/Rendering/RenderingOptions.h 2012-10-09 16:33:00 UTC (rev 7102)
+++ trunk/MgDev/Desktop/MgDesktop/Services/Rendering/RenderingOptions.h 2012-10-10 11:02:21 UTC (rev 7103)
@@ -23,15 +23,17 @@
/// \n
/// \c RenderSelection - Renders the selected feature(s).
/// \n
- /// \c RenderLayers - Renders the features on the map.
+ /// \c RenderLayers - Renders the dynamic layers on the map.
/// \n
/// \c KeepSelection - Renders the selected feature(s) even if they are outside the current scale.
- ///
+ /// \n
+ /// \c RenderLayers - Renders the base layers on the map
enum
{
RenderSelection = 1,
RenderLayers = 2,
- KeepSelection = 4
+ KeepSelection = 4,
+ RenderBaseLayers = 8,
};
/////////////////////////////////////////////////////////////////
Modified: trunk/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp
===================================================================
--- trunk/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp 2012-10-09 16:33:00 UTC (rev 7102)
+++ trunk/MgDev/Desktop/MgDesktop/Services/RenderingService.cpp 2012-10-10 11:02:21 UTC (rev 7103)
@@ -725,6 +725,9 @@
// initialize the renderer
auto_ptr<SE_Renderer> dr(CreateRenderer(width, height, bgColor, true));
+ bool bIncludeDynamicLayers = ((options->GetBehavior() & MgdRenderingOptions::RenderLayers) == MgdRenderingOptions::RenderLayers);
+ bool bIncludeBaseLayers = ((options->GetBehavior() & MgdRenderingOptions::RenderBaseLayers) == MgdRenderingOptions::RenderBaseLayers);
+
// create a temporary collection containing all the dynamic layers
Ptr<MgLayerCollection> layers = map->GetLayers();
Ptr<MgReadOnlyLayerCollection> roLayers = new MgReadOnlyLayerCollection();
@@ -732,8 +735,10 @@
{
Ptr<MgLayerBase> layer = layers->GetItem(i);
INT32 layerType = layer->GetLayerType();
- if (layerType == MgLayerType::Dynamic)
+ if (bIncludeDynamicLayers && layerType == MgLayerType::Dynamic)
roLayers->Add(layer);
+ else if (bIncludeBaseLayers && layerType == MgLayerType::BaseMap)
+ roLayers->Add(layer);
}
if(NULL != pPRMResult)
Modified: trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp
===================================================================
--- trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp 2012-10-09 16:33:00 UTC (rev 7102)
+++ trunk/MgDev/Desktop/UnitTest/TestRenderingService.cpp 2012-10-10 11:02:21 UTC (rev 7103)
@@ -281,6 +281,46 @@
Ptr<MgByteReader> wdfrdr1 = wdfsrc1->GetReader();
m_svcResource->SetResource(wdfres1, wdfrdr1, NULL);
+ // ------------------------------------------------------
+ // base map source data
+ // ------------------------------------------------------
+ // publish the map definition
+ Ptr<MgResourceIdentifier> mapres13 = new MgResourceIdentifier(L"Library://UnitTests/Maps/BaseMap.MapDefinition");
+ Ptr<MgByteSource> mdfsrc13 = new MgByteSource(L"../UnitTestFiles/UT_BaseMap.mdf", false);
+ Ptr<MgByteReader> mdfrdr13 = mdfsrc13->GetReader();
+ m_svcResource->SetResource(mapres13, mdfrdr13, NULL);
+
+ // publish the layer definitions
+ Ptr<MgResourceIdentifier> ldfres12 = new MgResourceIdentifier(L"Library://UnitTests/Layers/RoadCenterLines.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc12 = new MgByteSource(L"../UnitTestFiles/UT_RoadCenterLines.ldf", false);
+ Ptr<MgByteReader> ldfrdr12 = ldfsrc12->GetReader();
+ m_svcResource->SetResource(ldfres12, ldfrdr12, NULL);
+
+ Ptr<MgResourceIdentifier> ldfres13 = new MgResourceIdentifier(L"Library://UnitTests/Layers/VotingDistricts.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc13 = new MgByteSource(L"../UnitTestFiles/UT_VotingDistricts.ldf", false);
+ Ptr<MgByteReader> ldfrdr13 = ldfsrc13->GetReader();
+ m_svcResource->SetResource(ldfres13, ldfrdr13, NULL);
+
+ // publish the feature sources
+ Ptr<MgResourceIdentifier> fsres6 = new MgResourceIdentifier(L"Library://UnitTests/Data/RoadCenterLines.FeatureSource");
+ Ptr<MgByteSource> fssrc6 = new MgByteSource(L"../UnitTestFiles/UT_RoadCenterLines.fs", false);
+ Ptr<MgByteReader> fsrdr6 = fssrc6->GetReader();
+ m_svcResource->SetResource(fsres6, fsrdr6, NULL);
+
+ Ptr<MgResourceIdentifier> fsres7 = new MgResourceIdentifier(L"Library://UnitTests/Data/VotingDistricts.FeatureSource");
+ Ptr<MgByteSource> fssrc7 = new MgByteSource(L"../UnitTestFiles/UT_VotingDistricts.fs", false);
+ Ptr<MgByteReader> fsrdr7 = fssrc7->GetReader();
+ m_svcResource->SetResource(fsres7, fsrdr7, NULL);
+
+ // publish the resource data
+ Ptr<MgByteSource> dataSource6 = new MgByteSource(L"../UnitTestFiles/UT_RoadCenterLines.sdf", false);
+ Ptr<MgByteReader> dataReader6 = dataSource6->GetReader();
+ m_svcResource->SetResourceData(fsres5, L"UT_RoadCenterLines.sdf", L"File", dataReader6);
+
+ Ptr<MgByteSource> dataSource7 = new MgByteSource(L"../UnitTestFiles/UT_VotingDistricts.sdf", false);
+ Ptr<MgByteReader> dataReader7 = dataSource7->GetReader();
+ m_svcResource->SetResourceData(fsres6, L"UT_VotingDistricts.sdf", L"File", dataReader7);
+
}
catch (MgException* e)
{
@@ -389,6 +429,17 @@
m_svcResource->DeleteResource(mapres12);
Ptr<MgResourceIdentifier> wdfres1 = new MgResourceIdentifier(L"Library://UnitTests/Watermarks/PoweredByMapGuide.WatermarkDefinition");
m_svcResource->DeleteResource(wdfres1);
+
+ Ptr<MgResourceIdentifier> mapres13 = new MgResourceIdentifier(L"Library://UnitTests/Maps/BaseMap.MapDefinition");
+ m_svcResource->DeleteResource(mapres13);
+ Ptr<MgResourceIdentifier> ldfres12 = new MgResourceIdentifier(L"Library://UnitTests/Layers/RoadCenterLines.LayerDefinition");
+ m_svcResource->DeleteResource(ldfres12);
+ Ptr<MgResourceIdentifier> ldfres13 = new MgResourceIdentifier(L"Library://UnitTests/Layers/VotingDistricts.LayerDefinition");
+ m_svcResource->DeleteResource(ldfres13);
+ Ptr<MgResourceIdentifier> fsres6 = new MgResourceIdentifier(L"Library://UnitTests/Data/RoadCenterLines.FeatureSource");
+ m_svcResource->DeleteResource(fsres6);
+ Ptr<MgResourceIdentifier> fsres7 = new MgResourceIdentifier(L"Library://UnitTests/Data/VotingDistricts.FeatureSource");
+ m_svcResource->DeleteResource(fsres7);
}
catch(MgFileIoException* e)
{
@@ -411,8 +462,7 @@
ACE_DEBUG((LM_INFO, ACE_TEXT("\nRendering Service tests completed.\n\n")));
}
-
-void TestRenderingService::TestCase_RenderDynamicOverlay()
+void TestRenderingService::TestCase_RenderDynamicOverlay(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
@@ -426,16 +476,16 @@
// for (int i=0; i<10; i++)
// {
- Ptr<MgByteReader> rdr1 = m_svcRendering->RenderDynamicOverlay(map, NULL, L"PNG");
- rdr1->ToFile(L"../UnitTestFiles/RenderDynamicOverlay75k.png");
+ Ptr<MgByteReader> rdr1 = m_svcRendering->RenderDynamicOverlay(map, NULL, imageFormat);
+ rdr1->ToFile(GetPath(L"../UnitTestFiles/RenderDynamicOverlay75k", imageFormat, extension));
// }
map->SetViewScale(12000.0);
// for (int i=0; i<100; i++)
// {
- Ptr<MgByteReader> rdr2 = m_svcRendering->RenderDynamicOverlay(map, NULL, L"PNG");
- rdr2->ToFile(L"../UnitTestFiles/RenderDynamicOverlay12k.png");
+ Ptr<MgByteReader> rdr2 = m_svcRendering->RenderDynamicOverlay(map, NULL, imageFormat);
+ rdr2->ToFile(GetPath(L"../UnitTestFiles/RenderDynamicOverlay12k", imageFormat, extension));
// }
// clock_t t1 = clock();
@@ -454,21 +504,65 @@
}
-void TestRenderingService::TestCase_RenderMap()
+void TestRenderingService::TestCase_RenderDynamicOverlayTiledMap(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
+ Ptr<MgdMap> map = CreateTestTiledMap();
+
+// clock_t t0 = clock();
+
+ Ptr<MgdRenderingOptions> renderOpts = new MgdRenderingOptions(imageFormat, MgdRenderingOptions::RenderLayers | MgdRenderingOptions::RenderBaseLayers, NULL);
+
+ map->SetViewScale(12000.0);
+// for (int i=0; i<10; i++)
+// {
+ //EXPECT: Tiled layers rendered with transparent background for applicable formats
+ Ptr<MgByteReader> rdr1 = m_svcRendering->RenderDynamicOverlay(map, NULL, renderOpts);
+ rdr1->ToFile(GetPath(L"../UnitTestFiles/RenderDynamicOverlayTiled_WithBase12k", imageFormat, extension));
+// }
+
+ Ptr<MgdRenderingOptions> renderOpts2 = new MgdRenderingOptions(imageFormat, MgdRenderingOptions::RenderLayers, NULL);
+
+// for (int i=0; i<100; i++)
+// {
+ //EXPECT: Nothing, with transparent background for applicable formats
+ Ptr<MgByteReader> rdr2 = m_svcRendering->RenderDynamicOverlay(map, NULL, renderOpts2);
+ rdr2->ToFile(GetPath(L"../UnitTestFiles/RenderDynamicOverlayTiled_NoBase12k", imageFormat, extension));
+// }
+
+// clock_t t1 = clock();
+// printf ("delta clock %d\n", t1 - t0);
+ }
+ catch (MgException* e)
+ {
+ STRING message = e->GetDetails(TEST_LOCALE);
+ SAFE_RELEASE(e);
+ CPPUNIT_FAIL(MG_WCHAR_TO_CHAR(message.c_str()));
+ }
+ catch (...)
+ {
+ throw;
+ }
+}
+
+
+void TestRenderingService::TestCase_RenderMap(CREFSTRING imageFormat, CREFSTRING extension)
+{
+ try
+ {
+ // make a runtime map
Ptr<MgdMap> map = CreateTestMap();
// call the API using scales of 75000 and 12000
map->SetViewScale(75000.0);
- Ptr<MgByteReader> rdr1 = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr1->ToFile(L"../UnitTestFiles/RenderMap75k.png");
+ Ptr<MgByteReader> rdr1 = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr1->ToFile(GetPath(L"../UnitTestFiles/RenderMap75k", imageFormat, extension));
map->SetViewScale(12000.0);
- Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr2->ToFile(L"../UnitTestFiles/RenderMap12k.png");
+ Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr2->ToFile(GetPath(L"../UnitTestFiles/RenderMap12k", imageFormat, extension));
}
catch (MgException* e)
{
@@ -482,7 +576,7 @@
}
}
-void TestRenderingService::TestCase_RenderMapWithWatermark()
+void TestRenderingService::TestCase_RenderMapWithWatermark(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
@@ -491,12 +585,12 @@
// call the API using scales of 75000 and 12000
map->SetViewScale(75000.0);
- Ptr<MgByteReader> rdr1 = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr1->ToFile(L"../UnitTestFiles/RenderMapWithWatermark75k.png");
+ Ptr<MgByteReader> rdr1 = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr1->ToFile(GetPath(L"../UnitTestFiles/RenderMapWithWatermark75k", imageFormat, extension));
map->SetViewScale(12000.0);
- Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr2->ToFile(L"../UnitTestFiles/RenderMapWithWatermark12k.png");
+ Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr2->ToFile(GetPath(L"../UnitTestFiles/RenderMapWithWatermark12k", imageFormat, extension));
}
catch (MgException* e)
{
@@ -511,7 +605,7 @@
}
-void TestRenderingService::TestCase_RenderLegend()
+void TestRenderingService::TestCase_RenderLegend(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
@@ -522,12 +616,12 @@
Ptr<MgColor> bgc = new MgColor(255, 255, 255, 255);
map->SetViewScale(75000.0);
- Ptr<MgByteReader> rdr1 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, L"PNG");
- rdr1->ToFile(L"../UnitTestFiles/RenderLegend75k.png");
+ Ptr<MgByteReader> rdr1 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ rdr1->ToFile(GetPath(L"../UnitTestFiles/RenderLegend75k", imageFormat, extension));
map->SetViewScale(12000.0);
- Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, L"PNG");
- rdr2->ToFile(L"../UnitTestFiles/RenderLegend12k.png");
+ Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ rdr2->ToFile(GetPath(L"../UnitTestFiles/RenderLegend12k", imageFormat, extension));
// add a layer group
Ptr<MgLayerGroupCollection> layerGroups = map->GetLayerGroups();
@@ -550,18 +644,18 @@
//Re-draw at 75k. Layer group should not be there because it has no visible layers
map->SetViewScale(75000.0);
- Ptr<MgByteReader> rdr3 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, L"PNG");
- rdr3->ToFile(L"../UnitTestFiles/RenderLegend75kWithEmptyLayerGroup.png");
+ Ptr<MgByteReader> rdr3 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ rdr3->ToFile(GetPath(L"../UnitTestFiles/RenderLegend75kWithEmptyLayerGroup", imageFormat, extension));
//Re-draw at 14000. Layer group should still not be there because it has no visible layers
map->SetViewScale(14000.0);
- Ptr<MgByteReader> rdr4 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, L"PNG");
- rdr4->ToFile(L"../UnitTestFiles/RenderLegend14kWithEmptyLayerGroup.png");
+ Ptr<MgByteReader> rdr4 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ rdr4->ToFile(GetPath(L"../UnitTestFiles/RenderLegend14kWithEmptyLayerGroup", imageFormat, extension));
//Re-draw at 12000. Layer group should now be there because its child layer (Parcels) should be visible
map->SetViewScale(12000.0);
- Ptr<MgByteReader> rdr5 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, L"PNG");
- rdr5->ToFile(L"../UnitTestFiles/RenderLegend12kWithLayerGroup.png");
+ Ptr<MgByteReader> rdr5 = m_svcRendering->RenderMapLegend(map, 200, 400, bgc, imageFormat);
+ rdr5->ToFile(GetPath(L"../UnitTestFiles/RenderLegend12kWithLayerGroup", imageFormat, extension));
}
catch (MgException* e)
{
@@ -646,7 +740,22 @@
return map;
}
+MgdMap* TestRenderingService::CreateTestTiledMap()
+{
+ Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/BaseMap.MapDefinition");
+ MgdMap* map = new MgdMap(mdfres, L"UnitTestSheboyganTiled");
+ Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-87.733253, 43.746199);
+ Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+ map->SetViewCenter(ptNewCenter);
+ map->SetViewScale(75000.0);
+ map->SetDisplayDpi(96);
+ map->SetDisplayWidth(1024);
+ map->SetDisplayHeight(1024);
+
+ return map;
+}
+
// creates a selection bounds in mapping space
MgPolygon* TestRenderingService::CreateSelectionPolygon(MgdMap* map, double width, double height)
{
@@ -674,14 +783,13 @@
}
-void TestRenderingService::TestCase_SymbologyPoints()
+void TestRenderingService::TestCase_SymbologyPoints(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Capitals.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestSymbology");
- //map->Create(mdfres, L"UnitTestSymbology");
INT32 pixels = 512;
@@ -699,8 +807,8 @@
map->SetViewScale(scale);
// call the API
- Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr->ToFile(L"../UnitTestFiles/SymbologyPoints.png");
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr->ToFile(GetPath(L"../UnitTestFiles/SymbologyPoints", imageFormat, extension));
}
catch (MgException* e)
{
@@ -711,14 +819,13 @@
}
-void TestRenderingService::TestCase_SymbologyPointsParam()
+void TestRenderingService::TestCase_SymbologyPointsParam(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/CapitalsParam.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestSymbology");
- //map->Create(mdfres, L"UnitTestSymbology");
INT32 pixels = 512;
@@ -736,8 +843,8 @@
map->SetViewScale(scale);
// call the API
- Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr->ToFile(L"../UnitTestFiles/SymbologyPointsParam.png");
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr->ToFile(GetPath(L"../UnitTestFiles/SymbologyPointsParam", imageFormat, extension));
}
catch (MgException* e)
{
@@ -748,14 +855,13 @@
}
-void TestRenderingService::TestCase_SymbologyLines()
+void TestRenderingService::TestCase_SymbologyLines(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/Lines.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestSymbology");
- //map->Create(mdfres, L"UnitTestSymbology");
INT32 pixels = 512;
@@ -773,8 +879,8 @@
map->SetViewScale(scale);
// call the API
- Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr->ToFile(L"../UnitTestFiles/SymbologyLines.png");
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr->ToFile(GetPath(L"../UnitTestFiles/SymbologyLines", imageFormat, extension));
}
catch (MgException* e)
{
@@ -785,14 +891,13 @@
}
-void TestRenderingService::TestCase_SymbologyLinesCrossTick()
+void TestRenderingService::TestCase_SymbologyLinesCrossTick(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/LinesCrossTick.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestSymbology");
- //map->Create(mdfres, L"UnitTestSymbology");
INT32 pixels = 512;
@@ -810,8 +915,8 @@
map->SetViewScale(scale);
// call the API
- Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr->ToFile(L"../UnitTestFiles/SymbologyLinesCrossTick.png");
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr->ToFile(GetPath(L"../UnitTestFiles/SymbologyLinesCrossTick", imageFormat, extension));
}
catch (MgException* e)
{
@@ -822,14 +927,13 @@
}
-void TestRenderingService::TestCase_Annotation1()
+void TestRenderingService::TestCase_Annotation1(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/UT_Annotation1.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestAnnotation1");
- //map->Create(mdfres, L"UnitTestAnnotation1");
INT32 pixels = 512;
@@ -847,8 +951,8 @@
map->SetViewScale(scale);
// call the API
- Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr->ToFile(L"../UnitTestFiles/Annotation1.png");
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr->ToFile(GetPath(L"../UnitTestFiles/Annotation1", imageFormat, extension));
}
catch (MgException* e)
{
@@ -859,14 +963,13 @@
}
-void TestRenderingService::TestCase_Annotation2()
+void TestRenderingService::TestCase_Annotation2(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/UT_Annotation2.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestAnnotation2");
- // map->Create(mdfres, L"UnitTestAnnotation2");
INT32 pixels = 512;
@@ -884,8 +987,8 @@
map->SetViewScale(scale);
// call the API
- Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr->ToFile(L"../UnitTestFiles/Annotation2.png");
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr->ToFile(GetPath(L"../UnitTestFiles/Annotation2", imageFormat, extension));
}
catch (MgException* e)
{
@@ -896,14 +999,13 @@
}
-void TestRenderingService::TestCase_Annotation3()
+void TestRenderingService::TestCase_Annotation3(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/UT_Annotation3.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestAnnotation3");
- //map->Create(mdfres, L"UnitTestAnnotation3");
INT32 pixels = 512;
@@ -921,8 +1023,8 @@
map->SetViewScale(scale);
// call the API
- Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr->ToFile(L"../UnitTestFiles/Annotation3.png");
+ Ptr<MgByteReader> rdr = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr->ToFile(GetPath(L"../UnitTestFiles/Annotation3", imageFormat, extension));
}
catch (MgException* e)
{
@@ -933,14 +1035,13 @@
}
-void TestRenderingService::TestCase_SymbologyPolygons()
+void TestRenderingService::TestCase_SymbologyPolygons(CREFSTRING imageFormat, CREFSTRING extension)
{
try
{
// make a runtime map
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/UT_SymbologyPolygons.MapDefinition");
Ptr<MgdMap> map = new MgdMap(mdfres, L"UnitTestSymbologyPolygons");
- //map->Create(mdfres, L"UnitTestSymbologyPolygons");
Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-87.733253, 43.746199);
Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
@@ -950,8 +1051,8 @@
map->SetDisplayHeight(1024);
map->SetViewScale(12000.0);
- Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMap(map, NULL, L"PNG");
- rdr2->ToFile(L"../UnitTestFiles/SymbologyPolygons.png");
+ Ptr<MgByteReader> rdr2 = m_svcRendering->RenderMap(map, NULL, imageFormat);
+ rdr2->ToFile(GetPath(L"../UnitTestFiles/SymbologyPolygons", imageFormat, extension));
}
catch (MgException* e)
{
@@ -961,6 +1062,17 @@
}
}
+STRING TestRenderingService::GetPath(CREFSTRING basePath, CREFSTRING imageFormat, CREFSTRING extension)
+{
+ STRING ret;
+ ret += basePath;
+ ret += L"_";
+ ret += imageFormat;
+ ret += L".";
+ ret += extension;
+ return ret;
+}
+
//void TestRenderingService::TestCase_RendererPerformance()
//{
// /*
Modified: trunk/MgDev/Desktop/UnitTest/TestRenderingService.h
===================================================================
--- trunk/MgDev/Desktop/UnitTest/TestRenderingService.h 2012-10-09 16:33:00 UTC (rev 7102)
+++ trunk/MgDev/Desktop/UnitTest/TestRenderingService.h 2012-10-10 11:02:21 UTC (rev 7103)
@@ -25,20 +25,70 @@
CPPUNIT_TEST_SUITE(TestRenderingService);
CPPUNIT_TEST(TestStart); // This must be the very first unit test
- CPPUNIT_TEST(TestCase_SymbologyPoints);
- CPPUNIT_TEST(TestCase_SymbologyPointsParam);
- CPPUNIT_TEST(TestCase_SymbologyLines);
- CPPUNIT_TEST(TestCase_SymbologyLinesCrossTick);
- CPPUNIT_TEST(TestCase_SymbologyPolygons);
+ CPPUNIT_TEST(TestCase_SymbologyPointsPNG);
+ CPPUNIT_TEST(TestCase_SymbologyPointsParamPNG);
+ CPPUNIT_TEST(TestCase_SymbologyLinesPNG);
+ CPPUNIT_TEST(TestCase_SymbologyLinesCrossTickPNG);
+ CPPUNIT_TEST(TestCase_SymbologyPolygonsPNG);
- CPPUNIT_TEST(TestCase_Annotation1);
- CPPUNIT_TEST(TestCase_Annotation2);
- CPPUNIT_TEST(TestCase_Annotation3);
+ CPPUNIT_TEST(TestCase_Annotation1PNG);
+ CPPUNIT_TEST(TestCase_Annotation2PNG);
+ CPPUNIT_TEST(TestCase_Annotation3PNG);
- CPPUNIT_TEST(TestCase_RenderDynamicOverlay);
- CPPUNIT_TEST(TestCase_RenderMap);
- CPPUNIT_TEST(TestCase_RenderMapWithWatermark);
- CPPUNIT_TEST(TestCase_RenderLegend);
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayPNG);
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayTiledMapPNG);
+ CPPUNIT_TEST(TestCase_RenderMapPNG);
+ CPPUNIT_TEST(TestCase_RenderMapWithWatermarkPNG);
+ CPPUNIT_TEST(TestCase_RenderLegendPNG);
+
+ CPPUNIT_TEST(TestCase_SymbologyPointsPNG8);
+ CPPUNIT_TEST(TestCase_SymbologyPointsParamPNG8);
+ CPPUNIT_TEST(TestCase_SymbologyLinesPNG8);
+ CPPUNIT_TEST(TestCase_SymbologyLinesCrossTickPNG8);
+ CPPUNIT_TEST(TestCase_SymbologyPolygonsPNG8);
+
+ CPPUNIT_TEST(TestCase_Annotation1PNG8);
+ CPPUNIT_TEST(TestCase_Annotation2PNG8);
+ CPPUNIT_TEST(TestCase_Annotation3PNG8);
+
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayPNG8);
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayTiledMapPNG8);
+ CPPUNIT_TEST(TestCase_RenderMapPNG8);
+ CPPUNIT_TEST(TestCase_RenderMapWithWatermarkPNG8);
+ CPPUNIT_TEST(TestCase_RenderLegendPNG8);
+
+ CPPUNIT_TEST(TestCase_SymbologyPointsGIF);
+ CPPUNIT_TEST(TestCase_SymbologyPointsParamGIF);
+ CPPUNIT_TEST(TestCase_SymbologyLinesGIF);
+ CPPUNIT_TEST(TestCase_SymbologyLinesCrossTickGIF);
+ CPPUNIT_TEST(TestCase_SymbologyPolygonsGIF);
+
+ CPPUNIT_TEST(TestCase_Annotation1GIF);
+ CPPUNIT_TEST(TestCase_Annotation2GIF);
+ CPPUNIT_TEST(TestCase_Annotation3GIF);
+
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayGIF);
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayTiledMapGIF);
+ CPPUNIT_TEST(TestCase_RenderMapGIF);
+ CPPUNIT_TEST(TestCase_RenderMapWithWatermarkGIF);
+ CPPUNIT_TEST(TestCase_RenderLegendGIF);
+
+ CPPUNIT_TEST(TestCase_SymbologyPointsJPG);
+ CPPUNIT_TEST(TestCase_SymbologyPointsParamJPG);
+ CPPUNIT_TEST(TestCase_SymbologyLinesJPG);
+ CPPUNIT_TEST(TestCase_SymbologyLinesCrossTickJPG);
+ CPPUNIT_TEST(TestCase_SymbologyPolygonsJPG);
+
+ CPPUNIT_TEST(TestCase_Annotation1JPG);
+ CPPUNIT_TEST(TestCase_Annotation2JPG);
+ CPPUNIT_TEST(TestCase_Annotation3JPG);
+
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayJPG);
+ CPPUNIT_TEST(TestCase_RenderDynamicOverlayTiledMapJPG);
+ CPPUNIT_TEST(TestCase_RenderMapJPG);
+ CPPUNIT_TEST(TestCase_RenderMapWithWatermarkJPG);
+ CPPUNIT_TEST(TestCase_RenderLegendJPG);
+
CPPUNIT_TEST(TestCase_QueryFeatures);
//CPPUNIT_TEST(TestCase_RendererPerformance);
@@ -55,28 +105,93 @@
void TestStart();
void TestEnd();
- void TestCase_RenderDynamicOverlay();
- void TestCase_RenderMap();
- void TestCase_RenderMapWithWatermark();
- void TestCase_RenderLegend();
- void TestCase_QueryFeatures();
+ //Parameterized versions that all format-specific tests call into
+ void TestCase_RenderDynamicOverlay(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_RenderDynamicOverlayTiledMap(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_RenderMap(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_RenderMapWithWatermark(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_RenderLegend(CREFSTRING imageFormat, CREFSTRING extension);
+
+ void TestCase_SymbologyPoints(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_SymbologyPointsParam(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_SymbologyLines(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_SymbologyLinesCrossTick(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_SymbologyPolygons(CREFSTRING imageFormat, CREFSTRING extension);
- void TestCase_SymbologyPoints();
- void TestCase_SymbologyPointsParam();
- void TestCase_SymbologyLines();
- void TestCase_SymbologyLinesCrossTick();
- void TestCase_SymbologyPolygons();
+ void TestCase_Annotation1(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_Annotation2(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_Annotation3(CREFSTRING imageFormat, CREFSTRING extension);
- void TestCase_Annotation1();
- void TestCase_Annotation2();
- void TestCase_Annotation3();
+ //PNG output tests
+ void TestCase_RenderDynamicOverlayPNG() { TestCase_RenderDynamicOverlay(L"PNG", L"png"); }
+ void TestCase_RenderDynamicOverlayTiledMapPNG() { TestCase_RenderDynamicOverlayTiledMap(L"PNG", L"png"); }
+ void TestCase_RenderMapPNG() { TestCase_RenderMap(L"PNG", L"png"); }
+ void TestCase_RenderMapWithWatermarkPNG() { TestCase_RenderMapWithWatermark(L"PNG", L"png"); }
+ void TestCase_RenderLegendPNG() { TestCase_RenderLegend(L"PNG", L"png"); }
+ void TestCase_SymbologyPointsPNG() { TestCase_SymbologyPoints(L"PNG", L"png"); }
+ void TestCase_SymbologyPointsParamPNG() { TestCase_SymbologyPointsParam(L"PNG", L"png"); }
+ void TestCase_SymbologyLinesPNG() { TestCase_SymbologyLines(L"PNG", L"png"); }
+ void TestCase_SymbologyLinesCrossTickPNG() { TestCase_SymbologyLinesCrossTick(L"PNG", L"png"); }
+ void TestCase_SymbologyPolygonsPNG() { TestCase_SymbologyPolygons(L"PNG", L"png"); }
+ void TestCase_Annotation1PNG() { TestCase_Annotation1(L"PNG", L"png"); }
+ void TestCase_Annotation2PNG() { TestCase_Annotation2(L"PNG", L"png"); }
+ void TestCase_Annotation3PNG() { TestCase_Annotation3(L"PNG", L"png"); }
+ //PNG8 output tests
+ void TestCase_RenderDynamicOverlayPNG8() { TestCase_RenderDynamicOverlay(L"PNG8", L"png"); }
+ void TestCase_RenderDynamicOverlayTiledMapPNG8() { TestCase_RenderDynamicOverlayTiledMap(L"PNG8", L"png"); }
+ void TestCase_RenderMapPNG8() { TestCase_RenderMap(L"PNG8", L"png"); }
+ void TestCase_RenderMapWithWatermarkPNG8() { TestCase_RenderMapWithWatermark(L"PNG8", L"png"); }
+ void TestCase_RenderLegendPNG8() { TestCase_RenderLegend(L"PNG8", L"png"); }
+ void TestCase_SymbologyPointsPNG8() { TestCase_SymbologyPoints(L"PNG8", L"png"); }
+ void TestCase_SymbologyPointsParamPNG8() { TestCase_SymbologyPointsParam(L"PNG8", L"png"); }
+ void TestCase_SymbologyLinesPNG8() { TestCase_SymbologyLines(L"PNG8", L"png"); }
+ void TestCase_SymbologyLinesCrossTickPNG8() { TestCase_SymbologyLinesCrossTick(L"PNG8", L"png"); }
+ void TestCase_SymbologyPolygonsPNG8() { TestCase_SymbologyPolygons(L"PNG8", L"png"); }
+ void TestCase_Annotation1PNG8() { TestCase_Annotation1(L"PNG8", L"png"); }
+ void TestCase_Annotation2PNG8() { TestCase_Annotation2(L"PNG8", L"png"); }
+ void TestCase_Annotation3PNG8() { TestCase_Annotation3(L"PNG8", L"png"); }
+
+ //GIF output tests
+ void TestCase_RenderDynamicOverlayGIF() { TestCase_RenderDynamicOverlay(L"GIF", L"gif"); }
+ void TestCase_RenderDynamicOverlayTiledMapGIF() { TestCase_RenderDynamicOverlayTiledMap(L"GIF", L"gif"); }
+ void TestCase_RenderMapGIF() { TestCase_RenderMap(L"GIF", L"gif"); }
+ void TestCase_RenderMapWithWatermarkGIF() { TestCase_RenderMapWithWatermark(L"GIF", L"gif"); }
+ void TestCase_RenderLegendGIF() { TestCase_RenderLegend(L"GIF", L"gif"); }
+ void TestCase_SymbologyPointsGIF() { TestCase_SymbologyPoints(L"GIF", L"gif"); }
+ void TestCase_SymbologyPointsParamGIF() { TestCase_SymbologyPointsParam(L"GIF", L"gif"); }
+ void TestCase_SymbologyLinesGIF() { TestCase_SymbologyLines(L"GIF", L"gif"); }
+ void TestCase_SymbologyLinesCrossTickGIF() { TestCase_SymbologyLinesCrossTick(L"GIF", L"gif"); }
+ void TestCase_SymbologyPolygonsGIF() { TestCase_SymbologyPolygons(L"GIF", L"gif"); }
+ void TestCase_Annotation1GIF() { TestCase_Annotation1(L"GIF", L"gif"); }
+ void TestCase_Annotation2GIF() { TestCase_Annotation2(L"GIF", L"gif"); }
+ void TestCase_Annotation3GIF() { TestCase_Annotation3(L"GIF", L"gif"); }
+
+ //JPG output tests
+ void TestCase_RenderDynamicOverlayJPG() { TestCase_RenderDynamicOverlay(L"JPG", L"jpg"); }
+ void TestCase_RenderDynamicOverlayTiledMapJPG() { TestCase_RenderDynamicOverlayTiledMap(L"JPG", L"jpg"); }
+ void TestCase_RenderMapJPG() { TestCase_RenderMap(L"JPG", L"jpg"); }
+ void TestCase_RenderMapWithWatermarkJPG() { TestCase_RenderMapWithWatermark(L"JPG", L"jpg"); }
+ void TestCase_RenderLegendJPG() { TestCase_RenderLegend(L"JPG", L"jpg"); }
+ void TestCase_SymbologyPointsJPG() { TestCase_SymbologyPoints(L"JPG", L"jpg"); }
+ void TestCase_SymbologyPointsParamJPG() { TestCase_SymbologyPointsParam(L"JPG", L"jpg"); }
+ void TestCase_SymbologyLinesJPG() { TestCase_SymbologyLines(L"JPG", L"jpg"); }
+ void TestCase_SymbologyLinesCrossTickJPG() { TestCase_SymbologyLinesCrossTick(L"JPG", L"jpg"); }
+ void TestCase_SymbologyPolygonsJPG() { TestCase_SymbologyPolygons(L"JPG", L"jpg"); }
+ void TestCase_Annotation1JPG() { TestCase_Annotation1(L"JPG", L"jpg"); }
+ void TestCase_Annotation2JPG() { TestCase_Annotation2(L"JPG", L"jpg"); }
+ void TestCase_Annotation3JPG() { TestCase_Annotation3(L"JPG", L"jpg"); }
+
+ void TestCase_QueryFeatures();
+
//void TestCase_RendererPerformance();
private:
MgdMap* CreateTestMap();
+ MgdMap* CreateTestTiledMap();
MgdMap* CreateTestMapWithWatermark();
MgPolygon* CreateSelectionPolygon(MgdMap* map, double width, double height);
+ static STRING GetPath(CREFSTRING basePath, CREFSTRING imageFormat, CREFSTRING extension);
private:
Ptr<MgResourceService> m_svcResource;
Modified: trunk/MgDev/Desktop/UnitTest/main.cpp
===================================================================
--- trunk/MgDev/Desktop/UnitTest/main.cpp 2012-10-09 16:33:00 UTC (rev 7102)
+++ trunk/MgDev/Desktop/UnitTest/main.cpp 2012-10-10 11:02:21 UTC (rev 7103)
@@ -24,14 +24,14 @@
#endif
#endif
-#define TEST_COORDINATE_SYSTEM 0
-#define TEST_LOG_MANAGER 0
+#define TEST_COORDINATE_SYSTEM 1
+#define TEST_LOG_MANAGER 1
#define TEST_RESOURCE_SERVICE 1
-#define TEST_FEATURE_SERVICE 0
-#define TEST_MAPPING_SERVICE 0
-#define TEST_PROFILING_SERVICE 0
-#define TEST_RENDERING_SERVICE 0
-#define TEST_TILE_SERVICE 0
+#define TEST_FEATURE_SERVICE 1
+#define TEST_MAPPING_SERVICE 1
+#define TEST_PROFILING_SERVICE 1
+#define TEST_RENDERING_SERVICE 1
+#define TEST_TILE_SERVICE 1
int main(int argc, char** argv)
{
More information about the mapguide-commits
mailing list