def _check_valid_data(self): if self.ValidData is None: return True if len(self.ValidData) < 2: return True value = True valid_data = self.ValidData.get_array(dtype='float64') lin_ring = LinearRing(coordinates=valid_data) area = lin_ring.get_area() if area == 0: self.log_validity_error('ValidData encloses no area.') value = False elif area > 0: self.log_validity_error( "ValidData must be traversed in clockwise direction.") value = False for i, entry in enumerate(valid_data): if not ( (self.FirstRow <= entry[0] <= self.FirstRow + self.NumRows) and (self.FirstCol <= entry[1] <= self.FirstCol + self.NumCols)): self.log_validity_warning( 'ValidData entry {} is not contained in the image bounds'. format(i)) value = False return value
def _check_valid_data(self): if self.ValidData is None: return True if len(self.ValidData) < 2: return True if self.ValidData[0].Row > self.ValidData[1].Row or \ (self.ValidData[0].Row == self.ValidData[1].Row and self.ValidData[0].Col >= self.ValidData[1].Col): logging.error( "ValidData must have first vertex with minimum row/column. " "Got first two vertices {} and {}".format( self.ValidData[0], self.ValidData[1])) return False # check the details for valid data lin_ring = LinearRing(coordinates=self.ValidData.get_array( dtype=numpy.dtype('float64'))) area = lin_ring.get_area() if area == 0: logging.error('ValidData enclosed no area.') return False elif area > 0: logging.error( "ValidData must be traversed in clockwise direction.") return False return True
def _check_valid_data(self): cond = True for attribute in ['ImageCorners', 'ValidData']: value = getattr(self, attribute) if value is not None: lin_ring = LinearRing(coordinates=value.get_array( dtype='float64')) area = lin_ring.get_area() if area == 0: logging.error('{} encloses no area.'.format(attribute)) cond = False elif area < 0: logging.error( "{} must be traversed in clockwise direction.".format( attribute)) cond = False return cond
def from_dict(cls, input_dict): typ = input_dict.get('type', None) if typ is None: return cls() elif typ == 'Point': return cls(Point=PointType.from_dict(input_dict)) elif typ == 'LineString': return cls(Line=LineStringType.from_dict(input_dict)) elif typ == 'LinearRing': return cls(LinearRing=LinearRingType.from_dict(input_dict)) elif typ == 'Polygon': return cls(Polygon=PolygonType.from_dict(input_dict)) elif typ == 'MultiPoint': return cls(MultiPoint=MultiPointType.from_dict(input_dict)) elif typ == 'MultiLineString': return cls(MultiLineString=MultiLineStringType.from_dict(input_dict)) elif typ == 'MultiPolygon': return cls(MultiPolygon=MultiPolygonType.from_dict(input_dict)) else: logging.error('AnnotationObjectType got unsupported input dictionary {}. ' 'Returning None.'.format(input_dict)) return None