Changeset 649
- Timestamp:
- 22/02/06 16:48:40 (15 years ago)
- Location:
- TI02-CSML/trunk/newparser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/newparser/Parser.py
r632 r649 76 76 for elem in csmlFrag.getiterator(): 77 77 print str(elem.attrib) 78 #print 'hello'79 78 return csmlFrag 80 79 … … 489 488 return csmlFrag 490 489 490 class AbstractDiscreteCoverage(AbstractGML): 491 #note, does not inherit directly from AbstractGML but is sufficient for CSML purposes 492 #GML AbstractDiscreteCoverage 493 def __init__(self): 494 pass 495 def fromXML(self,csmlFrag): 496 AbstractGML.fromXML(self,csmlFrag) 497 def toXML(self,csmlFrag): 498 return csmlFrag 499 500 class AbstractCoverageFeature(AbstractDiscreteCoverage): 501 #CSML Abstract Coverage FT class 502 # AbstractCoverageFeature(): 503 # +gml:boundedBy[0..*]: AbstractFeature 504 # +csml:_Domain 505 # + gml:rangeSet 506 # + gml:coverageFunction[0..*] 507 # + parameter:om:PhenomenonPropertyType 508 def __init__(self,boundedBy=None,_Domain=None,rangeSet=None, coverageFunction=None, parameter=None, *args,**kwargs): 509 AbstractFileExtract.__init__(self,*args,**kwargs) 510 if boundedBy: 511 self.boundedBy=boundedBy 512 if _Domain: 513 self._Domain=_Domain 514 if rangeSet: 515 self.rangeSet=rangeSet 516 if coverageFunction: 517 self.coverageFunction=coverageFunction 518 if parameter: 519 self.parameter=parameter 520 def fromXML(self,csmlFrag): 521 AbstractDiscreteCoverage.fromXML(self,csmlFrag) 522 for frag in csmlFrag.getchildren(): 523 if frag.tag == GML('boundedBy'): 524 #hmmm check this one is right. 525 checkArrayAttrib(self,'boundedBy') 526 self.boundedBy.append(frag.text) 527 if frag.tag == CSML('_Domain'): 528 self.PointDomain = PointDomain() 529 self.PointDomain.fromXML(frag) 530 def toXML(self,csmlFrag): 531 return csmlFrag 532 533 534 535 536 class AbstractStaticCoverageFeature(AbstractCoverageFeature): 537 #CSML Abstract Static Coverage FT class 538 def __init__(self): 539 pass 540 def fromXML(self,csmlFrag): 541 AbstractCoverageFeature.fromXML(self,csmlFrag) 542 def toXML(self,csmlFrag): 543 AbstractCoverageFeature.toXML(self,csmlFrag) 544 return csmlFrag 545 546 class PointDomain: 547 def __init__(self): 548 pass 549 def fromXML(self,csmlFrag): 550 pass 551 def toXML(self,csmlFrag): 552 return csmlFrag 553 554 class rangeSet: 555 556 class PointFeature(AbstractStaticCoverageFeature): 557 #CSML PointFeature class 558 # PointFeature(AbstractStaticCoverageFeatureType): 559 # +PointDomain 560 # +gml:rangeSet 561 # +gml:coverageFunction[0..*] 562 # +parameter:om:PhenomenonPropertyType 563 def __init__(self,PointDomain=None,rangeSet=None,coverageFunction=None, parameter=None): 564 if PointDomain: 565 self.PointDomain=PointDomain 566 if rangeSet: 567 self.rangeSet=rangeSet 568 if coverageFunction: 569 self.coverageFunction=coverageFunction 570 if parameter: 571 self.parameter=parameter 572 def fromXML(self,csmlFrag): 573 AbstractStaticCoverageFeature.fromXML(self,csmlFrag) 574 for frag in csmlFrag.getchildren(): 575 print frag 576 if frag.tag == CSML('PointDomain'): 577 self.PointDomain = PointDomain() 578 self.PointDomain.fromXML(frag) 579 if frag.tag == GML('rangeSet'): 580 self.rangeSet=rangeSet() 581 self.rangeSet.fromXML(frag) 582 if frag.tag == GML('coverageFunction'): 583 checkArrayAttrib(self,'coverageFunction') 584 self.coverageFunction.append(frag.text) 585 ## else: 586 ## raise Exception('Unexpected element: "'+frag.tag+'"') 587 def toXML(self,csmlFrag): 588 csmlFrag = AbstractStaticCoverageFeature.toXML(self,csmlFrag) 589 frag = Element(CSML('PointDomain')) 590 frag.text = self.PointDomain 591 csmlFrag.append(frag) 592 return csmlFrag 593 594 class ProfileFeature: 595 def __init__(self): 596 pass 597 def fromXML(self,csmlFrag): 598 pass 599 def toXML(self,csmlFrag): 600 return csmlFrag 601 class GridFeature: 602 def __init__(self): 603 pass 604 def fromXML(self,csmlFrag): 605 pass 606 def toXML(self,csmlFrag): 607 return csmlFrag 608 class PointSeriesFeature: 609 def __init__(self): 610 pass 611 def fromXML(self,csmlFrag): 612 pass 613 def toXML(self,csmlFrag): 614 return csmlFrag 615 class ProfileSeriesFeature: 616 def __init__(self): 617 pass 618 def fromXML(self,csmlFrag): 619 pass 620 def toXML(self,csmlFrag): 621 return csmlFrag 622 class GridSeriesFeature: 623 def __init__(self): 624 pass 625 def fromXML(self,csmlFrag): 626 pass 627 def toXML(self,csmlFrag): 628 return csmlFrag 629 class TrajectoryFeature: 630 def __init__(self): 631 pass 632 def fromXML(self,csmlFrag): 633 pass 634 def toXML(self,csmlFrag): 635 return csmlFrag 636 491 637 class AbstractFeature(AbstractGML): 492 638 def __init__(self): … … 496 642 def toXML(self,csmlFrag): 497 643 return csmlFrag 644 498 645 499 646 class AbstractFeatureCollection(AbstractFeature): … … 515 662 if featureFrag.tag == CSML('PointFeature'): 516 663 self.members.append(PointFeature()) 517 self.members[-1].fromXML(f rag)664 self.members[-1].fromXML(featureFrag) 518 665 if featureFrag.tag == CSML('ProfileFeature'): 519 666 self.members.append(ProfileFeature()) 520 self.members[-1].fromXML(f rag)667 self.members[-1].fromXML(featureFrag) 521 668 if featureFrag.tag == CSML('GridFeature'): 522 669 self.members.append(GridFeature()) 523 self.members[-1].fromXML(f rag)670 self.members[-1].fromXML(featureFrag) 524 671 if featureFrag.tag == CSML('PointSeriesFeature'): 525 672 self.members.append(PointSeriesFeature()) 526 self.members[-1].fromXML(f rag)673 self.members[-1].fromXML(featureFrag) 527 674 if featureFrag.tag == CSML('ProfileSeriesFeature'): 528 675 self.members.append(ProfileSeriesFeature()) 529 self.members[-1].fromXML(f rag)676 self.members[-1].fromXML(featureFrag) 530 677 if featureFrag.tag == CSML('GridSeriesFeature'): 531 678 self.members.append(GridSeriesFeature()) 532 self.members[-1].fromXML(f rag)679 self.members[-1].fromXML(featureFrag) 533 680 if featureFrag.tag == CSML('TrajectoryFeature'): 534 681 self.members.append(TrajectoryFeature()) 535 self.members[-1].fromXML(frag) 536 def toXML(self,csmlFrag): 682 self.members[-1].fromXML(featureFrag) 683 def toXML(self,csmlFrag): 684 AbstractFeature.toXML(self,csmlFrag) 685 #add stuff here.. 686 for member in self.members: 687 if isinstance(member,PointFeature): 688 frag = Element(CSML('PointFeature')) 689 frag = PointFeature.toXML(member,frag) 690 691 537 692 return csmlFrag 538 693 … … 543 698 pass 544 699 def fromXML(self,csmlFrag): 545 pass 546 def toXML(self,csmlFrag): 700 AbstractFeatureCollection.fromXML(self,csmlFrag) 701 def toXML(self,csmlFrag): 702 AbstractFeatureCollection.toXML(self,csmlFrag) 547 703 return csmlFrag 548 704 -
TI02-CSML/trunk/newparser/test.py
r632 r649 98 98 setattr(ds, 'metaDataProperty', [md]) 99 99 setattr(ds, 'arrayDescriptors', nalist+nclist) 100 #setattr(ds, 'NASAAmesExtract', nalist)101 #setattr(ds, 'NetCDFExtract', nclist)102 100 103 101 104 #csml = ds.toXML(Element('Dataset'))105 102 csml = ds.toXML() 106 103 print parseString(tostring(csml)).toprettyxml()
Note: See TracChangeset
for help on using the changeset viewer.