@@ -24,6 +24,13 @@ def CheckExtentsValid(rootGroup, xyzGridSize, verbose=False):
2424
2525 """
2626 valid = True
27+ if ("epsg" in rootGroup .ncattrs ()):
28+ if verbose :
29+ print (" " , rootGroup .epsg )
30+ else :
31+ print ("(INVALID) No epsg format in project file" )
32+ valid = False
33+
2734 # Check Projection Model
2835 if "workingFormat" in rootGroup .ncattrs ():
2936 if verbose :
@@ -127,10 +134,13 @@ def GetExtents(rootGroup):
127134 Returns
128135 -------
129136 dict {"errorFlag", "errorString"/"value"}
130- value is a dict{"geodesic":[double, double, double, double],
131- "utm":[int, int, double, double, double, double], "depth":[double, double],
132- "spacing":[double, double, double]} containing the extents of this
133- project file
137+ value is a dict{
138+ "geodesic":[double, double, double, double],
139+ "utm":[int, int, double, double, double, double],
140+ "depth":[double, double],
141+ "spacing":[double, double, double],
142+ "epsg":str
143+ } containing the extents of this project file
134144
135145 """
136146 response = {"errorFlag" : False }
@@ -150,6 +160,7 @@ def GetExtents(rootGroup):
150160 errStr = "(ERROR) No or incomplete geodesic boundary in loop project file"
151161 print (errStr )
152162 response = {"errorFlag" : True , "errorString" : errStr }
163+
153164 if (
154165 "utmZone" in rootGroup .ncattrs ()
155166 and "utmNorthSouth" in rootGroup .ncattrs ()
@@ -170,12 +181,14 @@ def GetExtents(rootGroup):
170181 errStr = "(ERROR) No or incomplete UTM boundary in loop project file"
171182 print (errStr )
172183 response = {"errorFlag" : True , "errorString" : errStr }
184+
173185 if "topDepth" in rootGroup .ncattrs () and "bottomDepth" in rootGroup .ncattrs ():
174186 depth = [rootGroup .bottomDepth , rootGroup .topDepth ]
175187 else :
176188 errStr = "(ERROR) No or incomplete depth boundary in loop project file"
177189 print (errStr )
178190 response = {"errorFlag" : True , "errorString" : errStr }
191+
179192 if (
180193 "spacingX" in rootGroup .ncattrs ()
181194 and "spacingY" in rootGroup .ncattrs ()
@@ -186,18 +199,27 @@ def GetExtents(rootGroup):
186199 errStr = "(ERROR) No or incomplete spacing data in loop project file"
187200 print (errStr )
188201 response = {"errorFlag" : True , "errorString" : errStr }
202+
203+ if ("epsg" in rootGroup .ncattrs ()):
204+ epsg = rootGroup .epsg
205+ else :
206+ errStr = "(ERROR) No or incomplete epsg data in loop project file"
207+ print (errStr )
208+ response = {"errorFlag" : True , "errorString" : errStr }
209+
189210 if response ["errorFlag" ] is False :
190211 response ["value" ] = {
191212 "geodesic" : geodesic ,
192213 "utm" : utm ,
193214 "depth" : depth ,
194215 "spacing" : spacing ,
216+ "epsg" : epsg
195217 }
196218 return response
197219
198220
199221# Set extents of region of interest on root group
200- def SetExtents (rootGroup , geodesic , utm , depth , spacing , preference = "utm" ):
222+ def SetExtents (rootGroup , geodesic , utm , depth , spacing , epsg , preference = "utm" ):
201223 """
202224 **SetExtents** - Saves the extents of the region of interest as specified into
203225 the netCDF Loop Project File
@@ -220,6 +242,9 @@ def SetExtents(rootGroup, geodesic, utm, depth, spacing, preference="utm"):
220242 preference: string (optional)
221243 A string ("utm" or "geodesic") which specifies which format the Loop GUI
222244 region of interest should be displayed
245+ epsg: string
246+ A string of the EPSG projection used in the Loop Project in the
247+ format "EPSG:<value>"
223248
224249 Returns
225250 -------
@@ -273,6 +298,7 @@ def SetExtents(rootGroup, geodesic, utm, depth, spacing, preference="utm"):
273298 rootGroup .spacingY = spacing [1 ]
274299 rootGroup .spacingZ = spacing [2 ]
275300 rootGroup .workingFormat = 1 if preference == "utm" else 0
301+ rootGroup .epsg = epsg
276302
277303 # Do a quick sanity check and swap min and max values if wrong
278304 if rootGroup .minLatitude > rootGroup .maxLatitude :
0 commit comments