- Timestamp:
- 16/08/06 13:41:34 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/Scanner/csmllibs/csmlfeaturetypes.py
r1405 r1407 278 278 279 279 280 def createCSMLPointSeriesFeatures(self): 281 representativeFiles=self.ffmap.getRepresentativeFiles() 282 listOfFiles=[] 283 for repfile in representativeFiles: 284 repfilename=repfile.getRepresentativeFileName() 285 listOfFiles.append(repfilename) 286 relfiles = repfile.getRelatedFiles() 287 for f in relfiles: 288 #hopefully there are no related files at the moment! 289 fname = f.getRelatedFileName() 290 listOfFiles.append(fname) 291 file=repfilename 292 DI = csmllibs.csmldataiface.DataInterface() 293 DI=DI.getUnknownInterfaceType(file) 294 DI.openFile(file) 295 allVarNames=DI.getListofVariables() 296 numFeatures=len(allVarNames) 297 try: 298 DI.setAxis(self.timedim) 299 times=DI.getDataForAxis() 300 except: 301 times = DI.getTimes() 302 #times = ['time axis not determined'] 303 304 print "numFeatures" + str(numFeatures) 305 for i in range (0, numFeatures): 306 PointSeriesFeature_element=csmllibs.Parser.PointSeriesFeature() 307 if str(allVarNames[i]).upper() in ['ERROR FLAG', 'ERROR']: #might need to extend this list 308 break 309 PointSeriesFeature_element.id=str(allVarNames[i]) 310 try: 311 desc=DI.getVariableAttribute('long_name') 312 # print desc 313 except AttributeError: 314 desc = "missing name" 315 PointSeriesFeature_element.description=csmllibs.Parser.Description(desc) 316 317 #*********************************************************************** 318 #PointSeriesDomain: 319 #*********************************************************************** 320 psDomain=csmllibs.Parser.PointSeriesDomain() 321 322 print len(times) 323 print len(listOfFiles) 324 print len(times) * len(listOfFiles) 325 #*********************************************************************** 326 # domainReference element 327 #*********************************************************************** 328 t=csmllibs.Parser.Trajectory() 329 t.srsName='urn:EPSG:geographicCRS:4326' #TO Do 330 t.locations =csmllibs.Parser.DirectPositionList(vals='1 1') 331 if len(times) > 200: 332 pass 280 def createCSMLPointSeriesFeatures(self): 281 representativeFiles=self.ffmap.getRepresentativeFiles() 282 for repfile in representativeFiles: 283 self.repfilename,self.listOfFiles=self._populateListOfFiles(repfile) 284 DI = csmllibs.csmldataiface.DataInterface() 285 DI=DI.getUnknownInterfaceType(self.repfilename) 286 DI.openFile(self.repfilename) 287 allVarNames=DI.getListofVariables() 288 numFeatures=len(allVarNames) 289 try: 290 DI.setAxis(self.timedim) 291 times=DI.getDataForAxis() 292 except: 293 times = DI.getTimes() 294 #Create features: 295 for i in range (0, numFeatures): 296 PointSeriesFeature_element=csmllibs.Parser.PointSeriesFeature() 297 if str(allVarNames[i]).upper() in ['ERROR FLAG', 'ERROR']: #might need to extend this list 298 break 299 PointSeriesFeature_element.id=str(allVarNames[i]) 300 desc=self._getDescriptiveName(DI) 301 PointSeriesFeature_element.description=csmllibs.Parser.Description(desc) 302 #DOMAIN 303 psDomain=csmllibs.Parser.PointSeriesDomain() 304 t=csmllibs.Parser.Trajectory() 305 t.srsName='urn:EPSG:geographicCRS:4326' #TO Do 306 t.locations =csmllibs.Parser.DirectPositionList(vals='1 1') 307 if len(times) > 200: 308 pass 333 309 #create a file extract link for long lists 334 filenames=csmllibs.csmlextra.cleanString(str(listOfFiles))310 filenames=csmllibs.csmlextra.cleanString(str(self.listOfFiles)) 335 311 # print 'times: ' + str(allVarNames[i]) 336 312 # print len(times) … … 340 316 # tplist = csmllibs.Parser.TimePositionList(timePositions=fextract) 341 317 # t.times=tplist 342 318 else: 343 319 #encode short lists inline: 344 320 t.times=csmllibs.Parser.TimePositionList('#RefSysX',str(times)) 345 321 346 psDomain.domainReference=t 347 348 #*********************************************************************** 349 # gml:rangeSet_element 350 #*********************************************************************** 351 DI.setVariable(allVarNames[i]) 352 try: 353 strUom = DI.getVariableAttribute('units') 354 except AttributeError: 355 #if units attribute doesn't exist: 356 strUom ="dimensionless or units not determined" 357 358 try: 359 measuredvalues = DI.getDataForVar() 360 except: 361 measuredvalues = ' could not get values ' 362 363 rs=csmllibs.Parser.RangeSet() 364 if len(measuredvalues) > 200: 365 #create a file extract link for long lists 366 arraySize=len(measuredvalues)*len(listOfFiles) 367 #TODO this needs to be able to handle inline, use VALUESTORAGE to determine which to use: 368 fextract=csmllibs.csmlfileextracts.createSingleExtract(self.extractType,filenames,allVarNames[i],arraySize) 369 qlist = csmllibs.Parser.MeasureOrNullList(val=fextract) 370 rs.quantityList=qlist 371 else: 372 #encode short lists inline 373 rs.quantityList=csmllibs.Parser.MeasureOrNullList(uom=strUom, val=str(measuredvalues)[1:-1]) 374 375 PointSeriesFeature_element.rangeSet=rs 376 #*********************************************************************** 377 # gml:coverageFunction element (and sub-element MappingRule) 378 #*********************************************************************** 379 380 #need to do parameter element 381 382 383 PointSeriesFeature_element.domain=psDomain 384 self.fms.append(PointSeriesFeature_element) 385 DI.closeFile() 386 387 322 psDomain.domainReference=t 323 #RANGESET 324 DI.setVariable(allVarNames[i]) 325 try: 326 strUom = DI.getVariableAttribute('units') 327 except AttributeError: 328 #if units attribute doesn't exist: 329 strUom ="dimensionless or units not determined" 330 try: 331 measuredvalues = DI.getDataForVar() 332 except: 333 measuredvalues = ' could not get values ' 334 rs=csmllibs.Parser.RangeSet() 335 if len(measuredvalues) > 200: 336 #create a file extract link for long lists 337 arraySize=len(measuredvalues)*len(self.listOfFiles) 338 #TODO this needs to be able to handle inline, use VALUESTORAGE to determine which to use: 339 self.extractType=DI.extractType 340 fextract=csmllibs.csmlfileextracts.createSingleExtract(self.extractType,filenames,allVarNames[i],arraySize) 341 qlist = csmllibs.Parser.MeasureOrNullList(val=fextract) 342 rs.quantityList=qlist 343 else: 344 #encode short lists inline 345 rs.quantityList=csmllibs.Parser.MeasureOrNullList(uom=strUom, val=str(measuredvalues)[1:-1]) 346 PointSeriesFeature_element.rangeSet=rs 347 #COVERAGEFUNCTION 348 #PARAMETER 349 #need to do parameter and coverageFunction elements 350 PointSeriesFeature_element.domain=psDomain 351 self.fms.append(PointSeriesFeature_element) 352 DI.closeFile() 388 353
Note: See TracChangeset
for help on using the changeset viewer.