Exemplo n.º 1
0
    def validate(self):

        results = super(CHaMP_Polygon, self).validate()

        validate_geomtype = ValidationResult(self.__class__.__name__, "GeometryType")

        if self.exists():
            if len(self.features) > 0:
                feat = self.features[0] # Only Checking one feature right now
                if feat["geometry"].geom_type in self.geomType:
                    validate_geomtype.pass_validation()
                else:
                    validate_geomtype.error("Geometry Type (" + str(self.geomType) + ") is not correct Type (" + \
                                                str(feat["geometry"].geom_type) + ")")
            else:
                validate_geomtype.status = "NotTested"
                validate_geomtype.message = "Geometry has no features"

        results.append(validate_geomtype.get_dict())

        return results
Exemplo n.º 2
0
 def validate(self):
     results = super(CHaMP_Vector_Point_3D, self).validate()
     validate_is3d = ValidationResult(self.__class__.__name__, "HasZ")
     if self.exists():
         try:
             if self.features is not None and len(self.features) > 0:
                 feat = self.features[0] # Only Checking one feature right now
                 if feat["geometry"].has_z == self.zValues:
                     validate_is3d.status = "Pass"
                 else:
                     validate_is3d.status = "Error"
                     validate_is3d.message = "Feature class is not 3D"
         except DataException, e:
             validate_is3d.status = "Error"
             validate_is3d.message = e.message
    def validate(self):

        results = super(CHaMP_StreamFeature_Points, self).validate()

        validate_codefield = ValidationResult(self.__class__.__name__, "CodeFieldExists")

        if self.exists():
            if self.get_shapely_feats():
                if self.field_exists(self.fieldName_Description):
                    validate_codefield.pass_validation()
                else:
                    validate_codefield.error("Required Field '" + self.fieldName_Description + "' does not exist.")

        results.append(validate_codefield.get_dict())

        return results
Exemplo n.º 4
0
 def validate(self):
     results = super(CHaMP_Vector_Point, self).validate()
     validate_geomtype = ValidationResult(self.__class__.__name__, "GeometryType")
     if self.exists():
         if self.features: # TODO improve check geom type (at least one feat must exist)
             feat = self.features[0] # Only Checking one feature right now
             if feat["geometry"].geom_type == self.geomType:
                 validate_geomtype.status = "Pass"
             else:
                 validate_geomtype.status = "Error"
                 validate_geomtype.message = "Geometry Type (" + str(self.geomType) + ") is not correct Type (" + \
                                             str(feat["geometry"].geom_type) + ")"
     results.append(validate_geomtype.get_dict())
     return results
Exemplo n.º 5
0
    def validate(self):

        results = super(CHaMP_Vector, self).validate()

        validate_minfeatcount = ValidationResult(self.__class__.__name__, "MinFeatureCount")

        if len(self.features) >= self.minFeatureCount:
            validate_minfeatcount.status = "Pass"
            self.pass_minfeatcount = True
        else:
            validate_minfeatcount.status = "Error"
            validate_minfeatcount.message = "The number of features found (" + str(len(self.features)) + \
                                            ") is less than the minimum required (" + str(self.minFeatureCount) + ")"
            self.pass_minfeatcount = False

        results.append(validate_minfeatcount.get_dict())

        return results
Exemplo n.º 6
0
    def validate(self):

        results = super(GIS_Dataset, self).validate()
        validate_sr_exists = ValidationResult(self.__class__.__name__,
                                              "SpatialReferenceExists")
        validate_sr_dem_match = ValidationResult(self.__class__.__name__,
                                                 "SpatialReferenceMatchesDEM")

        if self.exists():
            if self.spatial_reference_wkt:
                validate_sr_exists.pass_validation()
                if self.spatial_reference_dem_wkt:
                    if self.spatial_reference_wkt == self.spatial_reference_dem_wkt:
                        validate_sr_dem_match.pass_validation()
                    else:
                        validate_sr_dem_match.error(
                            "Spatial reference does not match spatial reference of DEM."
                        )
            else:
                validate_sr_exists.error(
                    "Spatial Reference for dataset cannot be found or does not exist."
                )

        results.append(validate_sr_exists.get_dict())
        results.append(validate_sr_dem_match.get_dict())

        return results
Exemplo n.º 7
0
    def validate(self):

        results = []
        validate_exists = ValidationResult(self.__class__.__name__,
                                           "Dataset_Exists")
        validate_filelength = ValidationResult(self.__class__.__name__,
                                               "Filename_Max_Length")

        if self.exists():
            validate_exists.pass_validation()
            if len(self.filename) < self.maxFilenameLength:
                validate_filelength.pass_validation()
            else:
                validate_filelength.error("Filename length " +
                                          str(len(self.filename)) +
                                          " exceeds max length of " +
                                          str(self.maxFilenameLength))
        else:
            if self.required:
                validate_exists.error("Required dataset {} not found.".format(
                    self.name))
            else:
                validate_exists.warning(
                    "Optional dataset {} not found.".format(self.name))

        results.append(validate_exists.get_dict())
        results.append(validate_filelength.get_dict())

        return results
Exemplo n.º 8
0
    def validate(self, raster=None):

        results = super(CHaMP_TopoPoints, self).validate()

        validate_codefield = ValidationResult(self.__class__.__name__,
                                              "CodeFieldExists")
        validate_codenotnull = ValidationResult(self.__class__.__name__,
                                                "CodeFieldNotNull")
        validate_bfcount = ValidationResult(self.__class__.__name__, "bfCount")
        validate_tbcount = ValidationResult(self.__class__.__name__, "tbCount")
        validate_incount = ValidationResult(self.__class__.__name__, "inCount")
        validate_outcount = ValidationResult(self.__class__.__name__,
                                             "outCount")
        validate_pointsondem = ValidationResult(self.__class__.__name__,
                                                "PointsOnDEM")
        validate_tbondem = ValidationResult(self.__class__.__name__,
                                            "tbPointsOnDEM")
        validate_bfondem = ValidationResult(self.__class__.__name__,
                                            "bfPointsOnDEM")
        validate_inoutpointsDEM = ValidationResult(
            self.__class__.__name__, "InOutPointsOnDEMwithPosElev")
        validate_inhigherthatnoutpointsDEM = ValidationResult(
            self.__class__.__name__, "InHigherThanOutPointDEM")

        if self.exists():
            if self.field_exists(self.fieldName_Description):
                validate_codefield.pass_validation()
                if self.field_values_notnull(self.fieldName_Description):
                    validate_codenotnull.pass_validation()
                    codes = self.list_attributes(self.fieldName_Description)
                    if codes.count("bf") < self.code_count_bf_error:
                        validate_bfcount.error(
                            "Number of 'bf' points (" +
                            str(codes.count("bf")) +
                            ") are less than the required amount (" +
                            str(self.code_count_bf_error) + ").")
                    elif codes.count("bf") < self.code_count_bf_warning:
                        validate_bfcount.warning(
                            "Number of 'bf' points (" +
                            str(codes.count("bf")) +
                            ") are less than the recommended amount (" +
                            str(self.code_count_bf_warning) + ").")
                    else:
                        validate_bfcount.pass_validation()
                    if codes.count("tb") < self.code_count_tb_error:
                        validate_tbcount.warning(
                            "Number of 'tb' points (" +
                            str(codes.count("tb")) +
                            ") are less than the recommended amount (" +
                            str(self.code_count_tb_error) + ").")
                    else:
                        validate_tbcount.pass_validation()
                    if codes.count("in") != 1:
                        validate_incount.error(
                            "Number of 'in' points (" +
                            str(codes.count("in")) +
                            ") are not the required amount of 1 point")
                    else:
                        validate_incount.pass_validation()
                    if codes.count("out") != 1:
                        validate_outcount.error(
                            "Number of 'out' points (" +
                            str(codes.count("out")) +
                            ") are not the required amount of 1 point")
                    else:
                        validate_outcount.pass_validation()
                    if codes.count('in') == 1 and codes.count(
                            'out') == 1 and self.dem and self.demDataExtent:
                        in_out_z = self.get_z_on_dem(
                            ["in"]) + self.get_z_on_dem(["out"])
                        if self.features_on_raster(["in", "out"]):
                            if all(i >= 0 for i in in_out_z):
                                validate_inoutpointsDEM.pass_validation()
                            else:
                                validate_inoutpointsDEM.error(
                                    "Negative DEM elevations for in/out points found, which are not allowed"
                                )
                        else:
                            validate_inoutpointsDEM.error(
                                "in/out points not within DEM Data Extent.")
                        if in_out_z[0] > in_out_z[1]:
                            validate_inhigherthatnoutpointsDEM.pass_validation(
                            )
                        else:
                            validate_inhigherthatnoutpointsDEM.warning(
                                "Elevation of 'in' point (" +
                                str(in_out_z[0]) +
                                "is lower than elevation of 'out' point (" +
                                str(in_out_z[1]) + ").")
                else:
                    validate_codenotnull.error("Null values found in field '" +
                                               self.fieldName_Description +
                                               "' are not allowed.")
            else:
                validate_codefield.error("Required Field '" +
                                         self.fieldName_Description +
                                         "' does not exist.")

            if self.demDataExtent:
                if self.features_on_raster():
                    validate_pointsondem.pass_validation()
                else:
                    validate_pointsondem.warning(
                        "One or more points are not within DEM data extent.")
                if self.features_on_raster(['tb']):
                    validate_tbondem.pass_validation()
                else:
                    validate_tbondem.warning(
                        "One or more tb points are not within DEM data extent."
                    )
                if self.features_on_raster(['bf']):
                    validate_bfondem.pass_validation()
                else:
                    validate_bfondem.warning(
                        "One or more bf points are not within DEM data extent."
                    )

        results.append(validate_codefield.get_dict())
        results.append(validate_codenotnull.get_dict())
        results.append(validate_bfcount.get_dict())
        results.append(validate_tbcount.get_dict())
        results.append(validate_incount.get_dict())
        results.append(validate_outcount.get_dict())
        results.append(validate_pointsondem.get_dict())
        results.append(validate_tbondem.get_dict())
        results.append(validate_bfondem.get_dict())
        results.append(validate_inoutpointsDEM.get_dict())
        results.append(validate_inhigherthatnoutpointsDEM.get_dict())

        return results
Exemplo n.º 9
0
    def validate(self):

        results = super(CHaMP_Raster, self).validate()

        validate_cellsize = ValidationResult(self.__class__.__name__,
                                             "TargetCellSize")
        validate_rasterheight = ValidationResult(self.__class__.__name__,
                                                 "MaxRasterHeight")
        validate_rasterwidth = ValidationResult(self.__class__.__name__,
                                                "MaxRasterWidth")
        validate_wholemeterextents = ValidationResult(self.__class__.__name__,
                                                      "WholeMeterExtents")
        validate_concurrent_dem = ValidationResult(self.__class__.__name__,
                                                   "ConcurrentWithDEM")

        if self.exists():
            gRaster = self.get_raster()

            if (abs(gRaster.cellHeight) == self.targetCellsize) and (abs(
                    gRaster.cellWidth) == self.targetCellsize):
                validate_cellsize.pass_validation()
            else:
                validate_cellsize.error("Cell size (" + str(gRaster.cellHeight) + "," + str(gRaster.cellWidth) + \
                                            " not required size of " + str(self.targetCellsize))

            if gRaster.getHeight() < self.maxRasterHeight:
                validate_rasterheight.pass_validation()
            else:
                validate_rasterheight.error("Raster height " + str(gRaster.getHeight()) + " exceeds maximum of " + \
                                        str(self.maxRasterHeight))

            if gRaster.getWidth() < self.maxRasterWidth:
                validate_rasterwidth.pass_validation()
            else:
                validate_rasterwidth.error("Raster width " + str(gRaster.getWidth()) + " exceeds maximum of " + \
                                        str(self.maxRasterWidth))

            if float(gRaster.getHeight()).is_integer() and float(
                    gRaster.getWidth()).is_integer():
                validate_wholemeterextents.pass_validation()
            else:
                validate_wholemeterextents.error(
                    "Raster extents not whole meters.")

            if self.surveyDEM_Polygon:
                if self.surveyDEM_Polygon.equals(
                        self.get_raster().getBoundaryShape()):
                    validate_concurrent_dem.pass_validation()
                else:
                    validate_concurrent_dem.warning(
                        "Raster extent does not appear to be concurrent with DEM."
                    )

        results.append(validate_concurrent_dem.get_dict())
        results.append(validate_wholemeterextents.get_dict())
        results.append(validate_rasterwidth.get_dict())
        results.append(validate_rasterheight.get_dict())
        results.append(validate_cellsize.get_dict())

        return results
Exemplo n.º 10
0
    def validate(self):

        results = super(CHaMP_Vector_Polyline_LongLine,self).validate()

        validate_minlength = ValidationResult(self.__class__.__name__, "MinLength")
        validate_singlepart = ValidationResult(self.__class__.__name__, "SinglePartFeatures")
        validate_closedloop = ValidationResult(self.__class__.__name__, "ClosedLoopFeatures")
        validate_startstopraster = ValidationResult(self.__class__.__name__, "FeaturesStartStopOnDEM")
        validate_within_extent = ValidationResult(self.__class__.__name__, "FeaturesWithinChannelExtent")
        validate_not_intersec_islands = ValidationResult(self.__class__.__name__, "FeaturesNotIntersectIslands")

        if self.exists(): #TODO test logic works here, but is not very clear.
            if not self.feat_min_length(self.minLengthError):
                validate_minlength.status = "Error"
                validate_minlength.message = "Feature has length less than minimum required (" + \
                                             str(self.minLengthError) + ")"
            elif not self.feat_min_length(self.minLengthWarning):
                validate_minlength.status = "Warning"
                validate_minlength.message = "Feature has length less than minimum desired (" + \
                                         str(self.minLengthWarning) + ")"
            else:
                validate_minlength.status = "Pass"
            if self.singlepart_features_test():
                validate_singlepart.pass_validation()
                if self.demDataExtent and self.features:
                    if self.start_stop_on_raster():
                        validate_startstopraster.pass_validation()
                    else:
                        validate_startstopraster.warning("One or more line features does not start or stop on the DEM")

                if self.closed_loop_test():
                    validate_closedloop.pass_validation()
                else:
                    validate_closedloop.error("Closed Loop Features found and are not allowed")

                if self.extent_polygon and self.features:

                    if self.start_stop_on_raster(self.extent_polygon):
                        validate_within_extent.pass_validation()
                    else:
                        validate_within_extent.warning("One or more lines not within channel extent.")

                if self.island_polygons and self.features:
                    if not any(feat['geometry'].intersects(island) for island in self.island_polygons for feat in self.features):
                        validate_not_intersec_islands.pass_validation()
                    else:
                        validate_not_intersec_islands.error("one or more lines itersects a qualifying island, which is not allowed.")
            else:
                validate_singlepart.error("Mulitpart Features found and are not allowed.")

        results.append(validate_minlength.get_dict())
        results.append(validate_singlepart.get_dict())
        results.append(validate_closedloop.get_dict())
        results.append(validate_startstopraster.get_dict())
        results.append(validate_within_extent.get_dict())
        results.append(validate_not_intersec_islands.get_dict())

        return results