[mapguide-commits] r9228 - in sandbox/jng/geoprocessing: Common/Foundation/System Common/PlatformBase/Services Server/src/UnitTesting Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jun 28 06:50:07 PDT 2017
Author: jng
Date: 2017-06-28 06:50:07 -0700 (Wed, 28 Jun 2017)
New Revision: 9228
Modified:
sandbox/jng/geoprocessing/Common/Foundation/System/Util.cpp
sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.cpp
sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.h
sandbox/jng/geoprocessing/Server/src/UnitTesting/TestMisc.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h
sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.cpp
sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.h
Log:
- Make coordinate precision opt-in
- For mapagent operations, only opt-in to coordinate precision in MgGeoJsonWriter if PRECISION is actually specified.
- Re-implement MgUtil::DoubleToString using stringstream
Modified: sandbox/jng/geoprocessing/Common/Foundation/System/Util.cpp
===================================================================
--- sandbox/jng/geoprocessing/Common/Foundation/System/Util.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Common/Foundation/System/Util.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -1085,18 +1085,30 @@
void MgUtil::DoubleToString(double val, string& str, INT32 decimals)
{
- char buf[64] = { 0 };
-
- ::sprintf(buf, "%.*g", decimals + 1, val);
- str = &buf[0];
+ if (decimals <= 0) //Took a wrong turn?
+ {
+ DoubleToString(val, str);
+ }
+ else
+ {
+ std::stringstream ss;
+ ss << std::setprecision(decimals + 1) << val;
+ str = ss.str();
+ }
}
void MgUtil::DoubleToString(double val, STRING& str, INT32 decimals)
{
- wchar_t buf[64] = { 0 };
-
- ::swprintf(buf, 64, L"%.*g", decimals + 1, val);
- str = &buf[0];
+ if (decimals <= 0) //Took a wrong turn?
+ {
+ DoubleToString(val, str);
+ }
+ else
+ {
+ std::wstringstream ws;
+ ws << std::setprecision(decimals + 1) << val;
+ str = ws.str();
+ }
}
bool MgUtil::ValuesEqual(double value1, double value2, double tolerance, bool output)
Modified: sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.cpp
===================================================================
--- sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -6,6 +6,7 @@
MgGeoJsonWriter::MgGeoJsonWriter()
{
m_agfRw = new MgAgfReaderWriter();
+ m_precisionEnabled = false;
m_precision = 7;
}
@@ -390,9 +391,17 @@
{
str = L"[";
STRING sx;
- MgUtil::DoubleToString(coord->GetX(), sx, m_precision);
STRING sy;
- MgUtil::DoubleToString(coord->GetY(), sy, m_precision);
+ if (m_precisionEnabled)
+ {
+ MgUtil::DoubleToString(coord->GetX(), sx, m_precision);
+ MgUtil::DoubleToString(coord->GetY(), sy, m_precision);
+ }
+ else
+ {
+ MgUtil::DoubleToString(coord->GetX(), sx);
+ MgUtil::DoubleToString(coord->GetY(), sy);
+ }
str += sx;
str += L", ";
str += sy;
@@ -412,9 +421,17 @@
str += L"[";
STRING sx;
- MgUtil::DoubleToString(coord->GetX(), sx, m_precision);
STRING sy;
- MgUtil::DoubleToString(coord->GetY(), sy, m_precision);
+ if (m_precisionEnabled)
+ {
+ MgUtil::DoubleToString(coord->GetX(), sx, m_precision);
+ MgUtil::DoubleToString(coord->GetY(), sy, m_precision);
+ }
+ else
+ {
+ MgUtil::DoubleToString(coord->GetX(), sx);
+ MgUtil::DoubleToString(coord->GetY(), sy);
+ }
str += sx;
str += L", ";
str += sy;
@@ -535,4 +552,14 @@
void MgGeoJsonWriter::Dispose()
{
delete this;
+}
+
+void MgGeoJsonWriter::SetPrecisionEnabled(bool enabled)
+{
+ m_precisionEnabled = enabled;
+}
+
+bool MgGeoJsonWriter::IsPrecisionEnabled()
+{
+ return m_precisionEnabled;
}
\ No newline at end of file
Modified: sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.h
===================================================================
--- sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Common/PlatformBase/Services/GeoJsonWriter.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -110,7 +110,8 @@
//////////////////////////////////////////////////////////////////
/// \brief
- /// Sets the decimal precision to use when writing out coordinates. If you do not call this method, the default precision used is 7 decimal places
+ /// Sets the decimal precision to use when writing out coordinates. If you do not call this method, the default precision used is 7 decimal places.
+ /// Precision must be enabled in order for this setting to have any effect
///
/// <!-- Syntax in .Net, Java, and PHP -->
/// \htmlinclude DotNetSyntaxTop.html
@@ -126,8 +127,6 @@
/// \param precision (int)
/// The decimal precision to write out coordinates
///
- /// \return
- /// Returns the GeoJSON output as a string.
///
void SetPrecision(INT32 precision);
@@ -151,6 +150,49 @@
///
INT32 GetPrecision();
+ //////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Sets whether to apply coordinate precision when writing out GeoJSON coordinates
+ ///
+ /// <!-- Syntax in .Net, Java, and PHP -->
+ /// \htmlinclude DotNetSyntaxTop.html
+ /// void SetPrecisionEnabled(bool enabled);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude JavaSyntaxTop.html
+ /// void SetPrecisionEnabled(boolean enabled);
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude PHPSyntaxTop.html
+ /// void SetPrecisionEnabled(bool enabled);
+ /// \htmlinclude SyntaxBottom.html
+ ///
+ /// \param enabled (bool)
+ /// If true, enables coordinate precision. Otherwise disables it
+ ///
+ /// \return
+ /// Returns the GeoJSON output as a string.
+ ///
+ void SetPrecisionEnabled(bool enabled);
+
+ //////////////////////////////////////////////////////////////////
+ /// \brief
+ /// Gets whether coordinate precision is enabled
+ ///
+ /// <!-- Syntax in .Net, Java, and PHP -->
+ /// \htmlinclude DotNetSyntaxTop.html
+ /// bool IsPrecisionEnabled();
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude JavaSyntaxTop.html
+ /// boolean IsPrecisionEnabled();
+ /// \htmlinclude SyntaxBottom.html
+ /// \htmlinclude PHPSyntaxTop.html
+ /// bool IsPrecisionEnabled();
+ /// \htmlinclude SyntaxBottom.html
+ ///
+ /// \return
+ /// True if coordinate precision is enabled. False otherwise
+ ///
+ bool IsPrecisionEnabled();
+
INTERNAL_API:
STRING GeometryToGeoJson(MgGeometry* geom);
@@ -170,6 +212,7 @@
Ptr<MgAgfReaderWriter> m_agfRw;
INT32 m_precision;
+ bool m_precisionEnabled;
};
/// \}
Modified: sandbox/jng/geoprocessing/Server/src/UnitTesting/TestMisc.cpp
===================================================================
--- sandbox/jng/geoprocessing/Server/src/UnitTesting/TestMisc.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Server/src/UnitTesting/TestMisc.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -669,6 +669,20 @@
CPPUNIT_ASSERT(L"1.23456789" == ws);
CPPUNIT_ASSERT("1.23456789" == s);
+ ws.clear();
+ s.clear();
+
+ std::string s1;
+ STRING ws1;
+ //This should be the equivalent to not even passing in precision at all
+ MgUtil::DoubleToString(d, ws, -1);
+ MgUtil::DoubleToString(d, s, -1);
+ MgUtil::DoubleToString(d, ws1);
+ MgUtil::DoubleToString(d, s1);
+
+ CPPUNIT_ASSERT(ws1 == ws);
+ CPPUNIT_ASSERT(s1 == s);
+
double d1 = 1.1;
ws.clear();
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -31,10 +31,18 @@
m_format = params->GetParameterValue(MgHttpResourceStrings::reqGeoFormat);
m_coordinateSystem = params->GetParameterValue(MgHttpResourceStrings::reqGeoCoordinateSystem);
m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
void MgHttpGeoBinaryOperation::Execute(MgHttpResponse & hResponse)
@@ -90,6 +98,7 @@
else if (m_format == L"GEOJSON")
{
MgGeoJsonWriter gw;
+ gw.SetPrecisionEnabled(m_bEnablePrecision);
gw.SetPrecision(m_precision);
STRING geoJson = gw.GeometryToGeoJson(result);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBinaryOperation.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -60,6 +60,7 @@
STRING m_coordinateSystem;
STRING m_transformTo;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif
\ No newline at end of file
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -28,10 +28,18 @@
m_format = params->GetParameterValue(MgHttpResourceStrings::reqGeoFormat);
m_coordinateSystem = params->GetParameterValue(MgHttpResourceStrings::reqGeoCoordinateSystem);
m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
void MgHttpGeoBoundary::Execute(MgHttpResponse & hResponse)
@@ -77,6 +85,7 @@
else if (m_format == L"GEOJSON")
{
MgGeoJsonWriter gw;
+ gw.SetPrecisionEnabled(m_bEnablePrecision);
gw.SetPrecision(m_precision);
STRING geoJson = gw.GeometryToGeoJson(result);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBoundary.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -59,6 +59,7 @@
STRING m_coordinateSystem;
STRING m_transformTo;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -31,10 +31,18 @@
m_format = params->GetParameterValue(MgHttpResourceStrings::reqGeoFormat);
m_coordinateSystem = params->GetParameterValue(MgHttpResourceStrings::reqGeoCoordinateSystem);
m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
void MgHttpGeoBuffer::Execute(MgHttpResponse & hResponse)
@@ -112,6 +120,7 @@
else if (m_format == L"GEOJSON")
{
MgGeoJsonWriter gw;
+ gw.SetPrecisionEnabled(m_bEnablePrecision);
gw.SetPrecision(m_precision);
STRING geoJson = gw.GeometryToGeoJson(result);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoBuffer.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -61,6 +61,7 @@
STRING m_coordinateSystem;
STRING m_transformTo;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif
\ No newline at end of file
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -28,10 +28,18 @@
m_format = params->GetParameterValue(MgHttpResourceStrings::reqGeoFormat);
m_coordinateSystem = params->GetParameterValue(MgHttpResourceStrings::reqGeoCoordinateSystem);
m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
void MgHttpGeoConvexHull::Execute(MgHttpResponse & hResponse)
@@ -77,6 +85,7 @@
else if (m_format == L"GEOJSON")
{
MgGeoJsonWriter gw;
+ gw.SetPrecisionEnabled(m_bEnablePrecision);
gw.SetPrecision(m_precision);
STRING geoJson = gw.GeometryToGeoJson(result);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoConvexHull.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -59,6 +59,7 @@
STRING m_coordinateSystem;
STRING m_transformTo;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -30,10 +30,18 @@
m_format = params->GetParameterValue(MgHttpResourceStrings::reqGeoFormat);
m_coordinateSystem = params->GetParameterValue(MgHttpResourceStrings::reqGeoCoordinateSystem);
m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
void MgHttpGeoSimplify::Execute(MgHttpResponse & hResponse)
@@ -94,6 +102,7 @@
else if (m_format == L"GEOJSON")
{
MgGeoJsonWriter gw;
+ gw.SetPrecisionEnabled(m_bEnablePrecision);
gw.SetPrecision(m_precision);
STRING geoJson = gw.GeometryToGeoJson(result);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoSimplify.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -61,6 +61,7 @@
STRING m_coordinateSystem;
STRING m_transformTo;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif
\ No newline at end of file
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -28,10 +28,18 @@
m_format = params->GetParameterValue(MgHttpResourceStrings::reqGeoFormat);
m_coordinateSystem = params->GetParameterValue(MgHttpResourceStrings::reqGeoCoordinateSystem);
m_transformTo = params->GetParameterValue(MgHttpResourceStrings::reqGeoTransformTo);
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
void MgHttpGeoTessellate::Execute(MgHttpResponse & hResponse)
@@ -77,6 +85,7 @@
else if (m_format == L"GEOJSON")
{
MgGeoJsonWriter gw;
+ gw.SetPrecisionEnabled(m_bEnablePrecision);
gw.SetPrecision(m_precision);
STRING geoJson = gw.GeometryToGeoJson(result);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpGeoTessellate.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -59,6 +59,7 @@
STRING m_coordinateSystem;
STRING m_transformTo;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -43,10 +43,18 @@
if (m_responseFormat.empty())
m_responseFormat = MgMimeType::Xml;
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
/// <summary>
@@ -115,7 +123,7 @@
Ptr<MgFeatureReader> featureReader = service->SelectFeatures(&resId, m_className, qryOptions);
//MgByteSource owns this and will clean it up when done
- ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(featureReader, m_responseFormat, m_bCleanJson, m_precision);
+ ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(featureReader, m_responseFormat, m_bCleanJson, m_bEnablePrecision, m_precision);
Ptr<MgByteSource> byteSource = new MgByteSource(bsImpl);
byteSource->SetMimeType(m_responseFormat);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeatures.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -47,6 +47,7 @@
STRING m_resId;
STRING m_className;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif // _FS_SELECT_FEATURES_H
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -53,10 +53,18 @@
if (m_responseFormat.empty())
m_responseFormat = MgMimeType::Xml;
- m_precision = 7;
+ m_precision = -1;
+ m_bEnablePrecision = false;
STRING sPrecision = params->GetParameterValue(MgHttpResourceStrings::reqGeoPrecision);
if (!sPrecision.empty())
- m_precision = MgUtil::StringToInt32(sPrecision);
+ {
+ INT32 precision = MgUtil::StringToInt32(sPrecision);
+ if (precision > 0)
+ {
+ m_precision = precision;
+ m_bEnablePrecision = true;
+ }
+ }
}
/// <summary>
@@ -125,7 +133,7 @@
Ptr<MgDataReader> dataReader = service->SelectAggregate(&resId, m_className, qryOptions);
//MgByteSource owns this and will clean it up when done
- ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(dataReader, m_responseFormat, m_bCleanJson, m_precision);
+ ByteSourceImpl* bsImpl = new MgReaderByteSourceImpl(dataReader, m_responseFormat, m_bCleanJson, m_bEnablePrecision, m_precision);
Ptr<MgByteSource> byteSource = new MgByteSource(bsImpl);
byteSource->SetMimeType(m_responseFormat);
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/HttpSelectFeaturesSpatially.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -50,6 +50,7 @@
STRING m_geometryClass;
INT32 m_operation;
INT32 m_precision;
+ bool m_bEnablePrecision;
};
#endif // _FS_SELECT_FEATURES_SPATIALLY_H
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.cpp
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.cpp 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.cpp 2017-06-28 13:50:07 UTC (rev 9228)
@@ -17,7 +17,7 @@
#include "ReaderByteSourceImpl.h"
#include "PlatformBase.h"
-MgReaderByteSourceImpl::MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, INT32 precision)
+MgReaderByteSourceImpl::MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, bool bEnablePrecision, INT32 precision)
{
m_reader = SAFE_ADDREF(reader);
m_format = format;
@@ -27,6 +27,7 @@
m_bInternalReaderHasMore = true;
m_bFirstRecord = true;
m_bCleanJson = bCleanJson;
+ m_bEnablePrecision = bEnablePrecision;
m_precision = precision;
}
@@ -168,6 +169,7 @@
if (m_bCleanJson)
{
MgGeoJsonWriter geoJsonWriter;
+ geoJsonWriter.SetPrecisionEnabled(m_bEnablePrecision);
geoJsonWriter.SetPrecision(m_precision);
STRING sGeoJson;
if (m_reader->GetReaderType() == MgReaderType::FeatureReader)
Modified: sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.h
===================================================================
--- sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.h 2017-06-25 14:31:05 UTC (rev 9227)
+++ sandbox/jng/geoprocessing/Web/src/HttpHandler/ReaderByteSourceImpl.h 2017-06-28 13:50:07 UTC (rev 9228)
@@ -29,7 +29,7 @@
DECLARE_CLASSNAME(MgReaderByteSourceImpl)
public:
- MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, INT32 precision);
+ MgReaderByteSourceImpl(MgReader* reader, CREFSTRING format, bool bCleanJson, bool bEnablePrecision, INT32 precision);
virtual ~MgReaderByteSourceImpl();
///////////////////////////////////////////////////////////////////////////
@@ -89,6 +89,7 @@
bool m_bReadHeader;
bool m_bInternalReaderHasMore;
bool m_bFirstRecord;
+ bool m_bEnablePrecision;
std::string m_buf;
INT32 m_bufOffset;
More information about the mapguide-commits
mailing list