コード例 #1
0
 def pointSearchArea(self, center, kilometers):
     ring = Ring()
     ring.add(URIRef(PROPERTY.LAT), center.getLatitude())
     ring.add(URIRef(PROPERTY.LONG), center.getLongitude())
     maxR = ValueObject()
     maxR.setQuantity(RESOURCE.LENGTH)
     maxR.setUnit(RESOURCE.KILOMETER)
     maxR.setValue(Variant(kilometers))
     ring.setMaxRadius(maxR)
     self.entity.add(URIRef(NS.SMARTAPI + "ring"), ring)
コード例 #2
0
    def createValueObject(self,
                          name=None,
                          unit=None,
                          quantity=None,
                          description=None,
                          datatype=None):
        from SmartAPI.model.ValueObject import ValueObject
        from SmartAPI.rdf.Variant import Variant

        vo = None
        try:
            vo = ValueObject()
            if name is not None: vo.setName(name)
            if quantity is not None: vo.setQuantity(quantity)
            if unit is not None: vo.setUnit(unit)
            if description is not None: vo.setDescription(description)
            if datatype is not None: vo.setValue(Variant(datatype))
        except:
            print "Exception while creating a ValueObject"
            print sys.exc_info()[1]
            vo = None
        return vo