[GRASS-SVN] r50618 - in grass/trunk: gui/wxpython/iclass lib/imagery
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Feb 1 13:08:35 EST 2012
Author: annakrat
Date: 2012-02-01 10:08:35 -0800 (Wed, 01 Feb 2012)
New Revision: 50618
Modified:
grass/trunk/gui/wxpython/iclass/frame.py
grass/trunk/lib/imagery/iclass.c
grass/trunk/lib/imagery/iclass_perimeter.c
Log:
wxGUI/wxIClass: when there is no area with given cat, display warning, not error message
Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py 2012-02-01 17:21:49 UTC (rev 50617)
+++ grass/trunk/gui/wxpython/iclass/frame.py 2012-02-01 18:08:35 UTC (rev 50618)
@@ -562,8 +562,9 @@
stats.color,
stats.nstd)
- if I_iclass_analysis(statistics, self.refer, self.poMapInfo, "1",
- self.group, stats.rasterName):
+ ret = I_iclass_analysis(statistics, self.refer, self.poMapInfo, "1",
+ self.group, stats.rasterName)
+ if ret > 0:
# tests
self.cStatisticsDict[i] = statistics
@@ -576,9 +577,12 @@
alias = stats.name, resultsLayer = True)
# write statistics
I_iclass_add_signature(self.signatures, statistics)
+
+ elif ret == 0:
+ GMessage(parent = self, message = _("No area in category %s. Category skipped.") % stats.category)
+ I_iclass_free_statistics(statistics)
else:
- GMessage(parent = self, message = _("Analysis failed. "
- "Check training areas and their categories."))
+ GMessage(parent = self, message = _("Analysis failed."))
I_iclass_free_statistics(statistics)
self.UpdateChangeState(changes = False)
Modified: grass/trunk/lib/imagery/iclass.c
===================================================================
--- grass/trunk/lib/imagery/iclass.c 2012-02-01 17:21:49 UTC (rev 50617)
+++ grass/trunk/lib/imagery/iclass.c 2012-02-01 18:08:35 UTC (rev 50618)
@@ -44,13 +44,14 @@
\param group name of imagery group
\param raster_name name of temporary raster map (to be created)
- \return 1 on success
- \return 0 on failure
+ \return number of processed training areas
+ \return -1 on failure
*/
int I_iclass_analysis(IClass_statistics * statistics, struct Ref *refer,
struct Map_info *map_info, const char *layer_name,
const char *group, const char *raster_name)
{
+ int ret;
int category;
@@ -72,8 +73,14 @@
Rast_get_cellhd(refer->file[0].name, refer->file[0].mapset, &band_region);
/* find perimeter points from vector map */
- if (!vector2perimeters
- (map_info, layer_name, category, &perimeters, &band_region)) {
+ ret =
+ vector2perimeters(map_info, layer_name, category, &perimeters,
+ &band_region);
+ if (ret < 0) {
+ return -1;
+ }
+ else if (ret == 0) {
+ G_warning(_("No areas in category %d"), category);
return 0;
}
@@ -84,7 +91,7 @@
close_band_files(refer, band_buffer, band_fd);
free_perimeters(&perimeters);
- return 1;
+ return ret;
}
Modified: grass/trunk/lib/imagery/iclass_perimeter.c
===================================================================
--- grass/trunk/lib/imagery/iclass_perimeter.c 2012-02-01 17:21:49 UTC (rev 50617)
+++ grass/trunk/lib/imagery/iclass_perimeter.c 2012-02-01 18:08:35 UTC (rev 50618)
@@ -46,8 +46,8 @@
\param[out] perimeters list of perimeters
\param band_region region which determines perimeter cells
- \return 1 on success
- \return 0 on error
+ \return number of areas of given cat
+ \return -1 on error
*/
int vector2perimeters(struct Map_info *Map, const char *layer_name,
int category, IClass_perimeter_list * perimeters,
@@ -82,7 +82,6 @@
nareas_cat++;
}
}
-
if (nareas_cat == 0)
return 0;
@@ -108,14 +107,14 @@
Vect_destroy_line_struct(points);
free_perimeters(perimeters);
G_warning(_("Get area %d failed"), i);
- return 0;
+ return -1;
}
if (make_perimeter
(points, &perimeters->perimeters[j - 1], band_region) <= 0) {
Vect_destroy_line_struct(points);
free_perimeters(perimeters);
G_warning(_("Perimeter computation failed"));
- return 0;
+ return -1;
}
Vect_destroy_line_struct(points);
}
@@ -124,7 +123,7 @@
//Vect_close(&Map);
- return 1;
+ return nareas_cat;
}
/*!
More information about the grass-commit
mailing list