[mapguide-commits] r7460 - in sandbox/jng/extra_stylization_funcs/Desktop: MgDesktop/Services MgDesktop/Services/Rendering UnitTest
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Apr 17 10:29:08 PDT 2013
Author: jng
Date: 2013-04-17 10:29:08 -0700 (Wed, 17 Apr 2013)
New Revision: 7460
Modified:
sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/MappingService.cpp
sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp
sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/RenderingService.cpp
sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.cpp
sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.h
Log:
Fix mg-desktop breakage and include same stylization function test case to test suite
Modified: sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/MappingService.cpp
===================================================================
--- sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/MappingService.cpp 2013-04-17 16:14:50 UTC (rev 7459)
+++ sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/MappingService.cpp 2013-04-17 17:29:08 UTC (rev 7460)
@@ -834,7 +834,7 @@
if (userInfo != NULL)
sessionId = userInfo->GetMgSessionId();*/
- RS_MapUIInfo mapInfo(sessionId, map->GetName(), L"", srs, units, layoutColor);
+ RS_MapUIInfo mapInfo(sessionId, map->GetName(), L"", srs, units, layoutColor, center->GetX(), center->GetY(), dMapScale);
// Dynamically adjust the width and height of the map
printLayout->ComputeMapOffsetAndSize(dMapScale, extents, metersPerUnit, dr.mapOffsetX(), dr.mapOffsetY(), dr.mapWidth(), dr.mapHeight(), mapPlot->GetExpandToFit());
Modified: sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp
===================================================================
--- sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp 2013-04-17 16:14:50 UTC (rev 7459)
+++ sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/Rendering/MappingUtil.cpp 2013-04-17 17:29:08 UTC (rev 7460)
@@ -434,6 +434,7 @@
//layer legend and ui specific information
RS_UIGraphic uig(NULL, 0, mapLayer->GetLegendLabel());
RS_LayerUIInfo layerInfo( mapLayer->GetName(),
+ layerid->ToString(),
mapLayer->GetObjectId(),
mapLayer->GetSelectable(),
mapLayer->GetVisible(),
@@ -529,7 +530,7 @@
//string the viewer should be displaying as the name of each
//feature property
// TODO: check to see if name is FeatureClass or Extension name
- RS_FeatureClassInfo fcinfo(vl->GetFeatureName());
+ RS_FeatureClassInfo fcinfo(vl->GetFeatureName(), vl->GetResourceID());
MdfModel::NameStringPairCollection* pmappings = vl->GetPropertyMappings();
for (int j=0; j<pmappings->GetCount(); j++)
@@ -641,7 +642,7 @@
//string the viewer should be displaying as the name of each
//feature property
// TODO: check to see if name is FeatureClass or Extension name
- RS_FeatureClassInfo fcinfo(gl->GetFeatureName());
+ RS_FeatureClassInfo fcinfo(gl->GetFeatureName(), gl->GetResourceID());
//check for overridden feature query filter and remember it.
//we will use this when making feature queries
Modified: sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/RenderingService.cpp
===================================================================
--- sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/RenderingService.cpp 2013-04-17 16:14:50 UTC (rev 7459)
+++ sandbox/jng/extra_stylization_funcs/Desktop/MgDesktop/Services/RenderingService.cpp 2013-04-17 17:29:08 UTC (rev 7460)
@@ -1293,9 +1293,6 @@
// get the session ID
STRING sessionId = map->GetSessionId();
- //Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
- //if (userInfo != NULL)
- // sessionId = userInfo->GetMgSessionId();
// initialize the stylizer
RSMgdSymbolManager mgr(m_svcResource);
@@ -1308,7 +1305,9 @@
STRING format = options->GetImageFormat();
- RS_MapUIInfo mapInfo(sessionId, map->GetName(), map->GetObjectId(), srs, units, bgcolor);
+ Ptr<MgPoint> ptCenter = map->GetViewCenter();
+ Ptr<MgCoordinate> coord = ptCenter->GetCoordinate();
+ RS_MapUIInfo mapInfo(sessionId, map->GetName(), map->GetObjectId(), srs, units, bgcolor, coord->GetX(), coord->GetY(), scale);
// begin map stylization
dr->StartMap(&mapInfo, b, scale, map->GetDisplayDpi(), map->GetMetersPerUnit(), NULL);
@@ -2084,7 +2083,7 @@
// begin map stylization
RS_Color bgcolor(0, 0, 0, 255); // not used
STRING srs = map->GetMapSRS();
- RS_MapUIInfo mapInfo(sessionId, map->GetName(), map->GetObjectId(), srs, L"", bgcolor);
+ RS_MapUIInfo mapInfo(sessionId, map->GetName(), map->GetObjectId(), srs, L"", bgcolor, center->GetX(), center->GetY(), scale);
// initialize the stylizer
SEMgdSymbolManager semgr(m_svcResource);
@@ -2241,7 +2240,9 @@
//for the first feature hit
RS_UIGraphic uig(NULL, 0, L"");
+ Ptr<MgResourceIdentifier> layerDefId = layer->GetLayerDefinition();
RS_LayerUIInfo layerinfo(layer->GetName(),
+ layerDefId->ToString(),
layer->GetObjectId(), // object ID
true, // selectable
true, // visible
@@ -2263,7 +2264,7 @@
//string the viewer should be displaying as the name of each
//feature property
// TODO: can FeatureName be an extension name rather than a FeatureClass?
- RS_FeatureClassInfo fcinfo(vl->GetFeatureName());
+ RS_FeatureClassInfo fcinfo(vl->GetFeatureName(), vl->GetResourceID());
MdfModel::NameStringPairCollection* pmappings = vl->GetPropertyMappings();
for (int i=0; i<pmappings->GetCount(); i++)
Modified: sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.cpp
===================================================================
--- sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.cpp 2013-04-17 16:14:50 UTC (rev 7459)
+++ sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.cpp 2013-04-17 17:29:08 UTC (rev 7460)
@@ -315,12 +315,23 @@
// 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);
+ m_svcResource->SetResourceData(fsres6, 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);
+ m_svcResource->SetResourceData(fsres7, L"UT_VotingDistricts.sdf", L"File", dataReader7);
+ // Data related to stylization function tests
+ Ptr<MgResourceIdentifier> ldfres14 = new MgResourceIdentifier(L"Library://UnitTests/Layers/StylizationFuncs.LayerDefinition");
+ Ptr<MgByteSource> ldfsrc14 = new MgByteSource(L"../UnitTestFiles/UT_VotingDistrictsFunctions.ldf", false);
+ Ptr<MgByteReader> ldfrdr14 = ldfsrc14->GetReader();
+ m_svcResource->SetResource(ldfres14, ldfrdr14, NULL);
+
+ Ptr<MgResourceIdentifier> mapres15 = new MgResourceIdentifier(L"Library://UnitTests/Maps/StylizationFuncs.MapDefinition");
+ Ptr<MgByteSource> mdfsrc15 = new MgByteSource(L"../UnitTestFiles/UT_StylizationFuncs.mdf", false);
+ Ptr<MgByteReader> mdfrdr15 = mdfsrc15->GetReader();
+ m_svcResource->SetResource(mapres15, mdfrdr15, NULL);
+
}
catch (MgException* e)
{
@@ -440,6 +451,13 @@
m_svcResource->DeleteResource(fsres6);
Ptr<MgResourceIdentifier> fsres7 = new MgResourceIdentifier(L"Library://UnitTests/Data/VotingDistricts.FeatureSource");
m_svcResource->DeleteResource(fsres7);
+
+ // Data related to stylization function tests
+ Ptr<MgResourceIdentifier> ldfres14 = new MgResourceIdentifier(L"Library://UnitTests/Layers/StylizationFuncs.LayerDefinition");
+ m_svcResource->GetResourceHeader(ldfres14);
+
+ Ptr<MgResourceIdentifier> mapres15 = new MgResourceIdentifier(L"Library://UnitTests/Maps/StylizationFuncs.MapDefinition");
+ m_svcResource->GetResourceHeader(mapres15);
}
catch(MgFileIoException* e)
{
@@ -669,6 +687,42 @@
}
}
+void TestRenderingService::TestCase_StylizationFunctions(CREFSTRING imageFormat, CREFSTRING extension)
+{
+ try
+ {
+ Ptr<MgdMap> map = CreateTestStylizationFunctionMap();
+
+ // call the API using a scale of 75000
+ map->SetViewScale(75000.0);
+
+ Ptr<MgByteReader> rdr1 = m_svcRendering->RenderDynamicOverlay(map, NULL, imageFormat);
+ rdr1->ToFile(GetPath(L"../UnitTestFiles/StylizationFunc_75k", imageFormat, extension));
+
+ // call the API using a scale of 12000
+ map->SetViewScale(12000);
+ Ptr<MgByteReader> rdr2 = m_svcRendering->RenderDynamicOverlay(map, NULL, imageFormat);
+ rdr2->ToFile(GetPath(L"../UnitTestFiles/StylizationFunc_12k", imageFormat, extension));
+
+ // Move around
+ Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-87.733753, 43.746899);
+ Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+ map->SetViewCenter(ptNewCenter);
+ Ptr<MgByteReader> rdr3 = m_svcRendering->RenderDynamicOverlay(map, NULL, imageFormat);
+ rdr3->ToFile(GetPath(L"../UnitTestFiles/StylizationFunc_12k_Moved", imageFormat, extension));
+ }
+ 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_QueryFeatures()
{
try
@@ -740,6 +794,23 @@
return map;
}
+MgdMap* TestRenderingService::CreateTestStylizationFunctionMap()
+{
+ Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/StylizationFuncs.MapDefinition");
+ MgdMap* map = new MgdMap(mdfres);
+ //map->Create(mdfres, L"StylizationFuncs");
+
+ Ptr<MgCoordinate> coordNewCenter = new MgCoordinateXY(-87.733253, 43.746199);
+ Ptr<MgPoint> ptNewCenter = new MgPoint(coordNewCenter);
+ map->SetViewCenter(ptNewCenter);
+ map->SetViewScale(60000.0);
+ map->SetDisplayDpi(96);
+ map->SetDisplayWidth(1024);
+ map->SetDisplayHeight(1024);
+
+ return map;
+}
+
MgdMap* TestRenderingService::CreateTestTiledMap()
{
Ptr<MgResourceIdentifier> mdfres = new MgResourceIdentifier(L"Library://UnitTests/Maps/BaseMap.MapDefinition");
Modified: sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.h
===================================================================
--- sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.h 2013-04-17 16:14:50 UTC (rev 7459)
+++ sandbox/jng/extra_stylization_funcs/Desktop/UnitTest/TestRenderingService.h 2013-04-17 17:29:08 UTC (rev 7460)
@@ -25,6 +25,8 @@
CPPUNIT_TEST_SUITE(TestRenderingService);
CPPUNIT_TEST(TestStart); // This must be the very first unit test
+ CPPUNIT_TEST(TestCase_StylizationFunctionsPNG);
+
CPPUNIT_TEST(TestCase_SymbologyPointsPNG);
CPPUNIT_TEST(TestCase_SymbologyPointsParamPNG);
CPPUNIT_TEST(TestCase_SymbologyLinesPNG);
@@ -41,6 +43,8 @@
CPPUNIT_TEST(TestCase_RenderMapWithWatermarkPNG);
CPPUNIT_TEST(TestCase_RenderLegendPNG);
+ CPPUNIT_TEST(TestCase_StylizationFunctionsPNG8);
+
CPPUNIT_TEST(TestCase_SymbologyPointsPNG8);
CPPUNIT_TEST(TestCase_SymbologyPointsParamPNG8);
CPPUNIT_TEST(TestCase_SymbologyLinesPNG8);
@@ -57,6 +61,8 @@
CPPUNIT_TEST(TestCase_RenderMapWithWatermarkPNG8);
CPPUNIT_TEST(TestCase_RenderLegendPNG8);
+ CPPUNIT_TEST(TestCase_StylizationFunctionsGIF);
+
CPPUNIT_TEST(TestCase_SymbologyPointsGIF);
CPPUNIT_TEST(TestCase_SymbologyPointsParamGIF);
CPPUNIT_TEST(TestCase_SymbologyLinesGIF);
@@ -73,6 +79,8 @@
CPPUNIT_TEST(TestCase_RenderMapWithWatermarkGIF);
CPPUNIT_TEST(TestCase_RenderLegendGIF);
+ CPPUNIT_TEST(TestCase_StylizationFunctionsJPG);
+
CPPUNIT_TEST(TestCase_SymbologyPointsJPG);
CPPUNIT_TEST(TestCase_SymbologyPointsParamJPG);
CPPUNIT_TEST(TestCase_SymbologyLinesJPG);
@@ -122,6 +130,8 @@
void TestCase_Annotation2(CREFSTRING imageFormat, CREFSTRING extension);
void TestCase_Annotation3(CREFSTRING imageFormat, CREFSTRING extension);
+ void TestCase_StylizationFunctions(CREFSTRING imageFormat, CREFSTRING extension);
+
//PNG output tests
void TestCase_RenderDynamicOverlayPNG() { TestCase_RenderDynamicOverlay(L"PNG", L"png"); }
void TestCase_RenderDynamicOverlayTiledMapPNG() { TestCase_RenderDynamicOverlayTiledMap(L"PNG", L"png"); }
@@ -136,6 +146,7 @@
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"); }
+ void TestCase_StylizationFunctionsPNG() { TestCase_StylizationFunctions(L"PNG", L"png"); }
//PNG8 output tests
void TestCase_RenderDynamicOverlayPNG8() { TestCase_RenderDynamicOverlay(L"PNG8", L"png"); }
@@ -151,6 +162,7 @@
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"); }
+ void TestCase_StylizationFunctionsPNG8() { TestCase_StylizationFunctions(L"PNG8", L"png"); }
//GIF output tests
void TestCase_RenderDynamicOverlayGIF() { TestCase_RenderDynamicOverlay(L"GIF", L"gif"); }
@@ -166,6 +178,7 @@
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"); }
+ void TestCase_StylizationFunctionsGIF() { TestCase_StylizationFunctions(L"GIF", L"gif"); }
//JPG output tests
void TestCase_RenderDynamicOverlayJPG() { TestCase_RenderDynamicOverlay(L"JPG", L"jpg"); }
@@ -181,6 +194,7 @@
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_StylizationFunctionsJPG() { TestCase_StylizationFunctions(L"JPG", L"jpg"); }
void TestCase_QueryFeatures();
@@ -189,6 +203,7 @@
private:
MgdMap* CreateTestMap();
MgdMap* CreateTestTiledMap();
+ MgdMap* CreateTestStylizationFunctionMap();
MgdMap* CreateTestMapWithWatermark();
MgPolygon* CreateSelectionPolygon(MgdMap* map, double width, double height);
static STRING GetPath(CREFSTRING basePath, CREFSTRING imageFormat, CREFSTRING extension);
More information about the mapguide-commits
mailing list