File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed
libsrc/spatialdata/geocoords Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 1+ ## Main branch
2+
3+ * ** Fixed**
4+ * Detect Proj string coordinate system type when computing surface normal. Default to (0, 0, 1) if coordinate system type is not recognized.
5+ * Add missing include directive for cstddef to CoordSys.hh.
6+
17## Version 3.1.0 (2023/12/13)
28
39* Add ` AnalyticDB ` for a spatial database composed of analytic functions.
Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ spatialdata::geocoords::CSGeo::computeSurfaceNormal(double* dir,
121121 case PJ_TYPE_GEOGRAPHIC_3D_CRS:
122122 case PJ_TYPE_GEODETIC_CRS:
123123 case PJ_TYPE_PROJECTED_CRS:
124+ case PJ_TYPE_OTHER_COORDINATE_OPERATION:
124125 for (size_t i = 0 ; i < numLocs; ++i) {
125126 dir[i*numDims+0 ] = +0.0 ;
126127 dir[i*numDims+1 ] = +0.0 ;
@@ -146,9 +147,14 @@ spatialdata::geocoords::CSGeo::computeSurfaceNormal(double* dir,
146147 break ;
147148 } // PJ_TYPE_GEOCENTRIC_CRS
148149 default : {
149- std::ostringstream msg;
150- msg << " Unknown coordinate system type (" << projType << " ) for coordinate system '" << _string << " '." ;
151- throw std::logic_error (msg.str ());
150+ std::cout << " Internal error: Coordinate system type (" << projType
151+ << " ) not recognized for coordinate system '" << _string << " ' "
152+ << " when computing normal of ground surface. Using default value of (0, 0, +1)." ;
153+ for (size_t i = 0 ; i < numLocs; ++i) {
154+ dir[i*numDims+0 ] = +0.0 ;
155+ dir[i*numDims+1 ] = +0.0 ;
156+ dir[i*numDims+2 ] = +1.0 ;
157+ } // for
152158 } // default
153159
154160 } // switch
Original file line number Diff line number Diff line change @@ -152,6 +152,28 @@ spatialdata::geocoords::TestCSGeo::testComputeSurfaceNormal(void) {
152152 delete[] dirs;dirs = 0 ;
153153 } // UTM zone 10
154154
155+ { // Transverse mercator projection
156+ cs.setString (" +proj=tmerc +datum=WGS84 +lon_0=-100.0 +lat_0=+40.0 +k=0.9996 +units=km" );
157+ const size_t numLocs = 4 ;
158+ const size_t numDims = 3 ;
159+ const size_t size = numLocs * numDims;
160+ const double coords[size] = {
161+ 57.0 , 41.0 , -1.0 ,
162+ 40.0 , 40.0 , 2.0 ,
163+ 30.0 , 42.0 , 3.0 ,
164+ 55.0 , 41.0 , 4.0 ,
165+ };
166+ double * dirs = new double [size];
167+ cs.setSpaceDim (numDims);
168+ cs.computeSurfaceNormal (dirs, coords, numLocs, numDims);
169+ for (size_t iLoc = 0 , i = 0 ; iLoc < numLocs; ++iLoc) {
170+ CHECK (0.0 == dirs[i++]);
171+ CHECK (0.0 == dirs[i++]);
172+ CHECK (1.0 == dirs[i++]);
173+ } // for
174+ delete[] dirs;dirs = 0 ;
175+ } // Transverse mercator projection
176+
155177 { // Geocentric ECEF
156178 cs.setString (" EPSG:4978" );
157179
You can’t perform that action at this time.
0 commit comments