[GRASS-SVN] r38003 - in grass/trunk: display/d.colors
display/d.colortable display/d.extract display/d.graph
display/d.grid display/d.his display/d.histogram
display/d.labels display/d.legend display/d.nviz
display/d.path display/d.profile display/d.rast
display/d.rast.arrow display/d.rast.num display/d.rgb
display/d.thematic.area display/d.title display/d.vect
display/d.vect.chart display/d.what.rast display/d.zoom
doc/raster/r.example general/g.mremove general/g.region
general/g.remove general/g.rename general/manage/lister
imagery/i.albedo imagery/i.atcorr imagery/i.cca
imagery/i.class imagery/i.cluster imagery/i.eb.eta
imagery/i.eb.evapfr imagery/i.eb.h_SEBAL01
imagery/i.eb.soilheatflux imagery/i.emissivity
imagery/i.evapo.time_integration imagery/i.fft
imagery/i.gensig imagery/i.gensigset imagery/i.his.rgb
imagery/i.ifft imagery/i.latlong imagery/i.maxlik
imagery/i.modis.qc imagery/i.pca imagery/i.points
imagery/i.rectify imagery/i.rgb.his imagery/i.smap
imagery/i.sunhours imagery/i.vi imagery/i.vpoints
imagery/i.zc include include/Make lib lib/cluster lib/display
lib/g3d lib/gis lib/gpde lib/nviz lib/ogsf lib/raster
lib/rst/interp_float lib/stats ps/ps.map raster/r.basins.fill
raster/r.bitpattern raster/r.buffer raster/r.carve
raster/r.category raster/r.circle raster/r.clump
raster/r.coin raster/r.colors raster/r.colors.out
raster/r.composite raster/r.compress raster/r.contour
raster/r.cost raster/r.covar raster/r.cross raster/r.describe
raster/r.digit raster/r.distance raster/r.drain
raster/r.external raster/r.fill.dir raster/r.flow
raster/r.grow raster/r.grow.distance raster/r.gwflow
raster/r.his raster/r.horizon raster/r.in.arc
raster/r.in.ascii raster/r.in.bin raster/r.in.gdal
raster/r.in.gridatb raster/r.in.mat raster/r.in.poly
raster/r.in.xyz raster/r.info raster/r.kappa raster/r.lake
raster/r.le/r.le.patch raster/r.le/r.le.pixel
raster/r.le/r.le.setup raster/r.le/r.le.setup/polytocell
raster/r.le/r.le.trace raster/r.li/r.li.cwed
raster/r.li/r.li.daemon raster/r.li/r.li.dominance
raster/r.li/r.li.edgedensity raster/r.li/r.li.mpa
raster/r.li/r.li.mps raster/r.li/r.li.padcv
raster/r.li/r.li.padrange raster/r.li/r.li.padsd
raster/r.li/r.li.patchdensity raster/r.li/r.li.patchnum
raster/r.li/r.li.richness raster/r.li/r.li.shannon
raster/r.li/r.li.shape raster/r.li/r.li.simpson raster/r.los
raster/r.mapcalc raster/r.mfilter raster/r.mode
raster/r.neighbors raster/r.null raster/r.out.arc
raster/r.out.ascii raster/r.out.bin raster/r.out.gdal
raster/r.out.gridatb raster/r.out.mat raster/r.out.mpeg
raster/r.out.png raster/r.out.pov raster/r.out.ppm
raster/r.out.ppm3 raster/r.out.tiff raster/r.out.vrml
raster/r.out.vtk raster/r.param.scale raster/r.patch
raster/r.profile raster/r.proj raster/r.quant
raster/r.quantile raster/r.random raster/r.random.cells
raster/r.random.surface raster/r.reclass raster/r.recode
raster/r.region raster/r.report raster/r.resamp.interp
raster/r.resamp.rst raster/r.resamp.stats raster/r.resample
raster/r.rescale raster/r.rescale.eq raster/r.ros
raster/r.series raster/r.slope.aspect raster/r.spread
raster/r.spreadpath raster/r.statistics raster/r.statistics2
raster/r.statistics3 raster/r.stats raster/r.sun
raster/r.sun2 raster/r.sunmask raster/r.support
raster/r.support.stats raster/r.surf.area
raster/r.surf.contour raster/r.surf.fractal
raster/r.surf.gauss raster/r.surf.idw raster/r.surf.idw2
raster/r.surf.random raster/r.terraflow raster/r.texture
raster/r.thin raster/r.to.rast3 raster/r.to.rast3elev
raster/r.to.vect raster/r.topidx raster/r.topmodel
raster/r.univar raster/r.uslek raster/r.usler raster/r.volume
raster/r.walk raster/r.water.outlet raster/r.watershed/front
raster/r.watershed/ram raster/r.watershed/seg
raster/r.watershed/shed raster/r.what raster/r.what.color
raster/simwe/simlib raster3d/r3.cross.rast raster3d/r3.gwflow
raster3d/r3.mkdspf raster3d/r3.out.vtk raster3d/r3.to.rast
swig/perl/R_slope_aspect/r_slope_aspect vector/lidar/lidarlib
vector/lidar/v.lidar.correction vector/lidar/v.lidar.edgedetection
vector/lidar/v.lidar.growing vector/lidar/v.outlier
vector/lidar/v.surf.bspline vector/v.convert vector/v.drape
vector/v.extrude vector/v.kernel vector/v.neighbors
vector/v.sample vector/v.surf.idw vector/v.to.rast
vector/v.vol.rst vector/v.what.rast visualization/xganim
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jun 20 18:03:27 EDT 2009
Author: martinl
Date: 2009-06-20 18:03:23 -0400 (Sat, 20 Jun 2009)
New Revision: 38003
Added:
grass/trunk/include/Rast.h
grass/trunk/lib/raster/
grass/trunk/lib/raster/G.h
grass/trunk/lib/raster/adj_cellhd.c
grass/trunk/lib/raster/alloc_cell.c
grass/trunk/lib/raster/auto_mask.c
grass/trunk/lib/raster/cats.c
grass/trunk/lib/raster/cell_stats.c
grass/trunk/lib/raster/cell_title.c
grass/trunk/lib/raster/cellstats_eq.c
grass/trunk/lib/raster/closecell.c
grass/trunk/lib/raster/color_compat.c
grass/trunk/lib/raster/color_free.c
grass/trunk/lib/raster/color_get.c
grass/trunk/lib/raster/color_hist.c
grass/trunk/lib/raster/color_init.c
grass/trunk/lib/raster/color_insrt.c
grass/trunk/lib/raster/color_invrt.c
grass/trunk/lib/raster/color_look.c
grass/trunk/lib/raster/color_org.c
grass/trunk/lib/raster/color_rand.c
grass/trunk/lib/raster/color_range.c
grass/trunk/lib/raster/color_read.c
grass/trunk/lib/raster/color_remove.c
grass/trunk/lib/raster/color_rule.c
grass/trunk/lib/raster/color_rule_get.c
grass/trunk/lib/raster/color_rules.c
grass/trunk/lib/raster/color_set.c
grass/trunk/lib/raster/color_shift.c
grass/trunk/lib/raster/color_str.c
grass/trunk/lib/raster/color_write.c
grass/trunk/lib/raster/color_xform.c
grass/trunk/lib/raster/format.c
grass/trunk/lib/raster/fpreclass.c
grass/trunk/lib/raster/gdal.c
grass/trunk/lib/raster/get_cellhd.c
grass/trunk/lib/raster/get_row.c
grass/trunk/lib/raster/get_row_colr.c
grass/trunk/lib/raster/histo_eq.c
grass/trunk/lib/raster/histogram.c
grass/trunk/lib/raster/history.c
grass/trunk/lib/raster/interp.c
grass/trunk/lib/raster/mask_info.c
grass/trunk/lib/raster/maskfd.c
grass/trunk/lib/raster/null_val.c
grass/trunk/lib/raster/opencell.c
grass/trunk/lib/raster/put_cellhd.c
grass/trunk/lib/raster/put_row.c
grass/trunk/lib/raster/put_title.c
grass/trunk/lib/raster/quant.c
grass/trunk/lib/raster/quant_io.c
grass/trunk/lib/raster/quant_rw.c
grass/trunk/lib/raster/range.c
grass/trunk/lib/raster/raster.c
grass/trunk/lib/raster/raster_metadata.c
grass/trunk/lib/raster/rd_cellhd.c
grass/trunk/lib/raster/reclass.c
grass/trunk/lib/raster/sample.c
grass/trunk/lib/raster/zero_cell.c
Removed:
grass/trunk/lib/gis/G.h
grass/trunk/lib/gis/adj_cellhd.c
grass/trunk/lib/gis/alloc_cell.c
grass/trunk/lib/gis/auto_mask.c
grass/trunk/lib/gis/cats.c
grass/trunk/lib/gis/cell_stats.c
grass/trunk/lib/gis/cell_title.c
grass/trunk/lib/gis/cellstats_eq.c
grass/trunk/lib/gis/closecell.c
grass/trunk/lib/gis/color_compat.c
grass/trunk/lib/gis/color_free.c
grass/trunk/lib/gis/color_get.c
grass/trunk/lib/gis/color_hist.c
grass/trunk/lib/gis/color_init.c
grass/trunk/lib/gis/color_insrt.c
grass/trunk/lib/gis/color_invrt.c
grass/trunk/lib/gis/color_look.c
grass/trunk/lib/gis/color_org.c
grass/trunk/lib/gis/color_rand.c
grass/trunk/lib/gis/color_range.c
grass/trunk/lib/gis/color_read.c
grass/trunk/lib/gis/color_remove.c
grass/trunk/lib/gis/color_rule.c
grass/trunk/lib/gis/color_rule_get.c
grass/trunk/lib/gis/color_rules.c
grass/trunk/lib/gis/color_set.c
grass/trunk/lib/gis/color_shift.c
grass/trunk/lib/gis/color_str.c
grass/trunk/lib/gis/color_write.c
grass/trunk/lib/gis/color_xform.c
grass/trunk/lib/gis/format.c
grass/trunk/lib/gis/fpreclass.c
grass/trunk/lib/gis/gdal.c
grass/trunk/lib/gis/get_cellhd.c
grass/trunk/lib/gis/get_row.c
grass/trunk/lib/gis/get_row_colr.c
grass/trunk/lib/gis/histo_eq.c
grass/trunk/lib/gis/histogram.c
grass/trunk/lib/gis/history.c
grass/trunk/lib/gis/interp.c
grass/trunk/lib/gis/mask_info.c
grass/trunk/lib/gis/maskfd.c
grass/trunk/lib/gis/null_val.c
grass/trunk/lib/gis/opencell.c
grass/trunk/lib/gis/put_cellhd.c
grass/trunk/lib/gis/put_row.c
grass/trunk/lib/gis/put_title.c
grass/trunk/lib/gis/quant.c
grass/trunk/lib/gis/quant_io.c
grass/trunk/lib/gis/quant_rw.c
grass/trunk/lib/gis/range.c
grass/trunk/lib/gis/raster.c
grass/trunk/lib/gis/raster_metadata.c
grass/trunk/lib/gis/rd_cellhd.c
grass/trunk/lib/gis/reclass.c
grass/trunk/lib/gis/sample.c
grass/trunk/lib/gis/zero_cell.c
Modified:
grass/trunk/display/d.colors/curses.c
grass/trunk/display/d.colors/get_info.c
grass/trunk/display/d.colors/interact.c
grass/trunk/display/d.colors/main.c
grass/trunk/display/d.colors/tbl_toggle.c
grass/trunk/display/d.colortable/main.c
grass/trunk/display/d.extract/main.c
grass/trunk/display/d.graph/do_graph.c
grass/trunk/display/d.graph/graphics.c
grass/trunk/display/d.graph/main.c
grass/trunk/display/d.grid/fiducial.c
grass/trunk/display/d.grid/main.c
grass/trunk/display/d.grid/plot.c
grass/trunk/display/d.grid/plotborder.c
grass/trunk/display/d.his/his.c
grass/trunk/display/d.his/main.c
grass/trunk/display/d.histogram/bar.c
grass/trunk/display/d.histogram/draw_slice.c
grass/trunk/display/d.histogram/get_stats.c
grass/trunk/display/d.histogram/main.c
grass/trunk/display/d.histogram/pie.c
grass/trunk/display/d.labels/color.c
grass/trunk/display/d.labels/do_labels.c
grass/trunk/display/d.labels/main.c
grass/trunk/display/d.legend/main.c
grass/trunk/display/d.nviz/main.c
grass/trunk/display/d.path/main.c
grass/trunk/display/d.path/select.c
grass/trunk/display/d.profile/main.c
grass/trunk/display/d.rast.arrow/main.c
grass/trunk/display/d.rast.num/main.c
grass/trunk/display/d.rast/display.c
grass/trunk/display/d.rast/main.c
grass/trunk/display/d.rast/mask.c
grass/trunk/display/d.rgb/main.c
grass/trunk/display/d.thematic.area/area.c
grass/trunk/display/d.thematic.area/main.c
grass/trunk/display/d.thematic.area/plot1.c
grass/trunk/display/d.title/fancy.c
grass/trunk/display/d.title/main.c
grass/trunk/display/d.title/normal.c
grass/trunk/display/d.vect.chart/bar.c
grass/trunk/display/d.vect.chart/main.c
grass/trunk/display/d.vect.chart/pie.c
grass/trunk/display/d.vect.chart/plot.c
grass/trunk/display/d.vect/area.c
grass/trunk/display/d.vect/attr.c
grass/trunk/display/d.vect/dir.c
grass/trunk/display/d.vect/label.c
grass/trunk/display/d.vect/main.c
grass/trunk/display/d.vect/plot1.c
grass/trunk/display/d.vect/topo.c
grass/trunk/display/d.vect/utils.c
grass/trunk/display/d.vect/zcoor.c
grass/trunk/display/d.what.rast/main.c
grass/trunk/display/d.what.rast/opencell.c
grass/trunk/display/d.what.rast/show.c
grass/trunk/display/d.what.rast/what.c
grass/trunk/display/d.zoom/main.c
grass/trunk/display/d.zoom/set.c
grass/trunk/doc/raster/r.example/main.c
grass/trunk/general/g.mremove/check_reclass.c
grass/trunk/general/g.mremove/wc2regex.c
grass/trunk/general/g.region/adjust.c
grass/trunk/general/g.region/main.c
grass/trunk/general/g.region/printwindow.c
grass/trunk/general/g.region/zoom.c
grass/trunk/general/g.remove/main.c
grass/trunk/general/g.rename/main.c
grass/trunk/general/manage/lister/cell.c
grass/trunk/general/manage/lister/vector.c
grass/trunk/imagery/i.albedo/main.c
grass/trunk/imagery/i.atcorr/main.cpp
grass/trunk/imagery/i.cca/main.c
grass/trunk/imagery/i.cca/matrix.c
grass/trunk/imagery/i.cca/stats.c
grass/trunk/imagery/i.cca/transform.c
grass/trunk/imagery/i.class/band_files.c
grass/trunk/imagery/i.class/draw_cell.c
grass/trunk/imagery/i.class/main.c
grass/trunk/imagery/i.class/readbands.c
grass/trunk/imagery/i.class/signature.c
grass/trunk/imagery/i.cluster/checkpt.c
grass/trunk/imagery/i.cluster/main.c
grass/trunk/imagery/i.cluster/open_files.c
grass/trunk/imagery/i.cluster/print1.c
grass/trunk/imagery/i.cluster/print2.c
grass/trunk/imagery/i.cluster/print3.c
grass/trunk/imagery/i.cluster/print4.c
grass/trunk/imagery/i.cluster/print5.c
grass/trunk/imagery/i.cluster/print6.c
grass/trunk/imagery/i.cluster/timer.c
grass/trunk/imagery/i.eb.eta/main.c
grass/trunk/imagery/i.eb.evapfr/main.c
grass/trunk/imagery/i.eb.h_SEBAL01/main.c
grass/trunk/imagery/i.eb.soilheatflux/main.c
grass/trunk/imagery/i.emissivity/main.c
grass/trunk/imagery/i.evapo.time_integration/main.c
grass/trunk/imagery/i.fft/main.c
grass/trunk/imagery/i.gensig/alloc.c
grass/trunk/imagery/i.gensig/can_invert.c
grass/trunk/imagery/i.gensig/closefiles.c
grass/trunk/imagery/i.gensig/covariance.c
grass/trunk/imagery/i.gensig/eigen.c
grass/trunk/imagery/i.gensig/get_train.c
grass/trunk/imagery/i.gensig/labels.c
grass/trunk/imagery/i.gensig/lookup_class.c
grass/trunk/imagery/i.gensig/means.c
grass/trunk/imagery/i.gensig/openfiles.c
grass/trunk/imagery/i.gensig/parse.c
grass/trunk/imagery/i.gensig/read_train.c
grass/trunk/imagery/i.gensigset/closefiles.c
grass/trunk/imagery/i.gensigset/get_train.c
grass/trunk/imagery/i.gensigset/invert.c
grass/trunk/imagery/i.gensigset/labels.c
grass/trunk/imagery/i.gensigset/lookup_class.c
grass/trunk/imagery/i.gensigset/main.c
grass/trunk/imagery/i.gensigset/openfiles.c
grass/trunk/imagery/i.gensigset/parse.c
grass/trunk/imagery/i.gensigset/read_data.c
grass/trunk/imagery/i.gensigset/read_train.c
grass/trunk/imagery/i.gensigset/subcluster.c
grass/trunk/imagery/i.his.rgb/closefiles.c
grass/trunk/imagery/i.his.rgb/his2rgb.c
grass/trunk/imagery/i.his.rgb/main.c
grass/trunk/imagery/i.his.rgb/openfiles.c
grass/trunk/imagery/i.ifft/main.c
grass/trunk/imagery/i.latlong/main.c
grass/trunk/imagery/i.maxlik/classify.c
grass/trunk/imagery/i.maxlik/hist.c
grass/trunk/imagery/i.maxlik/invert.c
grass/trunk/imagery/i.maxlik/main.c
grass/trunk/imagery/i.maxlik/open.c
grass/trunk/imagery/i.modis.qc/main.c
grass/trunk/imagery/i.pca/main.c
grass/trunk/imagery/i.pca/support.c
grass/trunk/imagery/i.points/cell.c
grass/trunk/imagery/i.points/drawcell.c
grass/trunk/imagery/i.points/graphics.c
grass/trunk/imagery/i.points/main.c
grass/trunk/imagery/i.rectify/crs.c
grass/trunk/imagery/i.rectify/exec.c
grass/trunk/imagery/i.rectify/main.c
grass/trunk/imagery/i.rectify/perform.c
grass/trunk/imagery/i.rectify/rectify.c
grass/trunk/imagery/i.rectify/write.c
grass/trunk/imagery/i.rgb.his/closefiles.c
grass/trunk/imagery/i.rgb.his/main.c
grass/trunk/imagery/i.rgb.his/openfiles.c
grass/trunk/imagery/i.rgb.his/rgb2his.c
grass/trunk/imagery/i.smap/closefiles.c
grass/trunk/imagery/i.smap/decimate.c
grass/trunk/imagery/i.smap/history.c
grass/trunk/imagery/i.smap/interp.c
grass/trunk/imagery/i.smap/invert.c
grass/trunk/imagery/i.smap/labels.c
grass/trunk/imagery/i.smap/model.c
grass/trunk/imagery/i.smap/multialloc.c
grass/trunk/imagery/i.smap/opencell.c
grass/trunk/imagery/i.smap/openfiles.c
grass/trunk/imagery/i.smap/parse.c
grass/trunk/imagery/i.smap/read_block.c
grass/trunk/imagery/i.smap/write_img.c
grass/trunk/imagery/i.sunhours/main.c
grass/trunk/imagery/i.vi/main.c
grass/trunk/imagery/i.vpoints/cell.c
grass/trunk/imagery/i.vpoints/colors.c
grass/trunk/imagery/i.vpoints/drawcell.c
grass/trunk/imagery/i.vpoints/graphics.c
grass/trunk/imagery/i.vpoints/main.c
grass/trunk/imagery/i.zc/main.c
grass/trunk/include/Make/Grass.make
grass/trunk/include/arraystats.h
grass/trunk/include/cluster.h
grass/trunk/include/gis.h
grass/trunk/include/gisdefs.h
grass/trunk/include/nviz.h
grass/trunk/include/vedit.h
grass/trunk/lib/Makefile
grass/trunk/lib/cluster/c_point.c
grass/trunk/lib/display/raster.c
grass/trunk/lib/display/raster2.c
grass/trunk/lib/display/tran_colr.c
grass/trunk/lib/g3d/g3dcats.c
grass/trunk/lib/g3d/g3dclose.c
grass/trunk/lib/g3d/g3dcolor.c
grass/trunk/lib/g3d/g3dfpxdr.c
grass/trunk/lib/g3d/g3dhistory.c
grass/trunk/lib/g3d/g3dmisc.c
grass/trunk/lib/g3d/g3dnull.c
grass/trunk/lib/g3d/g3drange.c
grass/trunk/lib/g3d/g3dregion.c
grass/trunk/lib/g3d/g3dvolume.c
grass/trunk/lib/g3d/getblock.c
grass/trunk/lib/g3d/tileread.c
grass/trunk/lib/g3d/tilewrite.c
grass/trunk/lib/gis/Makefile
grass/trunk/lib/gis/align_window.c
grass/trunk/lib/gis/debug.c
grass/trunk/lib/gis/get_window.c
grass/trunk/lib/gis/gisinit.c
grass/trunk/lib/gis/set_window.c
grass/trunk/lib/gis/window_map.c
grass/trunk/lib/gpde/N_arrays.c
grass/trunk/lib/gpde/N_arrays_calc.c
grass/trunk/lib/gpde/N_arrays_io.c
grass/trunk/lib/nviz/nviz.c
grass/trunk/lib/ogsf/GS2.c
grass/trunk/lib/ogsf/Gp3.c
grass/trunk/lib/ogsf/Gs3.c
grass/trunk/lib/ogsf/Gvl3.c
grass/trunk/lib/ogsf/gsd_legend.c
grass/trunk/lib/rst/interp_float/input2d.c
grass/trunk/lib/rst/interp_float/interp2d.c
grass/trunk/lib/rst/interp_float/output2d.c
grass/trunk/lib/rst/interp_float/resout2d.c
grass/trunk/lib/rst/interp_float/ressegm2d.c
grass/trunk/lib/stats/c_ave.c
grass/trunk/lib/stats/c_count.c
grass/trunk/lib/stats/c_intr.c
grass/trunk/lib/stats/c_kurt.c
grass/trunk/lib/stats/c_max.c
grass/trunk/lib/stats/c_maxx.c
grass/trunk/lib/stats/c_median.c
grass/trunk/lib/stats/c_min.c
grass/trunk/lib/stats/c_minx.c
grass/trunk/lib/stats/c_mode.c
grass/trunk/lib/stats/c_percentile.c
grass/trunk/lib/stats/c_range.c
grass/trunk/lib/stats/c_reg.c
grass/trunk/lib/stats/c_skew.c
grass/trunk/lib/stats/c_stddev.c
grass/trunk/lib/stats/c_sum.c
grass/trunk/lib/stats/c_var.c
grass/trunk/lib/stats/sort_cell.c
grass/trunk/ps/ps.map/catval.c
grass/trunk/ps/ps.map/distance.c
grass/trunk/ps/ps.map/do_geogrid.c
grass/trunk/ps/ps.map/do_header.c
grass/trunk/ps/ps.map/do_labels.c
grass/trunk/ps/ps.map/do_masking.c
grass/trunk/ps/ps.map/do_plt.c
grass/trunk/ps/ps.map/do_psfiles.c
grass/trunk/ps/ps.map/do_vectors.c
grass/trunk/ps/ps.map/error.c
grass/trunk/ps/ps.map/get_font.c
grass/trunk/ps/ps.map/input.c
grass/trunk/ps/ps.map/main.c
grass/trunk/ps/ps.map/makeprocs.c
grass/trunk/ps/ps.map/map_setup.c
grass/trunk/ps/ps.map/outl_io.c
grass/trunk/ps/ps.map/parse_list.c
grass/trunk/ps/ps.map/ps_clrtbl.c
grass/trunk/ps/ps.map/ps_fclrtbl.c
grass/trunk/ps/ps.map/ps_header.c
grass/trunk/ps/ps.map/ps_info.h
grass/trunk/ps/ps.map/ps_outline.c
grass/trunk/ps/ps.map/ps_raster.c
grass/trunk/ps/ps.map/ps_vareas.c
grass/trunk/ps/ps.map/ps_vlines.c
grass/trunk/ps/ps.map/ps_vpoints.c
grass/trunk/ps/ps.map/r_border.c
grass/trunk/ps/ps.map/r_cell.c
grass/trunk/ps/ps.map/r_colortable.c
grass/trunk/ps/ps.map/r_group.c
grass/trunk/ps/ps.map/r_labels.c
grass/trunk/ps/ps.map/r_plt.c
grass/trunk/ps/ps.map/r_rgb.c
grass/trunk/ps/ps.map/r_text.c
grass/trunk/ps/ps.map/r_vareas.c
grass/trunk/ps/ps.map/r_vlines.c
grass/trunk/ps/ps.map/r_vpoints.c
grass/trunk/ps/ps.map/r_wind.c
grass/trunk/ps/ps.map/read_cfg.c
grass/trunk/ps/ps.map/scale.c
grass/trunk/ps/ps.map/scan_gis.c
grass/trunk/ps/ps.map/session.c
grass/trunk/ps/ps.map/vect.c
grass/trunk/ps/ps.map/vector.c
grass/trunk/raster/r.basins.fill/main.c
grass/trunk/raster/r.basins.fill/read_map.c
grass/trunk/raster/r.bitpattern/main.c
grass/trunk/raster/r.buffer/distance.h
grass/trunk/raster/r.buffer/find_dist.c
grass/trunk/raster/r.buffer/init.c
grass/trunk/raster/r.buffer/main.c
grass/trunk/raster/r.buffer/read_map.c
grass/trunk/raster/r.buffer/support.c
grass/trunk/raster/r.buffer/write_map.c
grass/trunk/raster/r.carve/enforce.h
grass/trunk/raster/r.carve/enforce_ds.c
grass/trunk/raster/r.carve/main.c
grass/trunk/raster/r.carve/raster.c
grass/trunk/raster/r.carve/support.c
grass/trunk/raster/r.carve/vect.c
grass/trunk/raster/r.category/cats.c
grass/trunk/raster/r.category/main.c
grass/trunk/raster/r.circle/main.c
grass/trunk/raster/r.clump/clump.c
grass/trunk/raster/r.clump/main.c
grass/trunk/raster/r.coin/coin.h
grass/trunk/raster/r.coin/main.c
grass/trunk/raster/r.coin/make_coin.c
grass/trunk/raster/r.coin/print_hdr.c
grass/trunk/raster/r.colors.out/main.c
grass/trunk/raster/r.colors/local_proto.h
grass/trunk/raster/r.colors/main.c
grass/trunk/raster/r.colors/rules.c
grass/trunk/raster/r.colors/stats.c
grass/trunk/raster/r.composite/main.c
grass/trunk/raster/r.compress/main.c
grass/trunk/raster/r.contour/cont.c
grass/trunk/raster/r.contour/main.c
grass/trunk/raster/r.cost/btree.c
grass/trunk/raster/r.cost/main.c
grass/trunk/raster/r.cost/memory.c
grass/trunk/raster/r.covar/main.c
grass/trunk/raster/r.cross/cats.c
grass/trunk/raster/r.cross/cross.c
grass/trunk/raster/r.cross/glob.h
grass/trunk/raster/r.cross/main.c
grass/trunk/raster/r.cross/renumber.c
grass/trunk/raster/r.describe/describe.c
grass/trunk/raster/r.describe/dumplist.c
grass/trunk/raster/r.describe/main.c
grass/trunk/raster/r.describe/tree.c
grass/trunk/raster/r.digit/digitize.c
grass/trunk/raster/r.digit/get_label.c
grass/trunk/raster/r.distance/defs.h
grass/trunk/raster/r.distance/distance.c
grass/trunk/raster/r.distance/edges.c
grass/trunk/raster/r.distance/labels.c
grass/trunk/raster/r.distance/main.c
grass/trunk/raster/r.distance/parse.c
grass/trunk/raster/r.drain/filldir.c
grass/trunk/raster/r.drain/main.c
grass/trunk/raster/r.drain/resolve.c
grass/trunk/raster/r.drain/tinf.c
grass/trunk/raster/r.external/main.c
grass/trunk/raster/r.fill.dir/dopolys.c
grass/trunk/raster/r.fill.dir/filldir.c
grass/trunk/raster/r.fill.dir/main.c
grass/trunk/raster/r.fill.dir/ppupdate.c
grass/trunk/raster/r.fill.dir/resolve.c
grass/trunk/raster/r.fill.dir/tinf.c
grass/trunk/raster/r.fill.dir/wtrshed.c
grass/trunk/raster/r.flow/aspect.c
grass/trunk/raster/r.flow/aspect.h
grass/trunk/raster/r.flow/io.c
grass/trunk/raster/r.flow/io.h
grass/trunk/raster/r.flow/main.c
grass/trunk/raster/r.flow/mem.c
grass/trunk/raster/r.flow/mem.h
grass/trunk/raster/r.flow/precomp.c
grass/trunk/raster/r.flow/r.flow.h
grass/trunk/raster/r.grow.distance/main.c
grass/trunk/raster/r.grow/main.c
grass/trunk/raster/r.gwflow/main.c
grass/trunk/raster/r.his/his.c
grass/trunk/raster/r.his/main.c
grass/trunk/raster/r.horizon/main.c
grass/trunk/raster/r.in.arc/gethead.c
grass/trunk/raster/r.in.arc/main.c
grass/trunk/raster/r.in.ascii/gethead.c
grass/trunk/raster/r.in.ascii/main.c
grass/trunk/raster/r.in.bin/main.c
grass/trunk/raster/r.in.gdal/main.c
grass/trunk/raster/r.in.gridatb/file_io.c
grass/trunk/raster/r.in.gridatb/local_proto.h
grass/trunk/raster/r.in.gridatb/main.c
grass/trunk/raster/r.in.mat/main.c
grass/trunk/raster/r.in.poly/get_item.c
grass/trunk/raster/r.in.poly/getformat.c
grass/trunk/raster/r.in.poly/main.c
grass/trunk/raster/r.in.poly/poly2rast.c
grass/trunk/raster/r.in.poly/raster.c
grass/trunk/raster/r.in.xyz/local_proto.h
grass/trunk/raster/r.in.xyz/main.c
grass/trunk/raster/r.in.xyz/support.c
grass/trunk/raster/r.info/main.c
grass/trunk/raster/r.info/reclas_txt.c
grass/trunk/raster/r.kappa/calc_kappa.c
grass/trunk/raster/r.kappa/kappa.h
grass/trunk/raster/r.kappa/main.c
grass/trunk/raster/r.kappa/mask.c
grass/trunk/raster/r.kappa/prt_hdr.c
grass/trunk/raster/r.kappa/prt_label.c
grass/trunk/raster/r.kappa/prt_mat.c
grass/trunk/raster/r.kappa/stats.c
grass/trunk/raster/r.lake/main.c
grass/trunk/raster/r.le/r.le.patch/driver.c
grass/trunk/raster/r.le/r.le.patch/patch.h
grass/trunk/raster/r.le/r.le.patch/trace.c
grass/trunk/raster/r.le/r.le.pixel/cellclip.c
grass/trunk/raster/r.le/r.le.pixel/driver.c
grass/trunk/raster/r.le/r.le.pixel/pixel.h
grass/trunk/raster/r.le/r.le.pixel/texture.c
grass/trunk/raster/r.le/r.le.setup/mv_wind.c
grass/trunk/raster/r.le/r.le.setup/polytocell/bmf_to_cll.c
grass/trunk/raster/r.le/r.le.setup/sample.c
grass/trunk/raster/r.le/r.le.setup/setup.c
grass/trunk/raster/r.le/r.le.setup/setup.h
grass/trunk/raster/r.le/r.le.trace/main.c
grass/trunk/raster/r.le/r.le.trace/r.le.trace.h
grass/trunk/raster/r.li/r.li.cwed/cwed.c
grass/trunk/raster/r.li/r.li.cwed/utility.c
grass/trunk/raster/r.li/r.li.daemon/GenericCell.h
grass/trunk/raster/r.li/r.li.daemon/avl.c
grass/trunk/raster/r.li/r.li.daemon/avlID.c
grass/trunk/raster/r.li/r.li.daemon/daemon.c
grass/trunk/raster/r.li/r.li.daemon/daemon.h
grass/trunk/raster/r.li/r.li.daemon/ipc.c
grass/trunk/raster/r.li/r.li.daemon/list.c
grass/trunk/raster/r.li/r.li.daemon/worker.c
grass/trunk/raster/r.li/r.li.dominance/dominance.c
grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c
grass/trunk/raster/r.li/r.li.mpa/mpa.c
grass/trunk/raster/r.li/r.li.mps/mps.c
grass/trunk/raster/r.li/r.li.padcv/padcv.c
grass/trunk/raster/r.li/r.li.padrange/padrange.c
grass/trunk/raster/r.li/r.li.padsd/padsd.c
grass/trunk/raster/r.li/r.li.patchdensity/main.c
grass/trunk/raster/r.li/r.li.patchnum/main.c
grass/trunk/raster/r.li/r.li.richness/richness.c
grass/trunk/raster/r.li/r.li.shannon/shannon.c
grass/trunk/raster/r.li/r.li.shape/main.c
grass/trunk/raster/r.li/r.li.simpson/simpson.c
grass/trunk/raster/r.los/delete.c
grass/trunk/raster/r.los/main.c
grass/trunk/raster/r.los/make_list.c
grass/trunk/raster/r.los/make_point.c
grass/trunk/raster/r.los/mark_pts.c
grass/trunk/raster/r.los/pts_elim.c
grass/trunk/raster/r.los/radians.h
grass/trunk/raster/r.mapcalc/column_shift.c
grass/trunk/raster/r.mapcalc/evaluate.c
grass/trunk/raster/r.mapcalc/expression.c
grass/trunk/raster/r.mapcalc/expression.h
grass/trunk/raster/r.mapcalc/map.c
grass/trunk/raster/r.mapcalc/map3.c
grass/trunk/raster/r.mapcalc/mapcalc.h
grass/trunk/raster/r.mapcalc/xabs.c
grass/trunk/raster/r.mapcalc/xacos.c
grass/trunk/raster/r.mapcalc/xadd.c
grass/trunk/raster/r.mapcalc/xand.c
grass/trunk/raster/r.mapcalc/xand2.c
grass/trunk/raster/r.mapcalc/xasin.c
grass/trunk/raster/r.mapcalc/xatan.c
grass/trunk/raster/r.mapcalc/xbitand.c
grass/trunk/raster/r.mapcalc/xbitnot.c
grass/trunk/raster/r.mapcalc/xbitor.c
grass/trunk/raster/r.mapcalc/xbitxor.c
grass/trunk/raster/r.mapcalc/xcoor.c
grass/trunk/raster/r.mapcalc/xcoor3.c
grass/trunk/raster/r.mapcalc/xcos.c
grass/trunk/raster/r.mapcalc/xdiv.c
grass/trunk/raster/r.mapcalc/xdouble.c
grass/trunk/raster/r.mapcalc/xeq.c
grass/trunk/raster/r.mapcalc/xeval.c
grass/trunk/raster/r.mapcalc/xexp.c
grass/trunk/raster/r.mapcalc/xfloat.c
grass/trunk/raster/r.mapcalc/xge.c
grass/trunk/raster/r.mapcalc/xgraph.c
grass/trunk/raster/r.mapcalc/xgt.c
grass/trunk/raster/r.mapcalc/xif.c
grass/trunk/raster/r.mapcalc/xint.c
grass/trunk/raster/r.mapcalc/xisnull.c
grass/trunk/raster/r.mapcalc/xle.c
grass/trunk/raster/r.mapcalc/xlog.c
grass/trunk/raster/r.mapcalc/xlt.c
grass/trunk/raster/r.mapcalc/xmax.c
grass/trunk/raster/r.mapcalc/xmedian.c
grass/trunk/raster/r.mapcalc/xmin.c
grass/trunk/raster/r.mapcalc/xmod.c
grass/trunk/raster/r.mapcalc/xmode.c
grass/trunk/raster/r.mapcalc/xmul.c
grass/trunk/raster/r.mapcalc/xne.c
grass/trunk/raster/r.mapcalc/xneg.c
grass/trunk/raster/r.mapcalc/xnot.c
grass/trunk/raster/r.mapcalc/xnull.c
grass/trunk/raster/r.mapcalc/xor.c
grass/trunk/raster/r.mapcalc/xor2.c
grass/trunk/raster/r.mapcalc/xpow.c
grass/trunk/raster/r.mapcalc/xrand.c
grass/trunk/raster/r.mapcalc/xres.c
grass/trunk/raster/r.mapcalc/xres3.c
grass/trunk/raster/r.mapcalc/xround.c
grass/trunk/raster/r.mapcalc/xrowcol.c
grass/trunk/raster/r.mapcalc/xshiftl.c
grass/trunk/raster/r.mapcalc/xshiftr.c
grass/trunk/raster/r.mapcalc/xshiftru.c
grass/trunk/raster/r.mapcalc/xsin.c
grass/trunk/raster/r.mapcalc/xsqrt.c
grass/trunk/raster/r.mapcalc/xsub.c
grass/trunk/raster/r.mapcalc/xtan.c
grass/trunk/raster/r.mfilter/apply.c
grass/trunk/raster/r.mfilter/execute.c
grass/trunk/raster/r.mfilter/filter.h
grass/trunk/raster/r.mfilter/getrow.c
grass/trunk/raster/r.mfilter/main.c
grass/trunk/raster/r.mfilter/perform.c
grass/trunk/raster/r.mode/main.c
grass/trunk/raster/r.mode/read_stats.c
grass/trunk/raster/r.neighbors/bufs.c
grass/trunk/raster/r.neighbors/divr_cats.c
grass/trunk/raster/r.neighbors/gather.c
grass/trunk/raster/r.neighbors/intr_cats.c
grass/trunk/raster/r.neighbors/main.c
grass/trunk/raster/r.neighbors/null_cats.c
grass/trunk/raster/r.neighbors/readcell.c
grass/trunk/raster/r.neighbors/readweights.c
grass/trunk/raster/r.null/main.c
grass/trunk/raster/r.null/mask.c
grass/trunk/raster/r.out.arc/main.c
grass/trunk/raster/r.out.ascii/formspecific.c
grass/trunk/raster/r.out.ascii/main.c
grass/trunk/raster/r.out.bin/main.c
grass/trunk/raster/r.out.gdal/export_band.c
grass/trunk/raster/r.out.gdal/main.c
grass/trunk/raster/r.out.gridatb/file_io.c
grass/trunk/raster/r.out.gridatb/local_proto.h
grass/trunk/raster/r.out.gridatb/main.c
grass/trunk/raster/r.out.mat/main.c
grass/trunk/raster/r.out.mpeg/main.c
grass/trunk/raster/r.out.mpeg/write.c
grass/trunk/raster/r.out.png/main.c
grass/trunk/raster/r.out.pov/main.c
grass/trunk/raster/r.out.ppm/main.c
grass/trunk/raster/r.out.ppm3/main.c
grass/trunk/raster/r.out.tiff/main.c
grass/trunk/raster/r.out.vrml/main.c
grass/trunk/raster/r.out.vrml/put_grid.c
grass/trunk/raster/r.out.vrml/pv.h
grass/trunk/raster/r.out.vtk/main.c
grass/trunk/raster/r.out.vtk/parameters.c
grass/trunk/raster/r.out.vtk/writeascii.c
grass/trunk/raster/r.param.scale/close_down.c
grass/trunk/raster/r.param.scale/interface.c
grass/trunk/raster/r.param.scale/nrutil.c
grass/trunk/raster/r.param.scale/open_files.c
grass/trunk/raster/r.param.scale/param.h
grass/trunk/raster/r.param.scale/process.c
grass/trunk/raster/r.param.scale/write_cats.c
grass/trunk/raster/r.param.scale/write_cols.c
grass/trunk/raster/r.patch/do_patch.c
grass/trunk/raster/r.patch/main.c
grass/trunk/raster/r.patch/support.c
grass/trunk/raster/r.profile/local_proto.h
grass/trunk/raster/r.profile/main.c
grass/trunk/raster/r.profile/read_rast.c
grass/trunk/raster/r.proj/bilinear.c
grass/trunk/raster/r.proj/bilinear_f.c
grass/trunk/raster/r.proj/bordwalk.c
grass/trunk/raster/r.proj/cubic.c
grass/trunk/raster/r.proj/cubic_f.c
grass/trunk/raster/r.proj/main.c
grass/trunk/raster/r.proj/nearest.c
grass/trunk/raster/r.proj/readcell.c
grass/trunk/raster/r.quant/global.h
grass/trunk/raster/r.quant/main.c
grass/trunk/raster/r.quant/read_rules.c
grass/trunk/raster/r.quantile/main.c
grass/trunk/raster/r.random.cells/flag.c
grass/trunk/raster/r.random.cells/indep.c
grass/trunk/raster/r.random.cells/init.c
grass/trunk/raster/r.random.cells/main.c
grass/trunk/raster/r.random.cells/random.c
grass/trunk/raster/r.random.cells/ransurf.h
grass/trunk/raster/r.random.surface/calcsurf.c
grass/trunk/raster/r.random.surface/gennorm.c
grass/trunk/raster/r.random.surface/init.c
grass/trunk/raster/r.random.surface/main.c
grass/trunk/raster/r.random.surface/random.c
grass/trunk/raster/r.random.surface/ransurf.h
grass/trunk/raster/r.random.surface/save.c
grass/trunk/raster/r.random/count.c
grass/trunk/raster/r.random/main.c
grass/trunk/raster/r.random/random.c
grass/trunk/raster/r.random/support.c
grass/trunk/raster/r.reclass/input.c
grass/trunk/raster/r.reclass/main.c
grass/trunk/raster/r.reclass/parse.c
grass/trunk/raster/r.reclass/range.c
grass/trunk/raster/r.reclass/reclass.c
grass/trunk/raster/r.reclass/rule.h
grass/trunk/raster/r.reclass/stats.c
grass/trunk/raster/r.recode/global.h
grass/trunk/raster/r.recode/main.c
grass/trunk/raster/r.recode/read_rules.c
grass/trunk/raster/r.recode/recode.c
grass/trunk/raster/r.region/main.c
grass/trunk/raster/r.report/global.h
grass/trunk/raster/r.report/header.c
grass/trunk/raster/r.report/maskinfo.c
grass/trunk/raster/r.report/parse.c
grass/trunk/raster/r.report/prt_report.c
grass/trunk/raster/r.report/stats.c
grass/trunk/raster/r.resamp.interp/main.c
grass/trunk/raster/r.resamp.rst/main.c
grass/trunk/raster/r.resamp.stats/main.c
grass/trunk/raster/r.resample/main.c
grass/trunk/raster/r.rescale.eq/get_range.c
grass/trunk/raster/r.rescale.eq/get_stats.c
grass/trunk/raster/r.rescale.eq/main.c
grass/trunk/raster/r.rescale/get_range.c
grass/trunk/raster/r.rescale/main.c
grass/trunk/raster/r.ros/main.c
grass/trunk/raster/r.ros/spot_dist.c
grass/trunk/raster/r.series/main.c
grass/trunk/raster/r.slope.aspect/main.c
grass/trunk/raster/r.slope.aspect/opennew.c
grass/trunk/raster/r.spread/collect_ori.c
grass/trunk/raster/r.spread/display.c
grass/trunk/raster/r.spread/insert2Ha.c
grass/trunk/raster/r.spread/main.c
grass/trunk/raster/r.spread/ram2out.c
grass/trunk/raster/r.spread/replaceHa.c
grass/trunk/raster/r.spread/select_linksB.c
grass/trunk/raster/r.spread/spot.c
grass/trunk/raster/r.spread/spread.c
grass/trunk/raster/r.spreadpath/insert.c
grass/trunk/raster/r.spreadpath/main.c
grass/trunk/raster/r.statistics/main.c
grass/trunk/raster/r.statistics/o_adev.c
grass/trunk/raster/r.statistics/o_average.c
grass/trunk/raster/r.statistics/o_distrib.c
grass/trunk/raster/r.statistics/o_divr.c
grass/trunk/raster/r.statistics/o_kurt.c
grass/trunk/raster/r.statistics/o_max.c
grass/trunk/raster/r.statistics/o_median.c
grass/trunk/raster/r.statistics/o_min.c
grass/trunk/raster/r.statistics/o_mode.c
grass/trunk/raster/r.statistics/o_sdev.c
grass/trunk/raster/r.statistics/o_skew.c
grass/trunk/raster/r.statistics/o_sum.c
grass/trunk/raster/r.statistics/o_var.c
grass/trunk/raster/r.statistics/read_stats.c
grass/trunk/raster/r.statistics2/main.c
grass/trunk/raster/r.statistics3/main.c
grass/trunk/raster/r.stats/cell_stats.c
grass/trunk/raster/r.stats/global.h
grass/trunk/raster/r.stats/main.c
grass/trunk/raster/r.stats/raw_stats.c
grass/trunk/raster/r.stats/stats.c
grass/trunk/raster/r.sun/main.c
grass/trunk/raster/r.sun2/main.c
grass/trunk/raster/r.sun2/rsunlib.c
grass/trunk/raster/r.sunmask/g_solposition.c
grass/trunk/raster/r.sunmask/main.c
grass/trunk/raster/r.sunmask/solpos00.c
grass/trunk/raster/r.support.stats/check.c
grass/trunk/raster/r.support.stats/histo.c
grass/trunk/raster/r.support.stats/main.c
grass/trunk/raster/r.support/check.c
grass/trunk/raster/r.support/histo.c
grass/trunk/raster/r.support/main.c
grass/trunk/raster/r.surf.area/main.c
grass/trunk/raster/r.surf.contour/contour.h
grass/trunk/raster/r.surf.contour/flag_create.c
grass/trunk/raster/r.surf.contour/flag_destroy.c
grass/trunk/raster/r.surf.contour/main.c
grass/trunk/raster/r.surf.contour/read_cell.c
grass/trunk/raster/r.surf.fractal/frac.h
grass/trunk/raster/r.surf.fractal/spec_syn.c
grass/trunk/raster/r.surf.fractal/write_rast.c
grass/trunk/raster/r.surf.gauss/gaussurf.c
grass/trunk/raster/r.surf.gauss/main.c
grass/trunk/raster/r.surf.idw/dist.c
grass/trunk/raster/r.surf.idw/ll.c
grass/trunk/raster/r.surf.idw/main.c
grass/trunk/raster/r.surf.idw/pi.h
grass/trunk/raster/r.surf.idw2/main.c
grass/trunk/raster/r.surf.idw2/read_cell.c
grass/trunk/raster/r.surf.random/main.c
grass/trunk/raster/r.surf.random/randsurf.c
grass/trunk/raster/r.terraflow/common.h
grass/trunk/raster/r.terraflow/grass2str.h
grass/trunk/raster/r.terraflow/main.cc
grass/trunk/raster/r.texture/h_measure.c
grass/trunk/raster/r.texture/main.c
grass/trunk/raster/r.thin/io.c
grass/trunk/raster/r.thin/main.c
grass/trunk/raster/r.thin/thin_lines.c
grass/trunk/raster/r.to.rast3/main.c
grass/trunk/raster/r.to.rast3elev/main.c
grass/trunk/raster/r.to.vect/areas.c
grass/trunk/raster/r.to.vect/areas_io.c
grass/trunk/raster/r.to.vect/lines.c
grass/trunk/raster/r.to.vect/lines_io.c
grass/trunk/raster/r.to.vect/main.c
grass/trunk/raster/r.to.vect/points.c
grass/trunk/raster/r.to.vect/util.c
grass/trunk/raster/r.topidx/file_io.c
grass/trunk/raster/r.topidx/global.h
grass/trunk/raster/r.topidx/main.c
grass/trunk/raster/r.topidx/topidx.c
grass/trunk/raster/r.topmodel/file_io.c
grass/trunk/raster/r.topmodel/global.h
grass/trunk/raster/r.topmodel/infiltration.c
grass/trunk/raster/r.topmodel/topmodel.c
grass/trunk/raster/r.univar/globals.h
grass/trunk/raster/r.univar/r.univar_main.c
grass/trunk/raster/r.uslek/main.c
grass/trunk/raster/r.usler/main.c
grass/trunk/raster/r.volume/centroids.c
grass/trunk/raster/r.volume/main.c
grass/trunk/raster/r.walk/btree.c
grass/trunk/raster/r.walk/main.c
grass/trunk/raster/r.walk/memory.c
grass/trunk/raster/r.water.outlet/basin.h
grass/trunk/raster/r.water.outlet/flag_create.c
grass/trunk/raster/r.water.outlet/flag_destroy.c
grass/trunk/raster/r.water.outlet/main.c
grass/trunk/raster/r.watershed/front/main.c
grass/trunk/raster/r.watershed/ram/Gwater.h
grass/trunk/raster/r.watershed/ram/close_maps.c
grass/trunk/raster/r.watershed/ram/close_maps2.c
grass/trunk/raster/r.watershed/ram/do_astar.c
grass/trunk/raster/r.watershed/ram/do_cum.c
grass/trunk/raster/r.watershed/ram/flag_create.c
grass/trunk/raster/r.watershed/ram/flag_destroy.c
grass/trunk/raster/r.watershed/ram/init_vars.c
grass/trunk/raster/r.watershed/ram/main.c
grass/trunk/raster/r.watershed/ram/sg_factor.c
grass/trunk/raster/r.watershed/ram/usage.c
grass/trunk/raster/r.watershed/seg/Gwater.h
grass/trunk/raster/r.watershed/seg/bseg_close.c
grass/trunk/raster/r.watershed/seg/bseg_get.c
grass/trunk/raster/r.watershed/seg/bseg_open.c
grass/trunk/raster/r.watershed/seg/bseg_put.c
grass/trunk/raster/r.watershed/seg/bseg_read.c
grass/trunk/raster/r.watershed/seg/bseg_write.c
grass/trunk/raster/r.watershed/seg/close_maps.c
grass/trunk/raster/r.watershed/seg/close_maps2.c
grass/trunk/raster/r.watershed/seg/cseg_close.c
grass/trunk/raster/r.watershed/seg/cseg_get.c
grass/trunk/raster/r.watershed/seg/cseg_open.c
grass/trunk/raster/r.watershed/seg/cseg_put.c
grass/trunk/raster/r.watershed/seg/cseg_read.c
grass/trunk/raster/r.watershed/seg/cseg_write.c
grass/trunk/raster/r.watershed/seg/do_astar.c
grass/trunk/raster/r.watershed/seg/do_cum.c
grass/trunk/raster/r.watershed/seg/dseg_close.c
grass/trunk/raster/r.watershed/seg/dseg_get.c
grass/trunk/raster/r.watershed/seg/dseg_open.c
grass/trunk/raster/r.watershed/seg/dseg_put.c
grass/trunk/raster/r.watershed/seg/dseg_read.c
grass/trunk/raster/r.watershed/seg/dseg_write.c
grass/trunk/raster/r.watershed/seg/init_vars.c
grass/trunk/raster/r.watershed/seg/main.c
grass/trunk/raster/r.watershed/seg/sg_factor.c
grass/trunk/raster/r.watershed/seg/sseg_close.c
grass/trunk/raster/r.watershed/seg/sseg_get.c
grass/trunk/raster/r.watershed/seg/sseg_open.c
grass/trunk/raster/r.watershed/seg/sseg_put.c
grass/trunk/raster/r.watershed/seg/usage.c
grass/trunk/raster/r.watershed/shed/print.c
grass/trunk/raster/r.watershed/shed/read.c
grass/trunk/raster/r.watershed/shed/valid.c
grass/trunk/raster/r.watershed/shed/watershed.h
grass/trunk/raster/r.what.color/main.c
grass/trunk/raster/r.what/main.c
grass/trunk/raster/simwe/simlib/input.c
grass/trunk/raster/simwe/simlib/output.c
grass/trunk/raster3d/r3.cross.rast/main.c
grass/trunk/raster3d/r3.gwflow/main.c
grass/trunk/raster3d/r3.mkdspf/calc_linefax.c
grass/trunk/raster3d/r3.mkdspf/iso_surface.c
grass/trunk/raster3d/r3.mkdspf/main.c
grass/trunk/raster3d/r3.mkdspf/r3_find.c
grass/trunk/raster3d/r3.out.vtk/errorHandling.c
grass/trunk/raster3d/r3.out.vtk/main.c
grass/trunk/raster3d/r3.out.vtk/parameters.c
grass/trunk/raster3d/r3.out.vtk/writeVTKData.c
grass/trunk/raster3d/r3.out.vtk/writeVTKHead.c
grass/trunk/raster3d/r3.to.rast/main.c
grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/opennew.c
grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/r_slope_aspect.c
grass/trunk/vector/lidar/lidarlib/TcholBand.c
grass/trunk/vector/lidar/lidarlib/raster.c
grass/trunk/vector/lidar/lidarlib/zones.c
grass/trunk/vector/lidar/v.lidar.correction/correction.c
grass/trunk/vector/lidar/v.lidar.correction/main.c
grass/trunk/vector/lidar/v.lidar.edgedetection/edgedetection.c
grass/trunk/vector/lidar/v.lidar.edgedetection/main.c
grass/trunk/vector/lidar/v.lidar.growing/ConvexHull.c
grass/trunk/vector/lidar/v.lidar.growing/main.c
grass/trunk/vector/lidar/v.outlier/main.c
grass/trunk/vector/lidar/v.outlier/outlier.c
grass/trunk/vector/lidar/v.surf.bspline/crosscorr.c
grass/trunk/vector/lidar/v.surf.bspline/main.c
grass/trunk/vector/v.convert/att.c
grass/trunk/vector/v.convert/dist.c
grass/trunk/vector/v.convert/main.c
grass/trunk/vector/v.convert/old2new.c
grass/trunk/vector/v.convert/read.c
grass/trunk/vector/v.drape/main.c
grass/trunk/vector/v.extrude/main.c
grass/trunk/vector/v.kernel/function.c
grass/trunk/vector/v.kernel/main.c
grass/trunk/vector/v.neighbors/main.c
grass/trunk/vector/v.sample/main.c
grass/trunk/vector/v.surf.idw/main.c
grass/trunk/vector/v.surf.idw/read_sites.c
grass/trunk/vector/v.to.rast/do_areas.c
grass/trunk/vector/v.to.rast/do_lines.c
grass/trunk/vector/v.to.rast/local.h
grass/trunk/vector/v.to.rast/main.c
grass/trunk/vector/v.to.rast/raster.c
grass/trunk/vector/v.to.rast/support.c
grass/trunk/vector/v.to.rast/vect2rast.c
grass/trunk/vector/v.vol.rst/dataoct.c
grass/trunk/vector/v.vol.rst/main.c
grass/trunk/vector/v.vol.rst/oct.c
grass/trunk/vector/v.vol.rst/user1.c
grass/trunk/vector/v.vol.rst/user2.c
grass/trunk/vector/v.vol.rst/user3.c
grass/trunk/vector/v.vol.rst/user4.c
grass/trunk/vector/v.vol.rst/vector.c
grass/trunk/vector/v.what.rast/main.c
grass/trunk/visualization/xganim/main.cc
Log:
rasterlib: raster-related fns moved from gislib to rasterlib (step 1)
Modified: grass/trunk/display/d.colors/curses.c
===================================================================
--- grass/trunk/display/d.colors/curses.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.colors/curses.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -63,11 +63,11 @@
CELL tmp = current_cat;
int start_cat, end_cat, at_cat, at_line;
- if (G_is_c_null_value(&tmp))
+ if (Rast_is_c_null_value(&tmp))
current_cat = 0;
else
current_cat++;
- G_set_c_null_value(&tmp, 1);
+ Rast_set_c_null_value(&tmp, 1);
start_cat = current_cat - 2;
start_cat = start_cat > 0 ? start_cat : 0;
end_cat = start_cat + 4;
@@ -85,18 +85,18 @@
if (at_cat == current_cat) {
if (!at_cat)
sprintf(buffer, "-> %3s %s", "N",
- G_get_c_raster_cat(&tmp, pcats));
+ Rast_get_c_raster_cat(&tmp, pcats));
else
sprintf(buffer, "-> %3d %s", at_cat - 1,
- G_get_cat(at_cat - 1, pcats));
+ Rast_get_cat(at_cat - 1, pcats));
}
else {
if (!at_cat)
sprintf(buffer, " %3s %s", "N",
- G_get_c_raster_cat(&tmp, pcats));
+ Rast_get_c_raster_cat(&tmp, pcats));
else
sprintf(buffer, " %3d %s", at_cat - 1,
- G_get_cat(at_cat - 1, pcats));
+ Rast_get_cat(at_cat - 1, pcats));
}
wmove(CAT_WIN, at_line++, 1);
waddstr(CAT_WIN, buffer);
@@ -155,7 +155,7 @@
if (hi_mode)
sprintf(buffer, "HIGHLIGHT COLOR");
else {
- if (!G_is_c_null_value(&tmp))
+ if (!Rast_is_c_null_value(&tmp))
sprintf(buffer, "CATEGORY NUMBER: %d", at_cat);
else
sprintf(buffer, "CATEGORY NUMBER: N");
Modified: grass/trunk/display/d.colors/get_info.c
===================================================================
--- grass/trunk/display/d.colors/get_info.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.colors/get_info.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,13 +18,13 @@
exit(0);
/* Reading color lookup table */
- if (G_read_cats(name, mapset, &categories) == -1) {
+ if (Rast_read_cats(name, mapset, &categories) == -1) {
sprintf(buff, "category file for [%s] not available", name);
G_fatal_error(buff);
}
/* Reading color lookup table */
- if (G_read_colors(name, mapset, &colors) == -1) {
+ if (Rast_read_colors(name, mapset, &colors) == -1) {
sprintf(buff, "color file for [%s] not available", name);
G_fatal_error(buff);
}
Modified: grass/trunk/display/d.colors/interact.c
===================================================================
--- grass/trunk/display/d.colors/interact.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.colors/interact.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -43,8 +43,8 @@
hi_save_mode = 0;
colors_changed = 0;
- G_set_c_null_value(&at_cat, 1);
- G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
+ Rast_set_c_null_value(&at_cat, 1);
+ Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
shift_incr = 10;
Initialize_curses();
@@ -89,10 +89,10 @@
case 'd':
case 'u':
if (hi_mode && !hi_save_mode) {
- G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
+ Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
}
/* tmark_category(at_cat, 0) ; */
- if (G_is_c_null_value(&at_cat))
+ if (Rast_is_c_null_value(&at_cat))
tmp = 0;
else
tmp = at_cat + 1;
@@ -115,7 +115,7 @@
}
tmp = tmp % (categories->num + 2); /* changed 11/99 M.N. */
if (!tmp)
- G_set_c_null_value(&at_cat, 1);
+ Rast_set_c_null_value(&at_cat, 1);
else
at_cat = tmp - 1;
@@ -124,12 +124,12 @@
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode) {
- G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
+ Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
colors_changed = 1;
}
}
else {
- G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
+ Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
}
WRITE_CATS;
@@ -167,12 +167,12 @@
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode) {
- G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
+ Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
colors_changed = 1;
}
}
else {
- G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
+ Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
switch (cur_char) {
case 'r':
cur_red = shift_color(cur_red, -shift_incr);
@@ -193,7 +193,7 @@
cur_blu = shift_color(cur_blu, shift_incr);
break;
}
- G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
+ Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
colors_changed = 1;
}
WRITE_STATUS;
@@ -207,25 +207,25 @@
WRITE_STATUS;
break;
case '+':
- G_shift_colors(1, colors);
+ Rast_shift_colors(1, colors);
if (hi_mode) {
cur_red = red_hi;
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode)
- G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
+ Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
}
colors_changed = 1;
WRITE_STATUS;
break;
case '-':
- G_shift_colors(-1, colors);
+ Rast_shift_colors(-1, colors);
if (hi_mode) {
cur_red = red_hi;
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode)
- G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
+ Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
}
colors_changed = 1;
WRITE_STATUS;
@@ -245,14 +245,14 @@
cur_grn = grn_hi;
cur_blu = blu_hi;
if (hi_save_mode)
- G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
+ Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
}
colors_changed = 1;
break;
case 'h':
case 'H':
if (hi_mode) {
- G_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
+ Rast_get_color(at_cat, &cur_red, &cur_grn, &cur_blu, colors);
hi_mode = 0;
hi_save_mode = 0;
}
@@ -262,7 +262,7 @@
cur_blu = blu_hi;
hi_mode = 1;
if (cur_char == 'H') {
- G_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
+ Rast_set_color(at_cat, cur_red, cur_grn, cur_blu, colors);
hi_save_mode = 1;
colors_changed = 1;
}
@@ -319,7 +319,7 @@
Clear_message();
Write_message(2, "Writing color table ");
- if (G_write_colors(name, mapset, colors) == -1) {
+ if (Rast_write_colors(name, mapset, colors) == -1) {
G_sleep(1);
Write_message(2, "Can't write color table ");
G_sleep(2);
Modified: grass/trunk/display/d.colors/main.c
===================================================================
--- grass/trunk/display/d.colors/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.colors/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -69,7 +69,7 @@
G_fatal_error(msg);
}
- if (G_raster_map_is_fp(map->answer, mapset)) {
+ if (Rast_raster_map_is_fp(map->answer, mapset)) {
sprintf(buff,
"Raster file [%s] is floating point! \nd.colors only works with integer maps",
map->answer);
Modified: grass/trunk/display/d.colors/tbl_toggle.c
===================================================================
--- grass/trunk/display/d.colors/tbl_toggle.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.colors/tbl_toggle.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,8 +9,8 @@
char *msg = '\0';
char info[100];
- G_get_color_range(&min, &max, colors);
- G_free_colors(colors);
+ Rast_get_color_range(&min, &max, colors);
+ Rast_free_colors(colors);
sprintf(info, "Color range: %d to %d\n", min, max);
toggle_number++;
@@ -18,27 +18,27 @@
switch (toggle_number) {
case 0:
msg = "Original colors";
- G_read_colors(name, mapset, colors);
+ Rast_read_colors(name, mapset, colors);
break;
case 1:
msg = "Ramp colors";
- G_make_ramp_colors(colors, min, max);
+ Rast_make_ramp_colors(colors, min, max);
break;
case 2:
msg = "Grey scale colors";
- G_make_grey_scale_colors(colors, min, max);
+ Rast_make_grey_scale_colors(colors, min, max);
break;
case 3:
msg = "Random colors";
- G_make_random_colors(colors, min, max);
+ Rast_make_random_colors(colors, min, max);
break;
case 4:
msg = "Wave colors";
- G_make_wave_colors(colors, min, max);
+ Rast_make_wave_colors(colors, min, max);
break;
case 5:
msg = "Aspect colors";
- G_make_aspect_colors(colors, min, max);
+ Rast_make_aspect_colors(colors, min, max);
break;
}
Write_message(2, msg);
Modified: grass/trunk/display/d.colortable/main.c
===================================================================
--- grass/trunk/display/d.colortable/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.colortable/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <math.h>
#include <grass/display.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
@@ -96,7 +97,7 @@
exit(EXIT_FAILURE);
map_name = opt1->answer;
- fp = G_raster_map_is_fp(map_name, "");
+ fp = Rast_raster_map_is_fp(map_name, "");
if (opt2->answer != NULL) {
new_colr = D_translate_color(opt2->answer);
@@ -128,9 +129,9 @@
}
/* Make sure map is available */
- if (G_read_colors(map_name, "", &colors) == -1)
+ if (Rast_read_colors(map_name, "", &colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), map_name);
- if (G_read_fp_range(map_name, "", &fp_range) == -1)
+ if (Rast_read_fp_range(map_name, "", &fp_range) == -1)
G_fatal_error(_("Range file for <%s> not available"), map_name);
if (R_open_driver() != 0)
G_fatal_error(_("No graphics device selected"));
@@ -138,8 +139,8 @@
D_setup_unity(0);
D_get_src(&t, &b, &l, &r);
- G_get_fp_range_min_max(&fp_range, &dmin, &dmax);
- if (G_is_d_null_value(&dmin) || G_is_d_null_value(&dmax))
+ Rast_get_fp_range_min_max(&fp_range, &dmin, &dmax);
+ if (Rast_is_d_null_value(&dmin) || Rast_is_d_null_value(&dmax))
G_fatal_error("Data range is empty");
cats_num = (int)dmax - (int)dmin + 1;
if (lines <= 0 && cols <= 0) {
@@ -173,7 +174,7 @@
white = D_translate_color("white");
black = D_translate_color("black");
- G_set_c_null_value(&atcat, 1);
+ Rast_set_c_null_value(&atcat, 1);
if (!fp) {
for (atcol = 0; atcol < cols; atcol++) {
cur_dot_row = t;
@@ -250,7 +251,7 @@
fprintf(stdout, "dots_per_line: %d\n", dots_per_line);
for (r = 0; r < dots_per_line - 6; r++) {
if (r <= 4)
- G_set_d_null_value(&dval, 1);
+ Rast_set_d_null_value(&dval, 1);
else
dval =
dmin + (r - 1) * (dmax - dmin) / (dots_per_line - 6 - 5);
Modified: grass/trunk/display/d.extract/main.c
===================================================================
--- grass/trunk/display/d.extract/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.extract/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -79,14 +79,14 @@
G_fatal_error(_("No graphics device selected"));
color = G_standard_color_rgb(BLACK);
- if (G_str_to_color(color_opt->answer, &r, &g, &b)) {
+ if (Rast_str_to_color(color_opt->answer, &r, &g, &b)) {
color.r = r;
color.g = g;
color.b = b;
}
hcolor = G_standard_color_rgb(RED);
- if (G_str_to_color(hcolor_opt->answer, &r, &g, &b)) {
+ if (Rast_str_to_color(hcolor_opt->answer, &r, &g, &b)) {
hcolor.r = r;
hcolor.g = g;
hcolor.b = b;
Modified: grass/trunk/display/d.graph/do_graph.c
===================================================================
--- grass/trunk/display/d.graph/do_graph.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.graph/do_graph.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/symbol.h>
@@ -99,7 +100,7 @@
}
/* Parse and select color */
- color = G_str_to_color(in_color, &R, &G, &B);
+ color = Rast_str_to_color(in_color, &R, &G, &B);
if (color == 0) {
G_warning(_("[%s]: No such color"), in_color);
/* store for backup */
@@ -339,7 +340,7 @@
size *= yincr;
/* parse line color */
- ret = G_str_to_color(line_color_str, &R, &G, &B);
+ ret = Rast_str_to_color(line_color_str, &R, &G, &B);
line_color->r = (unsigned char)R;
line_color->g = (unsigned char)G;
line_color->b = (unsigned char)B;
@@ -356,7 +357,7 @@
}
/* parse fill color */
- ret = G_str_to_color(fill_color_str, &R, &G, &B);
+ ret = Rast_str_to_color(fill_color_str, &R, &G, &B);
fill_color->r = (unsigned char)R;
fill_color->g = (unsigned char)G;
fill_color->b = (unsigned char)B;
Modified: grass/trunk/display/d.graph/graphics.c
===================================================================
--- grass/trunk/display/d.graph/graphics.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.graph/graphics.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/display/d.graph/main.c
===================================================================
--- grass/trunk/display/d.graph/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.graph/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
@@ -100,7 +101,7 @@
/* Parse and select color */
if (opt2->answer != NULL) {
- color = G_str_to_color(opt2->answer, &R, &G, &B);
+ color = Rast_str_to_color(opt2->answer, &R, &G, &B);
if (color == 0)
G_fatal_error(_("[%s]: No such color"), opt2->answer);
Modified: grass/trunk/display/d.grid/fiducial.c
===================================================================
--- grass/trunk/display/d.grid/fiducial.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.grid/fiducial.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/symbol.h>
#include <grass/colors.h>
@@ -33,7 +34,7 @@
if (D_color_number_to_RGB(color, &R, &G, &B) == 0)
/* fall back to black on failure */
- G_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B);
+ Rast_str_to_color(DEFAULT_FG_COLOR, &R, &G, &B);
line_color->r = (unsigned char)R;
line_color->g = (unsigned char)G;
Modified: grass/trunk/display/d.grid/main.c
===================================================================
--- grass/trunk/display/d.grid/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.grid/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/gprojects.h>
Modified: grass/trunk/display/d.grid/plot.c
===================================================================
--- grass/trunk/display/d.grid/plot.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.grid/plot.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/gprojects.h>
Modified: grass/trunk/display/d.grid/plotborder.c
===================================================================
--- grass/trunk/display/d.grid/plotborder.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.grid/plotborder.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
int plot_border(double grid_size, double east, double north)
Modified: grass/trunk/display/d.his/his.c
===================================================================
--- grass/trunk/display/d.his/his.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.his/his.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "his.h"
/****************************************************************************
@@ -65,10 +66,10 @@
{
int i;
- G_init_colors(gray);
+ Rast_init_colors(gray);
for (i = 0; i < 256; i++)
- G_set_color((CELL) i, i, i, i, gray);
+ Rast_set_color((CELL) i, i, i, i, gray);
return 0;
}
Modified: grass/trunk/display/d.his/main.c
===================================================================
--- grass/trunk/display/d.his/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.his/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
@@ -121,7 +122,7 @@
name_h = opt_h->answer;
/* Make sure map is available */
- if ((hue_file = G_open_cell_old(name_h, "")) == -1)
+ if ((hue_file = Rast_open_cell_old(name_h, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name_h);
hue_r = G_malloc(window.cols);
@@ -132,7 +133,7 @@
dummy = G_malloc(window.cols);
/* Reading color lookup table */
- if (G_read_colors(name_h, "", &hue_colors) == -1)
+ if (Rast_read_colors(name_h, "", &hue_colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name_h);
int_used = 0;
@@ -143,14 +144,14 @@
int_used = 1;
/* Make sure map is available */
- if ((int_file = G_open_cell_old(name_i, "")) == -1)
+ if ((int_file = Rast_open_cell_old(name_i, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name_i);
int_r = G_malloc(window.cols);
int_n = G_malloc(window.cols);
/* Reading color lookup table */
- if (G_read_colors(name_i, "", &int_colors) == -1)
+ if (Rast_read_colors(name_i, "", &int_colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name_i);
}
@@ -162,20 +163,20 @@
sat_used = 1;
/* Make sure map is available */
- if ((sat_file = G_open_cell_old(name_s, "")) == -1)
+ if ((sat_file = Rast_open_cell_old(name_s, "")) == -1)
G_fatal_error("Unable to open raster map <%s>", name_s);
sat_r = G_malloc(window.cols);
sat_n = G_malloc(window.cols);
/* Reading color lookup table */
- if (G_read_colors(name_s, "", &sat_colors) == -1)
+ if (Rast_read_colors(name_s, "", &sat_colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name_s);
}
- r_array = G_allocate_cell_buf();
- g_array = G_allocate_cell_buf();
- b_array = G_allocate_cell_buf();
+ r_array = Rast_allocate_cell_buf();
+ g_array = Rast_allocate_cell_buf();
+ b_array = Rast_allocate_cell_buf();
/* Make color table */
make_gray_scale(&gray_colors);
@@ -190,17 +191,17 @@
for (atrow = 0; atrow < window.rows;) {
G_percent(atrow, window.rows, 2);
- if (G_get_raster_row_colors
+ if (Rast_get_raster_row_colors
(hue_file, atrow, &hue_colors, hue_r, hue_g, hue_b, hue_n) < 0)
G_fatal_error(_("Error reading hue data"));
if (int_used &&
- (G_get_raster_row_colors
+ (Rast_get_raster_row_colors
(int_file, atrow, &int_colors, int_r, dummy, dummy, int_n) < 0))
G_fatal_error(_("Error reading intensity data"));
if (sat_used &&
- (G_get_raster_row_colors
+ (Rast_get_raster_row_colors
(sat_file, atrow, &sat_colors, sat_r, dummy, dummy, sat_n) < 0))
G_fatal_error(_("Error reading saturation data"));
@@ -209,9 +210,9 @@
if (hue_n[atcol]
|| (int_used && int_n[atcol])
|| (sat_used && sat_n[atcol])) {
- G_set_c_null_value(&r_array[atcol], 1);
- G_set_c_null_value(&g_array[atcol], 1);
- G_set_c_null_value(&b_array[atcol], 1);
+ Rast_set_c_null_value(&r_array[atcol], 1);
+ Rast_set_c_null_value(&g_array[atcol], 1);
+ Rast_set_c_null_value(&b_array[atcol], 1);
continue;
}
}
@@ -246,11 +247,11 @@
R_close_driver();
/* Close the raster maps */
- G_close_cell(hue_file);
+ Rast_close_cell(hue_file);
if (int_used)
- G_close_cell(int_file);
+ Rast_close_cell(int_file);
if (sat_used)
- G_close_cell(sat_file);
+ Rast_close_cell(sat_file);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/display/d.histogram/bar.c
===================================================================
--- grass/trunk/display/d.histogram/bar.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.histogram/bar.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -27,8 +27,11 @@
*/
#include <string.h>
+
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
+
#include "bar.h"
int bar(struct stat_list *dist_stats, /* list of distribution statistics */
@@ -102,9 +105,9 @@
max_tics--;
i = 0;
if (is_fp) {
- G_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
- if (G_is_d_null_value(&range_dmin) ||
- G_is_d_null_value(&range_dmax))
+ Rast_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
+ if (Rast_is_d_null_value(&range_dmin) ||
+ Rast_is_d_null_value(&range_dmax))
G_fatal_error("Floating point data range is empty");
if ((range_dmax - range_dmin) < 1.0)
@@ -124,9 +127,9 @@
}
else {
if (is_fp && !cat_ranges) {
- G_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
- if (G_is_d_null_value(&range_dmin) ||
- G_is_d_null_value(&range_dmax))
+ Rast_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
+ if (Rast_is_d_null_value(&range_dmin) ||
+ Rast_is_d_null_value(&range_dmax))
G_fatal_error("Floating point data range is empty");
}
tic_every = 1;
@@ -160,7 +163,7 @@
draw = NO;
else {
draw = YES;
- G_set_c_null_value(&bar_color, 1);
+ Rast_set_c_null_value(&bar_color, 1);
bar_height =
(yoffset - yscale * (double)dist_stats->null_stat);
}
@@ -212,9 +215,9 @@
if (draw == YES) {
if (xscale != 1) {
/* draw the bar as a box */
- if (!G_is_c_null_value(&bar_color) && is_fp) {
+ if (!Rast_is_c_null_value(&bar_color) && is_fp) {
if (cat_ranges)
- G_get_ith_d_raster_cat(&cats, bar_color,
+ Rast_get_ith_d_raster_cat(&cats, bar_color,
&dmin, &dmax);
else {
dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
@@ -267,7 +270,7 @@
/* draw the bar as a line */
if (is_fp) {
if (cat_ranges)
- G_get_ith_d_raster_cat(&cats, bar_color,
+ Rast_get_ith_d_raster_cat(&cats, bar_color,
&dmin, &dmax);
else {
dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
Modified: grass/trunk/display/d.histogram/draw_slice.c
===================================================================
--- grass/trunk/display/d.histogram/draw_slice.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.histogram/draw_slice.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
char percent[] = "%";
Modified: grass/trunk/display/d.histogram/get_stats.c
===================================================================
--- grass/trunk/display/d.histogram/get_stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.histogram/get_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
#include <stdarg.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "options.h"
#include "dhist.h"
@@ -50,17 +51,17 @@
/* write stats to a temp file */
tempfile = G_tempfile();
- is_fp = G_raster_map_is_fp(mapname, "");
+ is_fp = Rast_raster_map_is_fp(mapname, "");
if (is_fp) {
if (cat_ranges) {
- if (G_read_raster_cats(mapname, "", &cats) < 0)
+ if (Rast_read_raster_cats(mapname, "", &cats) < 0)
G_fatal_error("Can't read category file");
- if (G_number_of_raster_cats(&cats) <= 0) {
+ if (Rast_number_of_raster_cats(&cats) <= 0) {
G_warning("There are no labeled cats, using nsteps argument");
cat_ranges = 0;
}
}
- if (G_read_fp_range(map_name, "", &fp_range) <= 0)
+ if (Rast_read_fp_range(map_name, "", &fp_range) <= 0)
G_fatal_error("Can't read frange file");
}
if (cat_ranges) {
Modified: grass/trunk/display/d.histogram/main.c
===================================================================
--- grass/trunk/display/d.histogram/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.histogram/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
@@ -168,13 +169,13 @@
nodata = flag1->answer;
quiet = flag2->answer ? YES : NO;
- if (G_read_colors(map_name, "", &pcolors) == -1)
+ if (Rast_read_colors(map_name, "", &pcolors) == -1)
G_fatal_error(_("Color file for <%s> not available"), map_name);
- if (G_read_cats(map_name, "", &cats) == -1)
+ if (Rast_read_cats(map_name, "", &cats) == -1)
G_fatal_error(_("Category file for <%s> not available"), map_name);
- if (G_read_range(map_name, "", &range) == -1)
+ if (Rast_read_range(map_name, "", &range) == -1)
G_fatal_error(_("Range information for <%s> not available"),
map_name);
Modified: grass/trunk/display/d.histogram/pie.c
===================================================================
--- grass/trunk/display/d.histogram/pie.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.histogram/pie.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -29,8 +29,11 @@
*/
#include <string.h>
+
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
+
#include "pie.h"
/*#define DEBUG */
@@ -108,9 +111,9 @@
max_tics = (x_line[2] - x_line[1]) / XTIC_DIST;
i = 0;
if (is_fp) {
- G_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
- if (G_is_d_null_value(&range_dmin) ||
- G_is_d_null_value(&range_dmax))
+ Rast_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
+ if (Rast_is_d_null_value(&range_dmin) ||
+ Rast_is_d_null_value(&range_dmax))
G_fatal_error("Floating point data range is empty");
while ((range_dmax - range_dmin) / tics[i].every > max_tics)
@@ -125,9 +128,9 @@
}
else {
if (is_fp && !cat_ranges) {
- G_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
- if (G_is_d_null_value(&range_dmin) ||
- G_is_d_null_value(&range_dmax))
+ Rast_get_fp_range_min_max(&fp_range, &range_dmin, &range_dmax);
+ if (Rast_is_d_null_value(&range_dmin) ||
+ Rast_is_d_null_value(&range_dmax))
G_fatal_error("Floating point data range is empty");
}
tic_every = 1;
@@ -165,7 +168,7 @@
draw = NO;
else {
draw = YES;
- G_set_d_null_value(&dval, 1);
+ Rast_set_d_null_value(&dval, 1);
arc = 360.0 *((double)dist_stats->null_stat
/ (double)dist_stats->sumstat);
draw_slice_filled(colors, dval, color, ORIGIN_X,
@@ -185,7 +188,7 @@
draw = YES;
if (is_fp) {
if (cat_ranges)
- G_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
+ Rast_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
else {
dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
@@ -225,7 +228,7 @@
draw = YES;
if (is_fp) {
if (cat_ranges)
- G_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
+ Rast_get_ith_d_raster_cat(&cats, (CELL) i, &dmin, &dmax);
else {
dmin = range_dmin + i * (range_dmax - range_dmin) / nsteps;
dmax = range_dmin + (i + 1) * (range_dmax - range_dmin) / nsteps;
Modified: grass/trunk/display/d.labels/color.c
===================================================================
--- grass/trunk/display/d.labels/color.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.labels/color.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
/** ??? move these into libgis ??? (libraster for set_color_from_RGBA()) **/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/glocale.h>
@@ -52,7 +53,7 @@
int r, g, b;
int ret;
- ret = G_str_to_color(clr_str, &r, &g, &b);
+ ret = Rast_str_to_color(clr_str, &r, &g, &b);
if (ret == 1) {
color->a = RGBA_COLOR_OPAQUE;
Modified: grass/trunk/display/d.labels/do_labels.c
===================================================================
--- grass/trunk/display/d.labels/do_labels.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.labels/do_labels.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
Modified: grass/trunk/display/d.labels/main.c
===================================================================
--- grass/trunk/display/d.labels/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.labels/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include "local_proto.h"
Modified: grass/trunk/display/d.legend/main.c
===================================================================
--- grass/trunk/display/d.legend/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.legend/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -29,6 +29,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/glocale.h>
@@ -243,20 +244,20 @@
}
- if (G_read_colors(map_name, "", &colors) == -1)
+ if (Rast_read_colors(map_name, "", &colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), map_name);
- fp = G_raster_map_is_fp(map_name, "");
+ fp = Rast_raster_map_is_fp(map_name, "");
if (fp && !use_catlist) {
do_smooth = TRUE;
/* fprintf(stderr, "FP map found - switching gradient legend on\n"); */
flip = !flip;
}
- if (G_read_cats(map_name, "", &cats) == -1)
+ if (Rast_read_cats(map_name, "", &cats) == -1)
G_warning(_("Category file for <%s> not available"), map_name);
- G_set_c_null_value(&null_cell, 1);
+ Rast_set_c_null_value(&null_cell, 1);
if (R_open_driver() != 0)
G_fatal_error(_("No graphics device selected"));
@@ -318,15 +319,15 @@
/* How many categories to show */
if (!fp) {
- if (G_read_range(map_name, "", &range) == -1)
+ if (Rast_read_range(map_name, "", &range) == -1)
G_fatal_error(_("Range information for <%s> not available (run r.support)"),
map_name);
- G_get_range_min_max(&range, &min_ind, &max_ind);
- if (G_is_c_null_value(&min_ind))
+ Rast_get_range_min_max(&range, &min_ind, &max_ind);
+ if (Rast_is_c_null_value(&min_ind))
G_fatal_error(_("Input map contains no data"));
- G_get_color_range(&min_colr, &max_colr, &colors);
+ Rast_get_color_range(&min_colr, &max_colr, &colors);
if (UserRange) {
if (min_ind < UserRangeMin)
@@ -371,9 +372,9 @@
for (i = min_ind, j = 1, k = 0; j <= do_cats && i <= max_ind;
j++, i += thin) {
if (!flip)
- cstr = G_get_cat(i, &cats);
+ cstr = Rast_get_cat(i, &cats);
else
- cstr = G_get_cat((max_ind - (i - min_ind)), &cats);
+ cstr = Rast_get_cat((max_ind - (i - min_ind)), &cats);
if (!use_catlist)
catlist[j - 1] = (double)i;
@@ -404,7 +405,7 @@
opt8->answers[i], min_ind, max_ind);
}
- cstr = G_get_cat(catlist[i], &cats);
+ cstr = Rast_get_cat(catlist[i], &cats);
if (!cstr[0]) { /* no cat label found, skip str output */
if (hide_nodata)
continue;
@@ -464,7 +465,7 @@
}
/* R_text_size((int)(dots_per_line*4/5), (int)(dots_per_line*4/5)) ; redundant */
- /* if(G_is_c_null_value(&min_ind) && G_is_c_null_value(&max_ind))
+ /* if(Rast_is_c_null_value(&min_ind) && Rast_is_c_null_value(&max_ind))
{
min_ind = 1;
max_ind = 0;
@@ -480,13 +481,13 @@
}
}
else { /* is fp */
- if (G_read_fp_range(map_name, "", &fprange) == -1)
+ if (Rast_read_fp_range(map_name, "", &fprange) == -1)
G_fatal_error(_("Range information for <%s> not available"),
map_name);
- G_get_fp_range_min_max(&fprange, &dmin, &dmax);
+ Rast_get_fp_range_min_max(&fprange, &dmin, &dmax);
- G_get_d_color_range(&min_dcolr, &max_dcolr, &colors);
+ Rast_get_d_color_range(&min_dcolr, &max_dcolr, &colors);
if (UserRange) {
if (dmin < UserRangeMin)
@@ -603,7 +604,7 @@
max_ind - k * (double)(max_ind - min_ind) / (steps -
1);
- cstr = G_get_cat(tcell, &cats);
+ cstr = Rast_get_cat(tcell, &cats);
if (!cstr[0]) /* no cats found, disable str output */
hide_catstr = 1;
else
@@ -779,9 +780,9 @@
/* for(i=min_ind, j=1, k=0; j<=do_cats && i<=max_ind; j++, i+=thin) */
{
if (!flip)
- cstr = G_get_cat(catlist[i], &cats);
+ cstr = Rast_get_cat(catlist[i], &cats);
else
- cstr = G_get_cat(catlist[catlistCount - i - 1], &cats);
+ cstr = Rast_get_cat(catlist[catlistCount - i - 1], &cats);
if (!cstr[0]) { /* no cat label found, skip str output */
Modified: grass/trunk/display/d.nviz/main.c
===================================================================
--- grass/trunk/display/d.nviz/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.nviz/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <math.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include "local.h"
@@ -178,7 +179,7 @@
/* Open Raster File */
if (NULL == (mapset = G_find_cell2(name, "")))
G_fatal_error(_("Raster map <%s> not found"), name);
- if (0 > (fd = G_open_cell_old(name, mapset)))
+ if (0 > (fd = Rast_open_cell_old(name, mapset)))
G_fatal_error(_("Unable to open raster map <%s>"), name);
/* Set Image name */
@@ -199,7 +200,7 @@
G_fatal_error(_("Unable to open file <%s>"), outfile);
/* Get Raster Type */
- data_type = G_get_raster_map_type(fd);
+ data_type = Rast_get_raster_map_type(fd);
/* Done with file */
/* Output initial startup stuff */
@@ -315,7 +316,7 @@
fprintf(fp, "SendScriptLine \"set ScriptPlaying 0\"\n");
fprintf(fp, "puts \"DONE!\"\n");
- G_close_cell(fd);
+ Rast_close_cell(fd);
fclose(fp);
sprintf(buf1, _("Created NVIZ script <%s>."), outfile);
@@ -442,31 +443,31 @@
if (data_type == CELL_TYPE) {
- cell = G_allocate_c_raster_buf();
- if (G_get_c_raster_row(fd, cell, row) < 0)
+ cell = Rast_allocate_c_raster_buf();
+ if (Rast_get_c_raster_row(fd, cell, row) < 0)
exit(1);
- if (G_is_c_null_value(&cell[col]))
+ if (Rast_is_c_null_value(&cell[col]))
camera_height = (double)9999.;
else
camera_height = (double)cell[col];
}
if (data_type == FCELL_TYPE) {
- fcell = G_allocate_f_raster_buf();
- if (G_get_f_raster_row(fd, fcell, row) < 0)
+ fcell = Rast_allocate_f_raster_buf();
+ if (Rast_get_f_raster_row(fd, fcell, row) < 0)
exit(1);
- if (G_is_f_null_value(&fcell[col]))
+ if (Rast_is_f_null_value(&fcell[col]))
camera_height = (double)9999.;
else
camera_height = (double)fcell[col];
}
if (data_type == DCELL_TYPE) {
- dcell = G_allocate_d_raster_buf();
- if (G_get_d_raster_row(fd, dcell, row) < 0)
+ dcell = Rast_allocate_d_raster_buf();
+ if (Rast_get_d_raster_row(fd, dcell, row) < 0)
exit(1);
- if (G_is_d_null_value(&dcell[col]))
+ if (Rast_is_d_null_value(&dcell[col]))
camera_height = (double)9999.;
else
camera_height = (double)dcell[col];
Modified: grass/trunk/display/d.path/main.c
===================================================================
--- grass/trunk/display/d.path/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.path/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/colors.h>
@@ -152,21 +153,21 @@
G_fatal_error(_("No graphics device selected"));
color = G_standard_color_rgb(BLACK);
- if (G_str_to_color(color_opt->answer, &r, &g, &b)) {
+ if (Rast_str_to_color(color_opt->answer, &r, &g, &b)) {
color.r = r;
color.g = g;
color.b = b;
}
hcolor = G_standard_color_rgb(RED);
- if (G_str_to_color(hcolor_opt->answer, &r, &g, &b)) {
+ if (Rast_str_to_color(hcolor_opt->answer, &r, &g, &b)) {
hcolor.r = r;
hcolor.g = g;
hcolor.b = b;
}
bgcolor = G_standard_color_rgb(WHITE);
- if (G_str_to_color(bgcolor_opt->answer, &r, &g, &b)) {
+ if (Rast_str_to_color(bgcolor_opt->answer, &r, &g, &b)) {
bgcolor.r = r;
bgcolor.g = g;
bgcolor.b = b;
Modified: grass/trunk/display/d.path/select.c
===================================================================
--- grass/trunk/display/d.path/select.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.path/select.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/Vect.h>
Modified: grass/trunk/display/d.profile/main.c
===================================================================
--- grass/trunk/display/d.profile/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.profile/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/glocale.h>
@@ -38,7 +39,7 @@
static void get_region_range(int fd)
{
- DCELL *buf = G_allocate_d_raster_buf();
+ DCELL *buf = Rast_allocate_d_raster_buf();
int nrows = G_window_rows();
int ncols = G_window_cols();
int row, col;
@@ -47,7 +48,7 @@
max = -1e300;
for (row = 0; row < nrows; row++) {
- G_get_d_raster_row(fd, buf, row);
+ Rast_get_d_raster_row(fd, buf, row);
for (col = 0; col < ncols; col++) {
if (min > buf[col])
min = buf[col];
@@ -59,14 +60,14 @@
static void get_map_range(void)
{
- if (G_raster_map_type(mapname, "") == CELL_TYPE) {
+ if (Rast_raster_map_type(mapname, "") == CELL_TYPE) {
struct Range range;
CELL xmin, xmax;
- if (G_read_range(mapname, "", &range) <= 0)
+ if (Rast_read_range(mapname, "", &range) <= 0)
G_fatal_error(_("Unable to read range for %s"), mapname);
- G_get_range_min_max(&range, &xmin, &xmax);
+ Rast_get_range_min_max(&range, &xmin, &xmax);
max = xmax;
min = xmin;
@@ -74,10 +75,10 @@
else {
struct FPRange fprange;
- if (G_read_fp_range(mapname, "", &fprange) <= 0)
+ if (Rast_read_fp_range(mapname, "", &fprange) <= 0)
G_fatal_error(_("Unable to read FP range for %s"), mapname);
- G_get_fp_range_min_max(&fprange, &min, &max);
+ Rast_get_fp_range_min_max(&fprange, &min, &max);
}
}
@@ -123,8 +124,8 @@
DCELL *tmp;
if (!row1) {
- row1 = G_allocate_d_raster_buf();
- row2 = G_allocate_d_raster_buf();
+ row1 = Rast_allocate_d_raster_buf();
+ row2 = Rast_allocate_d_raster_buf();
}
col = (int)floor(x - 0.5);
@@ -134,33 +135,33 @@
if (row < 0 || row + 1 >= G_window_rows() ||
col < 0 || col + 1 >= G_window_cols()) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return 0;
}
if (cur_row != row) {
if (cur_row == row + 1) {
tmp = row1; row1 = row2; row2 = tmp;
- G_get_d_raster_row(fd, row1, row);
+ Rast_get_d_raster_row(fd, row1, row);
}
else if (cur_row == row - 1) {
tmp = row1; row1 = row2; row2 = tmp;
- G_get_d_raster_row(fd, row2, row + 1);
+ Rast_get_d_raster_row(fd, row2, row + 1);
}
else {
- G_get_d_raster_row(fd, row1, row);
- G_get_d_raster_row(fd, row2, row + 1);
+ Rast_get_d_raster_row(fd, row1, row);
+ Rast_get_d_raster_row(fd, row2, row + 1);
}
cur_row = row;
}
- if (G_is_d_null_value(&row1[col]) || G_is_d_null_value(&row1[col+1]) ||
- G_is_d_null_value(&row2[col]) || G_is_d_null_value(&row2[col+1])) {
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&row1[col]) || Rast_is_d_null_value(&row1[col+1]) ||
+ Rast_is_d_null_value(&row2[col]) || Rast_is_d_null_value(&row2[col+1])) {
+ Rast_set_d_null_value(result, 1);
return 0;
}
- *result = G_interp_bilinear(x, y,
+ *result = Rast_interp_bilinear(x, y,
row1[col], row1[col+1],
row2[col], row2[col+1]);
@@ -211,7 +212,7 @@
mapname = map->answer;
- fd = G_open_cell_old(mapname, "");
+ fd = Rast_open_cell_old(mapname, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), mapname);
Modified: grass/trunk/display/d.rast/display.c
===================================================================
--- grass/trunk/display/d.rast/display.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.rast/display.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,11 +1,15 @@
#include <stdlib.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
+#include <grass/glocale.h>
+
#include "mask.h"
#include "local_proto.h"
-#include <grass/glocale.h>
+
static int cell_draw(const char *, struct Colors *, int, int, RASTER_MAP_TYPE);
int display(const char *name,
@@ -15,15 +19,15 @@
struct Colors colors;
int r, g, b;
- if (G_read_colors(name, "", &colors) == -1)
+ if (Rast_read_colors(name, "", &colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name);
if (bg) {
- if (G_str_to_color(bg, &r, &g, &b) != 1) {
+ if (Rast_str_to_color(bg, &r, &g, &b) != 1) {
G_warning(_("[%s]: No such color"), bg);
r = g = b = 255;
}
- G_set_null_value_color(r, g, b, &colors);
+ Rast_set_null_value_color(r, g, b, &colors);
}
D_setup(0);
@@ -32,7 +36,7 @@
cell_draw(name, &colors, overlay, invert, data_type);
/* release the colors now */
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
return 0;
}
@@ -54,11 +58,11 @@
D_set_overlay_mode(overlay);
/* Make sure map is available */
- if ((cellfile = G_open_cell_old(name, "")) == -1)
+ if ((cellfile = Rast_open_cell_old(name, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name);
/* Allocate space for cell buffer */
- xarray = G_allocate_raster_buf(data_type);
+ xarray = Rast_allocate_raster_buf(data_type);
D_cell_draw_begin();
@@ -66,7 +70,7 @@
for (cur_A_row = 0; cur_A_row != -1;) {
G_percent(cur_A_row, nrows, 2);
/* Get window (array) row currently required */
- G_get_raster_row(cellfile, xarray, cur_A_row, data_type);
+ Rast_get_raster_row(cellfile, xarray, cur_A_row, data_type);
mask_raster_array(xarray, ncols, invert, data_type);
/* Draw the cell row, and get the next row number */
@@ -78,7 +82,7 @@
G_percent(nrows, nrows, 2);
/* Wrap up and return */
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
G_free(xarray);
return (0);
}
Modified: grass/trunk/display/d.rast/main.c
===================================================================
--- grass/trunk/display/d.rast/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.rast/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
*****************************************************************************/
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include "mask.h"
@@ -103,7 +104,7 @@
if (R_open_driver() != 0)
G_fatal_error(_("No graphics device selected"));
- fp = G_raster_map_is_fp(name, "");
+ fp = Rast_raster_map_is_fp(name, "");
if (catlist->answer) {
if (fp)
G_warning(_("Ignoring catlist: map is floating point (please use 'val=')"));
Modified: grass/trunk/display/d.rast/mask.c
===================================================================
--- grass/trunk/display/d.rast/mask.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.rast/mask.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "mask.h"
#include "local_proto.h"
@@ -50,7 +51,7 @@
if (mask_select(&x, mask, invert))
*cell++ = x;
else
- G_set_c_null_value(cell++, 1);
+ Rast_set_c_null_value(cell++, 1);
}
return 0;
}
@@ -64,7 +65,7 @@
if (mask_d_select(&x, mask, invert))
*dcell++ = x;
else
- G_set_d_null_value(dcell++, 1);
+ Rast_set_d_null_value(dcell++, 1);
}
return 0;
}
Modified: grass/trunk/display/d.rast.arrow/main.c
===================================================================
--- grass/trunk/display/d.rast.arrow/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.rast.arrow/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -38,6 +38,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/colors.h>
@@ -231,7 +232,7 @@
if (align->answer) {
struct Cell_head wind;
- if (G_get_cellhd(layer_name, "", &wind) < 0)
+ if (Rast_get_cellhd(layer_name, "", &wind) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), layer_name);
/* expand window extent by one wind resolution */
@@ -267,10 +268,10 @@
/* figure out arrow scaling if using a magnitude map */
if (opt7->answer) {
- G_init_fp_range(&range); /* really needed? */
- if (G_read_fp_range(mag_map, "", &range) != 1)
+ Rast_init_fp_range(&range); /* really needed? */
+ if (Rast_read_fp_range(mag_map, "", &range) != 1)
G_fatal_error(_("Problem reading range file"));
- G_get_fp_range_min_max(&range, &mag_min, &mag_max);
+ Rast_get_fp_range_min_max(&range, &mag_min, &mag_max);
scale *= 1.5 / fabs(mag_max);
G_debug(3, "scaling=%.2f rast_max=%.2f", scale, mag_max);
@@ -290,26 +291,26 @@
}
/* open the raster map */
- layer_fd = G_open_cell_old(layer_name, "");
+ layer_fd = Rast_open_cell_old(layer_name, "");
if (layer_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), layer_name);
- raster_type = G_get_raster_map_type(layer_fd);
+ raster_type = Rast_get_raster_map_type(layer_fd);
/* allocate the cell array */
- raster_row = G_allocate_raster_buf(raster_type);
+ raster_row = Rast_allocate_raster_buf(raster_type);
if (opt7->answer) {
/* open the magnitude raster map */
- mag_fd = G_open_cell_old(mag_map, "");
+ mag_fd = Rast_open_cell_old(mag_map, "");
if (mag_fd < 0)
G_fatal_error("Unable to open raster map <%s>", mag_map);
- mag_raster_type = G_get_raster_map_type(mag_fd);
+ mag_raster_type = Rast_get_raster_map_type(mag_fd);
/* allocate the cell array */
- mag_raster_row = G_allocate_raster_buf(mag_raster_type);
+ mag_raster_row = Rast_allocate_raster_buf(mag_raster_type);
}
@@ -317,11 +318,11 @@
and call appropriate function to draw an arrow on the cell */
for (row = 0; row < nrows; row++) {
- G_get_raster_row(layer_fd, raster_row, row, raster_type);
+ Rast_get_raster_row(layer_fd, raster_row, row, raster_type);
ptr = raster_row;
if (opt7->answer) {
- G_get_raster_row(mag_fd, mag_raster_row, row, mag_raster_type);
+ Rast_get_raster_row(mag_fd, mag_raster_row, row, mag_raster_type);
mag_ptr = mag_raster_row;
}
@@ -355,7 +356,7 @@
length *= scale;
- if (G_is_null_value(mag_ptr, mag_raster_type)) {
+ if (Rast_is_null_value(mag_ptr, mag_raster_type)) {
G_debug(5, "Invalid arrow length [NULL]. Skipping.");
no_arrow = TRUE;
}
@@ -367,11 +368,11 @@
}
if (no_arrow) {
- ptr = G_incr_void_ptr(ptr, G_raster_size(raster_type));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(raster_type));
if (opt7->answer)
mag_ptr =
- G_incr_void_ptr(mag_ptr,
- G_raster_size(mag_raster_type));
+ Rast_incr_void_ptr(mag_ptr,
+ Rast_raster_size(mag_raster_type));
no_arrow = FALSE;
continue;
}
@@ -379,7 +380,7 @@
/* treat AGNPS and ANSWERS data like old zero-as-null CELL */
/* TODO: update models */
if (map_type == 2 || map_type == 3) {
- if (G_is_null_value(ptr, raster_type))
+ if (Rast_is_null_value(ptr, raster_type))
aspect_c = 0;
else
aspect_c = (int)(aspect_f + 0.5);
@@ -393,7 +394,7 @@
if (map_type == 1) {
D_use_color(arrow_color);
- if (G_is_null_value(ptr, raster_type)) {
+ if (Rast_is_null_value(ptr, raster_type)) {
D_use_color(x_color);
draw_x();
D_use_color(arrow_color);
@@ -476,7 +477,7 @@
else if (map_type == 4) {
D_use_color(arrow_color);
- if (G_is_null_value(ptr, raster_type)) {
+ if (Rast_is_null_value(ptr, raster_type)) {
D_use_color(x_color);
draw_x();
D_use_color(arrow_color);
@@ -494,16 +495,16 @@
}
}
- ptr = G_incr_void_ptr(ptr, G_raster_size(raster_type));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(raster_type));
if (opt7->answer)
mag_ptr =
- G_incr_void_ptr(mag_ptr, G_raster_size(mag_raster_type));
+ Rast_incr_void_ptr(mag_ptr, Rast_raster_size(mag_raster_type));
}
}
- G_close_cell(layer_fd);
+ Rast_close_cell(layer_fd);
if (opt7->answer)
- G_close_cell(mag_fd);
+ Rast_close_cell(mag_fd);
R_close_driver();
Modified: grass/trunk/display/d.rast.num/main.c
===================================================================
--- grass/trunk/display/d.rast.num/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.rast.num/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -38,6 +38,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/colors.h>
@@ -126,12 +127,12 @@
else
fixed_color = 1;
- layer_fd = G_open_cell_old(map_name, "");
+ layer_fd = Rast_open_cell_old(map_name, "");
if (layer_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), map_name);
/* determine the inputmap type (CELL/FCELL/DCELL) */
- inmap_type = G_get_raster_map_type(layer_fd);
+ inmap_type = Rast_get_raster_map_type(layer_fd);
map_type = DCELL_TYPE;
/* Read in the map window associated with window */
@@ -141,7 +142,7 @@
if (align->answer) {
struct Cell_head wind;
- if (G_get_cellhd(map_name, "", &wind) < 0)
+ if (Rast_get_cellhd(map_name, "", &wind) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), map_name);
/* expand window extent by one wind resolution */
@@ -216,10 +217,10 @@
}
/* allocate the cell array */
- cell = G_allocate_raster_buf(map_type);
+ cell = Rast_allocate_raster_buf(map_type);
/* read the color table in the color structures of the displayed map */
- if (G_read_colors(map_name, "", &colors) == -1)
+ if (Rast_read_colors(map_name, "", &colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), map_name);
/* fixed text color */
@@ -228,12 +229,12 @@
/* loop through cells, find value, and draw text for value */
for (row = 0; row < nrows; row++) {
- G_get_raster_row(layer_fd, cell, row, map_type);
+ Rast_get_raster_row(layer_fd, cell, row, map_type);
for (col = 0; col < ncols; col++) {
if (fixed_color == 0) {
- G_get_raster_color(&cell[col], &R, &G, &B, &colors, map_type);
+ Rast_get_raster_color(&cell[col], &R, &G, &B, &colors, map_type);
D_RGB_color(R, G, B);
}
@@ -241,7 +242,7 @@
}
}
- G_close_cell(layer_fd);
+ Rast_close_cell(layer_fd);
R_close_driver();
@@ -264,13 +265,13 @@
/* maybe ugly, but works */
if (map_type == CELL_TYPE) {
- if (!G_is_c_null_value(&cell))
+ if (!Rast_is_c_null_value(&cell))
sprintf(no, "%d", (int)number);
else
sprintf(no, "Null");
}
else {
- if (!G_is_d_null_value(&dcell))
+ if (!Rast_is_d_null_value(&dcell))
sprintf(no, "%.*f", prec, number);
else
sprintf(no, "Null");
Modified: grass/trunk/display/d.rgb/main.c
===================================================================
--- grass/trunk/display/d.rgb/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.rgb/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
@@ -89,16 +90,16 @@
char *name = B[i].opt->answer;
/* Make sure map is available */
- if ((B[i].file = G_open_cell_old(name, "")) == -1)
+ if ((B[i].file = Rast_open_cell_old(name, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- B[i].type = G_get_raster_map_type(B[i].file);
+ B[i].type = Rast_get_raster_map_type(B[i].file);
/* Reading color lookup table */
- if (G_read_colors(name, "", &B[i].colors) == -1)
+ if (Rast_read_colors(name, "", &B[i].colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name);
- B[i].array = G_allocate_raster_buf(B[i].type);
+ B[i].array = Rast_allocate_raster_buf(B[i].type);
}
/* read in current window */
@@ -111,7 +112,7 @@
G_percent(row, window.rows, 5);
for (i = 0; i < 3; i++)
- if (G_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
+ if (Rast_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
G_fatal_error(_("Error reading row of data"));
if (row == next_row)
@@ -132,7 +133,7 @@
/* Close the raster maps */
for (i = 0; i < 3; i++)
- G_close_cell(B[i].file);
+ Rast_close_cell(B[i].file);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/display/d.thematic.area/area.c
===================================================================
--- grass/trunk/display/d.thematic.area/area.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.thematic.area/area.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
Modified: grass/trunk/display/d.thematic.area/main.c
===================================================================
--- grass/trunk/display/d.thematic.area/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.thematic.area/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <dirent.h>
#include <grass/config.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/Vect.h>
@@ -272,7 +273,7 @@
/*get border line color */
bcolor = G_standard_color_rgb(WHITE);
- ret = G_str_to_color(bcolor_opt->answer, &r, &g, &b);
+ ret = Rast_str_to_color(bcolor_opt->answer, &r, &g, &b);
if (ret == 1) {
has_color = 1;
bcolor.r = r;
@@ -347,7 +348,7 @@
G_fatal_error(_("Not enough colors or error in color specifications.\nNeed %i colors."),
nclass);
- ret = G_str_to_color(colors_opt->answers[i], &r, &g, &b);
+ ret = Rast_str_to_color(colors_opt->answers[i], &r, &g, &b);
if (!ret)
G_fatal_error(_("Error interpreting color %s"),
colors_opt->answers[i]);
Modified: grass/trunk/display/d.thematic.area/plot1.c
===================================================================
--- grass/trunk/display/d.thematic.area/plot1.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.thematic.area/plot1.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
@@ -267,7 +268,7 @@
G_debug(3, "element %d: colorstring: %s", line,
colorstring);
- if (G_str_to_color(colorstring, &red, &grn, &blu) ==
+ if (Rast_str_to_color(colorstring, &red, &grn, &blu) ==
1) {
custom_rgb = TRUE;
G_debug(3, "element:%d cat %d r:%d g:%d b:%d",
Modified: grass/trunk/display/d.title/fancy.c
===================================================================
--- grass/trunk/display/d.title/fancy.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.title/fancy.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "options.h"
void fancy(struct Cell_head *window, struct Categories *cats, FILE * fp)
Modified: grass/trunk/display/d.title/main.c
===================================================================
--- grass/trunk/display/d.title/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.title/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <grass/display.h>
#include <grass/display_raster.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "options.h"
@@ -103,11 +104,11 @@
if (!strlen(map_name))
G_fatal_error(_("No map name given"));
- if (G_get_cellhd(map_name, "", &window) == -1)
+ if (Rast_get_cellhd(map_name, "", &window) == -1)
G_fatal_error(_("Unable to read header of raster map <%s>"),
map_name);
- if (G_read_cats(map_name, "", &cats) == -1)
+ if (Rast_read_cats(map_name, "", &cats) == -1)
G_fatal_error(_("Unable to read category file of raster map <%s>"),
map_name);
Modified: grass/trunk/display/d.title/normal.c
===================================================================
--- grass/trunk/display/d.title/normal.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.title/normal.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "options.h"
#include "local_proto.h"
Modified: grass/trunk/display/d.vect/area.c
===================================================================
--- grass/trunk/display/d.vect/area.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/area.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
*/
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
@@ -242,8 +243,8 @@
area, centroid, cat, Points->x[0], Points->y[0],
Points->z[0]);
rgb = 1;
- G_make_fp_colors(&colors, style, box.B, box.T);
- G_get_raster_color(&zval, &red, &grn, &blu, &colors, DCELL_TYPE);
+ Rast_make_fp_colors(&colors, style, box.B, box.T);
+ Rast_get_raster_color(&zval, &red, &grn, &blu, &colors, DCELL_TYPE);
G_debug(3, "b %d, g: %d, r %d", blu, grn, red);
}
@@ -267,7 +268,7 @@
G_debug(3, "area %d: colorstring: %s", area,
colorstring);
- if (G_str_to_color(colorstring, &red, &grn, &blu) ==
+ if (Rast_str_to_color(colorstring, &red, &grn, &blu) ==
1) {
rgb = 1;
G_debug(3, "area:%d cat %d r:%d g:%d b:%d", area,
Modified: grass/trunk/display/d.vect/attr.c
===================================================================
--- grass/trunk/display/d.vect/attr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/attr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
Modified: grass/trunk/display/d.vect/dir.c
===================================================================
--- grass/trunk/display/d.vect/dir.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/dir.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
Modified: grass/trunk/display/d.vect/label.c
===================================================================
--- grass/trunk/display/d.vect/label.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/label.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
Modified: grass/trunk/display/d.vect/main.c
===================================================================
--- grass/trunk/display/d.vect/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/Vect.h>
@@ -392,7 +393,7 @@
}
color = G_standard_color_rgb(WHITE);
- ret = G_str_to_color(color_opt->answer, &r, &g, &b);
+ ret = Rast_str_to_color(color_opt->answer, &r, &g, &b);
if (ret == 1) {
has_color = 1;
color.r = r;
@@ -407,7 +408,7 @@
}
fcolor = G_standard_color_rgb(WHITE);
- ret = G_str_to_color(fcolor_opt->answer, &r, &g, &b);
+ ret = Rast_str_to_color(fcolor_opt->answer, &r, &g, &b);
if (ret == 1) {
has_fcolor = 1;
fcolor.r = r;
@@ -532,20 +533,20 @@
lattr.field = Clist->field;
lattr.color.R = lattr.color.G = lattr.color.B = 255;
- if (G_str_to_color(lcolor_opt->answer, &r, &g, &b)) {
+ if (Rast_str_to_color(lcolor_opt->answer, &r, &g, &b)) {
lattr.color.R = r;
lattr.color.G = g;
lattr.color.B = b;
}
lattr.has_bgcolor = 0;
- if (G_str_to_color(bgcolor_opt->answer, &r, &g, &b) == 1) {
+ if (Rast_str_to_color(bgcolor_opt->answer, &r, &g, &b) == 1) {
lattr.has_bgcolor = 1;
lattr.bgcolor.R = r;
lattr.bgcolor.G = g;
lattr.bgcolor.B = b;
}
lattr.has_bcolor = 0;
- if (G_str_to_color(bcolor_opt->answer, &r, &g, &b) == 1) {
+ if (Rast_str_to_color(bcolor_opt->answer, &r, &g, &b) == 1) {
lattr.has_bcolor = 1;
lattr.bcolor.R = r;
lattr.bcolor.G = g;
Modified: grass/trunk/display/d.vect/plot1.c
===================================================================
--- grass/trunk/display/d.vect/plot1.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/plot1.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
@@ -257,8 +258,8 @@
G_debug(3, "display line %d, cat %d, x: %f, y: %f, z: %f", line,
cat, Points->x[0], Points->y[0], Points->z[0]);
custom_rgb = TRUE;
- G_make_fp_colors(&colors, style, box.B, box.T);
- G_get_raster_color(&zval, &red, &grn, &blu, &colors, DCELL_TYPE);
+ Rast_make_fp_colors(&colors, style, box.B, box.T);
+ Rast_get_raster_color(&zval, &red, &grn, &blu, &colors, DCELL_TYPE);
G_debug(3, "b %d, g: %d, r %d", blu, grn, red);
}
@@ -284,7 +285,7 @@
G_debug(3, "element %d: colorstring: %s", line,
colorstring);
- if (G_str_to_color(colorstring, &red, &grn, &blu) ==
+ if (Rast_str_to_color(colorstring, &red, &grn, &blu) ==
1) {
custom_rgb = TRUE;
G_debug(3, "element:%d cat %d r:%d g:%d b:%d",
Modified: grass/trunk/display/d.vect/topo.c
===================================================================
--- grass/trunk/display/d.vect/topo.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/topo.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
Modified: grass/trunk/display/d.vect/utils.c
===================================================================
--- grass/trunk/display/d.vect/utils.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/utils.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
Modified: grass/trunk/display/d.vect/zcoor.c
===================================================================
--- grass/trunk/display/d.vect/zcoor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect/zcoor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
/* Print z coordinate value for each node */
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/display.h>
#include <grass/display_raster.h>
Modified: grass/trunk/display/d.vect.chart/bar.c
===================================================================
--- grass/trunk/display/d.vect.chart/bar.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect.chart/bar.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/display.h>
Modified: grass/trunk/display/d.vect.chart/main.c
===================================================================
--- grass/trunk/display/d.vect.chart/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect.chart/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
#include <grass/Vect.h>
@@ -170,7 +171,7 @@
field = atoi(field_opt->answer);
/* Outline color */
- ret = G_str_to_color(ocolor_opt->answer, &r, &g, &b);
+ ret = Rast_str_to_color(ocolor_opt->answer, &r, &g, &b);
if (ret == 1) {
ocolor.none = 0;
ocolor.r = r;
@@ -214,7 +215,7 @@
if (colors_opt->answers[i] == NULL)
break;
- ret = G_str_to_color(colors_opt->answers[i], &r, &g, &b);
+ ret = Rast_str_to_color(colors_opt->answers[i], &r, &g, &b);
if (ret == 1) {
colors[i].none = 0;
colors[i].r = r;
Modified: grass/trunk/display/d.vect.chart/pie.c
===================================================================
--- grass/trunk/display/d.vect.chart/pie.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect.chart/pie.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/display.h>
Modified: grass/trunk/display/d.vect.chart/plot.c
===================================================================
--- grass/trunk/display/d.vect.chart/plot.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.vect.chart/plot.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/display.h>
Modified: grass/trunk/display/d.what.rast/main.c
===================================================================
--- grass/trunk/display/d.what.rast/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.what.rast/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -123,7 +123,7 @@
if (j > mwidth)
mwidth = j;
- if (G_read_cats(name[i], mapset[i], &cats[i]) < 0)
+ if (Rast_read_cats(name[i], mapset[i], &cats[i]) < 0)
cats[i].ncats = -1;
}
}
Modified: grass/trunk/display/d.what.rast/opencell.c
===================================================================
--- grass/trunk/display/d.what.rast/opencell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.what.rast/opencell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,7 +19,7 @@
else
strcpy(mapset, m);
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd < 0)
G_warning(_("Unable to open raster map <%s>"), name);
Modified: grass/trunk/display/d.what.rast/show.c
===================================================================
--- grass/trunk/display/d.what.rast/show.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.what.rast/show.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,7 +19,7 @@
sprintf(buf, " ");
if (terse) {
fname = G_fully_qualified_name(name, mapset);
- if (G_is_c_null_value(&cell_val)) {
+ if (Rast_is_c_null_value(&cell_val)) {
if (!isatty(fileno(stdout)))
fprintf(stdout, "%s%s%sNull%s%s\n", fname, buf, fs, fs,
label);
@@ -33,7 +33,7 @@
}
}
else {
- if (G_is_c_null_value(&cell_val)) {
+ if (Rast_is_c_null_value(&cell_val)) {
if (!isatty(fileno(stdout)))
fprintf(stdout, "%*s in %-*s%s (Null)%s\n", width, name,
mwidth, mapset, buf, label);
@@ -63,7 +63,7 @@
dcell_val = dval;
if (terse) {
fname = G_fully_qualified_name(name, mapset);
- if (G_is_d_null_value(&dcell_val)) {
+ if (Rast_is_d_null_value(&dcell_val)) {
if (!isatty(fileno(stdout)))
fprintf(stdout, "%s, actual %sNull%s%s\n", fname, fs, fs,
label);
@@ -78,7 +78,7 @@
}
}
else {
- if (G_is_d_null_value(&dcell_val)) {
+ if (Rast_is_d_null_value(&dcell_val)) {
if (!isatty(fileno(stdout)))
fprintf(stdout, "%*s in %-*s, actual (Null)%s\n", width,
name, mwidth, mapset, label);
@@ -120,7 +120,7 @@
if (once) {
/* speed up? */
once = 0;
- G_get_cellhd(name, mapset, &cellhd);
+ Rast_get_cellhd(name, mapset, &cellhd);
}
n_row = (int)((cellhd.north - north) / window->ns_res);
Modified: grass/trunk/display/d.what.rast/what.c
===================================================================
--- grass/trunk/display/d.what.rast/what.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.what.rast/what.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,14 +23,14 @@
G_get_set_window(&window);
nrows = window.rows;
ncols = window.cols;
- buf = G_allocate_c_raster_buf();
- dbuf = G_allocate_d_raster_buf();
+ buf = Rast_allocate_c_raster_buf();
+ dbuf = Rast_allocate_d_raster_buf();
screen_x = ((int)D_get_d_west() + (int)D_get_d_east()) / 2;
screen_y = ((int)D_get_d_north() + (int)D_get_d_south()) / 2;
for (i = 0; i < nrasts; i++)
- map_type[i] = G_get_raster_map_type(fd[i]);
+ map_type[i] = Rast_get_raster_map_type(fd[i]);
do {
if (!terse)
@@ -50,19 +50,19 @@
show_utm(name[0], mapset[0], north, east, &window, terse, colrow,
button, fs);
- G_set_c_null_value(&null_cell, 1);
- G_set_d_null_value(&null_dcell, 1);
+ Rast_set_c_null_value(&null_cell, 1);
+ Rast_set_d_null_value(&null_dcell, 1);
for (i = 0; i < nrasts; i++) {
if (row < 0 || row >= nrows || col < 0 || col >= ncols) {
G_message(_("You are clicking outside the map"));
continue;
}
- if (G_get_c_raster_row(fd[i], buf, row) < 0)
+ if (Rast_get_c_raster_row(fd[i], buf, row) < 0)
show_cat(width, mwidth, name[i], mapset[i], null_cell,
"ERROR reading raster map", terse, fs, map_type[i]);
else if (map_type[i] == CELL_TYPE) {
show_cat(width, mwidth, name[i], mapset[i], buf[col],
- G_get_c_raster_cat(&buf[col], &cats[i]), terse, fs,
+ Rast_get_c_raster_cat(&buf[col], &cats[i]), terse, fs,
map_type[i]);
continue;
}
@@ -75,12 +75,12 @@
if (map_type[i] == CELL_TYPE)
continue;
- if (G_get_d_raster_row(fd[i], dbuf, row) < 0)
+ if (Rast_get_d_raster_row(fd[i], dbuf, row) < 0)
show_dval(width, mwidth, name[i], mapset[i], null_dcell,
"ERROR reading fcell file", terse, fs);
else
show_dval(width, mwidth, name[i], mapset[i], dbuf[col],
- G_get_d_raster_cat(&dbuf[col], &cats[i]), terse,
+ Rast_get_d_raster_cat(&dbuf[col], &cats[i]), terse,
fs);
}
}
Modified: grass/trunk/display/d.zoom/main.c
===================================================================
--- grass/trunk/display/d.zoom/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.zoom/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -138,7 +138,7 @@
nrasts = i;
for (i = 0; i < nrasts; i++) {
- if (G_get_cellhd(rast[i], "", &window) >= 0) {
+ if (Rast_get_cellhd(rast[i], "", &window) >= 0) {
if (first) {
first = 0;
U_east = window.east;
Modified: grass/trunk/display/d.zoom/set.c
===================================================================
--- grass/trunk/display/d.zoom/set.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/display/d.zoom/set.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -176,7 +176,7 @@
limit = print_limit(window, &defwin);
- G_adjust_Cell_head3(window, 0, 0, 0);
+ Rast_adjust_Cell_head3(window, 0, 0, 0);
G_put_window(window);
G_set_window(window);
redraw();
Modified: grass/trunk/doc/raster/r.example/main.c
===================================================================
--- grass/trunk/doc/raster/r.example/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/doc/raster/r.example/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -111,29 +111,29 @@
G_fatal_error(_("Raster map <%s> not found"), name);
/* determine the inputmap type (CELL/FCELL/DCELL) */
- data_type = G_raster_map_type(name, mapset);
+ data_type = Rast_raster_map_type(name, mapset);
- /* G_open_cell_old - returns file destriptor (>0) */
- if ((infd = G_open_cell_old(name, mapset)) < 0)
+ /* Rast_open_cell_old - returns file destriptor (>0) */
+ if ((infd = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
/* controlling, if we can open input raster */
- if (G_get_cellhd(name, mapset, &cellhd) < 0)
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0)
G_fatal_error(_("Unable to read file header of <%s>"), name);
G_debug(3, "number of rows %d", cellhd.rows);
/* Allocate input buffer */
- inrast = G_allocate_raster_buf(data_type);
+ inrast = Rast_allocate_raster_buf(data_type);
/* Allocate output buffer, use input map data_type */
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_raster_buf(data_type);
+ outrast = Rast_allocate_raster_buf(data_type);
/* controlling, if we can write the raster */
- if ((outfd = G_open_raster_new(result, data_type)) < 0)
+ if ((outfd = Rast_open_raster_new(result, data_type)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/* for each row */
@@ -146,7 +146,7 @@
G_percent(row, nrows, 2);
/* read input map */
- if (G_get_raster_row(infd, inrast, row, data_type) < 0)
+ if (Rast_get_raster_row(infd, inrast, row, data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), name,
row);
@@ -173,7 +173,7 @@
}
/* write raster row to output raster map */
- if (G_put_raster_row(outfd, outrast, data_type) < 0)
+ if (Rast_put_raster_row(outfd, outrast, data_type) < 0)
G_fatal_error(_("Failed writing raster map <%s>"), result);
}
@@ -182,13 +182,13 @@
G_free(outrast);
/* closing raster maps */
- G_close_cell(infd);
- G_close_cell(outfd);
+ Rast_close_cell(infd);
+ Rast_close_cell(outfd);
/* add command line incantation to history file */
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
Modified: grass/trunk/general/g.mremove/check_reclass.c
===================================================================
--- grass/trunk/general/g.mremove/check_reclass.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.mremove/check_reclass.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,7 @@
#include <string.h>
+
+#include <grass/Rast.h>
+
#include "global.h"
int check_reclass(const char *name, const char *mapset, int force)
@@ -7,7 +10,7 @@
char **rmaps;
int nrmaps;
- if (G_is_reclassed_to(name, mapset, &nrmaps, &rmaps) > 0) {
+ if (Rast_is_reclassed_to(name, mapset, &nrmaps, &rmaps) > 0) {
for (; *rmaps; rmaps++) {
/* force remove */
if (force)
@@ -23,8 +26,8 @@
return 1;
}
- if (G_is_reclass(name, mapset, rname, rmapset) > 0 &&
- G_is_reclassed_to(rname, rmapset, &nrmaps, &rmaps) > 0) {
+ if (Rast_is_reclass(name, mapset, rname, rmapset) > 0 &&
+ Rast_is_reclassed_to(rname, rmapset, &nrmaps, &rmaps) > 0) {
char path[GPATH_MAX];
char *p = strchr(rname, '@');
char *qname = G_fully_qualified_name(name, mapset);
Modified: grass/trunk/general/g.mremove/wc2regex.c
===================================================================
--- grass/trunk/general/g.mremove/wc2regex.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.mremove/wc2regex.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
char *wc2regex(const char *wc)
{
Modified: grass/trunk/general/g.region/adjust.c
===================================================================
--- grass/trunk/general/g.region/adjust.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.region/adjust.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,10 +1,11 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
void adjust_window(struct Cell_head *window, int row_flag, int col_flag, int depth_flag)
{
- const char *err = G_adjust_Cell_head3(window, row_flag, col_flag, depth_flag);
+ const char *err = Rast_adjust_Cell_head3(window, row_flag, col_flag, depth_flag);
if (err)
G_fatal_error(_("Invalid region: %s"), err);
Modified: grass/trunk/general/g.region/main.c
===================================================================
--- grass/trunk/general/g.region/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.region/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -441,7 +442,7 @@
mapset = G_find_cell2(rast_name, "");
if (!mapset)
G_fatal_error(_("Raster map <%s> not found"), rast_name);
- if (G_get_cellhd(rast_name, mapset, &temp_window) < 0)
+ if (Rast_get_cellhd(rast_name, mapset, &temp_window) < 0)
G_fatal_error(_("Unable to read header of raster map <%s@%s>"),
rast_name, mapset);
if (!first) {
@@ -459,7 +460,7 @@
window.west : temp_window.west;
}
}
- G_adjust_Cell_head3(&window, 0, 0, 0);
+ Rast_adjust_Cell_head3(&window, 0, 0, 0);
}
@@ -775,7 +776,7 @@
mapset = G_find_cell2(name, "");
if (!mapset)
G_fatal_error(_("Raster map <%s> not found"), name);
- if (G_get_cellhd(name, mapset, &temp_window) < 0)
+ if (Rast_get_cellhd(name, mapset, &temp_window) < 0)
G_fatal_error(_("Unable to read header of raster map <%s@%s>"),
name, mapset);
if ((err = G_align_window(&window, &temp_window)))
Modified: grass/trunk/general/g.region/printwindow.c
===================================================================
--- grass/trunk/general/g.region/printwindow.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.region/printwindow.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <projects.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/general/g.region/zoom.c
===================================================================
--- grass/trunk/general/g.region/zoom.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.region/zoom.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -18,12 +19,12 @@
nrows = window->rows;
ncols = window->cols;
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s> in <%s>"),
name, mapset);
- map_type = G_get_raster_map_type(fd);
- raster = G_allocate_raster_buf(map_type);
+ map_type = Rast_get_raster_map_type(fd);
+ raster = Rast_allocate_raster_buf(map_type);
/* find first non-null row */
top = nrows;
@@ -31,12 +32,12 @@
left = ncols;
right = -1;
for (row = 0; row < nrows; row++) {
- if (G_get_raster_row(fd, rast_ptr = raster, row, map_type) < 0)
+ if (Rast_get_raster_row(fd, rast_ptr = raster, row, map_type) < 0)
G_fatal_error(_("Could not read from <%s>"), name);
for (col = 0; col < ncols; col++) {
- if (!G_is_null_value(rast_ptr, map_type))
+ if (!Rast_is_null_value(rast_ptr, map_type))
break;
- rast_ptr = G_incr_void_ptr(rast_ptr, G_raster_size(map_type));
+ rast_ptr = Rast_incr_void_ptr(rast_ptr, Rast_raster_size(map_type));
}
if (col == ncols)
continue;
@@ -47,14 +48,14 @@
if (col < left)
left = col;
for (mark = col; col < ncols; col++) {
- if (!G_is_null_value(rast_ptr, map_type))
+ if (!Rast_is_null_value(rast_ptr, map_type))
mark = col;
- rast_ptr = G_incr_void_ptr(rast_ptr, G_raster_size(map_type));
+ rast_ptr = Rast_incr_void_ptr(rast_ptr, Rast_raster_size(map_type));
}
if (mark > right)
right = mark;
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(raster);
/* no data everywhere? */
Modified: grass/trunk/general/g.remove/main.c
===================================================================
--- grass/trunk/general/g.remove/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.remove/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,8 @@
*****************************************************************************/
#include <stdlib.h>
#include <string.h>
+
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/list.h>
@@ -29,7 +31,7 @@
char **rmaps;
int nrmaps;
- if (G_is_reclassed_to(name, mapset, &nrmaps, &rmaps) > 0) {
+ if (Rast_is_reclassed_to(name, mapset, &nrmaps, &rmaps) > 0) {
for (; *rmaps; rmaps++) {
/* force remove */
if (force)
@@ -44,8 +46,8 @@
return 1;
}
- if (G_is_reclass(name, mapset, rname, rmapset) > 0 &&
- G_is_reclassed_to(rname, rmapset, &nrmaps, &rmaps) > 0) {
+ if (Rast_is_reclass(name, mapset, rname, rmapset) > 0 &&
+ Rast_is_reclassed_to(rname, rmapset, &nrmaps, &rmaps) > 0) {
char path[GPATH_MAX];
char *p = strchr(rname, '@');
char *qname = G_fully_qualified_name(name, mapset);
Modified: grass/trunk/general/g.rename/main.c
===================================================================
--- grass/trunk/general/g.rename/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/g.rename/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/list.h>
@@ -93,7 +94,7 @@
continue;
}
- if (G_is_reclassed_to(old, mapset, &nrmaps, &rmaps) > 0) {
+ if (Rast_is_reclassed_to(old, mapset, &nrmaps, &rmaps) > 0) {
int ptr, l;
char buf1[256], buf2[256], buf3[256], *str;
FILE *fp;
Modified: grass/trunk/general/manage/lister/cell.c
===================================================================
--- grass/trunk/general/manage/lister/cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/manage/lister/cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
int main(int argc, char *argv[])
{
@@ -16,7 +17,7 @@
{
*title = 0;
if (*name)
- strcpy(title, G_get_cell_title(name, mapset));
+ strcpy(title, Rast_get_cell_title(name, mapset));
return 0;
}
Modified: grass/trunk/general/manage/lister/vector.c
===================================================================
--- grass/trunk/general/manage/lister/vector.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/general/manage/lister/vector.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
int main(int argc, char *argv[])
Modified: grass/trunk/imagery/i.albedo/main.c
===================================================================
--- grass/trunk/imagery/i.albedo/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.albedo/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define MAXFILES 8
@@ -146,19 +147,19 @@
G_fatal_error(_("Too many input maps. Only %d allowed."), MAXFILES);
name = *ptr;
- infd[nfiles] = G_open_cell_old(name, "");
+ infd[nfiles] = Rast_open_cell_old(name, "");
if (infd[nfiles] < 0)
continue;
/* Allocate input buffer */
- in_data_type[nfiles] = G_raster_map_type(name, "");
- if ((infd[nfiles] = G_open_cell_old(name, "")) < 0)
+ in_data_type[nfiles] = Rast_raster_map_type(name, "");
+ if ((infd[nfiles] = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- if ((G_get_cellhd(name, "", &cellhd)) < 0)
+ if ((Rast_get_cellhd(name, "", &cellhd)) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), name);
- inrast[nfiles] = G_allocate_raster_buf(in_data_type[nfiles]);
+ inrast[nfiles] = Rast_allocate_raster_buf(in_data_type[nfiles]);
nfiles++;
}
nfiles--;
@@ -168,10 +169,10 @@
/* Allocate output buffer, use input map data_type */
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_raster_buf(out_data_type);
+ outrast = Rast_allocate_raster_buf(out_data_type);
/* Create New raster files */
- if ((outfd = G_open_raster_new(result, 1)) < 0)
+ if ((outfd = Rast_open_raster_new(result, 1)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/*START ALBEDO HISTOGRAM STRETCH */
@@ -189,7 +190,7 @@
G_percent(row, nrows, 2);
/* read input map */
for (i = 1; i <= nfiles; i++) {
- if ((G_get_raster_row(
+ if ((Rast_get_raster_row(
infd[i], inrast[i], row, in_data_type[i])) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d >"),
name, row);
@@ -222,7 +223,7 @@
else if (aster) {
de = bb_alb_aster(d[1], d[2], d[3], d[4], d[5], d[6]);
}
- if (G_is_d_null_value(&de)) {
+ if (Rast_is_d_null_value(&de)) {
/*Do nothing */
}
else {
@@ -347,7 +348,7 @@
G_percent(row, nrows, 2);
/* read input map */
for (i = 1; i <= nfiles; i++) {
- if ((G_get_raster_row(
+ if ((Rast_get_raster_row(
infd[i], inrast[i], row, in_data_type[i])) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
name, row);
@@ -385,24 +386,24 @@
}
((DCELL *) outrast)[col] = de;
}
- if (G_put_raster_row(outfd, outrast, out_data_type) < 0)
+ if (Rast_put_raster_row(outfd, outrast, out_data_type) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
result, row);
}
for (i = 1; i <= nfiles; i++) {
G_free(inrast[i]);
- G_close_cell(infd[i]);
+ Rast_close_cell(infd[i]);
}
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
/* Color table from 0.0 to 1.0 */
- G_init_colors(&colors);
- G_add_color_rule(0.0, 0, 0, 0, 1.0, 255, 255, 255, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0.0, 0, 0, 0, 1.0, 255, 255, 255, &colors);
/* Metadata */
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.atcorr/main.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/main.cpp 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.atcorr/main.cpp 2009-06-20 22:03:23 UTC (rev 38003)
@@ -37,6 +37,7 @@
extern "C" {
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
}
@@ -95,7 +96,7 @@
{
struct Cell_head iimg_head; /* the input image header file */
- if(G_get_cellhd(name, mapset, &iimg_head) < 0)
+ if(Rast_get_cellhd(name, mapset, &iimg_head) < 0)
G_fatal_error (_("Unable to read header of raster map <%s>"),
G_fully_qualified_name(name, mapset));
@@ -120,10 +121,10 @@
CELL* cbuf;
int col;
- cbuf = (CELL*)G_allocate_raster_buf(CELL_TYPE);
+ cbuf = (CELL*)Rast_allocate_raster_buf(CELL_TYPE);
for(col = 0; col < G_window_cols(); col++) cbuf[col] = round_c(buf[col]);
- G_put_raster_row(ofd, cbuf, CELL_TYPE);
+ Rast_put_raster_row(ofd, cbuf, CELL_TYPE);
}
@@ -292,9 +293,9 @@
TICache ticache; /* use this to increase computation speed when an elevation map with categories are given */
/* allocate memory for buffers */
- buf = (FCELL*)G_allocate_raster_buf(FCELL_TYPE);
- if(ialt_fd >= 0) alt = (FCELL*)G_allocate_raster_buf(FCELL_TYPE);
- if(ivis_fd >= 0) vis = (FCELL*)G_allocate_raster_buf(FCELL_TYPE);
+ buf = (FCELL*)Rast_allocate_raster_buf(FCELL_TYPE);
+ if(ialt_fd >= 0) alt = (FCELL*)Rast_allocate_raster_buf(FCELL_TYPE);
+ if(ivis_fd >= 0) vis = (FCELL*)Rast_allocate_raster_buf(FCELL_TYPE);
G_verbose_message(_("Percent complete..."));
nrows = G_window_rows();
@@ -305,30 +306,30 @@
G_percent(row, nrows, 1); /* keep the user informed of our progress */
/* read the next row */
- if(G_get_raster_row(ifd, buf, row, FCELL_TYPE) < 0)
+ if(Rast_get_raster_row(ifd, buf, row, FCELL_TYPE) < 0)
G_fatal_error (_("Unable to read input raster map row %d"),
row);
/* read the next row of elevation values */
if(ialt_fd >= 0)
- if(G_get_raster_row(ialt_fd, alt, row, FCELL_TYPE) < 0)
+ if(Rast_get_raster_row(ialt_fd, alt, row, FCELL_TYPE) < 0)
G_fatal_error (_("Unable to read elevation raster map row %d"),
row);
/* read the next row of elevation values */
if(ivis_fd >= 0)
- if(G_get_raster_row(ivis_fd, vis, row, FCELL_TYPE) < 0)
+ if(Rast_get_raster_row(ivis_fd, vis, row, FCELL_TYPE) < 0)
G_fatal_error (_("Unable to read visibility raster map row %d"),
row);
/* loop over all the values in the row */
for(col = 0; col < ncols; col++)
{
- if(vis && G_is_f_null_value(&vis[col]) ||
- alt && G_is_f_null_value(&alt[col]) ||
- G_is_f_null_value(&buf[col]))
+ if(vis && Rast_is_f_null_value(&vis[col]) ||
+ alt && Rast_is_f_null_value(&alt[col]) ||
+ Rast_is_f_null_value(&buf[col]))
{
- G_set_f_null_value(&buf[col], 1);
+ Rast_set_f_null_value(&buf[col], 1);
continue;
}
alt[col] /= 1000.0f; /* converting to km from input which should be in meter */
@@ -404,7 +405,7 @@
}
/* write output */
- if(oflt) G_put_raster_row(ofd, buf, FCELL_TYPE);
+ if(oflt) Rast_put_raster_row(ofd, buf, FCELL_TYPE);
else write_fp_to_cell(ofd, buf);
}
@@ -421,8 +422,8 @@
{
struct Colors colors;
- G_read_colors(iname, imapset, &colors);
- G_write_colors(oname, G_mapset(), &colors);
+ Rast_read_colors(iname, imapset, &colors);
+ Rast_write_colors(oname, G_mapset(), &colors);
}
@@ -588,7 +589,7 @@
/* open input raster */
if ( (iimg_mapset = G_find_cell2 ( opts.iimg->answer, "") ) == NULL )
G_fatal_error ( _("Raster map <%s> not found"), opts.iimg->answer);
- if((iimg_fd = G_open_cell_old(opts.iimg->answer, iimg_mapset)) < 0)
+ if((iimg_fd = Rast_open_cell_old(opts.iimg->answer, iimg_mapset)) < 0)
G_fatal_error (_("Unable to open raster map <%s>"),
G_fully_qualified_name(opts.iimg->answer, iimg_mapset));
@@ -597,7 +598,7 @@
if(opts.ialt->answer) {
if ( (ialt_mapset = G_find_cell2 ( opts.ialt->answer, "") ) == NULL )
G_fatal_error ( _("Raster map <%s> not found"), opts.ialt->answer);
- if((ialt_fd = G_open_cell_old(opts.ialt->answer, ialt_mapset)) < 0)
+ if((ialt_fd = Rast_open_cell_old(opts.ialt->answer, ialt_mapset)) < 0)
G_fatal_error (_("Unable to open raster map <%s>"),
G_fully_qualified_name(opts.ialt->answer, ialt_mapset));
}
@@ -605,7 +606,7 @@
if(opts.ivis->answer) {
if ( (iviz_mapset = G_find_cell2 ( opts.ivis->answer, "") ) == NULL )
G_fatal_error ( _("Raster map <%s> not found"), opts.ivis->answer);
- if((ivis_fd = G_open_cell_old(opts.ivis->answer, iviz_mapset)) < 0)
+ if((ivis_fd = Rast_open_cell_old(opts.ivis->answer, iviz_mapset)) < 0)
G_fatal_error (_("Unable to open raster map <%s>"),
G_fully_qualified_name(opts.ivis->answer, iviz_mapset));
}
@@ -613,13 +614,13 @@
/* open a floating point raster or not? */
if(opts.oflt->answer)
{
- if((oimg_fd = G_open_fp_cell_new(opts.oimg->answer)) < 0)
+ if((oimg_fd = Rast_open_fp_cell_new(opts.oimg->answer)) < 0)
G_fatal_error (_("Unable to create raster map <%s>"),
opts.oimg->answer);
}
else
{
- if((oimg_fd = G_open_raster_new(opts.oimg->answer, CELL_TYPE)) < 0)
+ if((oimg_fd = Rast_open_raster_new(opts.oimg->answer, CELL_TYPE)) < 0)
G_fatal_error (_("Unable to create raster map <%s>"),
opts.oimg->answer);
}
@@ -644,14 +645,14 @@
/* Close the input and output file descriptors */
- G_short_history(opts.oimg->answer, "raster", &hist);
- G_close_cell(iimg_fd);
- if(opts.ialt->answer) G_close_cell(ialt_fd);
- if(opts.ivis->answer) G_close_cell(ivis_fd);
- G_close_cell(oimg_fd);
+ Rast_short_history(opts.oimg->answer, "raster", &hist);
+ Rast_close_cell(iimg_fd);
+ if(opts.ialt->answer) Rast_close_cell(ialt_fd);
+ if(opts.ivis->answer) Rast_close_cell(ivis_fd);
+ Rast_close_cell(oimg_fd);
- G_command_history(&hist);
- G_write_history(opts.oimg->answer, &hist);
+ Rast_command_history(&hist);
+ Rast_write_history(opts.oimg->answer, &hist);
/* Copy the colors of the input raster to the output raster.
Scaling is ignored and color ranges might not be correct. */
Modified: grass/trunk/imagery/i.cca/main.c
===================================================================
--- grass/trunk/imagery/i.cca/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cca/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -38,6 +38,7 @@
#include <string.h>
#include <math.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/gmath.h>
#include <grass/glocale.h>
@@ -167,14 +168,14 @@
outbandmax[i] = (CELL) 0;
outbandmin[i] = (CELL) 0;
- if ((datafds[i] = G_open_cell_old(refs.file[i - 1].name,
+ if ((datafds[i] = Rast_open_cell_old(refs.file[i - 1].name,
refs.file[i - 1].mapset)) < 0) {
G_fatal_error(_("Cannot open raster map <%s>"),
refs.file[i - 1].name);
}
sprintf(tempname, "%s.%d", out_opt->answer, i);
- if ((outfds[i] = G_open_cell_new(tempname)) < 0)
+ if ((outfds[i] = Rast_open_cell_new(tempname)) < 0)
G_fatal_error(_("Cannot create raster map <%s>"), tempname);
}
@@ -183,23 +184,23 @@
outbandmin, outbandmax);
/* make grey scale color table */
- G_init_colors(&color_tbl);
+ Rast_init_colors(&color_tbl);
/* close the cell maps */
for (i = 1; i <= bands; i++) {
- G_close_cell(datafds[i]);
- G_close_cell(outfds[i]);
+ Rast_close_cell(datafds[i]);
+ Rast_close_cell(outfds[i]);
if (outbandmin[i] < (CELL) 0 || outbandmax[i] > (CELL) 255) {
G_warning(_("The output cell map <%s.%d> has values "
"outside the 0-255 range."), out_opt->answer, i);
}
- G_make_grey_scale_colors(&color_tbl, 0, outbandmax[i]);
+ Rast_make_grey_scale_colors(&color_tbl, 0, outbandmax[i]);
sprintf(tempname, "%s.%d", out_opt->answer, i);
/* write a color table */
- G_write_colors(tempname, G_mapset(), &color_tbl);
+ Rast_write_colors(tempname, G_mapset(), &color_tbl);
}
I_free_signatures(&sigs);
Modified: grass/trunk/imagery/i.cca/matrix.c
===================================================================
--- grass/trunk/imagery/i.cca/matrix.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cca/matrix.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
#include "local_proto.h"
Modified: grass/trunk/imagery/i.cca/stats.c
===================================================================
--- grass/trunk/imagery/i.cca/stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cca/stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
Modified: grass/trunk/imagery/i.cca/transform.c
===================================================================
--- grass/trunk/imagery/i.cca/transform.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cca/transform.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -14,13 +15,13 @@
/* allocate row buffers for each band */
for (i = 1; i <= bands; i++)
- if ((rowbufs[i] = G_allocate_cell_buf()) == NULL)
+ if ((rowbufs[i] = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate cell buffers."));
for (i = 0; i < rows; i++) {
/* get one row of data */
for (j = 1; j <= bands; j++)
- if (G_get_map_row(datafds[j], rowbufs[j], i) < 0)
+ if (Rast_get_map_row(datafds[j], rowbufs[j], i) < 0)
G_fatal_error(_("Error reading cell map during transform."));
/* transform each cell in the row */
@@ -42,7 +43,7 @@
/* output the row of data */
for (j = 1; j <= bands; j++)
- if (G_put_raster_row(outfds[j], rowbufs[j], CELL_TYPE) < 0)
+ if (Rast_put_raster_row(outfds[j], rowbufs[j], CELL_TYPE) < 0)
G_fatal_error(_("Error writing cell map during transform."));
}
for (i = 1; i <= bands; i++)
Modified: grass/trunk/imagery/i.class/band_files.c
===================================================================
--- grass/trunk/imagery/i.class/band_files.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.class/band_files.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,10 +15,10 @@
Bandbuf = (CELL **) G_malloc(nbands * sizeof(CELL *));
Bandfd = (int *)G_malloc(nbands * sizeof(int));
for (n = 0; n < nbands; n++) {
- Bandbuf[n] = G_allocate_cell_buf();
+ Bandbuf[n] = Rast_allocate_cell_buf();
name = Refer.file[n].name;
mapset = Refer.file[n].mapset;
- if ((Bandfd[n] = G_open_cell_old(name, mapset)) < 0)
+ if ((Bandfd[n] = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open band files."));
}
@@ -34,7 +34,7 @@
nbands = Refer.nfiles;
for (n = 0; n < nbands; n++) {
G_free(Bandbuf[n]);
- G_close_cell(Bandfd[n]);
+ Rast_close_cell(Bandfd[n]);
}
G_free(Bandbuf);
G_free(Bandfd);
Modified: grass/trunk/imagery/i.class/draw_cell.c
===================================================================
--- grass/trunk/imagery/i.class/draw_cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.class/draw_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,7 +18,7 @@
if (!view->cell.configured)
return 0;
- if (G_read_colors(view->cell.name, view->cell.mapset, &colr) < 0)
+ if (Rast_read_colors(view->cell.name, view->cell.mapset, &colr) < 0)
return 0;
if (overlay == OVER_WRITE)
@@ -35,16 +35,16 @@
Outline_box(top, top + nrows - 1, left, left + ncols - 1);
if (getenv("NO_DRAW")) {
- G_free_colors(&colr);
+ Rast_free_colors(&colr);
return 1;
}
- fd = G_open_cell_old(view->cell.name, view->cell.mapset);
+ fd = Rast_open_cell_old(view->cell.name, view->cell.mapset);
if (fd < 0) {
- G_free_colors(&colr);
+ Rast_free_colors(&colr);
return 0;
}
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
sprintf(msg, "Plotting %s ...", view->cell.name);
@@ -53,14 +53,14 @@
D_set_overlay_mode(!overlay);
D_cell_draw_setup(top, top + nrows, left, left + ncols);
for (row = 0; row < nrows; row++) {
- if (G_get_d_raster_row_nomask(fd, dcell, row) < 0)
+ if (Rast_get_d_raster_row_nomask(fd, dcell, row) < 0)
break;
D_draw_d_raster(row, dcell, &colr);
}
D_cell_draw_end();
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(dcell);
- G_free_colors(&colr);
+ Rast_free_colors(&colr);
return row == nrows;
}
Modified: grass/trunk/imagery/i.class/main.c
===================================================================
--- grass/trunk/imagery/i.class/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.class/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -128,7 +128,7 @@
G_fatal_error(_("No graphics device selected"));
/* check to see if a MASK is set */
- if (G_maskfd() >= 0)
+ if (Rast_maskfd() >= 0)
G_fatal_error(_("You have a mask set. Unset mask and run again"));
@@ -161,7 +161,7 @@
display_title(VIEW_MAP1);
mapset = G_find_cell(bg_map->answer, "");
- if (G_get_cellhd(bg_map->answer, mapset, &cellhd) != 0)
+ if (Rast_get_cellhd(bg_map->answer, mapset, &cellhd) != 0)
G_fatal_error(_("Raster map <%s> not found"), bg_map->answer);
G_adjust_window_to_box(&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows,
@@ -265,7 +265,7 @@
G_fatal_error(_("The subgroup must have at least 2 files to run"));
}
- if (G_get_cellhd(Refer.file[0].name, Refer.file[0].mapset, &Band_cellhd)
+ if (Rast_get_cellhd(Refer.file[0].name, Refer.file[0].mapset, &Band_cellhd)
!= 0)
G_fatal_error(_("Unable to read cell header for first band file"));
Modified: grass/trunk/imagery/i.class/readbands.c
===================================================================
--- grass/trunk/imagery/i.class/readbands.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.class/readbands.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,7 +8,7 @@
register int i;
for (i = 0; i < nbands; i++)
- if (G_get_map_row_nomask(Bandfd[i], Bandbuf[i], cur) < 0)
+ if (Rast_get_map_row_nomask(Bandfd[i], Bandbuf[i], cur) < 0)
G_fatal_error(_("Error reading raster map in function readbands."));
return 0;
Modified: grass/trunk/imagery/i.class/signature.c
===================================================================
--- grass/trunk/imagery/i.class/signature.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.class/signature.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -272,9 +272,9 @@
G_set_window(&VIEW_MAP1->cell.head);
open_band_files();
- if ((fd = G_open_cell_new(MASK)) < 0)
+ if ((fd = Rast_open_cell_new(MASK)) < 0)
G_fatal_error(_("Unable to open the cell map MASK."));
- if ((buffer = G_allocate_cell_buf()) == NULL)
+ if ((buffer = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate the cell buffer in display_signature()."));
nrows = G_window_rows();
ncols = G_window_cols();
@@ -291,22 +291,22 @@
buffer[col] = (CELL) 1;
past:;
}
- G_put_raster_row(fd, buffer, CELL_TYPE);
+ Rast_put_raster_row(fd, buffer, CELL_TYPE);
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
close_band_files();
} /* end of if first_display */
/* generate and write the color table for the mask */
- G_init_colors(&mask_colors);
- G_set_color((CELL) 1, Color_table[Display_color].red,
+ Rast_init_colors(&mask_colors);
+ Rast_set_color((CELL) 1, Color_table[Display_color].red,
Color_table[Display_color].grn,
Color_table[Display_color].blue, &mask_colors);
- G_write_colors(MASK, G_mapset(), &mask_colors);
+ Rast_write_colors(MASK, G_mapset(), &mask_colors);
/* display new mask */
- if (G_get_cellhd(MASK, G_mapset(), &cellhd) != 0)
+ if (Rast_get_cellhd(MASK, G_mapset(), &cellhd) != 0)
G_fatal_error(_("Did not find input cell map MASK."));
G_adjust_window_to_box(&cellhd, &VIEW_MASK1->cell.head, VIEW_MASK1->nrows,
VIEW_MASK1->ncols);
Modified: grass/trunk/imagery/i.cluster/checkpt.c
===================================================================
--- grass/trunk/imagery/i.cluster/checkpt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/checkpt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
#include "local_proto.h"
Modified: grass/trunk/imagery/i.cluster/main.c
===================================================================
--- grass/trunk/imagery/i.cluster/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <time.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define GLOBAL
#include "global.h"
@@ -248,7 +249,7 @@
window.ew_res);
fprintf(report, _(" Rows: %12d Cols: %12d Cells: %d\n"), nrows, ncols,
nrows * ncols);
- fprintf(report, _("Mask: %s\n"), G_mask_info());
+ fprintf(report, _("Mask: %s\n"), Rast_mask_info());
fprintf(report, "\n");
fprintf(report, _("Cluster parameters\n"));
fprintf(report, _(" Number of initial classes: %d"), maxclass);
@@ -274,7 +275,7 @@
for (row = sample_rows - 1; row < nrows; row += sample_rows) {
G_percent(row, nrows, 2);
for (n = 0; n < ref.nfiles; n++)
- if (G_get_d_raster_row(cellfd[n], cell[n], row) < 0)
+ if (Rast_get_d_raster_row(cellfd[n], cell[n], row) < 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
for (col = sample_cols - 1; col < ncols; col += sample_cols) {
@@ -300,7 +301,7 @@
for (n = 0; n < ref.nfiles; n++) {
G_free(cell[n]);
- G_close_cell(cellfd[n]);
+ Rast_close_cell(cellfd[n]);
}
G_free(x);
Modified: grass/trunk/imagery/i.cluster/open_files.c
===================================================================
--- grass/trunk/imagery/i.cluster/open_files.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/open_files.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
@@ -49,10 +50,10 @@
cell = (DCELL **) G_malloc(ref.nfiles * sizeof(DCELL *));
cellfd = (int *)G_malloc(ref.nfiles * sizeof(int));
for (n = 0; n < ref.nfiles; n++) {
- cell[n] = G_allocate_d_raster_buf();
+ cell[n] = Rast_allocate_d_raster_buf();
name = ref.file[n].name;
mapset = ref.file[n].mapset;
- if ((cellfd[n] = G_open_cell_old(name, mapset)) < 0)
+ if ((cellfd[n] = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
G_fully_qualified_name(name, mapset));
}
Modified: grass/trunk/imagery/i.cluster/print1.c
===================================================================
--- grass/trunk/imagery/i.cluster/print1.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/print1.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include <grass/cluster.h>
Modified: grass/trunk/imagery/i.cluster/print2.c
===================================================================
--- grass/trunk/imagery/i.cluster/print2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/print2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include <grass/cluster.h>
Modified: grass/trunk/imagery/i.cluster/print3.c
===================================================================
--- grass/trunk/imagery/i.cluster/print3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/print3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include <grass/cluster.h>
Modified: grass/trunk/imagery/i.cluster/print4.c
===================================================================
--- grass/trunk/imagery/i.cluster/print4.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/print4.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include <grass/cluster.h>
Modified: grass/trunk/imagery/i.cluster/print5.c
===================================================================
--- grass/trunk/imagery/i.cluster/print5.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/print5.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include <grass/cluster.h>
Modified: grass/trunk/imagery/i.cluster/print6.c
===================================================================
--- grass/trunk/imagery/i.cluster/print6.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/print6.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include <grass/cluster.h>
Modified: grass/trunk/imagery/i.cluster/timer.c
===================================================================
--- grass/trunk/imagery/i.cluster/timer.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.cluster/timer.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "global.h"
Modified: grass/trunk/imagery/i.eb.eta/main.c
===================================================================
--- grass/trunk/imagery/i.eb.eta/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.eb.eta/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
double et_a(double r_net_day, double evap_fr, double tempk);
@@ -72,23 +73,23 @@
tempk = input3->answer;
result1 = output1->answer;
- if ((infd_rnetday = G_open_cell_old(rnetday, "")) < 0)
+ if ((infd_rnetday = Rast_open_cell_old(rnetday, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), rnetday);
- inrast_rnetday = G_allocate_d_raster_buf();
+ inrast_rnetday = Rast_allocate_d_raster_buf();
- if ((infd_evapfr = G_open_cell_old(evapfr, "")) < 0)
+ if ((infd_evapfr = Rast_open_cell_old(evapfr, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), evapfr);
- inrast_evapfr = G_allocate_d_raster_buf();
+ inrast_evapfr = Rast_allocate_d_raster_buf();
- if ((infd_tempk = G_open_cell_old(tempk, "")) < 0)
+ if ((infd_tempk = Rast_open_cell_old(tempk, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), tempk);
- inrast_tempk = G_allocate_d_raster_buf();
+ inrast_tempk = Rast_allocate_d_raster_buf();
nrows = G_window_rows();
ncols = G_window_cols();
- outrast1 = G_allocate_d_raster_buf();
+ outrast1 = Rast_allocate_d_raster_buf();
- if ((outfd1 = G_open_raster_new(result1, DCELL_TYPE)) < 0)
+ if ((outfd1 = Rast_open_raster_new(result1, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result1);
/* Process pixels */
@@ -101,11 +102,11 @@
G_percent(row, nrows, 2);
/* read input maps */
- if (G_get_d_raster_row(infd_rnetday,inrast_rnetday,row)<0)
+ if (Rast_get_d_raster_row(infd_rnetday,inrast_rnetday,row)<0)
G_fatal_error(_("Unable to read from <%s> row %d"), rnetday, row);
- if (G_get_d_raster_row(infd_evapfr,inrast_evapfr,row)<0)
+ if (Rast_get_d_raster_row(infd_evapfr,inrast_evapfr,row)<0)
G_fatal_error(_("Unable to read from <%s> row %d"), evapfr, row);
- if (G_get_d_raster_row(infd_tempk,inrast_tempk,row)<0)
+ if (Rast_get_d_raster_row(infd_tempk,inrast_tempk,row)<0)
G_fatal_error(_("Unable to read from <%s> row %d"), tempk, row);
/*process the data */
@@ -114,29 +115,29 @@
d_rnetday = ((DCELL *) inrast_rnetday)[col];
d_evapfr = ((DCELL *) inrast_evapfr)[col];
d_tempk = ((DCELL *) inrast_tempk)[col];
- if (G_is_d_null_value(&d_rnetday) ||
- G_is_d_null_value(&d_evapfr) ||
- G_is_d_null_value(&d_tempk))
- G_set_d_null_value(&outrast1[col], 1);
+ if (Rast_is_d_null_value(&d_rnetday) ||
+ Rast_is_d_null_value(&d_evapfr) ||
+ Rast_is_d_null_value(&d_tempk))
+ Rast_set_d_null_value(&outrast1[col], 1);
else {
d = et_a(d_rnetday, d_evapfr, d_tempk);
outrast1[col] = d;
}
}
- if (G_put_d_raster_row(outfd1,outrast1) < 0)
+ if (Rast_put_d_raster_row(outfd1,outrast1) < 0)
G_fatal_error(_("Failed writing raster map <%s>"), result1);
}
G_free(inrast_rnetday);
G_free(inrast_evapfr);
G_free(inrast_tempk);
- G_close_cell(infd_rnetday);
- G_close_cell(infd_evapfr);
- G_close_cell(infd_tempk);
+ Rast_close_cell(infd_rnetday);
+ Rast_close_cell(infd_evapfr);
+ Rast_close_cell(infd_tempk);
G_free(outrast1);
- G_close_cell(outfd1);
- G_short_history(result1, "raster", &history);
- G_command_history(&history);
- G_write_history(result1, &history);
+ Rast_close_cell(outfd1);
+ Rast_short_history(result1, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result1, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.eb.evapfr/main.c
===================================================================
--- grass/trunk/imagery/i.eb.evapfr/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.eb.evapfr/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
double evap_fr(double r_net, double g0, double h0);
@@ -91,32 +92,32 @@
makin = flag1->answer;
/***************************************************/
- if ((infd_rnet = G_open_cell_old(rnet, "")) < 0)
+ if ((infd_rnet = Rast_open_cell_old(rnet, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), rnet);
- inrast_rnet = G_allocate_d_raster_buf();
+ inrast_rnet = Rast_allocate_d_raster_buf();
/***************************************************/
- if ((infd_g0 = G_open_cell_old(g0, "")) < 0)
+ if ((infd_g0 = Rast_open_cell_old(g0, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), g0);
- inrast_g0 = G_allocate_d_raster_buf();
+ inrast_g0 = Rast_allocate_d_raster_buf();
/***************************************************/
- if ((infd_h0 = G_open_cell_old(h0, "")) < 0)
+ if ((infd_h0 = Rast_open_cell_old(h0, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), h0);
- inrast_h0 = G_allocate_d_raster_buf();
+ inrast_h0 = Rast_allocate_d_raster_buf();
/***************************************************/
nrows = G_window_rows();
ncols = G_window_cols();
- outrast1 = G_allocate_d_raster_buf();
+ outrast1 = Rast_allocate_d_raster_buf();
if (makin)
- outrast2 = G_allocate_d_raster_buf();
+ outrast2 = Rast_allocate_d_raster_buf();
/* Create New raster files */
- if ((outfd1 = G_open_raster_new(result1, DCELL_TYPE)) < 0)
+ if ((outfd1 = Rast_open_raster_new(result1, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result1);
if (makin)
- if ((outfd2 = G_open_raster_new(result2, DCELL_TYPE)) < 0)
+ if ((outfd2 = Rast_open_raster_new(result2, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result2);
/* Process pixels */
@@ -129,11 +130,11 @@
G_percent(row, nrows, 2);
/* read input maps */
- if (G_get_d_raster_row(infd_rnet, inrast_rnet, row)<0)
+ if (Rast_get_d_raster_row(infd_rnet, inrast_rnet, row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), rnet, row);
- if (G_get_d_raster_row(infd_g0, inrast_g0, row) < 0)
+ if (Rast_get_d_raster_row(infd_g0, inrast_g0, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), g0, row);
- if (G_get_d_raster_row(infd_h0, inrast_h0, row) < 0)
+ if (Rast_get_d_raster_row(infd_h0, inrast_h0, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), h0, row);
/*process the data */
@@ -142,12 +143,12 @@
d_rnet = ((DCELL *) inrast_rnet)[col];
d_g0 = ((DCELL *) inrast_g0)[col];
d_h0 = ((DCELL *) inrast_h0)[col];
- if (G_is_d_null_value(&d_rnet) ||
- G_is_d_null_value(&d_g0) ||
- G_is_d_null_value(&d_h0)) {
- G_set_d_null_value(&outrast1[col], 1);
+ if (Rast_is_d_null_value(&d_rnet) ||
+ Rast_is_d_null_value(&d_g0) ||
+ Rast_is_d_null_value(&d_h0)) {
+ Rast_set_d_null_value(&outrast1[col], 1);
if (makin)
- G_set_d_null_value(&outrast2[col], 1);
+ Rast_set_d_null_value(&outrast2[col], 1);
}
else {
/* calculate evaporative fraction */
@@ -161,33 +162,33 @@
}
}
}
- if (G_put_d_raster_row(outfd1, outrast1) < 0)
+ if (Rast_put_d_raster_row(outfd1, outrast1) < 0)
G_fatal_error(_("Failed writing raster map <%s>"), result1);
if (makin)
{
- if (G_put_d_raster_row(outfd2, outrast2) < 0)
+ if (Rast_put_d_raster_row(outfd2, outrast2) < 0)
G_fatal_error(_("Failed writing raster map <%s>"), result2);
}
}
G_free(inrast_rnet);
G_free(inrast_g0);
G_free(inrast_h0);
- G_close_cell(infd_rnet);
- G_close_cell(infd_g0);
- G_close_cell(infd_h0);
+ Rast_close_cell(infd_rnet);
+ Rast_close_cell(infd_g0);
+ Rast_close_cell(infd_h0);
G_free(outrast1);
G_free(outrast2);
if (makin) {
- G_close_cell(outfd1);
- G_close_cell(outfd2);
+ Rast_close_cell(outfd1);
+ Rast_close_cell(outfd2);
}
- G_short_history(result1, "raster", &history);
- G_command_history(&history);
- G_write_history(result1, &history);
+ Rast_short_history(result1, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result1, &history);
if (makin) {
- G_short_history(result2, "raster", &history);
- G_command_history(&history);
- G_write_history(result2, &history);
+ Rast_short_history(result2, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result2, &history);
}
exit(EXIT_SUCCESS);
Modified: grass/trunk/imagery/i.eb.h_SEBAL01/main.c
===================================================================
--- grass/trunk/imagery/i.eb.h_SEBAL01/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.eb.h_SEBAL01/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
double **G_alloc_matrix(int rows, int cols)
@@ -199,29 +200,29 @@
if (G_legal_filename(h0) < 0)
G_fatal_error(_("<%s> is an illegal name"), h0);
- if ((infd_Rn = G_open_cell_old(Rn, "")) < 0)
+ if ((infd_Rn = Rast_open_cell_old(Rn, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), Rn);
- if ((infd_g0 = G_open_cell_old(g0, "")) < 0)
+ if ((infd_g0 = Rast_open_cell_old(g0, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), g0);
- if ((infd_z0m = G_open_cell_old(z0m, "")) < 0)
+ if ((infd_z0m = Rast_open_cell_old(z0m, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), z0m);
- if ((infd_t0dem = G_open_cell_old(t0dem, "")) < 0)
+ if ((infd_t0dem = Rast_open_cell_old(t0dem, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), t0dem);
- if (G_get_cellhd(Rn, "", &cellhd) < 0)
+ if (Rast_get_cellhd(Rn, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), Rn);
- if (G_get_cellhd(g0, "", &cellhd) < 0)
+ if (Rast_get_cellhd(g0, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), g0);
- if (G_get_cellhd(z0m, "", &cellhd) < 0)
+ if (Rast_get_cellhd(z0m, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), z0m);
- if (G_get_cellhd(t0dem, "", &cellhd) < 0)
+ if (Rast_get_cellhd(t0dem, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), t0dem);
/* Allocate input buffer */
- inrast_Rn = G_allocate_d_raster_buf();
- inrast_g0 = G_allocate_d_raster_buf();
- inrast_z0m = G_allocate_d_raster_buf();
- inrast_t0dem = G_allocate_d_raster_buf();
+ inrast_Rn = Rast_allocate_d_raster_buf();
+ inrast_g0 = Rast_allocate_d_raster_buf();
+ inrast_z0m = Rast_allocate_d_raster_buf();
+ inrast_t0dem = Rast_allocate_d_raster_buf();
/***************************************************/
/* Setup pixel location variables */
@@ -240,9 +241,9 @@
/***************************************************/
/* Allocate output buffer */
/***************************************************/
- outrast = G_allocate_d_raster_buf();
+ outrast = Rast_allocate_d_raster_buf();
- if ((outfd = G_open_raster_new(h0, DCELL_TYPE)) < 0)
+ if ((outfd = Rast_open_raster_new(h0, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), h0);
/***************************************************/
@@ -275,20 +276,20 @@
for (row = 0; row < nrows; row++) {
DCELL d_t0dem;
G_percent(row, nrows, 2);
- if (G_get_d_raster_row(infd_t0dem,inrast_t0dem,row)<0)
+ if (Rast_get_d_raster_row(infd_t0dem,inrast_t0dem,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), t0dem, row);
- if (G_get_d_raster_row(infd_Rn,inrast_Rn,row)<0)
+ if (Rast_get_d_raster_row(infd_Rn,inrast_Rn,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), Rn, row);
- if (G_get_d_raster_row(infd_g0,inrast_g0,row)<0)
+ if (Rast_get_d_raster_row(infd_g0,inrast_g0,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), g0, row);
/*process the data */
for (col = 0; col < ncols; col++) {
d_t0dem = ((DCELL *) inrast_t0dem)[col];
d_Rn = ((DCELL *) inrast_Rn)[col];
d_g0 = ((DCELL *) inrast_g0)[col];
- if (G_is_d_null_value(&d_t0dem) ||
- G_is_d_null_value(&d_Rn) ||
- G_is_d_null_value(&d_g0)) {
+ if (Rast_is_d_null_value(&d_t0dem) ||
+ Rast_is_d_null_value(&d_Rn) ||
+ Rast_is_d_null_value(&d_g0)) {
/* do nothing */
}
else {
@@ -348,11 +349,11 @@
}
rowDry = row;
colDry = col;
- if (G_get_d_raster_row(infd_Rn, inrast_Rn, row) < 0)
+ if (Rast_get_d_raster_row(infd_Rn, inrast_Rn, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), Rn, row);
- if (G_get_d_raster_row(infd_g0, inrast_g0, row) < 0)
+ if (Rast_get_d_raster_row(infd_g0, inrast_g0, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), g0, row);
- if (G_get_d_raster_row(infd_t0dem, inrast_t0dem, row) < 0)
+ if (Rast_get_d_raster_row(infd_t0dem, inrast_t0dem, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), t0dem, row);
d_Rn_dry = ((DCELL *) inrast_Rn)[col];
d_g0_dry = ((DCELL *) inrast_g0)[col];
@@ -371,7 +372,7 @@
}
rowWet = row;
colWet = col;
- if (G_get_d_raster_row(infd_t0dem, inrast_t0dem, row) < 0)
+ if (Rast_get_d_raster_row(infd_t0dem, inrast_t0dem, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), t0dem, row);
d_t0dem_wet = ((DCELL *) inrast_t0dem)[col];
/* END OF MANUAL WET/DRY PIXELS */
@@ -393,15 +394,15 @@
DCELL d_u5;
G_percent(row, nrows, 2);
/* read a line input maps into buffers */
- if (G_get_d_raster_row(infd_z0m, inrast_z0m, row) < 0)
+ if (Rast_get_d_raster_row(infd_z0m, inrast_z0m, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), z0m, row);
- if (G_get_d_raster_row(infd_t0dem, inrast_t0dem,row)<0)
+ if (Rast_get_d_raster_row(infd_t0dem, inrast_t0dem,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), t0dem, row);
/* read every cell in the line buffers */
for (col = 0; col < ncols; col++) {
d_z0m = ((DCELL *) inrast_z0m)[col];
d_t0dem = ((DCELL *) inrast_t0dem)[col];
- if (G_is_d_null_value(&d_t0dem) || G_is_d_null_value(&d_z0m)) {
+ if (Rast_is_d_null_value(&d_t0dem) || Rast_is_d_null_value(&d_z0m)) {
/* do nothing */
d_Roh[row][col] = -999.9;
d_Rah[row][col] = -999.9;
@@ -456,9 +457,9 @@
DCELL d_u5;
G_percent(row, nrows, 2);
/* read a line input maps into buffers */
- if (G_get_d_raster_row(infd_z0m, inrast_z0m, row) < 0)
+ if (Rast_get_d_raster_row(infd_z0m, inrast_z0m, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), z0m, row);
- if (G_get_d_raster_row(infd_t0dem, inrast_t0dem,row)<0)
+ if (Rast_get_d_raster_row(infd_t0dem, inrast_t0dem,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), t0dem, row);
/* read every cell in the line buffers */
for (col = 0; col < ncols; col++) {
@@ -466,7 +467,7 @@
d_t0dem = ((DCELL *) inrast_t0dem)[col];
d_rah1 = d_Rah[row][col];
d_roh1 = d_Roh[row][col];
- if (G_is_d_null_value(&d_t0dem) || G_is_d_null_value(&d_z0m)) {
+ if (Rast_is_d_null_value(&d_t0dem) || Rast_is_d_null_value(&d_z0m)) {
/* do nothing */
}
else {
@@ -525,9 +526,9 @@
DCELL d_u5;
G_percent(row, nrows, 2);
/* read a line input maps into buffers */
- if (G_get_d_raster_row(infd_z0m,inrast_z0m,row)<0)
+ if (Rast_get_d_raster_row(infd_z0m,inrast_z0m,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), z0m, row);
- if (G_get_d_raster_row(infd_t0dem,inrast_t0dem,row)<0)
+ if (Rast_get_d_raster_row(infd_t0dem,inrast_t0dem,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), t0dem, row);
/* read every cell in the line buffers */
for (col = 0; col < ncols; col++) {
@@ -535,7 +536,7 @@
d_t0dem = ((DCELL *) inrast_t0dem)[col];
d_rah2 = d_Rah[row][col];
d_roh1 = d_Roh[row][col];
- if (G_is_d_null_value(&d_t0dem) || G_is_d_null_value(&d_z0m)) {
+ if (Rast_is_d_null_value(&d_t0dem) || Rast_is_d_null_value(&d_z0m)) {
/* do nothing */
}
else {
@@ -595,9 +596,9 @@
DCELL d; /* Output pixel */
G_percent(row, nrows, 2);
/* read a line input maps into buffers */
- if (G_get_d_raster_row(infd_z0m, inrast_z0m, row) < 0)
+ if (Rast_get_d_raster_row(infd_z0m, inrast_z0m, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), z0m, row);
- if (G_get_d_raster_row(infd_t0dem,inrast_t0dem,row)<0)
+ if (Rast_get_d_raster_row(infd_t0dem,inrast_t0dem,row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), t0dem, row);
/* read every cell in the line buffers */
for (col = 0; col < ncols; col++) {
@@ -605,8 +606,8 @@
d_t0dem = ((DCELL *) inrast_t0dem)[col];
d_rah3 = d_Rah[row][col];
d_roh1 = d_Roh[row][col];
- if (G_is_d_null_value(&d_t0dem) || G_is_d_null_value(&d_z0m)) {
- G_set_d_null_value(&outrast[col], 1);
+ if (Rast_is_d_null_value(&d_t0dem) || Rast_is_d_null_value(&d_z0m)) {
+ Rast_set_d_null_value(&outrast[col], 1);
}
else {
if (d_rah3 < 1.0) {
@@ -619,28 +620,28 @@
d_h3 = 0.0;
}
if (d_h3 < -50 || d_h3 > 1000) {
- G_set_d_null_value(&outrast[col], 1);
+ Rast_set_d_null_value(&outrast[col], 1);
}
outrast[col] = d_h3;
}
}
- if (G_put_d_raster_row(outfd, outrast) < 0)
+ if (Rast_put_d_raster_row(outfd, outrast) < 0)
G_fatal_error("Failed writing raster map <%s>", h0);
}
G_free(inrast_z0m);
- G_close_cell(infd_z0m);
+ Rast_close_cell(infd_z0m);
G_free(inrast_t0dem);
- G_close_cell(infd_t0dem);
+ Rast_close_cell(infd_t0dem);
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
/* add command line incantation to history file */
- G_short_history(h0, "raster", &history);
- G_command_history(&history);
- G_write_history(h0, &history);
+ Rast_short_history(h0, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(h0, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.eb.soilheatflux/main.c
===================================================================
--- grass/trunk/imagery/i.eb.soilheatflux/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.eb.soilheatflux/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
double g_0(double bbalb, double ndvi, double tempk, double rnet,
@@ -89,32 +90,32 @@
result = output1->answer;
roerink = flag1->answer;
- if ((infd_albedo = G_open_cell_old(albedo, "")) < 0)
+ if ((infd_albedo = Rast_open_cell_old(albedo, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), albedo);
- inrast_albedo = G_allocate_d_raster_buf();
+ inrast_albedo = Rast_allocate_d_raster_buf();
- if ((infd_ndvi = G_open_cell_old(ndvi, "")) < 0)
+ if ((infd_ndvi = Rast_open_cell_old(ndvi, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), ndvi);
- inrast_ndvi = G_allocate_d_raster_buf();
+ inrast_ndvi = Rast_allocate_d_raster_buf();
- if ((infd_tempk = G_open_cell_old(tempk, "")) < 0)
+ if ((infd_tempk = Rast_open_cell_old(tempk, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), tempk);
- inrast_tempk = G_allocate_d_raster_buf();
+ inrast_tempk = Rast_allocate_d_raster_buf();
- if ((infd_rnet = G_open_cell_old(rnet, "")) < 0)
+ if ((infd_rnet = Rast_open_cell_old(rnet, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), rnet);
- inrast_rnet = G_allocate_d_raster_buf();
+ inrast_rnet = Rast_allocate_d_raster_buf();
- if ((infd_time = G_open_cell_old(time, "")) < 0)
+ if ((infd_time = Rast_open_cell_old(time, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), time);
- inrast_time = G_allocate_d_raster_buf();
+ inrast_time = Rast_allocate_d_raster_buf();
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_d_raster_buf();
+ outrast = Rast_allocate_d_raster_buf();
/* Create New raster files */
- if ((outfd = G_open_raster_new(result,DCELL_TYPE)) < 0)
+ if ((outfd = Rast_open_raster_new(result,DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/* Process pixels */
@@ -128,19 +129,19 @@
DCELL d_time;
G_percent(row, nrows, 2);
/* read input maps */
- if (G_get_d_raster_row(infd_albedo, inrast_albedo, row) < 0)
+ if (Rast_get_d_raster_row(infd_albedo, inrast_albedo, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
albedo, row);
- if (G_get_d_raster_row(infd_ndvi, inrast_ndvi, row)<0)
+ if (Rast_get_d_raster_row(infd_ndvi, inrast_ndvi, row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
ndvi, row);
- if (G_get_d_raster_row(infd_tempk, inrast_tempk, row)< 0)
+ if (Rast_get_d_raster_row(infd_tempk, inrast_tempk, row)< 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
tempk, row);
- if (G_get_d_raster_row(infd_rnet, inrast_rnet, row)<0)
+ if (Rast_get_d_raster_row(infd_rnet, inrast_rnet, row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
rnet, row);
- if (G_get_d_raster_row(infd_time, inrast_time, row)<0)
+ if (Rast_get_d_raster_row(infd_time, inrast_time, row)<0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
time, row);
/*process the data */
@@ -151,12 +152,12 @@
d_tempk = ((DCELL *) inrast_tempk)[col];
d_rnet = ((DCELL *) inrast_rnet)[col];
d_time = ((DCELL *) inrast_time)[col];
- if (G_is_d_null_value(&d_albedo) ||
- G_is_d_null_value(&d_ndvi) ||
- G_is_d_null_value(&d_tempk) ||
- G_is_d_null_value(&d_rnet) ||
- G_is_d_null_value(&d_time)) {
- G_set_d_null_value(&outrast[col], 1);
+ if (Rast_is_d_null_value(&d_albedo) ||
+ Rast_is_d_null_value(&d_ndvi) ||
+ Rast_is_d_null_value(&d_tempk) ||
+ Rast_is_d_null_value(&d_rnet) ||
+ Rast_is_d_null_value(&d_time)) {
+ Rast_set_d_null_value(&outrast[col], 1);
}
else {
/* calculate soil heat flux */
@@ -164,7 +165,7 @@
outrast[col] = d;
}
}
- if (G_put_d_raster_row(outfd, outrast) < 0)
+ if (Rast_put_d_raster_row(outfd, outrast) < 0)
G_fatal_error(_("Failed writing raster map <%s>"), result);
}
G_free(inrast_albedo);
@@ -172,20 +173,20 @@
G_free(inrast_tempk);
G_free(inrast_rnet);
G_free(inrast_time);
- G_close_cell(infd_albedo);
- G_close_cell(infd_ndvi);
- G_close_cell(infd_tempk);
- G_close_cell(infd_rnet);
- G_close_cell(infd_time);
+ Rast_close_cell(infd_albedo);
+ Rast_close_cell(infd_ndvi);
+ Rast_close_cell(infd_tempk);
+ Rast_close_cell(infd_rnet);
+ Rast_close_cell(infd_time);
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
/* Colors in grey shade */
- G_init_colors(&colors);
- G_add_color_rule(0.0, 0, 0, 0, 200.0, 255, 255, 255, &colors);
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0.0, 0, 0, 0, 200.0, 255, 255, 255, &colors);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.emissivity/main.c
===================================================================
--- grass/trunk/imagery/i.emissivity/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.emissivity/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
double emissivity_generic(double ndvi);
@@ -59,17 +60,17 @@
result1 = output->answer;
/***************************************************/
- if ((infd = G_open_cell_old(ndvi, "")) < 0)
+ if ((infd = Rast_open_cell_old(ndvi, "")) < 0)
G_fatal_error(_("Cannot open cell file [%s]"), ndvi);
- inr = G_allocate_d_raster_buf();
+ inr = Rast_allocate_d_raster_buf();
/***************************************************/
nrows = G_window_rows();
ncols = G_window_cols();
- outr = G_allocate_d_raster_buf();
+ outr = Rast_allocate_d_raster_buf();
/* Create New raster files */
- if ((outfd = G_open_raster_new(result1, DCELL_TYPE)) < 0)
+ if ((outfd = Rast_open_raster_new(result1, DCELL_TYPE)) < 0)
G_fatal_error(_("Could not open <%s>"), result1);
/* Process pixels */
@@ -80,15 +81,15 @@
G_percent(row, nrows, 2);
/* read input maps */
- if (G_get_raster_row(infd,inr,row,DCELL_TYPE)< 0)
+ if (Rast_get_raster_row(infd,inr,row,DCELL_TYPE)< 0)
G_fatal_error(_("Could not read from <%s>"), ndvi);
/*process the data */
for (col = 0; col < ncols; col++)
{
d_ndvi = ((DCELL *) inr)[col];
- if (G_is_d_null_value(&d_ndvi))
- G_set_d_null_value(&outr[col], 1);
+ if (Rast_is_d_null_value(&d_ndvi))
+ Rast_set_d_null_value(&outr[col], 1);
else {
/****************************/
/* calculate emissivity */
@@ -96,17 +97,17 @@
outr[col] = d;
}
}
- if (G_put_raster_row(outfd, outr, DCELL_TYPE) < 0)
+ if (Rast_put_raster_row(outfd, outr, DCELL_TYPE) < 0)
G_fatal_error(_("Cannot write to output raster file"));
}
G_free(inr);
- G_close_cell(infd);
+ Rast_close_cell(infd);
G_free(outr);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
- G_short_history(result1, "raster", &history);
- G_command_history(&history);
- G_write_history(result1, &history);
+ Rast_short_history(result1, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result1, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.evapo.time_integration/main.c
===================================================================
--- grass/trunk/imagery/i.evapo.time_integration/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.evapo.time_integration/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,7 +17,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <grass/gis.h>
+#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define MAXFILES 400
@@ -160,18 +161,18 @@
}
if (!ok)
continue;
- infd[nfiles] = G_open_cell_old(name, mapset);
+ infd[nfiles] = Rast_open_cell_old(name, mapset);
if (infd[nfiles] < 0) {
ok = 0;
continue;
}
/* Allocate input buffer */
- in_data_type[nfiles] = G_raster_map_type(name, mapset);
- if ((infd[nfiles] = G_open_cell_old(name, mapset)) < 0)
+ in_data_type[nfiles] = Rast_raster_map_type(name, mapset);
+ if ((infd[nfiles] = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- if ((G_get_cellhd(name, mapset, &cellhd)) < 0)
+ if ((Rast_get_cellhd(name, mapset, &cellhd)) < 0)
G_fatal_error(_("Unable to read file header of raster map <%s>"), name);
- inrast[nfiles] = G_allocate_raster_buf(in_data_type[nfiles]);
+ inrast[nfiles] = Rast_allocate_raster_buf(in_data_type[nfiles]);
nfiles++;
}
nfiles--;
@@ -193,18 +194,18 @@
}
if (!ok)
continue;
- infd1[nfiles1] = G_open_cell_old(name1, mapset);
+ infd1[nfiles1] = Rast_open_cell_old(name1, mapset);
if (infd1[nfiles1] < 0) {
ok = 0;
continue;
}
/* Allocate input buffer */
- in_data_type1[nfiles1] = G_raster_map_type(name1, mapset);
- if ((infd1[nfiles1] = G_open_cell_old(name1, mapset)) < 0)
+ in_data_type1[nfiles1] = Rast_raster_map_type(name1, mapset);
+ if ((infd1[nfiles1] = Rast_open_cell_old(name1, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name1);
- if ((G_get_cellhd(name1, mapset, &cellhd)) < 0)
+ if ((Rast_get_cellhd(name1, mapset, &cellhd)) < 0)
G_fatal_error(_("Unable to read file header of raster map <%s>"), name1);
- inrast1[nfiles1] = G_allocate_raster_buf(in_data_type1[nfiles1]);
+ inrast1[nfiles1] = Rast_allocate_raster_buf(in_data_type1[nfiles1]);
nfiles1++;
}
nfiles1--;
@@ -232,20 +233,20 @@
}
if (!ok)
continue;
- infd2[nfiles2] = G_open_cell_old(name2, mapset);
+ infd2[nfiles2] = Rast_open_cell_old(name2, mapset);
if (infd2[nfiles2] < 0) {
ok = 0;
continue;
}
/* Allocate input buffer */
- in_data_type2[nfiles2] = G_raster_map_type(name2, mapset);
- if ((infd2[nfiles2] = G_open_cell_old(name2, mapset)) < 0) {
+ in_data_type2[nfiles2] = Rast_raster_map_type(name2, mapset);
+ if ((infd2[nfiles2] = Rast_open_cell_old(name2, mapset)) < 0) {
G_fatal_error(_("Unable to open raster map <%s>"), name2);
}
- if ((G_get_cellhd(name2, mapset, &cellhd)) < 0) {
+ if ((Rast_get_cellhd(name2, mapset, &cellhd)) < 0) {
G_fatal_error(_("Unable to read file header of raster map <%s>"), name2);
}
- inrast2[nfiles2] = G_allocate_d_raster_buf();
+ inrast2[nfiles2] = Rast_allocate_d_raster_buf();
nfiles2++;
}
nfiles2--;
@@ -255,11 +256,11 @@
/* Allocate output buffer, use input map data_type */
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_raster_buf(out_data_type);
+ outrast = Rast_allocate_raster_buf(out_data_type);
/* Create New raster files */
- if ((outfd = G_open_raster_new(result, 1)) < 0)
+ if ((outfd = Rast_open_raster_new(result, 1)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/*******************/
@@ -278,15 +279,15 @@
/* read input map */
for (i = 1; i <= nfiles; i++)
- if ((G_get_d_raster_row(infd[i], inrast[i], row)) < 0)
+ if ((Rast_get_d_raster_row(infd[i], inrast[i], row)) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), name, row);
for (i = 1; i <= nfiles1; i++)
- if ((G_get_d_raster_row(infd1[i], inrast1[i], row)) < 0)
+ if ((Rast_get_d_raster_row(infd1[i], inrast1[i], row)) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), name1, row);
for (i = 1; i <= nfiles2; i++)
- if ((G_get_d_raster_row (infd2[i], inrast2[i], row)) < 0)
+ if ((Rast_get_d_raster_row (infd2[i], inrast2[i], row)) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), name2, row);
/*process the data */
@@ -296,14 +297,14 @@
int d_null=0;
for (i = 1; i <= nfiles; i++)
{
- if (G_is_d_null_value(&((DCELL *) inrast[i])[col]))
+ if (Rast_is_d_null_value(&((DCELL *) inrast[i])[col]))
d_null=1;
else
d[i] = (double)((DCELL *) inrast[i])[col];
}
for (i = 1; i <= nfiles1; i++)
{
- if (G_is_d_null_value(&((DCELL *) inrast1[i])[col]))
+ if (Rast_is_d_null_value(&((DCELL *) inrast1[i])[col]))
d1_null=1;
else
d1[i] = ((DCELL *) inrast1[i])[col];
@@ -316,12 +317,12 @@
for (i = 1; i <= nfiles1; i++)
{
if ( d_null==1 || d1_null==1 )
- G_set_d_null_value(&outrast[col],1);
+ Rast_set_d_null_value(&outrast[col],1);
else
{
doy[i] = d1[i] - etodoy+1;
- if (G_is_d_null_value(&d2[(int)doy[i]]) || d2[(int)doy[i]]==0 )
- G_set_d_null_value(&outrast[col],1);
+ if (Rast_is_d_null_value(&d2[(int)doy[i]]) || d2[(int)doy[i]]==0 )
+ Rast_set_d_null_value(&outrast[col],1);
else
d_ETrF[i] = d[i] / d2[(int)doy[i]];
}
@@ -384,7 +385,7 @@
else
{
if (DOYbeforeETa[i]==0 || DOYbeforeETa[i]==0 )
- G_set_d_null_value(&outrast[col],1);
+ Rast_set_d_null_value(&outrast[col],1);
else
{
bfr = (int)DOYbeforeETa[i];
@@ -400,7 +401,7 @@
for (i = 1; i <= nfiles1; i++)
{
if(d_null==1 || d_null==1)
- G_set_d_null_value(&outrast[col],1);
+ Rast_set_d_null_value(&outrast[col],1);
else
{
d_out += d_ETrF[i] * sum[i];
@@ -408,28 +409,28 @@
}
}
}
- if (G_put_raster_row(outfd, outrast, out_data_type) < 0)
+ if (Rast_put_raster_row(outfd, outrast, out_data_type) < 0)
G_fatal_error(_("Unable to write to raster map<%s>"), result);
}
for (i = 1; i <= nfiles; i++) {
G_free(inrast[i]);
- G_close_cell(infd[i]);
+ Rast_close_cell(infd[i]);
G_free(inrast1[i]);
- G_close_cell(infd1[i]);
+ Rast_close_cell(infd1[i]);
G_free(inrast2[i]);
- G_close_cell(infd2[i]);
+ Rast_close_cell(infd2[i]);
}
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
/* Color table from 0.0 to 10.0 */
- G_init_colors(&colors);
- G_add_color_rule(0.0, 0, 0, 0, 10.0, 255, 255, 255, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0.0, 0, 0, 0, 10.0, 255, 255, 255, &colors);
/* Metadata */
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.fft/main.c
===================================================================
--- grass/trunk/imagery/i.fft/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.fft/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
#include <grass/glocale.h>
@@ -46,12 +47,12 @@
struct FPRange range;
DCELL min, max;
- G_read_fp_range(name, G_mapset(), &range);
- G_get_fp_range_min_max(&range, &min, &max);
- G_make_wave_colors(&wave, min, max);
- G_abs_log_colors(&colors, &wave, 100);
- G_write_colors(name, G_mapset(), &colors);
- G_free_colors(&colors);
+ Rast_read_fp_range(name, G_mapset(), &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
+ Rast_make_wave_colors(&wave, min, max);
+ Rast_abs_log_colors(&colors, &wave, 100);
+ Rast_write_colors(name, G_mapset(), &colors);
+ Rast_free_colors(&colors);
}
int main(int argc, char *argv[])
@@ -98,11 +99,11 @@
Cellmap_real = opt.real->answer;
Cellmap_imag = opt.imag->answer;
- inputfd = G_open_cell_old(Cellmap_orig, "");
+ inputfd = Rast_open_cell_old(Cellmap_orig, "");
if (inputfd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), Cellmap_orig);
- if (G_maskfd() >= 0)
+ if (Rast_maskfd() >= 0)
G_warning(_("Raster MASK found, consider to remove "
"(see man-page). Will continue..."));
@@ -120,8 +121,8 @@
data = G_malloc(rows * cols * 2 * sizeof(double));
/* allocate the space for one row of cell map data */
- cell_real = G_allocate_d_raster_buf();
- cell_imag = G_allocate_d_raster_buf();
+ cell_real = Rast_allocate_d_raster_buf();
+ cell_imag = Rast_allocate_d_raster_buf();
#define C(i, j) ((i) * cols + (j))
@@ -129,7 +130,7 @@
G_message(_("Reading the raster map <%s>..."),
Cellmap_orig);
for (i = 0; i < rows; i++) {
- if (G_get_d_raster_row(inputfd, cell_real, i) < 0)
+ if (Rast_get_d_raster_row(inputfd, cell_real, i) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
Cellmap_orig, i);
for (j = 0; j < cols; j++) {
@@ -141,16 +142,16 @@
}
/* close input cell map */
- G_close_cell(inputfd);
+ Rast_close_cell(inputfd);
/* perform FFT */
G_message(_("Starting FFT..."));
fft2(-1, data, totsize, cols, rows);
/* open the output cell maps */
- if ((realfd = G_open_fp_cell_new(Cellmap_real)) < 0)
+ if ((realfd = Rast_open_fp_cell_new(Cellmap_real)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), Cellmap_real);
- if ((imagfd = G_open_fp_cell_new(Cellmap_imag)) < 0)
+ if ((imagfd = Rast_open_fp_cell_new(Cellmap_imag)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), Cellmap_imag);
#define SWAP1(a, b) \
@@ -182,14 +183,14 @@
cell_real[j] = data[C(i, j)][0];
cell_imag[j] = data[C(i, j)][1];
}
- G_put_d_raster_row(realfd, cell_real);
- G_put_d_raster_row(imagfd, cell_imag);
+ Rast_put_d_raster_row(realfd, cell_real);
+ Rast_put_d_raster_row(imagfd, cell_imag);
G_percent(i+1, rows, 2);
}
- G_close_cell(realfd);
- G_close_cell(imagfd);
+ Rast_close_cell(realfd);
+ Rast_close_cell(imagfd);
G_free(cell_real);
G_free(cell_imag);
Modified: grass/trunk/imagery/i.gensig/alloc.c
===================================================================
--- grass/trunk/imagery/i.gensig/alloc.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/alloc.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
double *vector(int nl, int nh)
Modified: grass/trunk/imagery/i.gensig/can_invert.c
===================================================================
--- grass/trunk/imagery/i.gensig/can_invert.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/can_invert.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
int can_invert(double **a, int n)
Modified: grass/trunk/imagery/i.gensig/closefiles.c
===================================================================
--- grass/trunk/imagery/i.gensig/closefiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/closefiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,3 +1,4 @@
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include "files.h"
@@ -6,9 +7,9 @@
int n;
- G_close_cell(files->train_fd);
+ Rast_close_cell(files->train_fd);
for (n = 0; n < files->nbands; n++)
- G_close_cell(files->band_fd[n]);
+ Rast_close_cell(files->band_fd[n]);
return 0;
}
Modified: grass/trunk/imagery/i.gensig/covariance.c
===================================================================
--- grass/trunk/imagery/i.gensig/covariance.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/covariance.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "signature.h"
#include "files.h"
#include "local_proto.h"
@@ -30,8 +33,7 @@
G_percent(row, nrows, 2);
read_training_map(class, row, ncols, files);
for (b = 0; b < files->nbands; b++) /* NOTE: files->nbands == S->nbands */
- if (G_get_d_raster_row
- (files->band_fd[b], files->band_cell[b], row) < 0)
+ if (Rast_get_d_raster_row(files->band_fd[b], files->band_cell[b], row) < 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
for (b1 = 0; b1 < files->nbands; b1++) {
Modified: grass/trunk/imagery/i.gensig/eigen.c
===================================================================
--- grass/trunk/imagery/i.gensig/eigen.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/eigen.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <math.h>
double **matrix(), *vector();
Modified: grass/trunk/imagery/i.gensig/get_train.c
===================================================================
--- grass/trunk/imagery/i.gensig/get_train.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/get_train.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,7 +1,10 @@
#include <stdlib.h>
#include <string.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "signature.h"
#include "files.h"
@@ -25,27 +28,27 @@
/* determine the categories in the map */
I_init_signatures(S, files->nbands);
- G_init_cell_stats(&cell_stats);
+ Rast_init_cell_stats(&cell_stats);
G_message(_("Finding training classes..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_c_raster_row(fd, cell, row) < 0)
+ if (Rast_get_c_raster_row(fd, cell, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), cell,
row);
- G_update_cell_stats(cell, ncols, &cell_stats);
+ Rast_update_cell_stats(cell, ncols, &cell_stats);
}
G_percent(nrows, nrows, 2);
/* convert this to an array */
- G_rewind_cell_stats(&cell_stats);
+ Rast_rewind_cell_stats(&cell_stats);
n = 0;
- while (G_next_cell_stat(&cat, &count, &cell_stats)) {
+ while (Rast_next_cell_stat(&cat, &count, &cell_stats)) {
if (count > 1) {
I_new_signature(S);
S->sig[n].status = 1;
S->sig[n].npoints = count;
strncpy(S->sig[n].desc,
- G_get_cat(cat, &files->training_labels),
+ Rast_get_cat(cat, &files->training_labels),
sizeof(S->sig[n].desc)
);
n++;
@@ -60,12 +63,12 @@
list = (CELL *) G_calloc(n, sizeof(CELL));
n = 0;
- G_rewind_cell_stats(&cell_stats);
- while (G_next_cell_stat(&cat, &count, &cell_stats))
+ Rast_rewind_cell_stats(&cell_stats);
+ while (Rast_next_cell_stat(&cat, &count, &cell_stats))
if (count > 1)
list[n++] = cat;
- G_free_cell_stats(&cell_stats);
+ Rast_free_cell_stats(&cell_stats);
files->ncats = n;
files->training_cats = list;
Modified: grass/trunk/imagery/i.gensig/labels.c
===================================================================
--- grass/trunk/imagery/i.gensig/labels.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/labels.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,3 +1,4 @@
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include "parms.h"
#include "files.h"
@@ -9,6 +10,6 @@
map = parms->training_map;
mapset = G_find_cell2(map, "");
- if (G_read_cats(map, mapset, &files->training_labels) < 0)
- G_init_cats((CELL) 0, "", &files->training_labels);
+ if (Rast_read_cats(map, mapset, &files->training_labels) < 0)
+ Rast_init_cats((CELL) 0, "", &files->training_labels);
}
Modified: grass/trunk/imagery/i.gensig/lookup_class.c
===================================================================
--- grass/trunk/imagery/i.gensig/lookup_class.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/lookup_class.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/* build index of cell values from list */
/* -1 means not found in list */
@@ -14,7 +15,7 @@
while (ncats-- > 0) {
c = *cats++; /* extract the category */
- if (G_is_c_null_value(&c)) {
+ if (Rast_is_c_null_value(&c)) {
*class++ = -1;
continue;
}
Modified: grass/trunk/imagery/i.gensig/means.c
===================================================================
--- grass/trunk/imagery/i.gensig/means.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/means.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
#include "signature.h"
@@ -28,11 +29,10 @@
G_percent(row, nrows, 2);
read_training_map(class, row, ncols, files);
for (b = 0; b < files->nbands; b++) { /* NOTE: files->nbands == S->nbands */
- if (G_get_d_raster_row
- (files->band_fd[b], cell = files->band_cell[b], row) < 0)
+ if (Rast_get_d_raster_row(files->band_fd[b], cell = files->band_cell[b], row) < 0)
exit(1);
for (col = 0; col < ncols; col++) {
- if (G_is_d_null_value(&cell[col])) {
+ if (Rast_is_d_null_value(&cell[col])) {
n_nulls++;
continue;
}
Modified: grass/trunk/imagery/i.gensig/openfiles.c
===================================================================
--- grass/trunk/imagery/i.gensig/openfiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/openfiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "parms.h"
#include "files.h"
@@ -27,20 +30,20 @@
/* open training map for reading */
mapset = G_find_cell2(parms->training_map, "");
- files->train_fd = G_open_cell_old(parms->training_map, mapset);
+ files->train_fd = Rast_open_cell_old(parms->training_map, mapset);
if (files->train_fd < 0)
G_fatal_error(_("Unable to open training map <%s>"),
parms->training_map);
- files->train_cell = G_allocate_c_raster_buf();
+ files->train_cell = Rast_allocate_c_raster_buf();
/* open all maps for reading */
for (n = 0; n < Ref.nfiles; n++) {
files->band_fd[n] =
- G_open_cell_old(Ref.file[n].name, Ref.file[n].mapset);
+ Rast_open_cell_old(Ref.file[n].name, Ref.file[n].mapset);
if (files->band_fd[n] < 0)
G_fatal_error(_("Unable to open training map <%s in %s>"),
Ref.file[n].name, Ref.file[n].mapset);
- files->band_cell[n] = G_allocate_d_raster_buf();
+ files->band_cell[n] = Rast_allocate_d_raster_buf();
}
return 0;
Modified: grass/trunk/imagery/i.gensig/parse.c
===================================================================
--- grass/trunk/imagery/i.gensig/parse.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/parse.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include "parms.h"
Modified: grass/trunk/imagery/i.gensig/read_train.c
===================================================================
--- grass/trunk/imagery/i.gensig/read_train.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensig/read_train.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,12 +1,15 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "files.h"
#include "local_proto.h"
int read_training_map(CELL * class, int row, int ncols, struct files *files)
{
- if (G_get_c_raster_row(files->train_fd, files->train_cell, row) < 0)
+ if (Rast_get_c_raster_row(files->train_fd, files->train_cell, row) < 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
lookup_class(files->train_cell, ncols, files->training_cats, files->ncats,
Modified: grass/trunk/imagery/i.gensigset/closefiles.c
===================================================================
--- grass/trunk/imagery/i.gensigset/closefiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/closefiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,6 @@
+#include <grass/Rast.h>
#include <grass/imagery.h>
+
#include "files.h"
int closefiles(struct files *files)
@@ -6,9 +8,9 @@
int n;
- G_close_cell(files->train_fd);
+ Rast_close_cell(files->train_fd);
for (n = 0; n < files->nbands; n++)
- G_close_cell(files->band_fd[n]);
+ Rast_close_cell(files->band_fd[n]);
return 0;
}
Modified: grass/trunk/imagery/i.gensigset/get_train.c
===================================================================
--- grass/trunk/imagery/i.gensigset/get_train.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/get_train.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "files.h"
#include "parms.h"
@@ -26,26 +29,26 @@
/* determine the non-zero categories in the map */
I_InitSigSet(S);
I_SigSetNBands(S, files->nbands);
- I_SetSigTitle(S, G_get_cats_title(&files->training_labels));
+ I_SetSigTitle(S, Rast_get_cats_title(&files->training_labels));
- G_init_cell_stats(&cell_stats);
+ Rast_init_cell_stats(&cell_stats);
G_message(_("Finding training classes..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_c_raster_row(fd, cell, row) < 0)
+ if (Rast_get_c_raster_row(fd, cell, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), cell,
row);
- G_update_cell_stats(cell, ncols, &cell_stats);
+ Rast_update_cell_stats(cell, ncols, &cell_stats);
}
G_percent(nrows, nrows, 2);
/* convert this to an array */
- G_rewind_cell_stats(&cell_stats);
+ Rast_rewind_cell_stats(&cell_stats);
n = 0;
- while (G_next_cell_stat(&cat, &count, &cell_stats)) {
+ while (Rast_next_cell_stat(&cat, &count, &cell_stats)) {
if (count > 1) {
Sig = I_NewClassSig(S);
- I_SetClassTitle(Sig, G_get_cat(cat, &files->training_labels));
+ I_SetClassTitle(Sig, Rast_get_cat(cat, &files->training_labels));
Sig->classnum = cat;
/* initialize this class with maxsubclasses (by allocating them) */
for (i = 0; i < parms->maxsubclasses; i++)
@@ -64,12 +67,12 @@
list = (CELL *) G_calloc(n, sizeof(CELL));
n = 0;
- G_rewind_cell_stats(&cell_stats);
- while (G_next_cell_stat(&cat, &count, &cell_stats))
+ Rast_rewind_cell_stats(&cell_stats);
+ while (Rast_next_cell_stat(&cat, &count, &cell_stats))
if (count > 1)
list[n++] = cat;
- G_free_cell_stats(&cell_stats);
+ Rast_free_cell_stats(&cell_stats);
files->ncats = n;
files->training_cats = list;
Modified: grass/trunk/imagery/i.gensigset/invert.c
===================================================================
--- grass/trunk/imagery/i.gensigset/invert.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/invert.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
int invert(
Modified: grass/trunk/imagery/i.gensigset/labels.c
===================================================================
--- grass/trunk/imagery/i.gensigset/labels.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/labels.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,6 @@
+#include <grass/Rast.h>
#include <grass/imagery.h>
+
#include "parms.h"
#include "files.h"
@@ -9,6 +11,6 @@
map = parms->training_map;
mapset = G_find_cell2(map, "");
- if (G_read_cats(map, mapset, &files->training_labels) < 0)
- G_init_cats((CELL) 0, "", &files->training_labels);
+ if (Rast_read_cats(map, mapset, &files->training_labels) < 0)
+ Rast_init_cats((CELL) 0, "", &files->training_labels);
}
Modified: grass/trunk/imagery/i.gensigset/lookup_class.c
===================================================================
--- grass/trunk/imagery/i.gensigset/lookup_class.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/lookup_class.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/* build index of cell values from list */
/* -1 means not found in list */
@@ -14,7 +15,7 @@
while (ncats-- > 0) {
c = *cats++; /* extract the category */
- if (G_is_c_null_value(&c)) {
+ if (Rast_is_c_null_value(&c)) {
*class++ = -1;
continue;
}
Modified: grass/trunk/imagery/i.gensigset/main.c
===================================================================
--- grass/trunk/imagery/i.gensigset/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
*****************************************************************************/
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
#include "files.h"
Modified: grass/trunk/imagery/i.gensigset/openfiles.c
===================================================================
--- grass/trunk/imagery/i.gensigset/openfiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/openfiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "files.h"
#include "parms.h"
@@ -27,20 +30,20 @@
/* open training map for reading */
mapset = G_find_cell2(parms->training_map, "");
- files->train_fd = G_open_cell_old(parms->training_map, mapset);
+ files->train_fd = Rast_open_cell_old(parms->training_map, mapset);
if (files->train_fd < 0)
G_fatal_error(_("Unable to open training map <%s>"),
parms->training_map);
- files->train_cell = G_allocate_c_raster_buf();
+ files->train_cell = Rast_allocate_c_raster_buf();
/* open all maps for reading */
for (n = 0; n < Ref.nfiles; n++) {
files->band_fd[n] =
- G_open_cell_old(Ref.file[n].name, Ref.file[n].mapset);
+ Rast_open_cell_old(Ref.file[n].name, Ref.file[n].mapset);
if (files->band_fd[n] < 0)
G_fatal_error(_("Unable to open training map <%s in %s>"),
Ref.file[n].name, Ref.file[n].mapset);
- files->band_cell[n] = G_allocate_d_raster_buf();
+ files->band_cell[n] = Rast_allocate_d_raster_buf();
}
return 0;
Modified: grass/trunk/imagery/i.gensigset/parse.c
===================================================================
--- grass/trunk/imagery/i.gensigset/parse.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/parse.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
#include "parms.h"
Modified: grass/trunk/imagery/i.gensigset/read_data.c
===================================================================
--- grass/trunk/imagery/i.gensigset/read_data.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/read_data.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "files.h"
/* #include "local_proto.h" */
@@ -22,7 +25,7 @@
G_percent(row, nrows, 2);
read_training_map(class, row, ncols, files);
for (b = 0; b < files->nbands; b++)
- if (G_get_d_raster_row
+ if (Rast_get_d_raster_row
(files->band_fd[b], files->band_cell[b], row) < 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
@@ -33,8 +36,8 @@
continue;
Data = &S->ClassSig[n].ClassData;
for (b = 0; b < files->nbands; b++) {
- if (G_is_d_null_value(&files->band_cell[b][col]))
- G_set_d_null_value(&Data->x[Data->count][b], 1);
+ if (Rast_is_d_null_value(&files->band_cell[b][col]))
+ Rast_set_d_null_value(&Data->x[Data->count][b], 1);
else
Data->x[Data->count][b] = files->band_cell[b][col];
}
Modified: grass/trunk/imagery/i.gensigset/read_train.c
===================================================================
--- grass/trunk/imagery/i.gensigset/read_train.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/read_train.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,12 +1,15 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "files.h"
#include "local_proto.h"
int read_training_map(CELL * class, int row, int ncols, struct files *files)
{
- if (G_get_c_raster_row(files->train_fd, files->train_cell, row) < 0)
+ if (Rast_get_c_raster_row(files->train_fd, files->train_cell, row) < 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
lookup_class(files->train_cell, ncols, files->training_cats, files->ncats,
Modified: grass/trunk/imagery/i.gensigset/subcluster.c
===================================================================
--- grass/trunk/imagery/i.gensigset/subcluster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.gensigset/subcluster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <math.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
#include <grass/gmath.h>
@@ -131,7 +132,7 @@
n_nulls[b1] = 0;
mean[b1] = 0.0;
for (i = 0; i < Sig->ClassData.npixels; i++) {
- if (G_is_d_null_value(&Sig->ClassData.x[i][b1])) {
+ if (Rast_is_d_null_value(&Sig->ClassData.x[i][b1])) {
n_nulls[b1]++;
total_nulls++;
}
@@ -145,8 +146,8 @@
for (b2 = 0; b2 < nbands; b2++) {
R[b1][b2] = 0.0;
for (i = 0; i < Sig->ClassData.npixels; i++) {
- if (!G_is_d_null_value(&Sig->ClassData.x[i][b1]) &&
- !G_is_d_null_value(&Sig->ClassData.x[i][b2]))
+ if (!Rast_is_d_null_value(&Sig->ClassData.x[i][b1]) &&
+ !Rast_is_d_null_value(&Sig->ClassData.x[i][b2]))
R[b1][b2] +=
(Sig->ClassData.x[i][b1]) * (Sig->ClassData.x[i][b2]);
}
@@ -166,8 +167,8 @@
/* Seed the means and set the diagonal covariance components */
for (i = 0; i < Sig->nsubclasses; i++) {
for (b1 = 0; b1 < nbands; b1++) {
- if (G_is_d_null_value(&Sig->ClassData.x[(int)(i * period)][b1]))
- G_set_d_null_value(&Sig->SubSig[i].means[b1], 1);
+ if (Rast_is_d_null_value(&Sig->ClassData.x[(int)(i * period)][b1]))
+ Rast_set_d_null_value(&Sig->SubSig[i].means[b1], 1);
else
Sig->SubSig[i].means[b1] =
Sig->ClassData.x[(int)(i * period)][b1];
@@ -284,7 +285,7 @@
for (b1 = 0; b1 < nbands; b1++) {
Sig->SubSig[i].means[b1] = 0;
for (s = 0; s < Data->npixels; s++)
- if (!G_is_d_null_value(&Data->x[s][b1]))
+ if (!Rast_is_d_null_value(&Data->x[s][b1]))
Sig->SubSig[i].means[b1] +=
Data->p[s][i] * Data->x[s][b1];
Sig->SubSig[i].means[b1] /= (Sig->SubSig[i].N);
@@ -295,8 +296,8 @@
for (b2 = b1; b2 < nbands; b2++) {
Sig->SubSig[i].R[b1][b2] = 0;
for (s = 0; s < Data->npixels; s++) {
- if (!G_is_d_null_value(&Data->x[s][b1])
- && !G_is_d_null_value(&Data->x[s][b2])) {
+ if (!Rast_is_d_null_value(&Data->x[s][b1])
+ && !Rast_is_d_null_value(&Data->x[s][b2])) {
diff1 = Data->x[s][b1] - Sig->SubSig[i].means[b1];
diff2 = Data->x[s][b2] - Sig->SubSig[i].means[b2];
Sig->SubSig[i].R[b1][b2] +=
@@ -456,8 +457,8 @@
sum = 0;
for (b1 = 0; b1 < nbands; b1++)
for (b2 = 0; b2 < nbands; b2++) {
- if (G_is_d_null_value(&x[b1])
- || G_is_d_null_value(&x[b2]))
+ if (Rast_is_d_null_value(&x[b1])
+ || Rast_is_d_null_value(&x[b2]))
continue;
diff1 = x[b1] - SubSig->means[b1];
diff2 = x[b2] - SubSig->means[b2];
Modified: grass/trunk/imagery/i.his.rgb/closefiles.c
===================================================================
--- grass/trunk/imagery/i.his.rgb/closefiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.his.rgb/closefiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
/* This routine closes up the cell maps, frees up the row buffers and
@@ -16,26 +17,26 @@
const char *mapset;
for (i = 0; i < 3; i++) {
- G_close_cell(fd_output[i]);
+ Rast_close_cell(fd_output[i]);
G_free(rowbuf[i]);
}
mapset = G_mapset();
- G_read_range(r_name, mapset, &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_grey_scale_colors(&colors, min, max);
- G_write_colors(r_name, mapset, &colors);
+ Rast_read_range(r_name, mapset, &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_grey_scale_colors(&colors, min, max);
+ Rast_write_colors(r_name, mapset, &colors);
- G_read_range(g_name, mapset, &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_grey_scale_colors(&colors, min, max);
- G_write_colors(g_name, mapset, &colors);
+ Rast_read_range(g_name, mapset, &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_grey_scale_colors(&colors, min, max);
+ Rast_write_colors(g_name, mapset, &colors);
- G_read_range(b_name, mapset, &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_grey_scale_colors(&colors, min, max);
- G_write_colors(b_name, mapset, &colors);
+ Rast_read_range(b_name, mapset, &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_grey_scale_colors(&colors, min, max);
+ Rast_write_colors(b_name, mapset, &colors);
return 0;
}
Modified: grass/trunk/imagery/i.his.rgb/his2rgb.c
===================================================================
--- grass/trunk/imagery/i.his.rgb/his2rgb.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.his.rgb/his2rgb.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
each band is processed and written out. CWU GIS Lab: DBS 8/90 */
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
void his2rgb(CELL * rowbuffer[3], int columns)
Modified: grass/trunk/imagery/i.his.rgb/main.c
===================================================================
--- grass/trunk/imagery/i.his.rgb/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.his.rgb/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "globals.h"
@@ -90,7 +91,7 @@
/* read in a row from each cell map */
for (band = 0; band < 3; band++)
- if (G_get_map_row(fd_input[band], rowbuffer[band], i) < 0)
+ if (Rast_get_map_row(fd_input[band], rowbuffer[band], i) < 0)
G_fatal_error(_("Unable to read raster map row %d"), i);
/* process this row of the map */
@@ -98,7 +99,7 @@
/* write out the new row for each cell map */
for (band = 0; band < 3; band++)
- if (G_put_raster_row(fd_output[band], rowbuffer[band], CELL_TYPE)
+ if (Rast_put_raster_row(fd_output[band], rowbuffer[band], CELL_TYPE)
< 0)
G_fatal_error(_("Failed writing raster map row %d"), i);
}
Modified: grass/trunk/imagery/i.his.rgb/openfiles.c
===================================================================
--- grass/trunk/imagery/i.his.rgb/openfiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.his.rgb/openfiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "globals.h"
@@ -9,28 +10,28 @@
int fd_input[3], int fd_output[3], CELL * rowbuf[3])
{
/* open output files */
- if ((fd_output[0] = G_open_cell_new(r_name)) < 0)
+ if ((fd_output[0] = Rast_open_cell_new(r_name)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), r_name);
- if ((fd_output[1] = G_open_cell_new(g_name)) < 0)
+ if ((fd_output[1] = Rast_open_cell_new(g_name)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), g_name);
- if ((fd_output[2] = G_open_cell_new(b_name)) < 0)
+ if ((fd_output[2] = Rast_open_cell_new(b_name)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), b_name);
/* allocate the cell row buffer */
- if ((rowbuf[0] = G_allocate_cell_buf()) == NULL)
+ if ((rowbuf[0] = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate the input row buffer"));
- if ((rowbuf[1] = G_allocate_cell_buf()) == NULL)
+ if ((rowbuf[1] = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate the input row buffer"));
- if ((rowbuf[2] = G_allocate_cell_buf()) == NULL)
+ if ((rowbuf[2] = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate the input row buffer"));
/* open input files (maps can be in different mapsets) */
- if ((fd_input[0] = G_open_cell_old(h_name, "")) < 0)
+ if ((fd_input[0] = Rast_open_cell_old(h_name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), h_name);
- if ((fd_input[1] = G_open_cell_old(i_name, "")) < 0)
+ if ((fd_input[1] = Rast_open_cell_old(i_name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), i_name);
- if ((fd_input[2] = G_open_cell_old(s_name, "")) < 0)
+ if ((fd_input[2] = Rast_open_cell_old(s_name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), s_name);
}
Modified: grass/trunk/imagery/i.ifft/main.c
===================================================================
--- grass/trunk/imagery/i.ifft/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.ifft/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/gmath.h>
@@ -44,10 +45,10 @@
DCELL min, max;
/* make a real component color table */
- G_read_fp_range(name, G_mapset(), &range);
- G_get_fp_range_min_max(&range, &min, &max);
- G_make_grey_scale_fp_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_read_fp_range(name, G_mapset(), &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
+ Rast_make_grey_scale_fp_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
int main(int argc, char *argv[])
@@ -99,19 +100,19 @@
Cellmap_orig = opt.orig->answer;
/* open input raster map */
- realfd = G_open_cell_old(Cellmap_real, "");
+ realfd = Rast_open_cell_old(Cellmap_real, "");
if (realfd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
Cellmap_real);
- imagfd = G_open_cell_old(Cellmap_imag, "");
+ imagfd = Rast_open_cell_old(Cellmap_imag, "");
if (imagfd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
Cellmap_imag);
/* get and compare the original window data */
- G_get_cellhd(Cellmap_real, "", &realhead);
- G_get_cellhd(Cellmap_imag, "", &imaghead);
+ Rast_get_cellhd(Cellmap_real, "", &realhead);
+ Rast_get_cellhd(Cellmap_imag, "", &imaghead);
if (realhead.proj != imaghead.proj ||
realhead.zone != imaghead.zone ||
@@ -137,18 +138,18 @@
data = G_malloc(rows * cols * 2 * sizeof(double));
/* allocate the space for one row of cell map data */
- cell_real = G_allocate_d_raster_buf();
- cell_imag = G_allocate_d_raster_buf();
+ cell_real = Rast_allocate_d_raster_buf();
+ cell_imag = Rast_allocate_d_raster_buf();
#define C(i, j) ((i) * cols + (j))
/* Read in cell map values */
G_message(_("Reading raster maps..."));
for (i = 0; i < rows; i++) {
- if (G_get_d_raster_row(realfd, cell_real, i) < 0)
+ if (Rast_get_d_raster_row(realfd, cell_real, i) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
Cellmap_real, i);
- if (G_get_d_raster_row(imagfd, cell_imag, i) < 0)
+ if (Rast_get_d_raster_row(imagfd, cell_imag, i) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
Cellmap_imag, i);
for (j = 0; j < cols; j++) {
@@ -159,17 +160,17 @@
}
/* close input cell maps */
- G_close_cell(realfd);
- G_close_cell(imagfd);
+ Rast_close_cell(realfd);
+ Rast_close_cell(imagfd);
/* Read in cell map values */
G_message(_("Masking raster maps..."));
- maskfd = G_maskfd();
+ maskfd = Rast_maskfd();
if (maskfd >= 0) {
- maskbuf = G_allocate_cell_buf();
+ maskbuf = Rast_allocate_cell_buf();
for (i = 0; i < rows; i++) {
- G_get_map_row(maskfd, maskbuf, i);
+ Rast_get_map_row(maskfd, maskbuf, i);
for (j = 0; j < cols; j++) {
if (maskbuf[j] == 0) {
data[C(i, j)][0] = 0.0;
@@ -179,7 +180,7 @@
G_percent(i+1, rows, 2);
}
- G_close_cell(maskfd);
+ Rast_close_cell(maskfd);
G_free(maskbuf);
}
@@ -210,7 +211,7 @@
fft2(1, data, totsize, cols, rows);
/* open the output cell map */
- if ((outputfd = G_open_fp_cell_new(Cellmap_orig)) < 0)
+ if ((outputfd = Rast_open_fp_cell_new(Cellmap_orig)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
Cellmap_orig);
@@ -221,12 +222,12 @@
for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++)
cell_real[j] = data[C(i, j)][0];
- G_put_d_raster_row(outputfd, cell_real);
+ Rast_put_d_raster_row(outputfd, cell_real);
G_percent(i+1, rows, 2);
}
- G_close_cell(outputfd);
+ Rast_close_cell(outputfd);
G_free(cell_real);
G_free(cell_imag);
Modified: grass/trunk/imagery/i.latlong/main.c
===================================================================
--- grass/trunk/imagery/i.latlong/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.latlong/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
@@ -74,11 +75,11 @@
result1 = output1->answer;
/***************************************************/
- if ((infd = G_open_cell_old(in, "")) < 0)
+ if ((infd = Rast_open_cell_old(in, "")) < 0)
G_fatal_error(_("Cannot open cell file [%s]"), in);
- if (G_get_cellhd(in, "", &cellhd) < 0)
+ if (Rast_get_cellhd(in, "", &cellhd) < 0)
G_fatal_error(_("Cannot read file header of [%s])"), in);
- inrast = G_allocate_d_raster_buf();
+ inrast = Rast_allocate_d_raster_buf();
/***************************************************/
stepx = cellhd.ew_res;
@@ -113,16 +114,16 @@
G_fatal_error(_("Unable to set up lat/long projection parameters"));
} /* End of stolen from r.sun */
- outrast1 = G_allocate_d_raster_buf();
+ outrast1 = Rast_allocate_d_raster_buf();
- if ((outfd1 = G_open_raster_new(result1,DCELL_TYPE)) < 0)
+ if ((outfd1 = Rast_open_raster_new(result1,DCELL_TYPE)) < 0)
G_fatal_error(_("Could not open <%s>"), result1);
for (row = 0; row < nrows; row++)
{
G_percent(row, nrows, 2);
- if (G_get_d_raster_row(infd, inrast, row) < 0)
+ if (Rast_get_d_raster_row(infd, inrast, row) < 0)
G_fatal_error(_("Could not read from <%s>"), in);
for (col = 0; col < ncols; col++)
@@ -138,17 +139,17 @@
d = latitude;
outrast1[col] = d;
}
- if (G_put_d_raster_row(outfd1, outrast1) < 0)
+ if (Rast_put_d_raster_row(outfd1, outrast1) < 0)
G_fatal_error(_("Cannot write to output raster file"));
}
G_free(inrast);
- G_close_cell(infd);
+ Rast_close_cell(infd);
G_free(outrast1);
- G_close_cell(outfd1);
+ Rast_close_cell(outfd1);
- G_short_history(result1, "raster", &history);
- G_command_history(&history);
- G_write_history(result1, &history);
+ Rast_short_history(result1, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result1, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.maxlik/classify.c
===================================================================
--- grass/trunk/imagery/i.maxlik/classify.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.maxlik/classify.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "global.h"
@@ -24,13 +25,13 @@
for (col = 0; col < ncols; col++) {
valid_data = 0;
for (band = 0; band < nfiles; band++)
- if ((valid_data = !G_is_d_null_value(&cell[band][col])))
+ if ((valid_data = !Rast_is_d_null_value(&cell[band][col])))
break;
if (!valid_data) { /* all nulls are classified as nulls */
- G_set_c_null_value(class++, 1);
+ Rast_set_c_null_value(class++, 1);
if (reject)
- G_set_c_null_value(reject++, 1);
+ Rast_set_c_null_value(reject++, 1);
continue;
}
Modified: grass/trunk/imagery/i.maxlik/hist.c
===================================================================
--- grass/trunk/imagery/i.maxlik/hist.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.maxlik/hist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,12 +1,13 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
int make_history(char *name, char *group, char *subgroup, char *sigfile)
{
struct History hist;
- if (G_read_history(name, G_mapset(), &hist) >= 0) {
+ if (Rast_read_history(name, G_mapset(), &hist) >= 0) {
sprintf(hist.datsrc_1, "Group/subgroup: %s/%s", group, subgroup);
sprintf(hist.datsrc_2, "Signature file: %s", sigfile);
- G_write_history(name, &hist);
+ Rast_write_history(name, &hist);
}
return 0;
Modified: grass/trunk/imagery/i.maxlik/invert.c
===================================================================
--- grass/trunk/imagery/i.maxlik/invert.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.maxlik/invert.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
#include "local_proto.h"
Modified: grass/trunk/imagery/i.maxlik/main.c
===================================================================
--- grass/trunk/imagery/i.maxlik/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.maxlik/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
#include "local_proto.h"
@@ -105,63 +106,63 @@
G_percent(row, nrows, 2);
for (band = 0; band < Ref.nfiles; band++)
- if (G_get_d_raster_row(cellfd[band], cell[band], row) < 0)
+ if (Rast_get_d_raster_row(cellfd[band], cell[band], row) < 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
classify(class_cell, reject_cell, ncols);
- G_put_raster_row(class_fd, class_cell, CELL_TYPE);
+ Rast_put_raster_row(class_fd, class_cell, CELL_TYPE);
if (reject_fd > 0)
- G_put_raster_row(reject_fd, reject_cell, CELL_TYPE);
+ Rast_put_raster_row(reject_fd, reject_cell, CELL_TYPE);
}
G_percent(nrows, nrows, 2);
- G_close_cell(class_fd);
+ Rast_close_cell(class_fd);
if (reject_fd > 0)
- G_close_cell(reject_fd);
+ Rast_close_cell(reject_fd);
- G_init_cats((CELL) S.nsigs, "Maximum Likelihood Classification", &cats);
+ Rast_init_cats((CELL) S.nsigs, "Maximum Likelihood Classification", &cats);
for (i = 0; i < S.nsigs; i++) {
if (*S.sig[i].desc)
- G_set_cat((CELL) (i + 1), S.sig[i].desc, &cats);
+ Rast_set_cat((CELL) (i + 1), S.sig[i].desc, &cats);
}
- G_write_cats(class_name, &cats);
- G_free_cats(&cats);
+ Rast_write_cats(class_name, &cats);
+ Rast_free_cats(&cats);
if (reject_fd > 0) {
char title[100];
sprintf(title, "Rejection Probability for %s", class_name);
- G_init_cats((CELL) 17, title, &cats);
- G_set_cats_title(title, &cats);
- G_set_cat((CELL) 0, "no data", &cats);
- G_set_cat((CELL) 1, "0.1%", &cats);
- G_set_cat((CELL) 2, "0.5%", &cats);
- G_set_cat((CELL) 3, "1%", &cats);
- G_set_cat((CELL) 4, "2%", &cats);
- G_set_cat((CELL) 5, "5%", &cats);
- G_set_cat((CELL) 6, "10%", &cats);
- G_set_cat((CELL) 7, "20%", &cats);
- G_set_cat((CELL) 8, "30%", &cats);
- G_set_cat((CELL) 9, "50%", &cats);
- G_set_cat((CELL) 10, "70%", &cats);
- G_set_cat((CELL) 11, "80%", &cats);
- G_set_cat((CELL) 12, "90%", &cats);
- G_set_cat((CELL) 13, "95%", &cats);
- G_set_cat((CELL) 14, "98%", &cats);
- G_set_cat((CELL) 15, "99%", &cats);
- G_set_cat((CELL) 16, "100%", &cats);
- G_set_cat((CELL) 17, "bad", &cats);
- G_write_cats(reject_name, &cats);
- G_free_cats(&cats);
+ Rast_init_cats((CELL) 17, title, &cats);
+ Rast_set_cats_title(title, &cats);
+ Rast_set_cat((CELL) 0, "no data", &cats);
+ Rast_set_cat((CELL) 1, "0.1%", &cats);
+ Rast_set_cat((CELL) 2, "0.5%", &cats);
+ Rast_set_cat((CELL) 3, "1%", &cats);
+ Rast_set_cat((CELL) 4, "2%", &cats);
+ Rast_set_cat((CELL) 5, "5%", &cats);
+ Rast_set_cat((CELL) 6, "10%", &cats);
+ Rast_set_cat((CELL) 7, "20%", &cats);
+ Rast_set_cat((CELL) 8, "30%", &cats);
+ Rast_set_cat((CELL) 9, "50%", &cats);
+ Rast_set_cat((CELL) 10, "70%", &cats);
+ Rast_set_cat((CELL) 11, "80%", &cats);
+ Rast_set_cat((CELL) 12, "90%", &cats);
+ Rast_set_cat((CELL) 13, "95%", &cats);
+ Rast_set_cat((CELL) 14, "98%", &cats);
+ Rast_set_cat((CELL) 15, "99%", &cats);
+ Rast_set_cat((CELL) 16, "100%", &cats);
+ Rast_set_cat((CELL) 17, "bad", &cats);
+ Rast_write_cats(reject_name, &cats);
+ Rast_free_cats(&cats);
- G_make_grey_scale_colors(&colr, (CELL) 1, (CELL) 16);
+ Rast_make_grey_scale_colors(&colr, (CELL) 1, (CELL) 16);
- G_set_color((CELL) 0, 0, 255, 0, &colr);
- G_set_color((CELL) 17, 255, 0, 0, &colr);
- G_write_colors(reject_name, G_mapset(), &colr);
- G_free_colors(&colr);
+ Rast_set_color((CELL) 0, 0, 255, 0, &colr);
+ Rast_set_color((CELL) 17, 255, 0, 0, &colr);
+ Rast_write_colors(reject_name, G_mapset(), &colr);
+ Rast_free_colors(&colr);
}
/* associate the output files with the group */
Modified: grass/trunk/imagery/i.maxlik/open.c
===================================================================
--- grass/trunk/imagery/i.maxlik/open.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.maxlik/open.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
#include "local_proto.h"
@@ -34,10 +35,10 @@
cellfd = (int *)G_malloc(Ref.nfiles * sizeof(int));
P = (double *)G_malloc(Ref.nfiles * sizeof(double));
for (n = 0; n < Ref.nfiles; n++) {
- cell[n] = G_allocate_d_raster_buf();
+ cell[n] = Rast_allocate_d_raster_buf();
name = Ref.file[n].name;
mapset = Ref.file[n].mapset;
- if ((cellfd[n] = G_open_cell_old(name, mapset)) < 0)
+ if ((cellfd[n] = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
G_fully_qualified_name(name, mapset));
}
@@ -61,20 +62,20 @@
B = (double *)G_malloc(S.nsigs * sizeof(double));
invert_signatures();
- class_fd = G_open_cell_new(class_name);
+ class_fd = Rast_open_cell_new(class_name);
if (class_fd < 0)
exit(EXIT_FAILURE);
- class_cell = G_allocate_cell_buf();
+ class_cell = Rast_allocate_cell_buf();
reject_cell = NULL;
if (reject_name) {
- reject_fd = G_open_cell_new(reject_name);
+ reject_fd = Rast_open_cell_new(reject_name);
if (reject_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
reject_name);
else
- reject_cell = G_allocate_cell_buf();
+ reject_cell = Rast_allocate_cell_buf();
}
return 0;
Modified: grass/trunk/imagery/i.modis.qc/main.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.modis.qc/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
/* MOD09Q1 Products (250m, 8-Days) */
@@ -192,21 +193,21 @@
(!strcmp(qcflag, "pixel_adjacent_to_cloud") && (strcmp(product, "mod09A1s"))))
G_fatal_error(_("This flag is only available for MOD09A1s @ 500m products"));
- if ((infd = G_open_cell_old(qcchan, "")) < 0)
+ if ((infd = Rast_open_cell_old(qcchan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), qcchan);
- if (G_get_cellhd(qcchan, "", &cellhd) < 0)
+ if (Rast_get_cellhd(qcchan, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s> "), qcchan);
- inrast = G_allocate_c_raster_buf();
+ inrast = Rast_allocate_c_raster_buf();
G_debug(3, "number of rows %d", cellhd.rows);
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_c_raster_buf();
+ outrast = Rast_allocate_c_raster_buf();
/* Create New raster files */
- if ((outfd = G_open_raster_new(result, data_type_output)) < 0)
+ if ((outfd = Rast_open_raster_new(result, data_type_output)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/* Process pixels */
@@ -214,7 +215,7 @@
{
CELL c;
G_percent(row, nrows, 2);
- if (G_get_c_raster_row(infd, inrast, row) < 0)
+ if (Rast_get_c_raster_row(infd, inrast, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
qcchan, row);
@@ -222,8 +223,8 @@
for (col = 0; col < ncols; col++)
{
c = inrast[col];
- if (G_is_c_null_value(&c))
- G_set_c_null_value(&outrast[col], 1);
+ if (Rast_is_c_null_value(&c))
+ Rast_set_c_null_value(&outrast[col], 1);
else if (!strcmp(product, "mod09A1"))
{
if (!strcmp(qcflag, "modland_qa_bits"))
@@ -318,22 +319,22 @@
outrast[col] = c;
}
- if (G_put_c_raster_row(outfd, outrast) < 0)
+ if (Rast_put_c_raster_row(outfd, outrast) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
output->answer, row);
}
G_free(inrast);
- G_close_cell(infd);
+ Rast_close_cell(infd);
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
/* Color from 0 to 10 in grey */
- G_init_colors(&colors);
- G_add_color_rule(0, 0, 0, 0, 10, 255, 255, 255, &colors);
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0, 0, 0, 0, 10, 255, 255, 255, &colors);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.pca/main.c
===================================================================
--- grass/trunk/imagery/i.pca/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.pca/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -124,7 +125,7 @@
sprintf(tmpbuf, "%s.%d", opt_out->answer, i + 1);
G_check_input_output_name(opt_in->answers[i], tmpbuf, GR_FATAL_EXIT);
- if ((inp_fd[i] = G_open_cell_old(opt_in->answers[i], "")) < 0)
+ if ((inp_fd[i] = Rast_open_cell_old(opt_in->answers[i], "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
opt_in->answers[i]);
}
@@ -171,7 +172,7 @@
write_support(bands, outname, eigmat, eigval);
/* close output file */
- G_unopen_cell(inp_fd[i]);
+ Rast_unopen_cell(inp_fd[i]);
}
exit(EXIT_SUCCESS);
@@ -236,12 +237,12 @@
int row, col;
double sum = 0.;
- maptype = G_get_raster_map_type(fds[i]);
+ maptype = Rast_get_raster_map_type(fds[i]);
/* don't assume each image is of the same type */
if (rowbuf)
G_free(rowbuf);
- if ((rowbuf = G_allocate_raster_buf(maptype)) == NULL)
+ if ((rowbuf = Rast_allocate_raster_buf(maptype)) == NULL)
G_fatal_error(_("Unable allocate memory for row buffer"));
G_verbose_message(_("Computing means for band %d..."), i + 1);
@@ -251,18 +252,18 @@
if(G_verbose() > G_verbose_std())
G_percent(row, rows - 1, 2);
- if (G_get_raster_row(fds[i], rowbuf, row, maptype) < 0)
+ if (Rast_get_raster_row(fds[i], rowbuf, row, maptype) < 0)
G_fatal_error(_("Unable to read raster map row %d"), row);
for (col = 0; col < cols; col++) {
/* skip null cells */
- if (G_is_null_value(rowbuf, maptype)) {
- ptr = G_incr_void_ptr(ptr, G_raster_size(maptype));
+ if (Rast_is_null_value(rowbuf, maptype)) {
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(maptype));
continue;
}
- sum += G_get_raster_value_d(rowbuf, maptype);
- ptr = G_incr_void_ptr(ptr, G_raster_size(maptype));
+ sum += Rast_get_raster_value_d(rowbuf, maptype);
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(maptype));
}
}
@@ -284,14 +285,14 @@
int row, col;
for (j = 0; j < bands; j++) {
- RASTER_MAP_TYPE maptype = G_get_raster_map_type(fds[j]);
+ RASTER_MAP_TYPE maptype = Rast_get_raster_map_type(fds[j]);
void *rowbuf1 = NULL;
void *rowbuf2 = NULL;
/* don't assume each image is of the same type */
if (rowbuf1)
G_free(rowbuf1);
- if ((rowbuf1 = G_allocate_raster_buf(maptype)) == NULL)
+ if ((rowbuf1 = Rast_allocate_raster_buf(maptype)) == NULL)
G_fatal_error(_("Unable allocate memory for row buffer"));
G_verbose_message(_("Computing row %d of covariance matrix..."),
@@ -302,19 +303,19 @@
if(G_verbose() > G_verbose_std())
G_percent(row, rows - 1, 2);
- if (G_get_raster_row(fds[j], rowbuf1, row, maptype) < 0)
+ if (Rast_get_raster_row(fds[j], rowbuf1, row, maptype) < 0)
G_fatal_error(_("Unable to read raster map row %d"), row);
for (k = j; k < bands; k++) {
- RASTER_MAP_TYPE maptype2 = G_get_raster_map_type(fds[k]);
+ RASTER_MAP_TYPE maptype2 = Rast_get_raster_map_type(fds[k]);
/* don't assume each image is of the same type */
if (rowbuf2)
G_free(rowbuf2);
- if ((rowbuf2 = G_allocate_raster_buf(maptype2)) == NULL)
+ if ((rowbuf2 = Rast_allocate_raster_buf(maptype2)) == NULL)
G_fatal_error(_("Unable to allocate memory for row buffer"));
- if (G_get_raster_row(fds[k], rowbuf2, row, maptype2) < 0)
+ if (Rast_get_raster_row(fds[k], rowbuf2, row, maptype2) < 0)
G_fatal_error(_("Unable to read raster map row %d"), row);
ptr1 = rowbuf1;
@@ -322,20 +323,20 @@
for (col = 0; col < cols; col++) {
/* skip null cells */
- if (G_is_null_value(ptr1, maptype) ||
- G_is_null_value(ptr2, maptype2)) {
- ptr1 = G_incr_void_ptr(ptr1, G_raster_size(maptype));
- ptr2 = G_incr_void_ptr(ptr2, G_raster_size(maptype2));
+ if (Rast_is_null_value(ptr1, maptype) ||
+ Rast_is_null_value(ptr2, maptype2)) {
+ ptr1 = Rast_incr_void_ptr(ptr1, Rast_raster_size(maptype));
+ ptr2 = Rast_incr_void_ptr(ptr2, Rast_raster_size(maptype2));
continue;
}
covar[j][k] +=
- ((double)G_get_raster_value_d(ptr1, maptype) -
- mu[j]) * ((double)G_get_raster_value_d(ptr2,
+ ((double)Rast_get_raster_value_d(ptr1, maptype) -
+ mu[j]) * ((double)Rast_get_raster_value_d(ptr2,
maptype2) - mu[k]);
- ptr1 = G_incr_void_ptr(ptr1, G_raster_size(maptype));
- ptr2 = G_incr_void_ptr(ptr2, G_raster_size(maptype2));
+ ptr1 = Rast_incr_void_ptr(ptr1, Rast_raster_size(maptype));
+ ptr2 = Rast_incr_void_ptr(ptr2, Rast_raster_size(maptype2));
}
covar[k][j] = covar[j][k];
@@ -359,8 +360,8 @@
double new_range = 0.;
int rows = G_window_rows();
int cols = G_window_cols();
- int cell_mapsiz = G_raster_size(CELL_TYPE);
- int dcell_mapsiz = G_raster_size(DCELL_TYPE);
+ int cell_mapsiz = Rast_raster_size(CELL_TYPE);
+ int dcell_mapsiz = Rast_raster_size(DCELL_TYPE);
DCELL *d_buf;
/* 2 passes for rescale. 1 pass for no rescale */
@@ -370,8 +371,8 @@
d_buf = (DCELL *) G_malloc(cols * sizeof(double));
/* allocate memory for output row buffer */
- outbuf = (scale) ? G_allocate_raster_buf(CELL_TYPE) :
- G_allocate_raster_buf(DCELL_TYPE);
+ outbuf = (scale) ? Rast_allocate_raster_buf(CELL_TYPE) :
+ Rast_allocate_raster_buf(DCELL_TYPE);
if (!outbuf)
G_fatal_error(_("Unable to allocate memory for raster row"));
@@ -387,10 +388,10 @@
/* open a new file for output */
if (scale)
- out_fd = G_open_cell_new(name);
+ out_fd = Rast_open_cell_new(name);
else {
- out_fd = G_open_fp_cell_new(name);
- G_set_fp_type(DCELL_TYPE);
+ out_fd = Rast_open_fp_cell_new(name);
+ Rast_set_fp_type(DCELL_TYPE);
}
if (out_fd < 0)
@@ -421,15 +422,15 @@
for (j = 0; j < bands; j++) {
RASTER_MAP_TYPE maptype =
- G_get_raster_map_type(inp_fd[j]);
+ Rast_get_raster_map_type(inp_fd[j]);
/* don't assume each image is of the same type */
if (rowbuf)
G_free(rowbuf);
- if (!(rowbuf = G_allocate_raster_buf(maptype)))
+ if (!(rowbuf = Rast_allocate_raster_buf(maptype)))
G_fatal_error(_("Unable allocate memory for row buffer"));
- if (G_get_raster_row(inp_fd[j], rowbuf, row, maptype) < 0)
+ if (Rast_get_raster_row(inp_fd[j], rowbuf, row, maptype) < 0)
G_fatal_error(_("Unable to read raster map row %d"), row);
rowptr = rowbuf;
@@ -439,26 +440,26 @@
* of j-th band for current j */
for (col = 0; col < cols; col++) {
/* handle null cells */
- if (G_is_null_value(rowptr, maptype)) {
+ if (Rast_is_null_value(rowptr, maptype)) {
if (scale) {
- G_set_null_value(outptr, 1, CELL_TYPE);
- outptr = G_incr_void_ptr(outptr, cell_mapsiz);
+ Rast_set_null_value(outptr, 1, CELL_TYPE);
+ outptr = Rast_incr_void_ptr(outptr, cell_mapsiz);
}
else {
- G_set_null_value(outptr, 1, DCELL_TYPE);
+ Rast_set_null_value(outptr, 1, DCELL_TYPE);
outptr =
- G_incr_void_ptr(outptr, dcell_mapsiz);
+ Rast_incr_void_ptr(outptr, dcell_mapsiz);
}
rowptr =
- G_incr_void_ptr(rowptr,
- G_raster_size(maptype));
+ Rast_incr_void_ptr(rowptr,
+ Rast_raster_size(maptype));
continue;
}
/* corresp. cell of j-th band */
d_buf[col] +=
- eigmat[i][j] * G_get_raster_value_d(rowptr,
+ eigmat[i][j] * Rast_get_raster_value_d(rowptr,
maptype);
/* the cell entry is complete */
@@ -476,7 +477,7 @@
else if (scale) {
if (min == max) {
- G_set_raster_value_c(outptr, 1,
+ Rast_set_raster_value_c(outptr, 1,
CELL_TYPE);
}
else {
@@ -487,31 +488,31 @@
min) / old_range) +
scale_min);
- G_set_raster_value_c(outptr, tmpcell,
+ Rast_set_raster_value_c(outptr, tmpcell,
CELL_TYPE);
}
}
else { /* (!scale) */
- G_set_raster_value_d(outptr, d_buf[col],
+ Rast_set_raster_value_d(outptr, d_buf[col],
DCELL_TYPE);
}
}
outptr = (scale) ?
- G_incr_void_ptr(outptr, cell_mapsiz) :
- G_incr_void_ptr(outptr, dcell_mapsiz);
+ Rast_incr_void_ptr(outptr, cell_mapsiz) :
+ Rast_incr_void_ptr(outptr, dcell_mapsiz);
rowptr =
- G_incr_void_ptr(rowptr, G_raster_size(maptype));
+ Rast_incr_void_ptr(rowptr, Rast_raster_size(maptype));
}
} /* for j = 0 to bands */
if (pass == PASSES) {
if (scale)
- G_put_raster_row(out_fd, outbuf, CELL_TYPE);
+ Rast_put_raster_row(out_fd, outbuf, CELL_TYPE);
else
- G_put_raster_row(out_fd, outbuf, DCELL_TYPE);
+ Rast_put_raster_row(out_fd, outbuf, DCELL_TYPE);
}
}
@@ -520,7 +521,7 @@
/* close output file */
if (pass == PASSES)
- G_close_cell(out_fd);
+ Rast_close_cell(out_fd);
}
}
Modified: grass/trunk/imagery/i.pca/support.c
===================================================================
--- grass/trunk/imagery/i.pca/support.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.pca/support.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -15,15 +16,15 @@
DCELL min, max;
/* make grey scale color table */
- G_read_fp_range(outname, mapset, &range);
- G_get_fp_range_min_max(&range, &min, &max);
+ Rast_read_fp_range(outname, mapset, &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
- G_make_grey_scale_fp_colors(&colors, min, max);
+ Rast_make_grey_scale_fp_colors(&colors, min, max);
- if (G_raster_map_is_fp(outname, mapset))
- G_mark_colors_as_fp(&colors);
+ if (Rast_raster_map_is_fp(outname, mapset))
+ Rast_mark_colors_as_fp(&colors);
- if (G_write_colors(outname, mapset, &colors) < 0)
+ if (Rast_write_colors(outname, mapset, &colors) < 0)
G_message(_("Unable to write color table for raster map <%s>"), outname);
return write_history(bands, outname, eigmat, eigval);
@@ -37,7 +38,7 @@
struct History hist;
double eigval_total = 0.0;
- G_short_history(outname, "raster", &hist);
+ Rast_short_history(outname, "raster", &hist);
sprintf(hist.edhist[0], "Eigen values, (vectors), and [percent importance]:");
if(first_map)
@@ -71,10 +72,10 @@
}
hist.edlinecnt = i + 1;
- G_command_history(&hist);
+ Rast_command_history(&hist);
/* only write to stderr the first time (this fn runs for every output map) */
first_map = FALSE;
- return G_write_history(outname, &hist);
+ return Rast_write_history(outname, &hist);
}
Modified: grass/trunk/imagery/i.points/cell.c
===================================================================
--- grass/trunk/imagery/i.points/cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.points/cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -41,7 +41,7 @@
if (x > VIEW_MAP1->left && x < VIEW_MAP1->right) {
if (!choose_groupfile(name, mapset))
return 1;
- if (G_get_cellhd(name, mapset, &cellhd) < 0)
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0)
return 1;
Erase_view(VIEW_MAP1_ZOOM);
@@ -57,7 +57,7 @@
return 1;
select_target_env();
- if (G_get_cellhd(name, mapset, &cellhd) < 0) {
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0) {
select_current_env();
return 1;
}
Modified: grass/trunk/imagery/i.points/drawcell.c
===================================================================
--- grass/trunk/imagery/i.points/drawcell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.points/drawcell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -28,8 +28,8 @@
read_colors = view == VIEW_MAP2;
}
if (read_colors) {
- G_free_colors(colors);
- if (G_read_colors(view->cell.name, view->cell.mapset, colors) < 0)
+ Rast_free_colors(colors);
+ if (Rast_read_colors(view->cell.name, view->cell.mapset, colors) < 0)
return 0;
}
@@ -50,22 +50,22 @@
if (getenv("NO_DRAW"))
return 1;
- fd = G_open_cell_old(view->cell.name, view->cell.mapset);
+ fd = Rast_open_cell_old(view->cell.name, view->cell.mapset);
if (fd < 0)
return 0;
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
sprintf(msg, "Plotting %s ...", view->cell.name);
Menu_msg(msg);
D_cell_draw_setup(top, top + nrows, left, left + ncols);
for (row = 0; row < nrows; row++) {
- if (G_get_d_raster_row_nomask(fd, dcell, row) < 0)
+ if (Rast_get_d_raster_row_nomask(fd, dcell, row) < 0)
break;
D_draw_d_raster(row, dcell, colors);
}
D_cell_draw_end();
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(dcell);
if (colors != &VIEW_MAP1->cell.colors)
set_colors(&VIEW_MAP1->cell.colors);
Modified: grass/trunk/imagery/i.points/graphics.c
===================================================================
--- grass/trunk/imagery/i.points/graphics.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.points/graphics.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -74,8 +74,8 @@
VIEW_MAP2_ZOOM = makeview(2.5, 47.5, 50.0, 100.0);
VIEW_MENU = makeview(0.0, 2.5, 0.0, 100.0);
- G_init_colors(&VIEW_MAP1->cell.colors);
- G_init_colors(&VIEW_MAP2->cell.colors);
+ Rast_init_colors(&VIEW_MAP1->cell.colors);
+ Rast_init_colors(&VIEW_MAP2->cell.colors);
return 0;
}
Modified: grass/trunk/imagery/i.points/main.c
===================================================================
--- grass/trunk/imagery/i.points/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.points/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -108,7 +108,7 @@
exit(EXIT_FAILURE);
- G_suppress_masking(); /* need to do this for target location */
+ Rast_suppress_masking(); /* need to do this for target location */
interrupt_char = G_intr_char();
tempfile1 = G_tempfile();
@@ -185,7 +185,7 @@
quit(0);
/* display this file in "map1" */
}
- while (G_get_cellhd(name, mapset, &cellhd) < 0);
+ while (Rast_get_cellhd(name, mapset, &cellhd) < 0);
G_adjust_window_to_box(&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows,
VIEW_MAP1->ncols);
Configure_view(VIEW_MAP1, name, mapset, cellhd.ns_res, cellhd.ew_res);
Modified: grass/trunk/imagery/i.rectify/crs.c
===================================================================
--- grass/trunk/imagery/i.rectify/crs.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rectify/crs.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -32,6 +32,7 @@
#include <math.h>
#include <limits.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
/*
#define MSDOS 1
Modified: grass/trunk/imagery/i.rectify/exec.c
===================================================================
--- grass/trunk/imagery/i.rectify/exec.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rectify/exec.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,7 +13,10 @@
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
+
+#include <grass/Rast.h>
#include <grass/glocale.h>
+
#include "global.h"
int exec_rectify(int order, char *extension)
@@ -33,10 +36,10 @@
/* allocate the output cell matrix */
cell_buf = (void **)G_calloc(NROWS, sizeof(void *));
- n = NCOLS * G_raster_size(map_type);
+ n = NCOLS * Rast_raster_size(map_type);
for (i = 0; i < NROWS; i++) {
cell_buf[i] = (void *)G_malloc(n);
- G_set_null_value(cell_buf[i], NCOLS, map_type);
+ Rast_set_null_value(cell_buf[i], NCOLS, map_type);
}
/* rectify each file */
@@ -56,12 +59,12 @@
select_current_env();
- cats_ok = G_read_cats(name, mapset, &cats) >= 0;
- colr_ok = G_read_colors(name, mapset, &colr) > 0;
+ cats_ok = Rast_read_cats(name, mapset, &cats) >= 0;
+ colr_ok = Rast_read_colors(name, mapset, &colr) > 0;
/* Initialze History */
type = "raster";
- G_short_history(name, type, &hist);
+ Rast_short_history(name, type, &hist);
time(&start_time);
@@ -72,15 +75,15 @@
* This clobbers (with wrong values) head
* written by gislib. 99% sure it should
* be removed. EGM 2002/01/03
- G_put_cellhd (result,&target_window);
+ Rast_put_cellhd (result,&target_window);
*/
if (cats_ok) {
- G_write_cats(result, &cats);
- G_free_cats(&cats);
+ Rast_write_cats(result, &cats);
+ Rast_free_cats(&cats);
}
if (colr_ok) {
- G_write_colors(result, G_mapset(), &colr);
- G_free_colors(&colr);
+ Rast_write_colors(result, G_mapset(), &colr);
+ Rast_free_colors(&colr);
}
/* Write out History Structure History */
@@ -89,7 +92,7 @@
sprintf(hist.edhist[0], "Created from: i.rectify");
sprintf(hist.edhist[1], "Transformation order = %d", order);
hist.edlinecnt = 2;
- G_write_history(result, &hist);
+ Rast_write_history(result, &hist);
select_current_env();
time(&rectify_time);
Modified: grass/trunk/imagery/i.rectify/main.c
===================================================================
--- grass/trunk/imagery/i.rectify/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rectify/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,7 +24,10 @@
#include <stdlib.h>
#include <string.h>
+
+#include <grass/Rast.h>
#include <grass/glocale.h>
+
#include "global.h"
#include "crs.h"
@@ -188,13 +191,13 @@
else {
/* Calculate smallest region */
if (a->answer) {
- if (G_get_cellhd(ref.file[0].name, ref.file[0].mapset, &cellhd) <
+ if (Rast_get_cellhd(ref.file[0].name, ref.file[0].mapset, &cellhd) <
0)
G_fatal_error(_("Unable to read header of raster map <%s>"),
ref.file[0].name);
}
else {
- if (G_get_cellhd(ifile->answers[0], ref.file[0].mapset, &cellhd) <
+ if (Rast_get_cellhd(ifile->answers[0], ref.file[0].mapset, &cellhd) <
0)
G_fatal_error(_("Unable to read header of raster map <%s>"),
ifile->answers[0]);
Modified: grass/trunk/imagery/i.rectify/perform.c
===================================================================
--- grass/trunk/imagery/i.rectify/perform.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rectify/perform.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,3 +1,6 @@
+
+#include <grass/Rast.h>
+
#include "global.h"
static ROWCOL *rmap, *cmap, left, right;
@@ -12,10 +15,10 @@
int idx;
int i;
- rast_size = G_raster_size(map_type);
+ rast_size = Rast_raster_size(map_type);
for (row = 0; row < matrix_rows; row++)
- G_set_null_value(cell_buf[row], matrix_cols, map_type);
+ Rast_set_null_value(cell_buf[row], matrix_cols, map_type);
curidx = 0;
while (1) {
@@ -36,8 +39,8 @@
fprintf (stderr, "read row %d\n", row);
*/
- if (G_get_raster_row_nomask
- (infd, G_incr_void_ptr(rast, rast_size), row, map_type) < 0)
+ if (Rast_get_raster_row_nomask
+ (infd, Rast_incr_void_ptr(rast, rast_size), row, map_type) < 0)
return 0;
for (i = curidx; i < matrix_rows; i++) {
@@ -51,7 +54,7 @@
cmap = col_map[idx];
left = row_left[idx];
right = row_right[idx];
- do_cell(row, G_incr_void_ptr(rast, rast_size), cell_buf[idx]);
+ do_cell(row, Rast_incr_void_ptr(rast, rast_size), cell_buf[idx]);
row_min[idx]++;
if (row_min[idx] > row_max[idx])
@@ -70,28 +73,28 @@
void *inptr, *outptr;
for (; left <= right; left++) {
- inptr = G_incr_void_ptr(in, cmap[left] * rast_size);
- outptr = G_incr_void_ptr(out, left * rast_size);
+ inptr = Rast_incr_void_ptr(in, cmap[left] * rast_size);
+ outptr = Rast_incr_void_ptr(out, left * rast_size);
if (rmap[left] < 0)
continue;
if (rmap[left] != row)
break;
- G_raster_cpy(outptr, inptr, 1, map_type);
+ Rast_raster_cpy(outptr, inptr, 1, map_type);
}
for (; left <= right; right--) {
- inptr = G_incr_void_ptr(in, cmap[right] * rast_size);
- outptr = G_incr_void_ptr(out, right * rast_size);
+ inptr = Rast_incr_void_ptr(in, cmap[right] * rast_size);
+ outptr = Rast_incr_void_ptr(out, right * rast_size);
if (rmap[right] < 0)
continue;
if (rmap[right] != row)
break;
- G_raster_cpy(outptr, inptr, 1, map_type);
+ Rast_raster_cpy(outptr, inptr, 1, map_type);
}
for (col = left; col <= right; col++) {
- inptr = G_incr_void_ptr(in, cmap[col] * rast_size);
- outptr = G_incr_void_ptr(out, col * rast_size);
+ inptr = Rast_incr_void_ptr(in, cmap[col] * rast_size);
+ outptr = Rast_incr_void_ptr(out, col * rast_size);
if (rmap[col] == row)
- G_raster_cpy(outptr, inptr, 1, map_type);
+ Rast_raster_cpy(outptr, inptr, 1, map_type);
}
return 0;
Modified: grass/trunk/imagery/i.rectify/rectify.c
===================================================================
--- grass/trunk/imagery/i.rectify/rectify.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rectify/rectify.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,8 @@
#include <unistd.h>
+
+#include <grass/Rast.h>
#include <grass/glocale.h>
+
#include "global.h"
/* Modified to support Grass 5.0 fp format 11 april 2000
@@ -18,7 +21,7 @@
char buf[2048] = "";
select_current_env();
- if (G_get_cellhd(name, mapset, &cellhd) < 0)
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0)
return 0;
/* open the result file into target window
@@ -32,21 +35,21 @@
select_target_env();
G_set_window(&target_window);
- G_set_cell_format(cellhd.format);
+ Rast_set_cell_format(cellhd.format);
select_current_env();
/* open the file to be rectified
* set window to cellhd first to be able to read file exactly
*/
G_set_window(&cellhd);
- infd = G_open_cell_old(name, mapset);
+ infd = Rast_open_cell_old(name, mapset);
if (infd < 0) {
close(infd);
return 0;
}
- map_type = G_get_raster_map_type(infd);
- rast = (void *)G_calloc(G_window_cols() + 1, G_raster_size(map_type));
- G_set_null_value(rast, G_window_cols() + 1, map_type);
+ map_type = Rast_get_raster_map_type(infd);
+ rast = (void *)G_calloc(G_window_cols() + 1, Rast_raster_size(map_type));
+ Rast_set_null_value(rast, G_window_cols() + 1, map_type);
G_copy(&win, &target_window, sizeof(win));
@@ -102,7 +105,7 @@
}
target_window.compressed = cellhd.compressed;
- G_close_cell(infd); /* (pmx) 17 april 2000 */
+ Rast_close_cell(infd); /* (pmx) 17 april 2000 */
write_map(result);
select_current_env();
Modified: grass/trunk/imagery/i.rectify/write.c
===================================================================
--- grass/trunk/imagery/i.rectify/write.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rectify/write.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,7 +2,10 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+
+#include <grass/Rast.h>
#include <grass/glocale.h>
+
#include "global.h"
int write_matrix(int row, int col)
@@ -18,15 +21,15 @@
for (n = 0; n < matrix_rows; n++) {
offset =
((off_t) row++ * target_window.cols +
- col) * G_raster_size(map_type);
+ col) * Rast_raster_size(map_type);
lseek(temp_fd, offset, SEEK_SET);
- if (write(temp_fd, cell_buf[n], G_raster_size(map_type) * matrix_cols)
- != G_raster_size(map_type) * matrix_cols) {
+ if (write(temp_fd, cell_buf[n], Rast_raster_size(map_type) * matrix_cols)
+ != Rast_raster_size(map_type) * matrix_cols) {
unlink(temp_name);
G_fatal_error(_("Error while writing to temp file"));
}
- /*G_put_map_row_random (outfd, cell_buf[n], row++, col, matrix_cols); */
+ /*Rast_put_map_row_random (outfd, cell_buf[n], row++, col, matrix_cols); */
}
select_current_env();
@@ -40,19 +43,19 @@
G_set_window(&target_window);
- rast = G_allocate_raster_buf(map_type);
+ rast = Rast_allocate_raster_buf(map_type);
close(temp_fd);
temp_fd = open(temp_name, 0);
- fd = G_open_raster_new(name, map_type);
+ fd = Rast_open_raster_new(name, map_type);
if (fd <= 0)
G_fatal_error(_("Unable to create raster map <%s>"), name);
for (row = 0; row < target_window.rows; row++) {
- if (read(temp_fd, rast, target_window.cols * G_raster_size(map_type))
- != target_window.cols * G_raster_size(map_type))
+ if (read(temp_fd, rast, target_window.cols * Rast_raster_size(map_type))
+ != target_window.cols * Rast_raster_size(map_type))
G_fatal_error(_("Error writing row %d"), row);
- if (G_put_raster_row(fd, rast, map_type) < 0) {
+ if (Rast_put_raster_row(fd, rast, map_type) < 0) {
G_fatal_error(_("Failed writing raster map <%s> row %d"),
name, row);
unlink(temp_name);
@@ -60,7 +63,7 @@
}
close(temp_fd);
unlink(temp_name);
- G_close_cell(fd);
+ Rast_close_cell(fd);
return 0;
}
Modified: grass/trunk/imagery/i.rgb.his/closefiles.c
===================================================================
--- grass/trunk/imagery/i.rgb.his/closefiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rgb.his/closefiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
/* This routine closes up the cell maps, frees up the row buffers and
@@ -16,26 +17,26 @@
const char *mapset;
for (i = 0; i < 3; i++) {
- G_close_cell(fd_output[i]);
+ Rast_close_cell(fd_output[i]);
G_free(rowbuf[i]);
}
mapset = G_mapset();
- G_read_range(h_name, mapset, &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_grey_scale_colors(&colors, min, max);
- G_write_colors(h_name, mapset, &colors);
+ Rast_read_range(h_name, mapset, &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_grey_scale_colors(&colors, min, max);
+ Rast_write_colors(h_name, mapset, &colors);
- G_read_range(i_name, mapset, &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_grey_scale_colors(&colors, min, max);
- G_write_colors(i_name, mapset, &colors);
+ Rast_read_range(i_name, mapset, &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_grey_scale_colors(&colors, min, max);
+ Rast_write_colors(i_name, mapset, &colors);
- G_read_range(s_name, mapset, &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_grey_scale_colors(&colors, min, max);
- G_write_colors(s_name, mapset, &colors);
+ Rast_read_range(s_name, mapset, &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_grey_scale_colors(&colors, min, max);
+ Rast_write_colors(s_name, mapset, &colors);
return 0;
}
Modified: grass/trunk/imagery/i.rgb.his/main.c
===================================================================
--- grass/trunk/imagery/i.rgb.his/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rgb.his/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "globals.h"
@@ -88,7 +89,7 @@
G_percent(i, rows, 2);
for (band = 0; band < 3; band++)
- if (G_get_map_row(fd_input[band], rowbuffer[band], i) < 0)
+ if (Rast_get_map_row(fd_input[band], rowbuffer[band], i) < 0)
G_fatal_error(_("Unable to read raster map row %d"), i);
/* process this row of the map */
@@ -96,7 +97,7 @@
/* write out the new row for each cell map */
for (band = 0; band < 3; band++)
- if (G_put_raster_row(fd_output[band], rowbuffer[band], CELL_TYPE)
+ if (Rast_put_raster_row(fd_output[band], rowbuffer[band], CELL_TYPE)
< 0)
G_fatal_error(_("Failed writing raster map row %d"), i);
}
Modified: grass/trunk/imagery/i.rgb.his/openfiles.c
===================================================================
--- grass/trunk/imagery/i.rgb.his/openfiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rgb.his/openfiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "globals.h"
@@ -8,26 +9,26 @@
char *h_name, char *i_name, char *s_name,
int fd_input[3], int fd_output[3], CELL * rowbuf[3])
{
- if ((fd_input[0] = G_open_cell_old(r_name, "")) < 0)
+ if ((fd_input[0] = Rast_open_cell_old(r_name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), r_name);
- if ((fd_input[1] = G_open_cell_old(g_name, "")) < 0)
+ if ((fd_input[1] = Rast_open_cell_old(g_name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), g_name);
- if ((fd_input[2] = G_open_cell_old(b_name, "")) < 0)
+ if ((fd_input[2] = Rast_open_cell_old(b_name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), b_name);
/* open output files */
- if ((fd_output[0] = G_open_cell_new(h_name)) < 0)
+ if ((fd_output[0] = Rast_open_cell_new(h_name)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), h_name);
- if ((fd_output[1] = G_open_cell_new(i_name)) < 0)
+ if ((fd_output[1] = Rast_open_cell_new(i_name)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), i_name);
- if ((fd_output[2] = G_open_cell_new(s_name)) < 0)
+ if ((fd_output[2] = Rast_open_cell_new(s_name)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), s_name);
/* allocate the cell row buffer */
- if ((rowbuf[0] = G_allocate_cell_buf()) == NULL)
+ if ((rowbuf[0] = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate the input row buffer"));
- if ((rowbuf[1] = G_allocate_cell_buf()) == NULL)
+ if ((rowbuf[1] = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate the input row buffer"));
- if ((rowbuf[2] = G_allocate_cell_buf()) == NULL)
+ if ((rowbuf[2] = Rast_allocate_cell_buf()) == NULL)
G_fatal_error(_("Unable to allocate the input row buffer"));
}
Modified: grass/trunk/imagery/i.rgb.his/rgb2his.c
===================================================================
--- grass/trunk/imagery/i.rgb.his/rgb2his.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.rgb.his/rgb2his.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
each band is processed and written out. CWU GIS Lab: DBS 8/90 */
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
void rgb2his(CELL * rowbuffer[3], int columns)
Modified: grass/trunk/imagery/i.smap/closefiles.c
===================================================================
--- grass/trunk/imagery/i.smap/closefiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/closefiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include "bouman.h"
@@ -13,10 +14,10 @@
G_debug(1, "Creating support files for <%s>...", parms->output_map);
for (n = 0; n < files->nbands; n++)
- G_close_cell(files->band_fd[n]);
+ Rast_close_cell(files->band_fd[n]);
- G_close_cell(files->output_fd);
- G_write_cats(parms->output_map, &files->output_labels);
+ Rast_close_cell(files->output_fd);
+ Rast_write_cats(parms->output_map, &files->output_labels);
make_history(parms->output_map,
parms->group, parms->subgroup, parms->sigfile);
Modified: grass/trunk/imagery/i.smap/decimate.c
===================================================================
--- grass/trunk/imagery/i.smap/decimate.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/decimate.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "bouman.h"
#include "region.h"
Modified: grass/trunk/imagery/i.smap/history.c
===================================================================
--- grass/trunk/imagery/i.smap/history.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/history.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,12 +1,13 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void make_history(const char *name, const char *group, const char *subgroup, const char *sigfile)
{
struct History hist;
- if (G_read_history(name, G_mapset(), &hist) >= 0) {
+ if (Rast_read_history(name, G_mapset(), &hist) >= 0) {
sprintf(hist.datsrc_1, "Group/subgroup: %s/%s", group, subgroup);
sprintf(hist.datsrc_2, "Sigset file: %s", sigfile);
- G_write_history(name, &hist);
+ Rast_write_history(name, &hist);
}
}
Modified: grass/trunk/imagery/i.smap/interp.c
===================================================================
--- grass/trunk/imagery/i.smap/interp.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/interp.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "bouman.h"
#include "region.h"
Modified: grass/trunk/imagery/i.smap/invert.c
===================================================================
--- grass/trunk/imagery/i.smap/invert.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/invert.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
int invert(
Modified: grass/trunk/imagery/i.smap/labels.c
===================================================================
--- grass/trunk/imagery/i.smap/labels.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/labels.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,6 @@
+#include <grass/Rast.h>
#include <grass/imagery.h>
+
#include "bouman.h"
int create_output_labels(struct SigSet *S, struct files *files)
@@ -6,10 +8,10 @@
int n;
struct ClassSig *C;
- G_init_cats((CELL) 0, S->title, &files->output_labels);
+ Rast_init_cats((CELL) 0, S->title, &files->output_labels);
for (n = 0; n < S->nclasses; n++) {
C = &S->ClassSig[n];
- G_set_cat((CELL) C->classnum, C->title, &files->output_labels);
+ Rast_set_cat((CELL) C->classnum, C->title, &files->output_labels);
}
return 0;
Modified: grass/trunk/imagery/i.smap/model.c
===================================================================
--- grass/trunk/imagery/i.smap/model.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/model.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include <grass/gmath.h>
@@ -105,7 +106,7 @@
/* Check for no data condition */
no_data = 1;
for (b1 = 0; (b1 < nbands) && no_data; b1++)
- no_data = no_data && (G_is_d_null_value(&img[b1][i][j]));
+ no_data = no_data && (Rast_is_d_null_value(&img[b1][i][j]));
if (no_data) {
for (m = 0; m < S->nclasses; m++)
Modified: grass/trunk/imagery/i.smap/multialloc.c
===================================================================
--- grass/trunk/imagery/i.smap/multialloc.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/multialloc.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
Modified: grass/trunk/imagery/i.smap/opencell.c
===================================================================
--- grass/trunk/imagery/i.smap/opencell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/opencell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -9,7 +10,7 @@
if (mapset == NULL)
mapset = G_find_cell2(name, "");
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd >= 0)
return fd;
@@ -23,7 +24,7 @@
{
int fd;
- fd = G_open_cell_new(name);
+ fd = Rast_open_cell_new(name);
if (fd >= 0)
return fd;
Modified: grass/trunk/imagery/i.smap/openfiles.c
===================================================================
--- grass/trunk/imagery/i.smap/openfiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/openfiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "bouman.h"
#include "local_proto.h"
@@ -20,8 +23,8 @@
parms->subgroup, parms->group);
/* allocate file descriptors, and io buffer */
- files->cellbuf = G_allocate_d_raster_buf();
- files->outbuf = G_allocate_c_raster_buf();
+ files->cellbuf = Rast_allocate_d_raster_buf();
+ files->outbuf = Rast_allocate_c_raster_buf();
files->isdata = G_malloc(G_window_cols());
files->nbands = Ref.nfiles;
Modified: grass/trunk/imagery/i.smap/parse.c
===================================================================
--- grass/trunk/imagery/i.smap/parse.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/parse.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/imagery.h>
#include "bouman.h"
Modified: grass/trunk/imagery/i.smap/read_block.c
===================================================================
--- grass/trunk/imagery/i.smap/read_block.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/read_block.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdlib.h>
+
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "bouman.h"
#include "region.h"
@@ -11,7 +14,7 @@
for (band = 0; band < files->nbands; band++) {
for (row = region->ymin; row < region->ymax; row++) {
- if (G_get_d_raster_row(files->band_fd[band], files->cellbuf, row)
+ if (Rast_get_d_raster_row(files->band_fd[band], files->cellbuf, row)
< 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
Modified: grass/trunk/imagery/i.smap/write_img.c
===================================================================
--- grass/trunk/imagery/i.smap/write_img.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.smap/write_img.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,8 +1,9 @@
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
+
#include "bouman.h"
-
int write_img(unsigned char **img, int ncols, int nrows, struct SigSet *S, /* class parameters */
struct parms *parms, /* parms: command line parameters */
struct files *files)
@@ -19,7 +20,7 @@
G_debug(3, "class: [%d] row/col: [%d][%d]", class, row, col);
files->outbuf[col] = (CELL) S->ClassSig[class].classnum;
}
- G_put_raster_row(files->output_fd, files->outbuf, CELL_TYPE);
+ Rast_put_raster_row(files->output_fd, files->outbuf, CELL_TYPE);
}
G_percent(nrows, nrows, 2);
Modified: grass/trunk/imagery/i.sunhours/main.c
===================================================================
--- grass/trunk/imagery/i.sunhours/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.sunhours/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define PI 3.1415927
@@ -67,21 +68,21 @@
result1 = output1->answer;
/***************************************************/
- if ((infd_doy = G_open_cell_old(doy, "")) < 0)
+ if ((infd_doy = Rast_open_cell_old(doy, "")) < 0)
G_fatal_error(_("Cannot open cell file [%s]"), doy);
- inrast_doy = G_allocate_d_raster_buf();
+ inrast_doy = Rast_allocate_d_raster_buf();
/***************************************************/
- if ((infd_lat = G_open_cell_old(lat, "")) < 0)
+ if ((infd_lat = Rast_open_cell_old(lat, "")) < 0)
G_fatal_error(_("Cannot open cell file [%s]"), lat);
- inrast_lat = G_allocate_d_raster_buf();
+ inrast_lat = Rast_allocate_d_raster_buf();
/***************************************************/
nrows = G_window_rows();
ncols = G_window_cols();
- outrast1 = G_allocate_d_raster_buf();
- if ((outfd1 = G_open_raster_new(result1, DCELL_TYPE)) < 0)
+ outrast1 = Rast_allocate_d_raster_buf();
+ if ((outfd1 = Rast_open_raster_new(result1, DCELL_TYPE)) < 0)
G_fatal_error(_("Could not open <%s>"), result1);
for (row = 0; row < nrows; row++)
@@ -95,9 +96,9 @@
DCELL d_doy;
G_percent(row, nrows, 2);
- if (G_get_raster_row(infd_doy, inrast_doy, row, DCELL_TYPE) < 0)
+ if (Rast_get_raster_row(infd_doy, inrast_doy, row, DCELL_TYPE) < 0)
G_fatal_error(_("Could not read from <%s>"), doy);
- if (G_get_raster_row(infd_lat, inrast_lat, row, DCELL_TYPE) < 0)
+ if (Rast_get_raster_row(infd_lat, inrast_lat, row, DCELL_TYPE) < 0)
G_fatal_error(_("Could not read from <%s>"), lat);
for (col = 0; col < ncols; col++)
@@ -114,19 +115,19 @@
d_N = (360.0 / (15.0 * PI)) * d_Ws;
((DCELL *) outrast1)[col] = d_N;
}
- if (G_put_raster_row(outfd1, outrast1, DCELL_TYPE) < 0)
+ if (Rast_put_raster_row(outfd1, outrast1, DCELL_TYPE) < 0)
G_fatal_error(_("Cannot write to output raster file"));
}
G_free(inrast_lat);
G_free(inrast_doy);
- G_close_cell(infd_lat);
- G_close_cell(infd_doy);
+ Rast_close_cell(infd_lat);
+ Rast_close_cell(infd_doy);
G_free(outrast1);
- G_close_cell(outfd1);
+ Rast_close_cell(outfd1);
- G_short_history(result1, "raster", &history);
- G_command_history(&history);
- G_write_history(result1, &history);
+ Rast_short_history(result1, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result1, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.vi/main.c
===================================================================
--- grass/trunk/imagery/i.vi/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.vi/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
double s_r(double redchan, double nirchan);
@@ -206,46 +207,46 @@
|| !(input6->answer) || !(input7->answer)) )
G_fatal_error(_("gvi index requires blue, green, red, nir, chan5 and chan7 maps"));
- if ((infd_redchan = G_open_cell_old(redchan, "")) < 0)
+ if ((infd_redchan = Rast_open_cell_old(redchan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), redchan);
- inrast_redchan = G_allocate_d_raster_buf();
+ inrast_redchan = Rast_allocate_d_raster_buf();
if (nirchan) {
- if ((infd_nirchan = G_open_cell_old(nirchan, "")) < 0)
+ if ((infd_nirchan = Rast_open_cell_old(nirchan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), nirchan);
- inrast_nirchan = G_allocate_d_raster_buf();
+ inrast_nirchan = Rast_allocate_d_raster_buf();
}
if (greenchan) {
- if ((infd_greenchan = G_open_cell_old(greenchan, "")) < 0)
+ if ((infd_greenchan = Rast_open_cell_old(greenchan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), greenchan);
- inrast_greenchan = G_allocate_d_raster_buf();
+ inrast_greenchan = Rast_allocate_d_raster_buf();
}
if (bluechan) {
- if ((infd_bluechan = G_open_cell_old(bluechan, "")) < 0)
+ if ((infd_bluechan = Rast_open_cell_old(bluechan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), bluechan);
- inrast_bluechan = G_allocate_d_raster_buf();
+ inrast_bluechan = Rast_allocate_d_raster_buf();
}
if (chan5chan) {
- if ((infd_chan5chan = G_open_cell_old(chan5chan, "")) < 0)
+ if ((infd_chan5chan = Rast_open_cell_old(chan5chan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), chan5chan);
- inrast_chan5chan = G_allocate_d_raster_buf();
+ inrast_chan5chan = Rast_allocate_d_raster_buf();
}
if (chan7chan) {
- if ((infd_chan7chan = G_open_cell_old(chan7chan, "")) < 0)
+ if ((infd_chan7chan = Rast_open_cell_old(chan7chan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), chan7chan);
- inrast_chan7chan = G_allocate_d_raster_buf();
+ inrast_chan7chan = Rast_allocate_d_raster_buf();
}
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_d_raster_buf();
+ outrast = Rast_allocate_d_raster_buf();
/* Create New raster files */
- if ((outfd = G_open_raster_new(result, DCELL_TYPE)) < 0)
+ if ((outfd = Rast_open_raster_new(result, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/* Process pixels */
@@ -260,31 +261,31 @@
G_percent(row, nrows, 2);
- if (G_get_d_raster_row(infd_redchan, inrast_redchan, row) < 0)
+ if (Rast_get_d_raster_row(infd_redchan, inrast_redchan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
redchan, row);
if (nirchan) {
- if (G_get_d_raster_row(infd_nirchan, inrast_nirchan, row) < 0)
+ if (Rast_get_d_raster_row(infd_nirchan, inrast_nirchan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
nirchan, row);
}
if (greenchan) {
- if (G_get_d_raster_row(infd_greenchan, inrast_greenchan, row) < 0)
+ if (Rast_get_d_raster_row(infd_greenchan, inrast_greenchan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
greenchan, row);
}
if (bluechan) {
- if (G_get_d_raster_row(infd_bluechan, inrast_bluechan, row) < 0)
+ if (Rast_get_d_raster_row(infd_bluechan, inrast_bluechan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
bluechan, row);
}
if (chan5chan) {
- if (G_get_d_raster_row(infd_chan5chan, inrast_chan5chan, row) < 0)
+ if (Rast_get_d_raster_row(infd_chan5chan, inrast_chan5chan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
chan5chan, row);
}
if (chan7chan) {
- if (G_get_d_raster_row(infd_chan7chan, inrast_chan7chan, row) < 0)
+ if (Rast_get_d_raster_row(infd_chan7chan, inrast_chan7chan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
chan7chan, row);
}
@@ -304,13 +305,13 @@
if(chan7chan)
d_chan7chan = inrast_chan7chan[col];
- if (G_is_d_null_value(&d_redchan) ||
- ((nirchan) && G_is_d_null_value(&d_nirchan)) ||
- ((greenchan) && G_is_d_null_value(&d_greenchan)) ||
- ((bluechan) && G_is_d_null_value(&d_bluechan)) ||
- ((chan5chan) && G_is_d_null_value(&d_chan5chan)) ||
- ((chan7chan) && G_is_d_null_value(&d_chan7chan))) {
- G_set_d_null_value(&outrast[col], 1);
+ if (Rast_is_d_null_value(&d_redchan) ||
+ ((nirchan) && Rast_is_d_null_value(&d_nirchan)) ||
+ ((greenchan) && Rast_is_d_null_value(&d_greenchan)) ||
+ ((bluechan) && Rast_is_d_null_value(&d_bluechan)) ||
+ ((chan5chan) && Rast_is_d_null_value(&d_chan5chan)) ||
+ ((chan7chan) && Rast_is_d_null_value(&d_chan7chan))) {
+ Rast_set_d_null_value(&outrast[col], 1);
}
else {
/* calculate simple_ratio */
@@ -320,7 +321,7 @@
/* calculate ndvi */
if (!strcmp(viflag, "ndvi")) {
if (d_redchan + d_nirchan < 0.001)
- G_set_d_null_value(&outrast[col], 1);
+ Rast_set_d_null_value(&outrast[col], 1);
else
outrast[col] = nd_vi(d_redchan, d_nirchan);
}
@@ -366,41 +367,41 @@
outrast[col] = va_ri(d_redchan, d_greenchan, d_bluechan);
}
}
- if (G_put_d_raster_row(outfd, outrast) < 0)
+ if (Rast_put_d_raster_row(outfd, outrast) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
result, row);
}
G_free(inrast_redchan);
- G_close_cell(infd_redchan);
+ Rast_close_cell(infd_redchan);
G_free(inrast_nirchan);
- G_close_cell(infd_nirchan);
+ Rast_close_cell(infd_nirchan);
if (greenchan) {
G_free(inrast_greenchan);
- G_close_cell(infd_greenchan);
+ Rast_close_cell(infd_greenchan);
}
if (bluechan) {
G_free(inrast_bluechan);
- G_close_cell(infd_bluechan);
+ Rast_close_cell(infd_bluechan);
}
if (chan5chan) {
G_free(inrast_chan5chan);
- G_close_cell(infd_chan5chan);
+ Rast_close_cell(infd_chan5chan);
}
if (chan7chan) {
G_free(inrast_chan7chan);
- G_close_cell(infd_chan7chan);
+ Rast_close_cell(infd_chan7chan);
}
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
/* Color from -1.0 to +1.0 in grey */
- G_init_colors(&colors);
- G_add_color_rule(-1.0, 0, 0, 0, 1.0, 255, 255, 255, &colors);
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(-1.0, 0, 0, 0, 1.0, 255, 255, 255, &colors);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.vpoints/cell.c
===================================================================
--- grass/trunk/imagery/i.vpoints/cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.vpoints/cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -41,7 +41,7 @@
if (x > VIEW_MAP1->left && x < VIEW_MAP1->right) {
if (!choose_groupfile(name, mapset))
return 1;
- if (G_get_cellhd(name, mapset, &cellhd) < 0)
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0)
return 1;
Erase_view(VIEW_MAP1_ZOOM);
@@ -57,7 +57,7 @@
return 1;
select_target_env();
- if (G_get_cellhd(name, mapset, &cellhd) < 0) {
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0) {
select_current_env();
return 1;
}
Modified: grass/trunk/imagery/i.vpoints/colors.c
===================================================================
--- grass/trunk/imagery/i.vpoints/colors.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.vpoints/colors.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -29,48 +29,48 @@
{
/* SCREEN OUTLINE and CURSOR */
- G_add_color_rule((CELL) 241, 180, 180, 180, (CELL) 241, 180, 180, 180,
+ Rast_add_color_rule((CELL) 241, 180, 180, 180, (CELL) 241, 180, 180, 180,
colors);
/* RED */
- G_add_color_rule((CELL) 242, 200, 90, 90, (CELL) 242, 200, 90, 90,
+ Rast_add_color_rule((CELL) 242, 200, 90, 90, (CELL) 242, 200, 90, 90,
colors);
/* ORANGE */
- G_add_color_rule((CELL) 243, 150, 100, 50, (CELL) 243, 150, 100, 50,
+ Rast_add_color_rule((CELL) 243, 150, 100, 50, (CELL) 243, 150, 100, 50,
colors);
/* YELLOW */
- G_add_color_rule((CELL) 244, 200, 200, 10, (CELL) 244, 200, 200, 10,
+ Rast_add_color_rule((CELL) 244, 200, 200, 10, (CELL) 244, 200, 200, 10,
colors);
/* GREEN */
- G_add_color_rule((CELL) 245, 90, 200, 90, (CELL) 245, 90, 200, 90,
+ Rast_add_color_rule((CELL) 245, 90, 200, 90, (CELL) 245, 90, 200, 90,
colors);
/* BLUE */
- G_add_color_rule((CELL) 246, 90, 90, 200, (CELL) 246, 90, 90, 200,
+ Rast_add_color_rule((CELL) 246, 90, 90, 200, (CELL) 246, 90, 90, 200,
colors);
/* INDIGO */
- G_add_color_rule((CELL) 247, 100, 100, 10, (CELL) 247, 100, 100, 10,
+ Rast_add_color_rule((CELL) 247, 100, 100, 10, (CELL) 247, 100, 100, 10,
colors);
/* VIOLET */
- G_add_color_rule((CELL) 248, 150, 150, 10, (CELL) 248, 150, 150, 10,
+ Rast_add_color_rule((CELL) 248, 150, 150, 10, (CELL) 248, 150, 150, 10,
colors);
/* WHITE */
- G_add_color_rule((CELL) 249, 250, 250, 250, (CELL) 249, 250, 250, 250,
+ Rast_add_color_rule((CELL) 249, 250, 250, 250, (CELL) 249, 250, 250, 250,
colors);
/* BLACK */
- G_add_color_rule((CELL) 250, 0, 0, 0, (CELL) 250, 0, 0, 0, colors);
+ Rast_add_color_rule((CELL) 250, 0, 0, 0, (CELL) 250, 0, 0, 0, colors);
/* GRAY */
- G_add_color_rule((CELL) 251, 180, 180, 180, (CELL) 251, 180, 180, 180,
+ Rast_add_color_rule((CELL) 251, 180, 180, 180, (CELL) 251, 180, 180, 180,
colors);
/* BROWN */
- G_add_color_rule((CELL) 252, 100, 100, 30, (CELL) 252, 100, 100, 30,
+ Rast_add_color_rule((CELL) 252, 100, 100, 30, (CELL) 252, 100, 100, 30,
colors);
/* MAGENTA */
- G_add_color_rule((CELL) 253, 150, 90, 150, (CELL) 253, 150, 90, 150,
+ Rast_add_color_rule((CELL) 253, 150, 90, 150, (CELL) 253, 150, 90, 150,
colors);
/* AQUA */
- G_add_color_rule((CELL) 254, 50, 120, 120, (CELL) 254, 50, 120, 120,
+ Rast_add_color_rule((CELL) 254, 50, 120, 120, (CELL) 254, 50, 120, 120,
colors);
/* */
- G_add_color_rule((CELL) 255, 250, 0, 0, (CELL) 255, 250, 0, 0, colors);
+ Rast_add_color_rule((CELL) 255, 250, 0, 0, (CELL) 255, 250, 0, 0, colors);
set_colors(colors);
@@ -144,32 +144,32 @@
switch (curs_color) {
case BLUE:
- G_add_color_rule((CELL) 241, 90, 90, 200, (CELL) 241, 90, 90, 200,
+ Rast_add_color_rule((CELL) 241, 90, 90, 200, (CELL) 241, 90, 90, 200,
colors);
break;
case GRAY:
- G_add_color_rule((CELL) 241, 180, 180, 180, (CELL) 241, 180, 180, 180,
+ Rast_add_color_rule((CELL) 241, 180, 180, 180, (CELL) 241, 180, 180, 180,
colors);
break;
case GREEN:
- G_add_color_rule((CELL) 241, 90, 200, 90, (CELL) 241, 90, 200, 90,
+ Rast_add_color_rule((CELL) 241, 90, 200, 90, (CELL) 241, 90, 200, 90,
colors);
break;
case RED:
- G_add_color_rule((CELL) 241, 200, 90, 90, (CELL) 241, 200, 90, 90,
+ Rast_add_color_rule((CELL) 241, 200, 90, 90, (CELL) 241, 200, 90, 90,
colors);
break;
case WHITE:
- G_add_color_rule((CELL) 241, 250, 250, 250, (CELL) 241, 250, 250, 250,
+ Rast_add_color_rule((CELL) 241, 250, 250, 250, (CELL) 241, 250, 250, 250,
colors);
break;
case YELLOW:
- G_add_color_rule((CELL) 241, 200, 200, 10, (CELL) 241, 200, 200, 10,
+ Rast_add_color_rule((CELL) 241, 200, 200, 10, (CELL) 241, 200, 200, 10,
colors);
break;
}
Modified: grass/trunk/imagery/i.vpoints/drawcell.c
===================================================================
--- grass/trunk/imagery/i.vpoints/drawcell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.vpoints/drawcell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -27,8 +27,8 @@
}
if (read_colors) {
- G_free_colors(colors);
- if (G_read_colors(view->cell.name, view->cell.mapset, colors) < 0)
+ Rast_free_colors(colors);
+ if (Rast_read_colors(view->cell.name, view->cell.mapset, colors) < 0)
return 0;
/* set_menu_colors(colors); */
}
@@ -60,17 +60,17 @@
if (getenv("NO_DRAW"))
return 1;
- fd = G_open_cell_old(view->cell.name, view->cell.mapset);
+ fd = Rast_open_cell_old(view->cell.name, view->cell.mapset);
if (fd < 0)
return 0;
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
sprintf(msg, "Displaying %s ...", view->cell.name);
Menu_msg(msg);
D_cell_draw_setup(top, top + nrows, left, left + ncols);
for (row = 0; row < nrows; row++) {
- if (G_get_d_raster_row_nomask(fd, dcell, row) < 0)
+ if (Rast_get_d_raster_row_nomask(fd, dcell, row) < 0)
break;
D_draw_d_raster(row, dcell, colors);
}
@@ -80,7 +80,7 @@
if (view == VIEW_MAP2 || view == VIEW_MAP2_ZOOM)
cellmap_present = 1; /* for drawcell */
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(dcell);
Modified: grass/trunk/imagery/i.vpoints/graphics.c
===================================================================
--- grass/trunk/imagery/i.vpoints/graphics.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.vpoints/graphics.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -61,8 +61,8 @@
VIEW_MAP2_ZOOM = makeview(2.5, 47.5, 50.0, 100.0);
VIEW_MENU = makeview(0.0, 2.5, 0.0, 100.0);
- G_init_colors(&VIEW_MAP1->cell.colors);
- G_init_colors(&VIEW_MAP2->cell.colors);
+ Rast_init_colors(&VIEW_MAP1->cell.colors);
+ Rast_init_colors(&VIEW_MAP2->cell.colors);
return 0;
}
Modified: grass/trunk/imagery/i.vpoints/main.c
===================================================================
--- grass/trunk/imagery/i.vpoints/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.vpoints/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -107,7 +107,7 @@
exit(EXIT_FAILURE);
- G_suppress_masking(); /* to do this for target location */
+ Rast_suppress_masking(); /* to do this for target location */
interrupt_char = G_intr_char();
tempfile1 = G_tempfile();
@@ -181,7 +181,7 @@
quit(0);
/* display this file in "map1" */
}
- while (G_get_cellhd(name, mapset, &cellhd) < 0);
+ while (Rast_get_cellhd(name, mapset, &cellhd) < 0);
G_adjust_window_to_box(&cellhd, &VIEW_MAP1->cell.head, VIEW_MAP1->nrows,
VIEW_MAP1->ncols);
Modified: grass/trunk/imagery/i.zc/main.c
===================================================================
--- grass/trunk/imagery/i.zc/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/imagery/i.zc/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
#include <grass/glocale.h>
@@ -99,7 +100,7 @@
exit(EXIT_FAILURE);
/* open input cell map */
- inputfd = G_open_cell_old(input_map->answer, "");
+ inputfd = Rast_open_cell_old(input_map->answer, "");
if (inputfd < 0)
exit(EXIT_FAILURE);
@@ -146,19 +147,19 @@
}
/* allocate the space for one row of cell map data */
- cell_row = G_allocate_cell_buf();
+ cell_row = Rast_allocate_cell_buf();
/* Read in cell map values */
G_message(_("Reading raster map..."));
for (i = 0; i < or; i++) {
- if (G_get_map_row(inputfd, cell_row, i) < 0)
+ if (Rast_get_map_row(inputfd, cell_row, i) < 0)
G_fatal_error(_("Error while reading input raster map."));
for (j = 0; j < oc; j++)
*(data[0] + (i * size) + j) = (double)cell_row[j];
}
/* close input cell map and release the row buffer */
- G_close_cell(inputfd);
+ Rast_close_cell(inputfd);
G_free(cell_row);
/* take the del**2g of image */
@@ -171,19 +172,19 @@
/* open the output cell maps and allocate cell row buffers */
G_message(_("Writing transformed data to file..."));
- if ((zcfd = G_open_cell_new(output_map->answer)) < 0)
+ if ((zcfd = Rast_open_cell_new(output_map->answer)) < 0)
exit(EXIT_FAILURE);
- cell_row = G_allocate_cell_buf();
+ cell_row = Rast_allocate_cell_buf();
/* Write out result to a new cell map */
for (i = 0; i < or; i++) {
for (j = 0; j < oc; j++) {
*(cell_row + j) = (CELL) (*(data[1] + i * cols + j));
}
- G_put_raster_row(zcfd, cell_row, CELL_TYPE);
+ Rast_put_raster_row(zcfd, cell_row, CELL_TYPE);
}
- G_close_cell(zcfd);
+ Rast_close_cell(zcfd);
G_free(cell_row);
Modified: grass/trunk/include/Make/Grass.make
===================================================================
--- grass/trunk/include/Make/Grass.make 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/include/Make/Grass.make 2009-06-20 22:03:23 UTC (rev 38003)
@@ -142,6 +142,9 @@
XGI_LIBNAME = grass_Xgi
XPM_LIBNAME = grass_Xpm
+# Raster
+RASTR_LIBNAME = grass_rast
+
# Vector
DIG_LIBNAME = grass_dig
DIG2_LIBNAME = grass_dig2
@@ -238,6 +241,9 @@
XGILIB = -l$(XGI_LIBNAME)
XPMLIB = -l$(XPM_LIBNAME)
+# Raster
+RASTRLIB = -l$(RASTR_LIBNAME) $(DATETIMELIB) $(XDRLIB) $(SOCKLIB) $(INTLLIB)
+
# DBMI
DBMIBASELIB = -l$(DBMIBASE_LIBNAME) $(GISLIB)
DBMICLIENTLIB = -l$(DBMICLIENT_LIBNAME) $(DBMIBASELIB) $(GISLIB)
@@ -333,6 +339,9 @@
XGIDEP = $(BASE_LIBDIR)/$(LIB_PREFIX)$(XGI_LIBNAME)$(LIB_SUFFIX)
XPMDEP = $(BASE_LIBDIR)/$(LIB_PREFIX)$(XPM_LIBNAME)$(LIB_SUFFIX)
+# Raster
+RASTRDEP = $(BASE_LIBDIR)/$(LIB_PREFIX)$(RASTR_LIBNAME)$(LIB_SUFFIX)
+
# DBMI
DBMIBASEDEP = $(BASE_LIBDIR)/$(LIB_PREFIX)$(DBMIBASE_LIBNAME)$(LIB_SUFFIX)
DBMICLIENTDEP = $(BASE_LIBDIR)/$(LIB_PREFIX)$(DBMICLIENT_LIBNAME)$(LIB_SUFFIX)
Added: grass/trunk/include/Rast.h
===================================================================
--- grass/trunk/include/Rast.h (rev 0)
+++ grass/trunk/include/Rast.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,537 @@
+#ifndef GRASS_RAST_H
+#define GRASS_RAST_H
+#include <grass/gis.h>
+
+/* --- ANSI prototypes for the lib/raster functions --- */
+
+/* adj_cellhd.c */
+const char *Rast_adjust_Cell_head(struct Cell_head *, int, int);
+const char *Rast_adjust_Cell_head3(struct Cell_head *, int, int, int);
+
+/* alloc_cell.c */
+size_t Rast_raster_size(RASTER_MAP_TYPE);
+CELL *Rast_allocate_cell_buf(void);
+void *Rast_allocate_raster_buf(RASTER_MAP_TYPE);
+CELL *Rast_allocate_c_raster_buf(void);
+FCELL *Rast_allocate_f_raster_buf(void);
+DCELL *Rast_allocate_d_raster_buf(void);
+char *Rast_allocate_null_buf(void);
+unsigned char *Rast__allocate_null_bits(int);
+int Rast__null_bitstream_size(int);
+
+/* auto_mask.c */
+int Rast__check_for_auto_masking(void);
+void Rast_suppress_masking(void);
+void Rast_unsuppress_masking(void);
+
+/* cats.c */
+int Rast_read_cats(const char *, const char *, struct Categories *);
+int Rast_read_raster_cats(const char *, const char *, struct Categories *);
+int Rast_read_vector_cats(const char *, const char *, struct Categories *);
+CELL Rast_number_of_cats(const char *, const char *);
+char *Rast_get_cats_title(const struct Categories *);
+char *Rast_get_raster_cats_title(const struct Categories *);
+char *Rast_get_cat(CELL, struct Categories *);
+char *Rast_get_c_raster_cat(CELL *, struct Categories *);
+char *Rast_get_f_raster_cat(FCELL *, struct Categories *);
+char *Rast_get_d_raster_cat(DCELL *, struct Categories *);
+char *Rast_get_raster_cat(void *, struct Categories *, RASTER_MAP_TYPE);
+void Rast_unmark_raster_cats(struct Categories *);
+void Rast_mark_c_raster_cats(const CELL *, int, struct Categories *);
+void Rast_mark_f_raster_cats(const FCELL *, int, struct Categories *);
+void Rast_mark_d_raster_cats(const DCELL *, int, struct Categories *);
+int Rast_mark_raster_cats(const void *, int, struct Categories *, RASTER_MAP_TYPE);
+void Rast_rewind_raster_cats(struct Categories *);
+char *Rast_get_next_marked_d_raster_cat(struct Categories *, DCELL *, DCELL *,
+ long *);
+char *Rast_get_next_marked_c_raster_cat(struct Categories *, CELL *, CELL *,
+ long *);
+char *Rast_get_next_marked_f_raster_cat(struct Categories *, FCELL *, FCELL *,
+ long *);
+char *Rast_get_next_marked_raster_cat(struct Categories *, void *, void *,
+ long *, RASTER_MAP_TYPE);
+int Rast_set_cat(CELL, const char *, struct Categories *);
+int Rast_set_c_raster_cat(const CELL *, const CELL *, const char *, struct Categories *);
+int Rast_set_f_raster_cat(const FCELL *, const FCELL *, const char *, struct Categories *);
+int Rast_set_d_raster_cat(const DCELL *, const DCELL *, const char *, struct Categories *);
+int Rast_set_raster_cat(const void *, const void *, const char *, struct Categories *,
+ RASTER_MAP_TYPE);
+int Rast_write_cats(const char *, struct Categories *);
+int Rast_write_raster_cats(const char *, struct Categories *);
+int Rast_write_vector_cats(const char *, struct Categories *);
+char *Rast_get_ith_d_raster_cat(const struct Categories *, int, DCELL *,
+ DCELL *);
+char *Rast_get_ith_f_raster_cat(const struct Categories *, int, void *, void *);
+char *Rast_get_ith_c_raster_cat(const struct Categories *, int, void *, void *);
+char *Rast_get_ith_raster_cat(const struct Categories *, int, void *, void *,
+ RASTER_MAP_TYPE);
+void Rast_init_cats(CELL, const char *, struct Categories *);
+void Rast_init_raster_cats(const char *, struct Categories *);
+void Rast_set_cats_title(const char *, struct Categories *);
+void Rast_set_raster_cats_title(const char *, struct Categories *);
+void Rast_set_cats_fmt(const char *, double, double, double, double,
+ struct Categories *);
+void Rast_set_raster_cats_fmt(const char *, double, double, double, double,
+ struct Categories *);
+void Rast_free_cats(struct Categories *);
+void Rast_free_raster_cats(struct Categories *);
+void Rast_copy_raster_cats(struct Categories *, const struct Categories *);
+int Rast_number_of_raster_cats(struct Categories *);
+int Rast_sort_cats(struct Categories *);
+
+/* cell_stats.c */
+void Rast_init_cell_stats(struct Cell_stats *);
+int Rast_update_cell_stats(const CELL *, int, struct Cell_stats *);
+int Rast_find_cell_stat(CELL, long *, const struct Cell_stats *);
+int Rast_rewind_cell_stats(struct Cell_stats *);
+int Rast_next_cell_stat(CELL *, long *, struct Cell_stats *);
+void Rast_get_stats_for_null_value(long *, const struct Cell_stats *);
+void Rast_free_cell_stats(struct Cell_stats *);
+
+/* cell_title.c */
+char *Rast_get_cell_title(const char *, const char *);
+
+/* cellstats_eq.c */
+int Rast_cell_stats_histo_eq(struct Cell_stats *, CELL, CELL, CELL, CELL, int,
+ void (*)(CELL, CELL, CELL));
+
+/* closecell.c */
+int Rast_close_cell(int);
+int Rast_unopen_cell(int);
+
+/* color_compat.c */
+void Rast_make_ryg_colors(struct Colors *, CELL, CELL);
+void Rast_make_ryg_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_aspect_colors(struct Colors *, CELL, CELL);
+void Rast_make_aspect_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_byr_colors(struct Colors *, CELL, CELL);
+void Rast_make_byr_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_bgyr_colors(struct Colors *, CELL, CELL);
+void Rast_make_bgyr_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_byg_colors(struct Colors *, CELL, CELL);
+void Rast_make_byg_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_grey_scale_colors(struct Colors *, CELL, CELL);
+void Rast_make_grey_scale_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_gyr_colors(struct Colors *, CELL, CELL);
+void Rast_make_gyr_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_rainbow_colors(struct Colors *, CELL, CELL);
+void Rast_make_rainbow_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_ramp_colors(struct Colors *, CELL, CELL);
+void Rast_make_ramp_fp_colors(struct Colors *, DCELL, DCELL);
+void Rast_make_wave_colors(struct Colors *, CELL, CELL);
+void Rast_make_wave_fp_colors(struct Colors *, DCELL, DCELL);
+
+/* color_free.c */
+void Rast_free_colors(struct Colors *);
+void Rast__color_free_rules(struct _Color_Info_ *);
+void Rast__color_free_lookup(struct _Color_Info_ *);
+void Rast__color_free_fp_lookup(struct _Color_Info_ *);
+void Rast__color_reset(struct Colors *);
+
+/* color_get.c */
+int Rast_get_color(CELL, int *, int *, int *, struct Colors *);
+int Rast_get_raster_color(const void *, int *, int *, int *, struct Colors *,
+ RASTER_MAP_TYPE);
+int Rast_get_c_raster_color(const CELL *, int *, int *, int *, struct Colors *);
+int Rast_get_f_raster_color(const FCELL *, int *, int *, int *, struct Colors *);
+int Rast_get_d_raster_color(const DCELL *, int *, int *, int *, struct Colors *);
+void Rast_get_null_value_color(int *, int *, int *, const struct Colors *);
+void Rast_get_default_color(int *, int *, int *, const struct Colors *);
+
+/* color_hist.c */
+void Rast_make_histogram_eq_colors(struct Colors *, struct Cell_stats *);
+void Rast_make_histogram_log_colors(struct Colors *, struct Cell_stats *, int, int);
+
+/* color_init.c */
+void Rast_init_colors(struct Colors *);
+
+/* color_insrt.c */
+int Rast__insert_color_into_lookup(CELL, int, int, int, struct _Color_Info_ *);
+
+/* color_invrt.c */
+int Rast_invert_colors(struct Colors *);
+
+/* color_look.c */
+void Rast_lookup_colors(const CELL *, unsigned char *, unsigned char *,
+ unsigned char *, unsigned char *, int, struct Colors *);
+void Rast_lookup_c_raster_colors(const CELL *, unsigned char *, unsigned char *,
+ unsigned char *, unsigned char *, int,
+ struct Colors *);
+void Rast_lookup_raster_colors(const void *, unsigned char *, unsigned char *,
+ unsigned char *, unsigned char *, int,
+ struct Colors *, RASTER_MAP_TYPE);
+void Rast_lookup_f_raster_colors(const FCELL *, unsigned char *, unsigned char *,
+ unsigned char *, unsigned char *, int,
+ struct Colors *);
+void Rast_lookup_d_raster_colors(const DCELL *, unsigned char *, unsigned char *,
+ unsigned char *, unsigned char *, int,
+ struct Colors *);
+void Rast__lookup_colors(const void *, unsigned char *, unsigned char *,
+ unsigned char *, unsigned char *, int, struct Colors *,
+ int, int, RASTER_MAP_TYPE);
+void Rast__interpolate_color_rule(DCELL, unsigned char *, unsigned char *,
+ unsigned char *, const struct _Color_Rule_ *);
+
+/* color_org.c */
+void Rast__organize_colors(struct Colors *);
+
+/* color_rand.c */
+void Rast_make_random_colors(struct Colors *, CELL, CELL);
+
+/* color_range.c */
+void Rast_set_color_range(CELL, CELL, struct Colors *);
+void Rast_set_d_color_range(DCELL, DCELL, struct Colors *);
+void Rast_get_color_range(CELL *, CELL *, const struct Colors *);
+void Rast_get_d_color_range(DCELL *, DCELL *, const struct Colors *);
+
+/* color_read.c */
+int Rast_read_colors(const char *, const char *, struct Colors *);
+void Rast_mark_colors_as_fp(struct Colors *);
+
+/* color_remove.c */
+int Rast_remove_colors(const char *, const char *);
+
+/* color_rule.c */
+void Rast_add_d_raster_color_rule(const DCELL *, int, int, int,
+ const DCELL *, int, int, int,
+ struct Colors *);
+void Rast_add_f_raster_color_rule(const FCELL *, int, int, int,
+ const FCELL *, int, int, int,
+ struct Colors *);
+void Rast_add_c_raster_color_rule(const CELL *, int, int, int,
+ const CELL *, int, int, int,
+ struct Colors *);
+void Rast_add_raster_color_rule(const void *, int, int, int,
+ const void *, int, int, int,
+ struct Colors *, RASTER_MAP_TYPE);
+void Rast_add_color_rule(const CELL, int, int, int,
+ const CELL, int, int, int,
+ struct Colors *);
+int Rast_add_modular_d_raster_color_rule(const DCELL *, int, int, int,
+ const DCELL *, int, int, int,
+ struct Colors *);
+int Rast_add_modular_f_raster_color_rule(const FCELL *, int, int, int,
+ const FCELL *, int, int, int,
+ struct Colors *);
+int Rast_add_modular_c_raster_color_rule(const CELL *, int, int, int,
+ const CELL *, int, int, int,
+ struct Colors *);
+int Rast_add_modular_raster_color_rule(const void *, int, int, int,
+ const void *, int, int, int,
+ struct Colors *, RASTER_MAP_TYPE);
+int Rast_add_modular_color_rule(CELL, int, int, int,
+ CELL, int, int, int,
+ struct Colors *);
+
+/* color_rule_get.c */
+int Rast_colors_count(const struct Colors *);
+int Rast_get_f_color_rule(DCELL *, unsigned char *, unsigned char *,
+ unsigned char *, DCELL *, unsigned char *,
+ unsigned char *, unsigned char *,
+ const struct Colors *, int);
+
+/* color_rules.c */
+typedef int read_rule_fn(void *, DCELL, DCELL,
+ DCELL *, int *, int *, int *, int *, int *, int *);
+int Rast_parse_color_rule(DCELL, DCELL, const char *, DCELL *, int *, int *,
+ int *, int *, int *, int *);
+const char *Rast_parse_color_rule_error(int);
+int Rast_read_color_rule(void *, DCELL, DCELL, DCELL *, int *, int *, int *,
+ int *, int *, int *);
+int Rast_read_color_rules(struct Colors *, DCELL, DCELL, read_rule_fn *, void *);
+int Rast_load_colors(struct Colors *, const char *, CELL, CELL);
+int Rast_load_fp_colors(struct Colors *, const char *, DCELL, DCELL);
+void Rast_make_colors(struct Colors *, const char *, CELL, CELL);
+void Rast_make_fp_colors(struct Colors *, const char *, DCELL, DCELL);
+
+/* color_set.c */
+void Rast_set_color(CELL, int, int, int, struct Colors *);
+void Rast_set_d_color(DCELL, int, int, int, struct Colors *);
+void Rast_set_null_value_color(int, int, int, struct Colors *);
+void Rast_set_default_color(int, int, int, struct Colors *);
+
+/* color_shift.c */
+void Rast_shift_colors(int, struct Colors *);
+void Rast_shift_d_colors(DCELL, struct Colors *);
+
+/* color_str.c */
+int Rast_str_to_color(const char *, int *, int *, int *);
+
+/* color_write.c */
+int Rast_write_colors(const char *, const char *, struct Colors *);
+void Rast__write_colors(FILE *, struct Colors *);
+
+/* color_xform.c */
+void Rast_histogram_eq_colors(struct Colors *, struct Colors *,
+ struct Cell_stats *);
+void Rast_histogram_eq_colors_fp(struct Colors *,
+ struct Colors *, struct FP_stats *);
+void Rast_log_colors(struct Colors *, struct Colors *, int);
+void Rast_abs_log_colors(struct Colors *, struct Colors *, int);
+
+/* format.c */
+int Rast__check_format(int);
+int Rast__read_row_ptrs(int);
+int Rast__write_row_ptrs(int);
+
+/* fpreclass.c */
+void Rast_fpreclass_clear(struct FPReclass *);
+void Rast_fpreclass_reset(struct FPReclass *);
+void Rast_fpreclass_init(struct FPReclass *);
+void Rast_fpreclass_set_domain(struct FPReclass *, DCELL, DCELL);
+void Rast_fpreclass_set_range(struct FPReclass *, DCELL, DCELL);
+int Rast_fpreclass_get_limits(const struct FPReclass *, DCELL *, DCELL *,
+ DCELL *, DCELL *);
+int Rast_fpreclass_nof_rules(const struct FPReclass *);
+void Rast_fpreclass_get_ith_rule(const struct FPReclass *, int, DCELL *, DCELL *,
+ DCELL *, DCELL *);
+void Rast_fpreclass_set_neg_infinite_rule(struct FPReclass *, DCELL, DCELL);
+int Rast_fpreclass_get_neg_infinite_rule(const struct FPReclass *, DCELL *,
+ DCELL *);
+void Rast_fpreclass_set_pos_infinite_rule(struct FPReclass *, DCELL, DCELL);
+int Rast_fpreclass_get_pos_infinite_rule(const struct FPReclass *, DCELL *,
+ DCELL *);
+void Rast_fpreclass_add_rule(struct FPReclass *, DCELL, DCELL, DCELL, DCELL);
+void Rast_fpreclass_reverse_rule_order(struct FPReclass *);
+DCELL Rast_fpreclass_get_cell_value(const struct FPReclass *, DCELL);
+void Rast_fpreclass_perform_di(const struct FPReclass *, const DCELL *, CELL *,
+ int);
+void Rast_fpreclass_perform_df(const struct FPReclass *, const DCELL *, FCELL *,
+ int);
+void Rast_fpreclass_perform_dd(const struct FPReclass *, const DCELL *, DCELL *,
+ int);
+void Rast_fpreclass_perform_fi(const struct FPReclass *, const FCELL *, CELL *,
+ int);
+void Rast_fpreclass_perform_ff(const struct FPReclass *, const FCELL *, FCELL *,
+ int);
+void Rast_fpreclass_perform_fd(const struct FPReclass *, const FCELL *, DCELL *,
+ int);
+void Rast_fpreclass_perform_ii(const struct FPReclass *, const CELL *, CELL *,
+ int);
+void Rast_fpreclass_perform_if(const struct FPReclass *, const CELL *, FCELL *,
+ int);
+void Rast_fpreclass_perform_id(const struct FPReclass *, const CELL *, DCELL *,
+ int);
+/* gdal.c */
+void Rast_init_gdal(void);
+struct GDAL_link *Rast_get_gdal_link(const char *, const char *);
+struct GDAL_link *Rast_create_gdal_link(const char *, RASTER_MAP_TYPE);
+void Rast_close_gdal_link(struct GDAL_link *);
+int Rast_close_gdal_write_link(struct GDAL_link *);
+
+/* get_cellhd.c */
+int Rast_get_cellhd(const char *, const char *, struct Cell_head *);
+
+/* get_row.c */
+int Rast_get_map_row_nomask(int, CELL *, int);
+int Rast_get_raster_row_nomask(int, void *, int, RASTER_MAP_TYPE);
+int Rast_get_c_raster_row_nomask(int, CELL *, int);
+int Rast_get_f_raster_row_nomask(int, FCELL *, int);
+int Rast_get_d_raster_row_nomask(int, DCELL *, int);
+int Rast_get_map_row(int, CELL *, int);
+int Rast_get_raster_row(int, void *, int, RASTER_MAP_TYPE);
+int Rast_get_c_raster_row(int, CELL *, int);
+int Rast_get_f_raster_row(int, FCELL *, int);
+int Rast_get_d_raster_row(int, DCELL *, int);
+int Rast_get_null_value_row(int, char *, int);
+
+/* get_row_colr.c */
+int Rast_get_raster_row_colors(int, int, struct Colors *,
+ unsigned char *, unsigned char *, unsigned char *,
+ unsigned char *);
+/* histo_eq.c */
+void Rast_histogram_eq(const struct Histogram *, unsigned char **,
+ CELL *, CELL *);
+
+/* histogram.c */
+void Rast_init_histogram(struct Histogram *);
+int Rast_read_histogram(const char *, const char *, struct Histogram *);
+int Rast_write_histogram(const char *, const struct Histogram *);
+int Rast_write_histogram_cs(const char *, struct Cell_stats *);
+void Rast_make_histogram_cs(struct Cell_stats *, struct Histogram *);
+int Rast_get_histogram_num(const struct Histogram *);
+CELL Rast_get_histogram_cat(int, const struct Histogram *);
+long Rast_get_histogram_count(int, const struct Histogram *);
+void Rast_free_histogram(struct Histogram *);
+int Rast_sort_histogram(struct Histogram *);
+int Rast_sort_histogram_by_count(struct Histogram *);
+void Rast_remove_histogram(const char *);
+int Rast_add_histogram(CELL, long, struct Histogram *);
+int Rast_set_histogram(CELL, long, struct Histogram *);
+void Rast_extend_histogram(CELL, long, struct Histogram *);
+void Rast_zero_histogram(struct Histogram *);
+
+/* history.c */
+int Rast_read_history(const char *, const char *, struct History *);
+int Rast_write_history(const char *, struct History *);
+void Rast_short_history(const char *, const char *, struct History *);
+int Rast_command_history(struct History *);
+
+/* interp.c */
+DCELL Rast_interp_linear(double, DCELL, DCELL);
+DCELL Rast_interp_bilinear(double, double, DCELL, DCELL, DCELL, DCELL);
+DCELL Rast_interp_cubic(double, DCELL, DCELL, DCELL, DCELL);
+DCELL Rast_interp_bicubic(double, double,
+ DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL,
+ DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL,
+ DCELL);
+
+/* mask_info.c */
+char *Rast_mask_info(void);
+int Rast__mask_info(char *, char *);
+
+/* maskfd.c */
+int Rast_maskfd(void);
+
+/* null_val.c */
+void Rast__set_null_value(void *, int, int, RASTER_MAP_TYPE);
+void Rast_set_null_value(void *, int, RASTER_MAP_TYPE);
+void Rast_set_c_null_value(CELL *, int);
+void Rast_set_f_null_value(FCELL *, int);
+void Rast_set_d_null_value(DCELL *, int);
+int Rast_is_null_value(const void *, RASTER_MAP_TYPE);
+int Rast_is_c_null_value(const CELL *);
+int Rast_is_f_null_value(const FCELL *);
+int Rast_is_d_null_value(const DCELL *);
+void Rast_insert_null_values(void *, char *, int, RASTER_MAP_TYPE);
+void Rast_insert_c_null_values(CELL *, char *, int);
+void Rast_insert_f_null_values(FCELL *, char *, int);
+void Rast_insert_d_null_values(DCELL *, char *, int);
+int Rast__check_null_bit(const unsigned char *, int, int);
+void Rast__convert_01_flags(const char *, unsigned char *, int);
+void Rast__convert_flags_01(char *, const unsigned char *, int);
+void Rast__init_null_bits(unsigned char *, int);
+
+/* opencell.c */
+int Rast_open_cell_old(const char *, const char *);
+int Rast__open_cell_old(const char *, const char *);
+int Rast_open_cell_new(const char *);
+int Rast_open_cell_new_uncompressed(const char *);
+void Rast_want_histogram(int);
+void Rast_set_cell_format(int);
+int Rast_cellvalue_format(CELL);
+int Rast_open_fp_cell_new(const char *);
+int Rast_open_fp_cell_new_uncompressed(const char *);
+int Rast_set_fp_type(RASTER_MAP_TYPE);
+int Rast_raster_map_is_fp(const char *, const char *);
+RASTER_MAP_TYPE Rast_raster_map_type(const char *, const char *);
+RASTER_MAP_TYPE Rast__check_fp_type(const char *, const char *);
+RASTER_MAP_TYPE Rast_get_raster_map_type(int);
+int Rast_open_raster_new(const char *, RASTER_MAP_TYPE);
+int Rast_open_raster_new_uncompressed(const char *, RASTER_MAP_TYPE);
+int Rast_set_quant_rules(int, struct Quant *);
+
+/* put_cellhd.c */
+int Rast_put_cellhd(const char *, struct Cell_head *);
+
+/* put_row.c */
+int Rast_put_map_row(int, const CELL *);
+int Rast_put_raster_row(int, const void *, RASTER_MAP_TYPE);
+int Rast_put_c_raster_row(int, const CELL *);
+int Rast_put_f_raster_row(int, const FCELL *);
+int Rast_put_d_raster_row(int, const DCELL *);
+int Rast__open_null_write(int);
+int Rast__write_null_bits(int, const unsigned char *, int, int, int);
+
+/* put_title.c */
+int Rast_put_cell_title(const char *, const char *);
+
+/* quant.c */
+void Rast_quant_clear(struct Quant *);
+void Rast_quant_free(struct Quant *);
+int Rast__quant_organize_fp_lookup(struct Quant *);
+void Rast_quant_init(struct Quant *);
+int Rast_quant_is_truncate(const struct Quant *);
+int Rast_quant_is_round(const struct Quant *);
+void Rast_quant_truncate(struct Quant *);
+void Rast_quant_round(struct Quant *);
+int Rast_quant_get_limits(const struct Quant *, DCELL *, DCELL *, CELL *,
+ CELL *);
+int Rast_quant_nof_rules(const struct Quant *);
+void Rast_quant_get_ith_rule(const struct Quant *, int, DCELL *, DCELL *, CELL *,
+ CELL *);
+void Rast_quant_set_neg_infinite_rule(struct Quant *, DCELL, CELL);
+int Rast_quant_get_neg_infinite_rule(const struct Quant *, DCELL *, CELL *);
+void Rast_quant_set_pos_infinite_rule(struct Quant *, DCELL, CELL);
+int Rast_quant_get_pos_infinite_rule(const struct Quant *, DCELL *, CELL *);
+void Rast_quant_add_rule(struct Quant *, DCELL, DCELL, CELL, CELL);
+void Rast_quant_reverse_rule_order(struct Quant *);
+CELL Rast_quant_get_cell_value(struct Quant *, DCELL);
+void Rast_quant_perform_d(struct Quant *, const DCELL *, CELL *, int);
+void Rast_quant_perform_f(struct Quant *, const FCELL *, CELL *, int);
+struct Quant_table *Rast__quant_get_rule_for_d_raster_val(const struct Quant *,
+ DCELL);
+
+/* quant_io.c */
+int Rast__quant_import(const char *, const char *, struct Quant *);
+int Rast__quant_export(const char *, const char *, const struct Quant *);
+
+/* quant_rw.c */
+int Rast_truncate_fp_map(const char *, const char *);
+int Rast_round_fp_map(const char *, const char *);
+int Rast_quantize_fp_map(const char *, const char *, CELL, CELL);
+int Rast_quantize_fp_map_range(const char *, const char *, DCELL, DCELL, CELL,
+ CELL);
+int Rast_write_quant(const char *, const char *, const struct Quant *);
+int Rast_read_quant(const char *, const char *, struct Quant *);
+
+/* range.c */
+void Rast__remove_fp_range(const char *);
+void Rast_construct_default_range(struct Range *);
+int Rast_read_fp_range(const char *, const char *, struct FPRange *);
+int Rast_read_range(const char *, const char *, struct Range *);
+int Rast_write_range(const char *, const struct Range *);
+int Rast_write_fp_range(const char *, const struct FPRange *);
+void Rast_update_range(CELL, struct Range *);
+void Rast_update_fp_range(DCELL, struct FPRange *);
+void Rast_row_update_range(const CELL *, int, struct Range *);
+void Rast__row_update_range(const CELL *, int, struct Range *, int);
+void Rast_row_update_fp_range(const void *, int, struct FPRange *,
+ RASTER_MAP_TYPE);
+void Rast_init_range(struct Range *);
+void Rast_get_range_min_max(const struct Range *, CELL *, CELL *);
+void Rast_init_fp_range(struct FPRange *);
+void Rast_get_fp_range_min_max(const struct FPRange *, DCELL *, DCELL *);
+
+/* raster.c */
+void *Rast_incr_void_ptr(const void *, const size_t);
+int Rast_raster_cmp(const void *, const void *, RASTER_MAP_TYPE);
+void Rast_raster_cpy(void *, const void *, int, RASTER_MAP_TYPE);
+void Rast_set_raster_value_c(void *, CELL, RASTER_MAP_TYPE);
+void Rast_set_raster_value_f(void *, FCELL, RASTER_MAP_TYPE);
+void Rast_set_raster_value_d(void *, DCELL, RASTER_MAP_TYPE);
+CELL Rast_get_raster_value_c(const void *, RASTER_MAP_TYPE);
+FCELL Rast_get_raster_value_f(const void *, RASTER_MAP_TYPE);
+DCELL Rast_get_raster_value_d(const void *, RASTER_MAP_TYPE);
+
+/* raster_metadata.c */
+int Rast_read_raster_units(const char *, const char *, char *);
+int Rast_read_raster_vdatum(const char *, const char *, char *);
+int Rast_write_raster_units(const char *, const char *);
+int Rast_write_raster_vdatum(const char *, const char *);
+int Rast__raster_misc_read_line(const char *, const char *, const char *,
+ char *);
+int Rast__raster_misc_write_line(const char *, const char *, const char *);
+
+/* rd_cellhd.c */
+char *Rast__read_Cell_head(FILE *, struct Cell_head *, int);
+char *Rast__read_Cell_head_array(char **, struct Cell_head *, int);
+
+/* reclass.c */
+int Rast_is_reclass(const char *, const char *, char *, char *);
+int Rast_is_reclassed_to(const char *, const char *, int *, char ***);
+int Rast_get_reclass(const char *, const char *, struct Reclass *);
+void Rast_free_reclass(struct Reclass *);
+int Rast_put_reclass(const char *, const struct Reclass *);
+
+/* sample.c */
+DCELL Rast_get_raster_sample_nearest(int, const struct Cell_head *, struct Categories *, double, double, int);
+DCELL Rast_get_raster_sample_bilinear(int, const struct Cell_head *, struct Categories *, double, double, int);
+DCELL Rast_get_raster_sample_cubic(int, const struct Cell_head *, struct Categories *, double, double, int);
+DCELL Rast_get_raster_sample(int, const struct Cell_head *, struct Categories *, double, double, int, INTERP_TYPE);
+
+/* zero_cell.c */
+void Rast_zero_cell_buf(CELL *);
+void Rast_zero_raster_buf(void *, RASTER_MAP_TYPE);
+
+#endif
Property changes on: grass/trunk/include/Rast.h
___________________________________________________________________
Name: svn:mime-type
+ text/x-chdr
Name: svn:keywords
+ Author Date Id
Name: svn:eol-style
+ native
Property changes on: grass/trunk/include/arraystats.h
___________________________________________________________________
Name: svn:mime-type
+ text/x-chdr
Name: svn:keywords
+ Author Date Id
Property changes on: grass/trunk/include/cluster.h
___________________________________________________________________
Name: svn:mime-type
+ text/x-chdr
Name: svn:keywords
+ Author Date Id
Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/include/gis.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -38,7 +38,7 @@
static const char *GRASS_copyright __attribute__ ((unused))
= "GRASS GNU GPL licensed Software";
-#define GIS_H_VERSION "$Revision$"
+#define GIS_H_VERSION "$Revision: 37043 $"
#define GIS_H_DATE "$Date$"
#define G_gisinit(pgm) G__gisinit(GIS_H_VERSION, (pgm))
Property changes on: grass/trunk/include/gis.h
___________________________________________________________________
Name: svn:keywords
- Author Date Id Revision
+ Author Date Id
Modified: grass/trunk/include/gisdefs.h
===================================================================
--- grass/trunk/include/gisdefs.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/include/gisdefs.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -46,10 +46,6 @@
#include <sys/types.h>
-/* adj_cellhd.c */
-const char *G_adjust_Cell_head(struct Cell_head *, int, int);
-const char *G_adjust_Cell_head3(struct Cell_head *, int, int, int);
-
/* align_window.c */
const char *G_align_window(struct Cell_head *, const struct Cell_head *);
@@ -63,17 +59,6 @@
#define G_calloc(m, n) G__calloc(__FILE__, __LINE__, (m), (n))
#define G_realloc(p, n) G__realloc(__FILE__, __LINE__, (p), (n))
-/* alloc_cell.c */
-size_t G_raster_size(RASTER_MAP_TYPE);
-CELL *G_allocate_cell_buf(void);
-void *G_allocate_raster_buf(RASTER_MAP_TYPE);
-CELL *G_allocate_c_raster_buf(void);
-FCELL *G_allocate_f_raster_buf(void);
-DCELL *G_allocate_d_raster_buf(void);
-char *G_allocate_null_buf(void);
-unsigned char *G__allocate_null_bits(int);
-int G__null_bitstream_size(int);
-
/* area.c */
int G_begin_cell_area_calculations(void);
double G_area_of_cell_at_row(int);
@@ -116,268 +101,18 @@
int G_asprintf(char **, const char *, ...)
__attribute__ ((format(printf, 2, 3)));
-/* auto_mask.c */
-int G__check_for_auto_masking(void);
-void G_suppress_masking(void);
-void G_unsuppress_masking(void);
-
/* basename.c */
char *G_basename(char *, const char *);
/* bres_line.c */
void G_bresenham_line(int, int, int, int, int (*)(int, int));
-/* cats.c */
-int G_read_cats(const char *, const char *, struct Categories *);
-int G_read_raster_cats(const char *, const char *, struct Categories *);
-int G_read_vector_cats(const char *, const char *, struct Categories *);
-CELL G_number_of_cats(const char *, const char *);
-char *G_get_cats_title(const struct Categories *);
-char *G_get_raster_cats_title(const struct Categories *);
-char *G_get_cat(CELL, struct Categories *);
-char *G_get_c_raster_cat(CELL *, struct Categories *);
-char *G_get_f_raster_cat(FCELL *, struct Categories *);
-char *G_get_d_raster_cat(DCELL *, struct Categories *);
-char *G_get_raster_cat(void *, struct Categories *, RASTER_MAP_TYPE);
-void G_unmark_raster_cats(struct Categories *);
-void G_mark_c_raster_cats(const CELL *, int, struct Categories *);
-void G_mark_f_raster_cats(const FCELL *, int, struct Categories *);
-void G_mark_d_raster_cats(const DCELL *, int, struct Categories *);
-int G_mark_raster_cats(const void *, int, struct Categories *, RASTER_MAP_TYPE);
-void G_rewind_raster_cats(struct Categories *);
-char *G_get_next_marked_d_raster_cat(struct Categories *, DCELL *, DCELL *,
- long *);
-char *G_get_next_marked_c_raster_cat(struct Categories *, CELL *, CELL *,
- long *);
-char *G_get_next_marked_f_raster_cat(struct Categories *, FCELL *, FCELL *,
- long *);
-char *G_get_next_marked_raster_cat(struct Categories *, void *, void *,
- long *, RASTER_MAP_TYPE);
-int G_set_cat(CELL, const char *, struct Categories *);
-int G_set_c_raster_cat(const CELL *, const CELL *, const char *, struct Categories *);
-int G_set_f_raster_cat(const FCELL *, const FCELL *, const char *, struct Categories *);
-int G_set_d_raster_cat(const DCELL *, const DCELL *, const char *, struct Categories *);
-int G_set_raster_cat(const void *, const void *, const char *, struct Categories *,
- RASTER_MAP_TYPE);
-int G_write_cats(const char *, struct Categories *);
-int G_write_raster_cats(const char *, struct Categories *);
-int G_write_vector_cats(const char *, struct Categories *);
-char *G_get_ith_d_raster_cat(const struct Categories *, int, DCELL *,
- DCELL *);
-char *G_get_ith_f_raster_cat(const struct Categories *, int, void *, void *);
-char *G_get_ith_c_raster_cat(const struct Categories *, int, void *, void *);
-char *G_get_ith_raster_cat(const struct Categories *, int, void *, void *,
- RASTER_MAP_TYPE);
-void G_init_cats(CELL, const char *, struct Categories *);
-void G_init_raster_cats(const char *, struct Categories *);
-void G_set_cats_title(const char *, struct Categories *);
-void G_set_raster_cats_title(const char *, struct Categories *);
-void G_set_cats_fmt(const char *, double, double, double, double,
- struct Categories *);
-void G_set_raster_cats_fmt(const char *, double, double, double, double,
- struct Categories *);
-void G_free_cats(struct Categories *);
-void G_free_raster_cats(struct Categories *);
-void G_copy_raster_cats(struct Categories *, const struct Categories *);
-int G_number_of_raster_cats(struct Categories *);
-int G_sort_cats(struct Categories *);
-
-/* cell_stats.c */
-void G_init_cell_stats(struct Cell_stats *);
-int G_update_cell_stats(const CELL *, int, struct Cell_stats *);
-int G_find_cell_stat(CELL, long *, const struct Cell_stats *);
-int G_rewind_cell_stats(struct Cell_stats *);
-int G_next_cell_stat(CELL *, long *, struct Cell_stats *);
-void G_get_stats_for_null_value(long *, const struct Cell_stats *);
-void G_free_cell_stats(struct Cell_stats *);
-
-/* cell_title.c */
-char *G_get_cell_title(const char *, const char *);
-
-/* cellstats_eq.c */
-int G_cell_stats_histo_eq(struct Cell_stats *, CELL, CELL, CELL, CELL, int,
- void (*)(CELL, CELL, CELL));
-
/* clear_scrn.c */
void G_clear_screen(void);
/* clicker.c */
void G_clicker(void);
-/* closecell.c */
-int G_close_cell(int);
-int G_unopen_cell(int);
-
-/* color_compat.c */
-void G_make_ryg_colors(struct Colors *, CELL, CELL);
-void G_make_ryg_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_aspect_colors(struct Colors *, CELL, CELL);
-void G_make_aspect_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_byr_colors(struct Colors *, CELL, CELL);
-void G_make_byr_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_bgyr_colors(struct Colors *, CELL, CELL);
-void G_make_bgyr_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_byg_colors(struct Colors *, CELL, CELL);
-void G_make_byg_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_grey_scale_colors(struct Colors *, CELL, CELL);
-void G_make_grey_scale_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_gyr_colors(struct Colors *, CELL, CELL);
-void G_make_gyr_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_rainbow_colors(struct Colors *, CELL, CELL);
-void G_make_rainbow_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_ramp_colors(struct Colors *, CELL, CELL);
-void G_make_ramp_fp_colors(struct Colors *, DCELL, DCELL);
-void G_make_wave_colors(struct Colors *, CELL, CELL);
-void G_make_wave_fp_colors(struct Colors *, DCELL, DCELL);
-
-/* color_free.c */
-void G_free_colors(struct Colors *);
-void G__color_free_rules(struct _Color_Info_ *);
-void G__color_free_lookup(struct _Color_Info_ *);
-void G__color_free_fp_lookup(struct _Color_Info_ *);
-void G__color_reset(struct Colors *);
-
-/* color_get.c */
-int G_get_color(CELL, int *, int *, int *, struct Colors *);
-int G_get_raster_color(const void *, int *, int *, int *, struct Colors *,
- RASTER_MAP_TYPE);
-int G_get_c_raster_color(const CELL *, int *, int *, int *, struct Colors *);
-int G_get_f_raster_color(const FCELL *, int *, int *, int *, struct Colors *);
-int G_get_d_raster_color(const DCELL *, int *, int *, int *, struct Colors *);
-void G_get_null_value_color(int *, int *, int *, const struct Colors *);
-void G_get_default_color(int *, int *, int *, const struct Colors *);
-
-/* color_hist.c */
-void G_make_histogram_eq_colors(struct Colors *, struct Cell_stats *);
-void G_make_histogram_log_colors(struct Colors *, struct Cell_stats *, int, int);
-
-/* color_init.c */
-void G_init_colors(struct Colors *);
-
-/* color_insrt.c */
-int G__insert_color_into_lookup(CELL, int, int, int, struct _Color_Info_ *);
-
-/* color_invrt.c */
-void G_invert_colors(struct Colors *);
-
-/* color_look.c */
-void G_lookup_colors(const CELL *, unsigned char *, unsigned char *,
- unsigned char *, unsigned char *, int, struct Colors *);
-void G_lookup_c_raster_colors(const CELL *, unsigned char *, unsigned char *,
- unsigned char *, unsigned char *, int,
- struct Colors *);
-void G_lookup_raster_colors(const void *, unsigned char *, unsigned char *,
- unsigned char *, unsigned char *, int,
- struct Colors *, RASTER_MAP_TYPE);
-void G_lookup_f_raster_colors(const FCELL *, unsigned char *, unsigned char *,
- unsigned char *, unsigned char *, int,
- struct Colors *);
-void G_lookup_d_raster_colors(const DCELL *, unsigned char *, unsigned char *,
- unsigned char *, unsigned char *, int,
- struct Colors *);
-void G__lookup_colors(const void *, unsigned char *, unsigned char *,
- unsigned char *, unsigned char *, int, struct Colors *,
- int, int, RASTER_MAP_TYPE);
-void G__interpolate_color_rule(DCELL, unsigned char *, unsigned char *,
- unsigned char *, const struct _Color_Rule_ *);
-
-/* color_org.c */
-void G__organize_colors(struct Colors *);
-
-/* color_rand.c */
-void G_make_random_colors(struct Colors *, CELL, CELL);
-
-/* color_range.c */
-void G_set_color_range(CELL, CELL, struct Colors *);
-void G_set_d_color_range(DCELL, DCELL, struct Colors *);
-void G_get_color_range(CELL *, CELL *, const struct Colors *);
-void G_get_d_color_range(DCELL *, DCELL *, const struct Colors *);
-
-/* color_read.c */
-int G_read_colors(const char *, const char *, struct Colors *);
-void G_mark_colors_as_fp(struct Colors *);
-
-/* color_remove.c */
-int G_remove_colors(const char *, const char *);
-
-/* color_rule.c */
-void G_add_d_raster_color_rule(const DCELL *, int, int, int,
- const DCELL *, int, int, int,
- struct Colors *);
-void G_add_f_raster_color_rule(const FCELL *, int, int, int,
- const FCELL *, int, int, int,
- struct Colors *);
-void G_add_c_raster_color_rule(const CELL *, int, int, int,
- const CELL *, int, int, int,
- struct Colors *);
-void G_add_raster_color_rule(const void *, int, int, int,
- const void *, int, int, int,
- struct Colors *, RASTER_MAP_TYPE);
-void G_add_color_rule(const CELL, int, int, int,
- const CELL, int, int, int,
- struct Colors *);
-int G_add_modular_d_raster_color_rule(const DCELL *, int, int, int,
- const DCELL *, int, int, int,
- struct Colors *);
-int G_add_modular_f_raster_color_rule(const FCELL *, int, int, int,
- const FCELL *, int, int, int,
- struct Colors *);
-int G_add_modular_c_raster_color_rule(const CELL *, int, int, int,
- const CELL *, int, int, int,
- struct Colors *);
-int G_add_modular_raster_color_rule(const void *, int, int, int,
- const void *, int, int, int,
- struct Colors *, RASTER_MAP_TYPE);
-int G_add_modular_color_rule(CELL, int, int, int,
- CELL, int, int, int,
- struct Colors *);
-
-/* color_rule_get.c */
-int G_colors_count(const struct Colors *);
-int G_get_f_color_rule(DCELL *, unsigned char *, unsigned char *,
- unsigned char *, DCELL *, unsigned char *,
- unsigned char *, unsigned char *,
- const struct Colors *, int);
-
-/* color_rules.c */
-typedef int read_rule_fn(void *, DCELL, DCELL,
- DCELL *, int *, int *, int *, int *, int *, int *);
-int G_parse_color_rule(DCELL, DCELL, const char *, DCELL *, int *, int *,
- int *, int *, int *, int *);
-const char *G_parse_color_rule_error(int);
-int G_read_color_rule(void *, DCELL, DCELL, DCELL *, int *, int *, int *,
- int *, int *, int *);
-int G_read_color_rules(struct Colors *, DCELL, DCELL, read_rule_fn *, void *);
-int G_load_colors(struct Colors *, const char *, CELL, CELL);
-int G_load_fp_colors(struct Colors *, const char *, DCELL, DCELL);
-void G_make_colors(struct Colors *, const char *, CELL, CELL);
-void G_make_fp_colors(struct Colors *, const char *, DCELL, DCELL);
-
-/* color_set.c */
-void G_set_color(CELL, int, int, int, struct Colors *);
-void G_set_d_color(DCELL, int, int, int, struct Colors *);
-void G_set_null_value_color(int, int, int, struct Colors *);
-void G_set_default_color(int, int, int, struct Colors *);
-
-/* color_shift.c */
-void G_shift_colors(int, struct Colors *);
-void G_shift_d_colors(DCELL, struct Colors *);
-
-/* color_str.c */
-int G_str_to_color(const char *, int *, int *, int *);
-
-/* color_write.c */
-int G_write_colors(const char *, const char *, struct Colors *);
-void G__write_colors(FILE *, struct Colors *);
-
-/* color_xform.c */
-void G_histogram_eq_colors(struct Colors *, struct Colors *,
- struct Cell_stats *);
-void G_histogram_eq_colors_fp(struct Colors *,
- struct Colors *, struct FP_stats *);
-void G_log_colors(struct Colors *, struct Colors *, int);
-void G_abs_log_colors(struct Colors *, struct Colors *, int);
-
/* commas.c */
int G_insert_commas(char *);
void G_remove_commas(char *);
@@ -493,56 +228,6 @@
int G_zlib_read(int, int, unsigned char *, int);
int G_zlib_write_noCompress(int, const unsigned char *, int);
-/* format.c */
-int G__check_format(int);
-int G__read_row_ptrs(int);
-int G__write_row_ptrs(int);
-
-/* fpreclass.c */
-void G_fpreclass_clear(struct FPReclass *);
-void G_fpreclass_reset(struct FPReclass *);
-void G_fpreclass_init(struct FPReclass *);
-void G_fpreclass_set_domain(struct FPReclass *, DCELL, DCELL);
-void G_fpreclass_set_range(struct FPReclass *, DCELL, DCELL);
-int G_fpreclass_get_limits(const struct FPReclass *, DCELL *, DCELL *,
- DCELL *, DCELL *);
-int G_fpreclass_nof_rules(const struct FPReclass *);
-void G_fpreclass_get_ith_rule(const struct FPReclass *, int, DCELL *, DCELL *,
- DCELL *, DCELL *);
-void G_fpreclass_set_neg_infinite_rule(struct FPReclass *, DCELL, DCELL);
-int G_fpreclass_get_neg_infinite_rule(const struct FPReclass *, DCELL *,
- DCELL *);
-void G_fpreclass_set_pos_infinite_rule(struct FPReclass *, DCELL, DCELL);
-int G_fpreclass_get_pos_infinite_rule(const struct FPReclass *, DCELL *,
- DCELL *);
-void G_fpreclass_add_rule(struct FPReclass *, DCELL, DCELL, DCELL, DCELL);
-void G_fpreclass_reverse_rule_order(struct FPReclass *);
-DCELL G_fpreclass_get_cell_value(const struct FPReclass *, DCELL);
-void G_fpreclass_perform_di(const struct FPReclass *, const DCELL *, CELL *,
- int);
-void G_fpreclass_perform_df(const struct FPReclass *, const DCELL *, FCELL *,
- int);
-void G_fpreclass_perform_dd(const struct FPReclass *, const DCELL *, DCELL *,
- int);
-void G_fpreclass_perform_fi(const struct FPReclass *, const FCELL *, CELL *,
- int);
-void G_fpreclass_perform_ff(const struct FPReclass *, const FCELL *, FCELL *,
- int);
-void G_fpreclass_perform_fd(const struct FPReclass *, const FCELL *, DCELL *,
- int);
-void G_fpreclass_perform_ii(const struct FPReclass *, const CELL *, CELL *,
- int);
-void G_fpreclass_perform_if(const struct FPReclass *, const CELL *, FCELL *,
- int);
-void G_fpreclass_perform_id(const struct FPReclass *, const CELL *, DCELL *,
- int);
-/* gdal.c */
-void G_init_gdal(void);
-struct GDAL_link *G_get_gdal_link(const char *, const char *);
-struct GDAL_link *G_create_gdal_link(const char *, RASTER_MAP_TYPE);
-void G_close_gdal_link(struct GDAL_link *);
-int G_close_gdal_write_link(struct GDAL_link *);
-
/* geodesic.c */
int G_begin_geodesic_equation(double, double, double, double);
double G_geodesic_lat_from_lon(double);
@@ -554,9 +239,6 @@
double G_geodesic_distance_lon_to_lon(double, double);
double G_geodesic_distance(double, double, double, double);
-/* get_cellhd.c */
-int G_get_cellhd(const char *, const char *, struct Cell_head *);
-
/* get_ellipse.c */
int G_get_ellipsoid_parameters(double *, double *);
int G_get_spheroid_by_name(const char *, double *, double *, double *);
@@ -569,24 +251,6 @@
struct Key_Value *G_get_projunits(void);
struct Key_Value *G_get_projinfo(void);
-/* get_row.c */
-int G_get_map_row_nomask(int, CELL *, int);
-int G_get_raster_row_nomask(int, void *, int, RASTER_MAP_TYPE);
-int G_get_c_raster_row_nomask(int, CELL *, int);
-int G_get_f_raster_row_nomask(int, FCELL *, int);
-int G_get_d_raster_row_nomask(int, DCELL *, int);
-int G_get_map_row(int, CELL *, int);
-int G_get_raster_row(int, void *, int, RASTER_MAP_TYPE);
-int G_get_c_raster_row(int, CELL *, int);
-int G_get_f_raster_row(int, FCELL *, int);
-int G_get_d_raster_row(int, DCELL *, int);
-int G_get_null_value_row(int, char *, int);
-
-/* get_row_colr.c */
-int G_get_raster_row_colors(int, int, struct Colors *,
- unsigned char *, unsigned char *, unsigned char *,
- unsigned char *);
-
/* get_window.c */
void G_get_window(struct Cell_head *);
void G_get_default_window(struct Cell_head *);
@@ -609,34 +273,6 @@
void G__check_gisinit(void);
void G_init_all(void);
-/* histo_eq.c */
-void G_histogram_eq(const struct Histogram *, unsigned char **,
- CELL *, CELL *);
-
-/* histogram.c */
-void G_init_histogram(struct Histogram *);
-int G_read_histogram(const char *, const char *, struct Histogram *);
-int G_write_histogram(const char *, const struct Histogram *);
-int G_write_histogram_cs(const char *, struct Cell_stats *);
-void G_make_histogram_cs(struct Cell_stats *, struct Histogram *);
-int G_get_histogram_num(const struct Histogram *);
-CELL G_get_histogram_cat(int, const struct Histogram *);
-long G_get_histogram_count(int, const struct Histogram *);
-void G_free_histogram(struct Histogram *);
-int G_sort_histogram(struct Histogram *);
-int G_sort_histogram_by_count(struct Histogram *);
-void G_remove_histogram(const char *);
-int G_add_histogram(CELL, long, struct Histogram *);
-int G_set_histogram(CELL, long, struct Histogram *);
-void G_extend_histogram(CELL, long, struct Histogram *);
-void G_zero_histogram(struct Histogram *);
-
-/* history.c */
-int G_read_history(const char *, const char *, struct History *);
-int G_write_history(const char *, struct History *);
-void G_short_history(const char *, const char *, struct History *);
-int G_command_history(struct History *);
-
/* home.c */
const char *G_home(void);
const char *G__home(void);
@@ -645,15 +281,6 @@
char *G_index(const char *, int);
char *G_rindex(const char *, int);
-/* interp.c */
-DCELL G_interp_linear(double, DCELL, DCELL);
-DCELL G_interp_bilinear(double, double, DCELL, DCELL, DCELL, DCELL);
-DCELL G_interp_cubic(double, DCELL, DCELL, DCELL, DCELL);
-DCELL G_interp_bicubic(double, double,
- DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL,
- DCELL, DCELL, DCELL, DCELL, DCELL, DCELL, DCELL,
- DCELL);
-
/* intersect.c */
int G_intersect_line_segments(double, double, double, double, double, double,
double, double, double *, double *, double *,
@@ -765,13 +392,6 @@
void G_add_mapset_to_search_path(const char *);
int G_is_mapset_in_search_path(const char *);
-/* mask_info.c */
-char *G_mask_info(void);
-int G__mask_info(char *, char *);
-
-/* maskfd.c */
-int G_maskfd(void);
-
/* myname.c */
char *G_myname(void);
@@ -787,25 +407,6 @@
char *G_fully_qualified_name(const char *, const char *);
int G__unqualified_name(const char *, const char *, char *, char *);
-/* null_val.c */
-void G__set_null_value(void *, int, int, RASTER_MAP_TYPE);
-void G_set_null_value(void *, int, RASTER_MAP_TYPE);
-void G_set_c_null_value(CELL *, int);
-void G_set_f_null_value(FCELL *, int);
-void G_set_d_null_value(DCELL *, int);
-int G_is_null_value(const void *, RASTER_MAP_TYPE);
-int G_is_c_null_value(const CELL *);
-int G_is_f_null_value(const FCELL *);
-int G_is_d_null_value(const DCELL *);
-void G_insert_null_values(void *, char *, int, RASTER_MAP_TYPE);
-void G_insert_c_null_values(CELL *, char *, int);
-void G_insert_f_null_values(FCELL *, char *, int);
-void G_insert_d_null_values(DCELL *, char *, int);
-int G__check_null_bit(const unsigned char *, int, int);
-void G__convert_01_flags(const char *, unsigned char *, int);
-void G__convert_flags_01(char *, const unsigned char *, int);
-void G__init_null_bits(unsigned char *, int);
-
/* open.c */
int G_open_new(const char *, const char *);
int G_open_old(const char *, const char *, const char *);
@@ -825,25 +426,6 @@
FILE *G_fopen_append_misc(const char *, const char *, const char *);
FILE *G_fopen_modify_misc(const char *, const char *, const char *);
-/* opencell.c */
-int G_open_cell_old(const char *, const char *);
-int G__open_cell_old(const char *, const char *);
-int G_open_cell_new(const char *);
-int G_open_cell_new_uncompressed(const char *);
-void G_want_histogram(int);
-void G_set_cell_format(int);
-int G_cellvalue_format(CELL);
-int G_open_fp_cell_new(const char *);
-int G_open_fp_cell_new_uncompressed(const char *);
-int G_set_fp_type(RASTER_MAP_TYPE);
-int G_raster_map_is_fp(const char *, const char *);
-RASTER_MAP_TYPE G_raster_map_type(const char *, const char *);
-RASTER_MAP_TYPE G__check_fp_type(const char *, const char *);
-RASTER_MAP_TYPE G_get_raster_map_type(int);
-int G_open_raster_new(const char *, RASTER_MAP_TYPE);
-int G_open_raster_new_uncompressed(const char *, RASTER_MAP_TYPE);
-int G_set_quant_rules(int, struct Quant *);
-
/* overwrite.c */
int G_check_overwrite(int argc, char **argv);
@@ -912,21 +494,6 @@
const char *G_database_ellipse_name(void);
double G_database_units_to_meters_factor(void);
-/* put_cellhd.c */
-int G_put_cellhd(const char *, struct Cell_head *);
-
-/* put_row.c */
-int G_put_map_row(int, const CELL *);
-int G_put_raster_row(int, const void *, RASTER_MAP_TYPE);
-int G_put_c_raster_row(int, const CELL *);
-int G_put_f_raster_row(int, const FCELL *);
-int G_put_d_raster_row(int, const DCELL *);
-int G__open_null_write(int);
-int G__write_null_bits(int, const unsigned char *, int, int, int);
-
-/* put_title.c */
-int G_put_cell_title(const char *, const char *);
-
/* put_window.c */
int G_put_window(const struct Cell_head *);
int G__put_window(const struct Cell_head *, const char *, const char *);
@@ -934,99 +501,11 @@
/* putenv.c */
void G_putenv(const char *, const char *);
-/* quant.c */
-void G_quant_clear(struct Quant *);
-void G_quant_free(struct Quant *);
-int G__quant_organize_fp_lookup(struct Quant *);
-void G_quant_init(struct Quant *);
-int G_quant_is_truncate(const struct Quant *);
-int G_quant_is_round(const struct Quant *);
-void G_quant_truncate(struct Quant *);
-void G_quant_round(struct Quant *);
-int G_quant_get_limits(const struct Quant *, DCELL *, DCELL *, CELL *,
- CELL *);
-int G_quant_nof_rules(const struct Quant *);
-void G_quant_get_ith_rule(const struct Quant *, int, DCELL *, DCELL *, CELL *,
- CELL *);
-void G_quant_set_neg_infinite_rule(struct Quant *, DCELL, CELL);
-int G_quant_get_neg_infinite_rule(const struct Quant *, DCELL *, CELL *);
-void G_quant_set_pos_infinite_rule(struct Quant *, DCELL, CELL);
-int G_quant_get_pos_infinite_rule(const struct Quant *, DCELL *, CELL *);
-void G_quant_add_rule(struct Quant *, DCELL, DCELL, CELL, CELL);
-void G_quant_reverse_rule_order(struct Quant *);
-CELL G_quant_get_cell_value(struct Quant *, DCELL);
-void G_quant_perform_d(struct Quant *, const DCELL *, CELL *, int);
-void G_quant_perform_f(struct Quant *, const FCELL *, CELL *, int);
-struct Quant_table *G__quant_get_rule_for_d_raster_val(const struct Quant *,
- DCELL);
-
-/* quant_io.c */
-int G__quant_import(const char *, const char *, struct Quant *);
-int G__quant_export(const char *, const char *, const struct Quant *);
-
-/* quant_rw.c */
-int G_truncate_fp_map(const char *, const char *);
-int G_round_fp_map(const char *, const char *);
-int G_quantize_fp_map(const char *, const char *, CELL, CELL);
-int G_quantize_fp_map_range(const char *, const char *, DCELL, DCELL, CELL,
- CELL);
-int G_write_quant(const char *, const char *, const struct Quant *);
-int G_read_quant(const char *, const char *, struct Quant *);
-
/* radii.c */
double G_meridional_radius_of_curvature(double, double, double);
double G_transverse_radius_of_curvature(double, double, double);
double G_radius_of_conformal_tangent_sphere(double, double, double);
-/* range.c */
-void G__remove_fp_range(const char *);
-void G_construct_default_range(struct Range *);
-int G_read_fp_range(const char *, const char *, struct FPRange *);
-int G_read_range(const char *, const char *, struct Range *);
-int G_write_range(const char *, const struct Range *);
-int G_write_fp_range(const char *, const struct FPRange *);
-void G_update_range(CELL, struct Range *);
-void G_update_fp_range(DCELL, struct FPRange *);
-void G_row_update_range(const CELL *, int, struct Range *);
-void G__row_update_range(const CELL *, int, struct Range *, int);
-void G_row_update_fp_range(const void *, int, struct FPRange *,
- RASTER_MAP_TYPE);
-void G_init_range(struct Range *);
-void G_get_range_min_max(const struct Range *, CELL *, CELL *);
-void G_init_fp_range(struct FPRange *);
-void G_get_fp_range_min_max(const struct FPRange *, DCELL *, DCELL *);
-
-/* raster.c */
-void *G_incr_void_ptr(const void *, const size_t);
-int G_raster_cmp(const void *, const void *, RASTER_MAP_TYPE);
-void G_raster_cpy(void *, const void *, int, RASTER_MAP_TYPE);
-void G_set_raster_value_c(void *, CELL, RASTER_MAP_TYPE);
-void G_set_raster_value_f(void *, FCELL, RASTER_MAP_TYPE);
-void G_set_raster_value_d(void *, DCELL, RASTER_MAP_TYPE);
-CELL G_get_raster_value_c(const void *, RASTER_MAP_TYPE);
-FCELL G_get_raster_value_f(const void *, RASTER_MAP_TYPE);
-DCELL G_get_raster_value_d(const void *, RASTER_MAP_TYPE);
-
-/* raster_metadata.c */
-int G_read_raster_units(const char *, const char *, char *);
-int G_read_raster_vdatum(const char *, const char *, char *);
-int G_write_raster_units(const char *, const char *);
-int G_write_raster_vdatum(const char *, const char *);
-int G__raster_misc_read_line(const char *, const char *, const char *,
- char *);
-int G__raster_misc_write_line(const char *, const char *, const char *);
-
-/* rd_cellhd.c */
-char *G__read_Cell_head(FILE *, struct Cell_head *, int);
-char *G__read_Cell_head_array(char **, struct Cell_head *, int);
-
-/* reclass.c */
-int G_is_reclass(const char *, const char *, char *, char *);
-int G_is_reclassed_to(const char *, const char *, int *, char ***);
-int G_get_reclass(const char *, const char *, struct Reclass *);
-void G_free_reclass(struct Reclass *);
-int G_put_reclass(const char *, const struct Reclass *);
-
/* remove.c */
int G_remove(const char *, const char *);
int G_remove_misc(const char *, const char *, const char *);
@@ -1043,12 +522,6 @@
void G_rotate_around_point(double, double, double *, double *, double);
void G_rotate_around_point_int(int, int, int *, int *, double);
-/* sample.c */
-DCELL G_get_raster_sample_nearest(int, const struct Cell_head *, struct Categories *, double, double, int);
-DCELL G_get_raster_sample_bilinear(int, const struct Cell_head *, struct Categories *, double, double, int);
-DCELL G_get_raster_sample_cubic(int, const struct Cell_head *, struct Categories *, double, double, int);
-DCELL G_get_raster_sample(int, const struct Cell_head *, struct Categories *, double, double, int, INTERP_TYPE);
-
/* seek.c */
off_t G_ftell(FILE *);
void G_fseek(FILE *, off_t, int);
@@ -1195,10 +668,6 @@
/* zero.c */
void G_zero(void *, int);
-/* zero_cell.c */
-void G_zero_cell_buf(CELL *);
-void G_zero_raster_buf(void *, RASTER_MAP_TYPE);
-
/* zone.c */
int G_zone(void);
Property changes on: grass/trunk/include/nviz.h
___________________________________________________________________
Name: svn:mime-type
- text/x-chrc
+ text/x-chdr
Property changes on: grass/trunk/include/vedit.h
___________________________________________________________________
Name: svn:mime-type
+ text/x-chdr
Name: svn:keywords
+ Author Date Id
Modified: grass/trunk/lib/Makefile
===================================================================
--- grass/trunk/lib/Makefile 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/Makefile 2009-06-20 22:03:23 UTC (rev 38003)
@@ -6,6 +6,7 @@
SUBDIRS = \
datetime \
gis \
+ raster \
gmath \
linkm \
driver \
Modified: grass/trunk/lib/cluster/c_point.c
===================================================================
--- grass/trunk/lib/cluster/c_point.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/cluster/c_point.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,7 +17,9 @@
* note: if all values in x are zero, the point is rejected
***************************************************************/
+#include <grass/Rast.h>
#include <grass/cluster.h>
+
static int extend(struct Cluster *, int);
static int all_zero(struct Cluster *, int);
@@ -27,7 +29,7 @@
/* reject points which contain nulls in one of the bands */
for (band = 0; band < C->nbands; band++)
- if (G_is_d_null_value(&x[band]))
+ if (Rast_is_d_null_value(&x[band]))
return 1; /* fixed 11/99 Agus Carr */
/*
if (band >= C->nbands)
@@ -42,7 +44,7 @@
for (band = 0; band < C->nbands; band++) {
register double z;
- /* if(G_is_d_null_value(&x[band])) continue; */
+ /* if(Rast_is_d_null_value(&x[band])) continue; */
z = C->points[band][C->npoints] = x[band];
C->band_sum[band] += z;
C->band_sum2[band] += z * z;
@@ -60,7 +62,7 @@
{
DCELL tmp = x;
- if (G_is_d_null_value(&tmp))
+ if (Rast_is_d_null_value(&tmp))
return 1;
C->points[band][C->npoints + n] = x;
C->band_sum[band] += x;
Modified: grass/trunk/lib/display/raster.c
===================================================================
--- grass/trunk/lib/display/raster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/display/raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,7 +25,9 @@
#include <stdio.h>
#include <stdlib.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/display.h>
@@ -98,13 +100,13 @@
set = G_realloc(set, nalloc);
}
- G_lookup_raster_colors(array, red, grn, blu, set, ncols, colors,
+ Rast_lookup_raster_colors(array, red, grn, blu, set, ncols, colors,
data_type);
if (D__overlay_mode)
for (i = 0; i < ncols; i++) {
- set[i] = G_is_null_value(array, data_type);
- array = G_incr_void_ptr(array, G_raster_size(data_type));
+ set[i] = Rast_is_null_value(array, data_type);
+ array = Rast_incr_void_ptr(array, Rast_raster_size(data_type));
}
A_row =
@@ -148,9 +150,9 @@
static unsigned char *r_buf, *g_buf, *b_buf, *n_buf;
static int nalloc;
- int r_size = G_raster_size(r_type);
- int g_size = G_raster_size(g_type);
- int b_size = G_raster_size(b_type);
+ int r_size = Rast_raster_size(r_type);
+ int g_size = Rast_raster_size(g_type);
+ int b_size = Rast_raster_size(b_type);
int ncols = src[0][1] - src[0][0];
int i;
@@ -164,22 +166,22 @@
}
/* convert cell values to bytes */
- G_lookup_raster_colors(r_raster, r_buf, n_buf, n_buf, n_buf, ncols,
+ Rast_lookup_raster_colors(r_raster, r_buf, n_buf, n_buf, n_buf, ncols,
r_colors, r_type);
- G_lookup_raster_colors(g_raster, n_buf, g_buf, n_buf, n_buf, ncols,
+ Rast_lookup_raster_colors(g_raster, n_buf, g_buf, n_buf, n_buf, ncols,
g_colors, g_type);
- G_lookup_raster_colors(b_raster, n_buf, n_buf, b_buf, n_buf, ncols,
+ Rast_lookup_raster_colors(b_raster, n_buf, n_buf, b_buf, n_buf, ncols,
b_colors, b_type);
if (D__overlay_mode)
for (i = 0; i < ncols; i++) {
- n_buf[i] = (G_is_null_value(r_raster, r_type) ||
- G_is_null_value(g_raster, g_type) ||
- G_is_null_value(b_raster, b_type));
+ n_buf[i] = (Rast_is_null_value(r_raster, r_type) ||
+ Rast_is_null_value(g_raster, g_type) ||
+ Rast_is_null_value(b_raster, b_type));
- r_raster = G_incr_void_ptr(r_raster, r_size);
- g_raster = G_incr_void_ptr(g_raster, g_size);
- b_raster = G_incr_void_ptr(b_raster, b_size);
+ r_raster = Rast_incr_void_ptr(r_raster, r_size);
+ g_raster = Rast_incr_void_ptr(g_raster, g_size);
+ b_raster = Rast_incr_void_ptr(b_raster, b_size);
}
A_row =
Modified: grass/trunk/lib/display/raster2.c
===================================================================
--- grass/trunk/lib/display/raster2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/display/raster2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -28,7 +28,9 @@
*
*/
#include <stdlib.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
@@ -136,7 +138,7 @@
{
int r, g, b;
- G_get_raster_color(raster, &r, &g, &b, colors, data_type);
+ Rast_get_raster_color(raster, &r, &g, &b, colors, data_type);
R__RGB_color((unsigned char)r, (unsigned char)g, (unsigned char)b);
return 0;
Modified: grass/trunk/lib/display/tran_colr.c
===================================================================
--- grass/trunk/lib/display/tran_colr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/display/tran_colr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,8 +3,10 @@
*/
#include <string.h>
+
#include <grass/display.h>
#include <grass/colors.h>
+#include <grass/Rast.h>
#include <grass/display_raster.h>
#include <grass/glocale.h>
@@ -55,7 +57,7 @@
colors[i] = G_standard_color_rgb(i);
}
- ret = G_str_to_color(str, &red, &grn, &blu);
+ ret = Rast_str_to_color(str, &red, &grn, &blu);
/* None color */
if (ret == 2)
Modified: grass/trunk/lib/g3d/g3dcats.c
===================================================================
--- grass/trunk/lib/g3d/g3dcats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dcats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,7 +4,10 @@
#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
+
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -15,7 +18,7 @@
*
* Writes the
* categories stored in the <em>cats</em> structure into the categories file for
- * map <em>name</em> in the current mapset. See <em>G_write_cats</em>
+ * map <em>name</em> in the current mapset. See <em>Rast_write_cats</em>
* (Raster_Category_File) for details and return values.
*
* \param name
@@ -24,7 +27,7 @@
*/
int G3d_writeCats(const char *name, struct Categories *cats)
- /* adapted from G_write_cats */
+ /* adapted from Rast_write_cats */
{
FILE *fd;
int i;
@@ -48,8 +51,8 @@
cats->m1, cats->a1, cats->m2, cats->a2);
/* write the cat numbers:label */
- for (i = 0; i < G_quant_nof_rules(&cats->q); i++) {
- descr = G_get_ith_d_raster_cat(cats, i, &val1, &val2);
+ for (i = 0; i < Rast_quant_nof_rules(&cats->q); i++) {
+ descr = Rast_get_ith_d_raster_cat(cats, i, &val1, &val2);
if ((cats->fmt && cats->fmt[0]) || (descr && descr[0])) {
if (val1 == val2) {
sprintf(str1, "%.10f", val1);
@@ -101,7 +104,7 @@
goto error;
G_strip(buff);
- G_init_raster_cats(buff, pcats);
+ Rast_init_raster_cats(buff, pcats);
if (num >= 0)
pcats->num = num;
@@ -116,7 +119,7 @@
goto error;
if (sscanf(buff, "%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
goto error;
- G_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
+ Rast_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
}
/* Read all category names */
@@ -127,7 +130,7 @@
break;
if (old)
- G_set_cat(cat, buff, pcats);
+ Rast_set_cat(cat, buff, pcats);
else {
*label = 0;
if (sscanf(buff, "%1s", label) != 1)
@@ -138,11 +141,11 @@
/* try to read a range of data */
if (sscanf(buff, "%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
- G_set_raster_cat(&val1, &val2, label, pcats, DCELL_TYPE);
+ Rast_set_raster_cat(&val1, &val2, label, pcats, DCELL_TYPE);
else if (sscanf(buff, "%d:%[^\n]", &cat, label) >= 1)
- G_set_raster_cat(&cat, &cat, label, pcats, CELL_TYPE);
+ Rast_set_raster_cat(&cat, &cat, label, pcats, CELL_TYPE);
else if (sscanf(buff, "%lf:%[^\n]", &val1, label) >= 1)
- G_set_raster_cat(&val1, &val1, label, pcats, DCELL_TYPE);
+ Rast_set_raster_cat(&val1, &val1, label, pcats, DCELL_TYPE);
else
goto error;
}
@@ -163,7 +166,7 @@
* \brief
*
* Reads the categories file for map <em>name</em> in <em>mapset</em> and
- * stores the categories in the <em>pcats</em> structure. See <em>G_read_cats</em>
+ * stores the categories in the <em>pcats</em> structure. See <em>Rast_read_cats</em>
* (Raster_Category_File) for details and return values.
*
* \param name
@@ -174,7 +177,7 @@
int
G3d_readCats(const char *name, const char *mapset, struct Categories *pcats)
- /* adapted from G_read_cats */
+ /* adapted from Rast_read_cats */
{
const char *type;
Modified: grass/trunk/lib/g3d/g3dclose.c
===================================================================
--- grass/trunk/lib/g3d/g3dclose.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dclose.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,9 @@
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
+
+#include <grass/Rast.h>
+
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -18,13 +21,13 @@
G3d_removeColor(map->fileName);
/* create empty cats file */
- G_init_raster_cats(NULL, &cats);
+ Rast_init_raster_cats(NULL, &cats);
G3d_writeCats(map->fileName, &cats);
- G_free_cats(&cats);
+ Rast_free_cats(&cats);
/*genrate the history file, use the normal G_ functions */
- G_short_history(map->fileName, "raster3d", &hist);
- G_command_history(&hist);
+ Rast_short_history(map->fileName, "raster3d", &hist);
+ Rast_command_history(&hist);
/*Use the G3d function to write the history file,
* otherwise the path is wrong */
if (!G3d_writeHistory(map->fileName, &hist)) {
Modified: grass/trunk/lib/g3d/g3dcolor.c
===================================================================
--- grass/trunk/lib/g3d/g3dcolor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dcolor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,4 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -7,8 +6,11 @@
#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
+
#include "G3d_intern.h"
static int read_colors(const char *, const char *, struct Colors *);
@@ -27,22 +29,22 @@
int
G3d_readColors(const char *name, const char *mapset, struct Colors *colors)
- /* adapted from G_read_colors */
+ /* adapted from Rast_read_colors */
{
const char *err;
struct FPRange drange;
DCELL dmin, dmax;
- G_init_colors(colors);
+ Rast_init_colors(colors);
- G_mark_colors_as_fp(colors);
+ Rast_mark_colors_as_fp(colors);
switch (read_colors(name, mapset, colors)) {
case -2:
if (G3d_readRange(name, mapset, &drange) >= 0) {
- G_get_fp_range_min_max(&drange, &dmin, &dmax);
- if (!G_is_d_null_value(&dmin) && !G_is_d_null_value(&dmax))
- G_make_rainbow_fp_colors(colors, dmin, dmax);
+ Rast_get_fp_range_min_max(&drange, &dmin, &dmax);
+ if (!Rast_is_d_null_value(&dmin) && !Rast_is_d_null_value(&dmax))
+ Rast_make_rainbow_fp_colors(colors, dmin, dmax);
return 0;
}
err = "missing";
@@ -122,7 +124,7 @@
G_strip(buf);
if (sscanf(buf + 1, "%lf %lf", &val1, &val2) == 2)
- G_set_d_color_range((DCELL) val1, (DCELL) val2, colors);
+ Rast_set_d_color_range((DCELL) val1, (DCELL) val2, colors);
modular = 0;
while (fgets(buf, sizeof buf, fd)) {
@@ -135,11 +137,11 @@
if (sscanf(word1, "shift:%lf", &shift) == 1
|| (strcmp(word1, "shift:") == 0 &&
sscanf(word2, "%lf", &shift) == 1)) {
- G_shift_d_colors(shift, colors);
+ Rast_shift_d_colors(shift, colors);
continue;
}
if (strcmp(word1, "invert") == 0) {
- G_invert_colors(colors);
+ Rast_invert_colors(colors);
continue;
}
if (strcmp(word1, "%%") == 0) {
@@ -220,26 +222,26 @@
b2 = b1;
}
if (null)
- G_set_null_value_color(r1, g1, b1, colors);
+ Rast_set_null_value_color(r1, g1, b1, colors);
else if (undef)
- G_set_default_color(r1, g1, b1, colors);
+ Rast_set_default_color(r1, g1, b1, colors);
else if (modular) {
if (fp_rule)
- G_add_modular_d_raster_color_rule((DCELL *) & val1, r1, g1,
+ Rast_add_modular_d_raster_color_rule((DCELL *) & val1, r1, g1,
b1, (DCELL *) & val2, r2,
g2, b2, colors);
else
- G_add_modular_color_rule((CELL) cat1, r1, g1, b1,
+ Rast_add_modular_color_rule((CELL) cat1, r1, g1, b1,
(CELL) cat2, r2, g2, b2, colors);
}
else {
if (fp_rule)
- G_add_d_raster_color_rule((DCELL *) & val1, r1, g1, b1,
+ Rast_add_d_raster_color_rule((DCELL *) & val1, r1, g1, b1,
(DCELL *) & val2, r2, g2, b2,
colors);
else
- G_add_color_rule((CELL) cat1, r1, g1, b1,
+ Rast_add_color_rule((CELL) cat1, r1, g1, b1,
(CELL) cat2, r2, g2, b2, colors);
}
/*
@@ -259,7 +261,7 @@
int old;
int zero;
- G_init_colors(colors);
+ Rast_init_colors(colors);
/*
* first line in pre 3.0 color files is number of colors - ignore
* otherwise it is #min first color, and the next line is for color 0
@@ -306,12 +308,12 @@
}
}
if (zero) {
- G__insert_color_into_lookup((CELL) 0, red, grn, blu,
+ Rast__insert_color_into_lookup((CELL) 0, red, grn, blu,
&colors->fixed);
zero = 0;
}
else
- G__insert_color_into_lookup((CELL) n++, red, grn, blu,
+ Rast__insert_color_into_lookup((CELL) n++, red, grn, blu,
&colors->fixed);
}
colors->cmax = n - 1;
@@ -323,7 +325,7 @@
int
G3d_writeColors(const char *name, const char *mapset, struct Colors *colors)
- /* adapted from G_write_colors */
+ /* adapted from Rast_write_colors */
{
FILE *fd;
@@ -336,7 +338,7 @@
if (!fd)
return -1;
- G__write_colors(fd, colors);
+ Rast__write_colors(fd, colors);
fclose(fd);
return 1;
Modified: grass/trunk/lib/g3d/g3dfpxdr.c
===================================================================
--- grass/trunk/lib/g3d/g3dfpxdr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dfpxdr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,9 @@
#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+
+#include <grass/Rast.h>
+
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -150,11 +153,11 @@
if (useXdr == G3D_NO_XDR) {
G3d_copyValues(src, 0, srcType, xdrTmp, 0, type, nofNum);
- xdrTmp = G_incr_void_ptr(xdrTmp, nofNum * G3d_externLength(type));
+ xdrTmp = Rast_incr_void_ptr(xdrTmp, nofNum * G3d_externLength(type));
return 1;
}
- for (i = 0; i < nofNum; i++, src = G_incr_void_ptr(src, eltLength)) {
+ for (i = 0; i < nofNum; i++, src = Rast_incr_void_ptr(src, eltLength)) {
if (G3d_isNullValueNum(src, srcType)) {
G3d_setXdrNullNum(xdrTmp, isFloat);
@@ -182,7 +185,7 @@
}
}
- xdrTmp = G_incr_void_ptr(xdrTmp, externLength);
+ xdrTmp = Rast_incr_void_ptr(xdrTmp, externLength);
}
return 1;
@@ -225,11 +228,11 @@
if (useXdr == G3D_NO_XDR) {
G3d_copyValues(xdrTmp, 0, type, dst, 0, dstType, nofNum);
- xdrTmp = G_incr_void_ptr(xdrTmp, nofNum * G3d_externLength(type));
+ xdrTmp = Rast_incr_void_ptr(xdrTmp, nofNum * G3d_externLength(type));
return 1;
}
- for (i = 0; i < nofNum; i++, dst = G_incr_void_ptr(dst, eltLength)) {
+ for (i = 0; i < nofNum; i++, dst = Rast_incr_void_ptr(dst, eltLength)) {
if (G3d_isXdrNullNum(xdrTmp, isFloat)) {
G3d_setNullValue(dst, 1, dstType);
@@ -257,7 +260,7 @@
}
}
- xdrTmp = G_incr_void_ptr(xdrTmp, externLength);
+ xdrTmp = Rast_incr_void_ptr(xdrTmp, externLength);
}
return 1;
Modified: grass/trunk/lib/g3d/g3dhistory.c
===================================================================
--- grass/trunk/lib/g3d/g3dhistory.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dhistory.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -61,7 +61,7 @@
*/
int G3d_readHistory(const char *name, const char *mapset, struct History *hist)
-/* This function is adapted from G_read_history */
+/* This function is adapted from Rast_read_history */
{
FILE *fd;
@@ -140,7 +140,7 @@
* A diagnostic message is printed and -1 is returned if there is an error
* writing the History file. Otherwise, 0 is returned.
* <b>Note.</b> The <b>history</b> structure should first be initialized
- * using <i>G_short_history.</i>
+ * using <i>Rast_short_history.</i>
*
* \param name
* \param history
@@ -148,7 +148,7 @@
*/
int G3d_writeHistory(const char *name, struct History *hist)
-/* This function is adapted from G_write_history */
+/* This function is adapted from Rast_write_history */
{
FILE *fd;
int i;
Modified: grass/trunk/lib/g3d/g3dmisc.c
===================================================================
--- grass/trunk/lib/g3d/g3dmisc.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dmisc.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,9 @@
#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+
+#include <grass/Rast.h>
+
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -66,8 +69,8 @@
eltLength = G3d_length(typeSrc);
- src = G_incr_void_ptr(src, eltLength * offsSrc);
- dst = G_incr_void_ptr(dst, eltLength * offsDst);
+ src = Rast_incr_void_ptr(src, eltLength * offsSrc);
+ dst = Rast_incr_void_ptr(dst, eltLength * offsDst);
memcpy(dst, src, nElts * eltLength);
}
Modified: grass/trunk/lib/g3d/g3dnull.c
===================================================================
--- grass/trunk/lib/g3d/g3dnull.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dnull.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,9 @@
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
+
+#include <grass/Rast.h>
+
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -9,9 +12,9 @@
int G3d_isNullValueNum(const void *n, int type)
{
if (type == FCELL_TYPE)
- return G_is_f_null_value(n);
+ return Rast_is_f_null_value(n);
else
- return G_is_d_null_value(n);
+ return Rast_is_d_null_value(n);
}
/*---------------------------------------------------------------------------*/
@@ -32,9 +35,9 @@
void G3d_setNullValue(void *c, int nofElts, int type)
{
if (type == FCELL_TYPE) {
- G_set_f_null_value((float *)c, nofElts);
+ Rast_set_f_null_value((float *)c, nofElts);
return;
}
- G_set_d_null_value((double *)c, nofElts);
+ Rast_set_d_null_value((double *)c, nofElts);
}
Modified: grass/trunk/lib/g3d/g3drange.c
===================================================================
--- grass/trunk/lib/g3d/g3drange.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3drange.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,8 +4,11 @@
#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
+
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -22,19 +25,19 @@
cellType = G3d_g3dType2cellType(type);
if (nofNum == map->tileSize) {
- G_row_update_fp_range(tile, map->tileSize, range, cellType);
+ Rast_row_update_fp_range(tile, map->tileSize, range, cellType);
return;
}
if (xRedundant) {
for (z = 0; z < depths; z++) {
for (y = 0; y < rows; y++) {
- G_row_update_fp_range(tile, cols, range, cellType);
- tile = G_incr_void_ptr(tile, map->tileX * G3d_length(type));
+ Rast_row_update_fp_range(tile, cols, range, cellType);
+ tile = Rast_incr_void_ptr(tile, map->tileX * G3d_length(type));
}
if (yRedundant)
tile =
- G_incr_void_ptr(tile,
+ Rast_incr_void_ptr(tile,
map->tileX * yRedundant *
G3d_length(type));
}
@@ -43,27 +46,27 @@
if (yRedundant) {
for (z = 0; z < depths; z++) {
- G_row_update_fp_range(tile, map->tileX * rows, range, cellType);
- tile = G_incr_void_ptr(tile, map->tileXY * G3d_length(type));
+ Rast_row_update_fp_range(tile, map->tileX * rows, range, cellType);
+ tile = Rast_incr_void_ptr(tile, map->tileXY * G3d_length(type));
}
return;
}
- G_row_update_fp_range(tile, map->tileXY * depths, range, cellType);
+ Rast_row_update_fp_range(tile, map->tileXY * depths, range, cellType);
}
/*---------------------------------------------------------------------------*/
int
G3d_readRange(const char *name, const char *mapset, struct FPRange *drange)
- /* adapted from G_read_fp_range */
+ /* adapted from Rast_read_fp_range */
{
int fd;
char xdr_buf[100];
DCELL dcell1, dcell2;
XDR xdr_str;
- G_init_fp_range(drange);
+ Rast_init_fp_range(drange);
fd = -1;
@@ -89,8 +92,8 @@
return -1;
}
- G_update_fp_range(dcell1, drange);
- G_update_fp_range(dcell2, drange);
+ Rast_update_fp_range(dcell1, drange);
+ Rast_update_fp_range(dcell2, drange);
close(fd);
return 1;
}
@@ -136,13 +139,13 @@
void G3d_range_min_max(G3D_Map * map, double *min, double *max)
{
- G_get_fp_range_min_max(&(map->range), min, max);
+ Rast_get_fp_range_min_max(&(map->range), min, max);
}
/*-------------------------------------------------------------------------*/
static int writeRange(const char *name, struct FPRange *range)
- /* adapted from G_write_fp_range */
+ /* adapted from Rast_write_fp_range */
{
char xdr_buf[100];
int fd;
@@ -214,6 +217,6 @@
int G3d_range_init(G3D_Map * map)
{
- G_init_fp_range(&(map->range));
+ Rast_init_fp_range(&(map->range));
return 0;
}
Modified: grass/trunk/lib/g3d/g3dregion.c
===================================================================
--- grass/trunk/lib/g3d/g3dregion.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dregion.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,9 @@
#include <stdio.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
+
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -152,7 +155,7 @@
const char *err;
G3d_regionToCellHead(region, ®ion2d);
- if ((err = G_adjust_Cell_head3(®ion2d, 1, 1, 1)) != NULL) {
+ if ((err = Rast_adjust_Cell_head3(®ion2d, 1, 1, 1)) != NULL) {
G_fatal_error("G3d_adjustRegion: %s", err);
}
G3d_regionFromToCellHead(®ion2d, region);
@@ -181,7 +184,7 @@
const char *err;
G3d_regionToCellHead(region, ®ion2d);
- if ((err = G_adjust_Cell_head3(®ion2d, 1, 1, 1)) != NULL) {
+ if ((err = Rast_adjust_Cell_head3(®ion2d, 1, 1, 1)) != NULL) {
G_fatal_error("G3d_adjustRegionRes: %s", err);
}
G3d_regionFromToCellHead(®ion2d, region);
Modified: grass/trunk/lib/g3d/g3dvolume.c
===================================================================
--- grass/trunk/lib/g3d/g3dvolume.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/g3dvolume.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
+
+#include <grass/Rast.h>
#include <grass/G3d.h>
/*---------------------------------------------------------------------------*/
@@ -248,7 +250,7 @@
for (x = 0; x < nx; x++) {
/* G3d_putValueRegion? */
if (!G3d_putValue(mapVolume, x, y, z,
- G_incr_void_ptr(volumeBuf,
+ Rast_incr_void_ptr(volumeBuf,
(z * ny * nx + y * nx +
x) * eltLength),
G3d_fileTypeMap(mapVolume)))
Modified: grass/trunk/lib/g3d/getblock.c
===================================================================
--- grass/trunk/lib/g3d/getblock.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/getblock.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
+
+#include <grass/Rast.h>
#include "G3d_intern.h"
/*---------------------------------------------------------------------------*/
@@ -120,15 +122,15 @@
for (y = y0; y < y1; y++) {
for (x = x0; x < x1; x++) {
G3d_getValueRegion(map, x, y, z, block, type);
- block = G_incr_void_ptr(block, length);
+ block = Rast_incr_void_ptr(block, length);
}
nNull = x0 + nx - x;
G3d_setNullValue(block, nNull, type);
- block = G_incr_void_ptr(block, length * nNull);
+ block = Rast_incr_void_ptr(block, length * nNull);
}
nNull = (y0 + ny - y) * nx;
G3d_setNullValue(block, nNull, type);
- block = G_incr_void_ptr(block, length * nNull);
+ block = Rast_incr_void_ptr(block, length * nNull);
}
nNull = (z0 + nz - z) * ny * nx;
G3d_setNullValue(block, nNull, type);
Modified: grass/trunk/lib/g3d/tileread.c
===================================================================
--- grass/trunk/lib/g3d/tileread.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/tileread.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,8 @@
#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+
+#include <grass/Rast.h>
#include "G3d_intern.h"
static int
@@ -37,13 +39,13 @@
G3d_error("G3d_xdrTile2tile: error in G3d_copyFromXdr");
return 0;
}
- tile = G_incr_void_ptr(tile, cols * length);
+ tile = Rast_incr_void_ptr(tile, cols * length);
G3d_setNullValue(tile, xRedundant, type);
- tile = G_incr_void_ptr(tile, xLength);
+ tile = Rast_incr_void_ptr(tile, xLength);
}
if (yRedundant) {
G3d_setNullValue(tile, map->tileX * yRedundant, type);
- tile = G_incr_void_ptr(tile, yLength);
+ tile = Rast_incr_void_ptr(tile, yLength);
}
}
if (!zRedundant)
@@ -59,9 +61,9 @@
G3d_error("G3d_xdrTile2tile: error in G3d_copyFromXdr");
return 0;
}
- tile = G_incr_void_ptr(tile, map->tileX * rows * length);
+ tile = Rast_incr_void_ptr(tile, map->tileX * rows * length);
G3d_setNullValue(tile, map->tileX * yRedundant, type);
- tile = G_incr_void_ptr(tile, yLength);
+ tile = Rast_incr_void_ptr(tile, yLength);
}
if (!zRedundant)
return 1;
@@ -78,7 +80,7 @@
if (!zRedundant)
return 1;
- tile = G_incr_void_ptr(tile, map->tileXY * depths * length);
+ tile = Rast_incr_void_ptr(tile, map->tileXY * depths * length);
G3d_setNullValue(tile, map->tileXY * zRedundant, type);
return 1;
Modified: grass/trunk/lib/g3d/tilewrite.c
===================================================================
--- grass/trunk/lib/g3d/tilewrite.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/g3d/tilewrite.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,8 @@
#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
+
+#include <grass/Rast.h>
#include "G3d_intern.h"
@@ -37,11 +39,11 @@
G3d_error("G3d_tile2xdrTile: error in G3d_copyToXdr");
return 0;
}
- tile = G_incr_void_ptr(tile, map->tileX * G3d_length(type));
+ tile = Rast_incr_void_ptr(tile, map->tileX * G3d_length(type));
}
if (yRedundant)
tile =
- G_incr_void_ptr(tile,
+ Rast_incr_void_ptr(tile,
map->tileX * yRedundant *
G3d_length(type));
}
@@ -54,7 +56,7 @@
G3d_error("G3d_tile2xdrTile: error in G3d_copyToXdr");
return 0;
}
- tile = G_incr_void_ptr(tile, map->tileXY * G3d_length(type));
+ tile = Rast_incr_void_ptr(tile, map->tileXY * G3d_length(type));
}
return 1;
}
Deleted: grass/trunk/lib/gis/G.h
===================================================================
--- grass/trunk/lib/gis/G.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/G.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,94 +0,0 @@
-#include <grass/config.h>
-#include <grass/gis.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#ifdef HAVE_GDAL
-#include <gdal.h>
-#endif
-
-#define XDR_FLOAT_NBYTES 4
-#define XDR_DOUBLE_NBYTES 8
-#define NULL_ROWS_INMEM 8
-
-/* if short is 16 bits, then
- * short will allow 32767 cols
- * unsigned short will allow 65536 cols
- * use int if you need more columns (but this will take more memory).
- *
- */
-typedef int COLUMN_MAPPING;
-
-struct GDAL_link
-{
- char *filename;
- int band_num;
- DCELL null_val;
- int hflip;
- int vflip;
-#ifdef HAVE_GDAL
- GDALDatasetH data;
- GDALRasterBandH band;
- GDALDataType type;
-#endif
-};
-
-#ifdef HAVE_GDAL
-extern CPLErr G_gdal_raster_IO(
- GDALRasterBandH, GDALRWFlag,
- int, int, int, int,
- void *, int, int, GDALDataType,
- int, int);
-#endif
-
-struct fileinfo /* Information for opened cell files */
-{
- int open_mode; /* see defines below */
- struct Cell_head cellhd; /* Cell header */
- struct Reclass reclass; /* Table reclass */
- struct Cell_stats statf; /* Cell stats */
- struct Range range; /* Range structure */
- struct FPRange fp_range; /* float Range structure */
- int want_histogram;
- int reclass_flag; /* Automatic reclass flag */
- off_t *row_ptr; /* File row addresses */
- COLUMN_MAPPING *col_map; /* Data to window col mapping */
- double C1, C2; /* Data to window row constants */
- int cur_row; /* Current data row in memory */
- int null_cur_row; /* Current null row in memory */
- int cur_nbytes; /* nbytes per cell for current row */
- unsigned char *data; /* Decompressed data buffer */
- int nbytes; /* bytes per cell */
- RASTER_MAP_TYPE map_type; /* type: int, float or double map */
- char *temp_name; /* Temporary name for NEW files */
- char *null_temp_name; /* Temporary name for NEW NULL files */
- int null_file_exists; /* for existing raster maps */
- char *name; /* Name of open file */
- char *mapset; /* Mapset of open file */
- int io_error; /* io error warning given */
- XDR xdrstream; /* xdr stream for reading fp */
- unsigned char *NULL_ROWS[NULL_ROWS_INMEM];
- int min_null_row; /* Minimum row null row number in memory */
- struct Quant quant;
- struct GDAL_link *gdal;
-};
-
-struct G__ /* Structure of library globals */
-{
- RASTER_MAP_TYPE fp_type; /* type for writing floating maps */
- struct Cell_head window; /* Contains the current window */
- int window_set; /* Flag: window set? */
- int mask_fd; /* File descriptor for automatic mask */
- int auto_mask; /* Flag denoting automatic masking */
- int want_histogram;
- int nbytes;
- int compression_type;
-
- int fileinfo_count;
- struct fileinfo *fileinfo;
-};
-
-extern struct G__ G__; /* allocated in gisinit */
-
-#define OPEN_OLD 1
-#define OPEN_NEW_COMPRESSED 2
-#define OPEN_NEW_UNCOMPRESSED 3
Modified: grass/trunk/lib/gis/Makefile
===================================================================
--- grass/trunk/lib/gis/Makefile 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/Makefile 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,13 +1,13 @@
MODULE_TOPDIR = ../..
-GDAL_LINK = $(USE_GDAL)
-GDAL_DYNAMIC = 1
-
LIB_NAME = $(GIS_LIBNAME)
-EXTRA_LIBS = $(XDRLIB) $(SOCKLIB) $(DATETIMELIB) $(PTHREADLIBPATH) $(PTHREADLIB) $(INTLLIB) $(MATHLIB)
-DATASRC = ellipse.table datum.table datumtransform.table FIPS.code state27 state83 projections
+
+EXTRA_LIBS = $(XDRLIB) $(SOCKLIB) $(DATETIMELIB) $(PTHREADLIBPATH) $(PTHREADLIB) \
+ $(INTLLIB) $(MATHLIB) $(RASTRLIB)
EXTRA_INC = $(ZLIBINCPATH) $(PTHREADINCPATH)
+DATASRC = ellipse.table datum.table datumtransform.table FIPS.code state27 state83 projections
+
include $(MODULE_TOPDIR)/include/Make/Vars.make
MOD_OBJS := $(filter-out fmode.o,$(AUTO_OBJS))
@@ -16,6 +16,7 @@
include $(MODULE_TOPDIR)/include/Make/Doxygen.make
DATAFILES := $(patsubst %,$(ETC)/%,$(DATASRC))
+
COLORSRC := $(filter-out colors/CVS,$(wildcard colors/[abcdefghijklmnopqrstuvwxyz]*))
COLORFILES := $(patsubst colors/%,$(ETC)/colors/%,$(COLORSRC))
@@ -24,23 +25,6 @@
EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
endif
-ifneq ($(GDAL_LINK),)
-EXTRA_CFLAGS += -DGDAL_LINK=1
-EXTRA_INC += $(PROJINC) $(GDALCFLAGS)
-
-ifneq ($(GDAL_DYNAMIC),)
-EXTRA_CFLAGS += -DGDAL_DYNAMIC=1
-ifneq ($(MINGW),)
-EXTRA_LIBS += -lkernel32
-else
-EXTRA_LIBS += $(DLLIB)
-endif
-else
-EXTRA_LIBS += $(GDALLIBS)
-endif
-
-endif
-
default: lib $(FMODE_OBJ) $(DATAFILES) $(COLORFILES) $(ETC)/colors.desc $(ETC)/element_list
ifdef MINGW
@@ -61,23 +45,16 @@
$(ETC)/%: %
$(INSTALL_DATA) $< $@
-#doxygen:
-DOXNAME=gis
+DOXNAME=gislib
$(OBJDIR)/area_ellipse.o: pi.h
$(OBJDIR)/area_sphere.o: pi.h
-$(OBJDIR)/auto_mask.o: G.h
-$(OBJDIR)/closecell.o: G.h
-$(OBJDIR)/format.o: G.h
+$(OBJDIR)/debug.o: ../raster/G.h
$(OBJDIR)/geodesic.o: pi.h
$(OBJDIR)/geodist.o: pi.h
-$(OBJDIR)/get_row.o: G.h
-$(OBJDIR)/get_window.o: G.h
-$(OBJDIR)/gisinit.o: G.h
-$(OBJDIR)/maskfd.o: G.h
-$(OBJDIR)/opencell.o: G.h
-$(OBJDIR)/put_row.o: G.h
+$(OBJDIR)/get_window.o: ../raster/G.h
+$(OBJDIR)/gisinit.o: ../raster/G.h
$(OBJDIR)/radii.o: pi.h
$(OBJDIR)/rhumbline.o: pi.h
-$(OBJDIR)/set_window.o: G.h
-$(OBJDIR)/window_map.o: G.h
+$(OBJDIR)/set_window.o: ../raster/G.h
+$(OBJDIR)/window_map.o: ../raster/G.h
Deleted: grass/trunk/lib/gis/adj_cellhd.c
===================================================================
--- grass/trunk/lib/gis/adj_cellhd.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/adj_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,356 +0,0 @@
-/*!
- * \file gis/adj_cellhd.c
- *
- * \brief GIS Library - CELL header adjustment.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-/*!
- * \brief Adjust cell header.
- *
- * This function fills in missing parts of the input cell header (or
- * region). It also makes projection-specific adjustments. The
- * <i>cellhd</i> structure must have its <i>north, south, east,
- * west</i>, and <i>proj</i> fields set.
- *
- * If <i>row_flag</i> is true, then the north-south resolution is
- * computed from the number of <i>rows</i> in the <i>cellhd</i>
- * structure. Otherwise the number of <i>rows</i> is computed from the
- * north-south resolution in the structure, similarly for
- * <i>col_flag</i> and the number of columns and the east-west
- * resolution.
- *
- * <b>Note:</b> 3D values are not adjusted.
- *
- * \param[in,out] cellhd pointer to Cell_head structure
- * \param row_flag compute n-s resolution
- * \param col_flag compute e-w resolution
-
- * \return NULL on success
- * \return localized text string on error
- */
-const char *G_adjust_Cell_head(struct Cell_head *cellhd, int row_flag, int col_flag)
-{
- if (!row_flag) {
- if (cellhd->ns_res <= 0)
- return (_("Illegal n-s resolution value"));
- }
- else {
- if (cellhd->rows <= 0)
- return (_("Illegal row value"));
- }
- if (!col_flag) {
- if (cellhd->ew_res <= 0)
- return (_("Illegal e-w resolution value"));
- }
- else {
- if (cellhd->cols <= 0)
- return (_("Illegal col value"));
- }
-
- /* for lat/lon, check north,south. force east larger than west */
- if (cellhd->proj == PROJECTION_LL) {
- double epsilon_ns, epsilon_ew;
-
- /* TODO: find good thresholds */
- epsilon_ns = 1. / cellhd->rows * 0.001;
- epsilon_ew = .000001; /* epsilon_ew calculation doesn't work due to cellhd->cols update/global wraparound below */
-
- G_debug(3, "G_adjust_Cell_head: epsilon_ns: %g, epsilon_ew: %g",
- epsilon_ns, epsilon_ew);
-
- /* TODO: once working, change below G_warning to G_debug */
-
- /* fix rounding problems if input map slightly exceeds the world definition -180 90 180 -90 */
- if (cellhd->north > 90.0) {
- if (((cellhd->north - 90.0) < epsilon_ns) &&
- ((cellhd->north - 90.0) > GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of north boundary (%g>%g)"),
- cellhd->north - 90.0, epsilon_ns);
- cellhd->north = 90.0;
- }
- else
- return (_("Illegal latitude for North"));
- }
-
- if (cellhd->south < -90.0) {
- if (((cellhd->south + 90.0) < epsilon_ns) &&
- ((cellhd->south + 90.0) < GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of south boundary (%g>%g)"),
- cellhd->south + 90.0, epsilon_ns);
- cellhd->south = -90.0;
- }
- else
- return (_("Illegal latitude for South"));
- }
-
-#if 0
- /* DISABLED: this breaks global wrap-around */
-
- G_debug(3,
- "G_adjust_Cell_head() cellhd->west: %f, devi: %g, eps: %g",
- cellhd->west, cellhd->west + 180.0, epsilon_ew);
-
- if ((cellhd->west < -180.0) && ((cellhd->west + 180.0) < epsilon_ew)
- && ((cellhd->west + 180.0) < GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of west boundary (%g>%g)"),
- cellhd->west + 180.0, epsilon_ew);
- cellhd->west = -180.0;
- }
-
- G_debug(3,
- "G_adjust_Cell_head() cellhd->east: %f, devi: %g, eps: %g",
- cellhd->east, cellhd->east - 180.0, epsilon_ew);
-
- if ((cellhd->east > 180.0) && ((cellhd->east - 180.0) > epsilon_ew)
- && ((cellhd->east - 180.0) > GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of east boundary (%g>%g)"),
- cellhd->east - 180.0, epsilon_ew);
- cellhd->east = 180.0;
- }
-#endif
-
- while (cellhd->east <= cellhd->west)
- cellhd->east += 360.0;
- }
-
- /* check the edge values */
- if (cellhd->north <= cellhd->south) {
- if (cellhd->proj == PROJECTION_LL)
- return (_("North must be north of South"));
- else
- return (_("North must be larger than South"));
- }
- if (cellhd->east <= cellhd->west)
- return (_("East must be larger than West"));
-
- /* compute rows and columns, if not set */
- if (!row_flag) {
- cellhd->rows =
- (cellhd->north - cellhd->south +
- cellhd->ns_res / 2.0) / cellhd->ns_res;
- if (cellhd->rows == 0)
- cellhd->rows = 1;
- }
- if (!col_flag) {
- cellhd->cols =
- (cellhd->east - cellhd->west +
- cellhd->ew_res / 2.0) / cellhd->ew_res;
- if (cellhd->cols == 0)
- cellhd->cols = 1;
- }
-
- if (cellhd->cols < 0 || cellhd->rows < 0) {
- return (_("Invalid coordinates"));
- }
-
-
- /* (re)compute the resolutions */
- cellhd->ns_res = (cellhd->north - cellhd->south) / cellhd->rows;
- cellhd->ew_res = (cellhd->east - cellhd->west) / cellhd->cols;
-
- return NULL;
-}
-
-/*!
- * \brief Adjust cell header for 3D values.
- *
- * This function fills in missing parts of the input cell header (or
- * region). It also makes projection-specific adjustments. The
- * <i>cellhd</i> structure must have its <i>north, south, east,
- * west</i>, and <i>proj</i> fields set.
- *
- * If <i>row_flag</i> is true, then the north-south resolution is computed
- * from the number of <i>rows</i> in the <i>cellhd</i> structure.
- * Otherwise the number of <i>rows</i> is computed from the north-south
- * resolution in the structure, similarly for <i>col_flag</i> and the
- * number of columns and the east-west resolution.
- *
- * If <i>depth_flag</i> is true, top-bottom resolution is calculated
- * from depths.
- * If <i>depth_flag</i> are false, number of depths is calculated from
- * top-bottom resolution.
- *
- * \param[in,out] cellhd pointer to Cell_head structure
- * \param row_flag compute n-s resolution
- * \param col_flag compute e-w resolution
- * \param depth_flag compute t-b resolution
- *
- * \return NULL on success
- * \return localized text string on error
- */
-const char *G_adjust_Cell_head3(struct Cell_head *cellhd, int row_flag,
- int col_flag, int depth_flag)
-{
- if (!row_flag) {
- if (cellhd->ns_res <= 0)
- return (_("Illegal n-s resolution value"));
- if (cellhd->ns_res3 <= 0)
- return (_("Illegal n-s3 resolution value"));
- }
- else {
- if (cellhd->rows <= 0)
- return (_("Illegal row value"));
- if (cellhd->rows3 <= 0)
- return (_("Illegal row3 value"));
- }
- if (!col_flag) {
- if (cellhd->ew_res <= 0)
- return (_("Illegal e-w resolution value"));
- if (cellhd->ew_res3 <= 0)
- return (_("Illegal e-w3 resolution value"));
- }
- else {
- if (cellhd->cols <= 0)
- return (_("Illegal col value"));
- if (cellhd->cols3 <= 0)
- return (_("Illegal col3 value"));
- }
- if (!depth_flag) {
- if (cellhd->tb_res <= 0)
- return (_("Illegal t-b3 resolution value"));
- }
- else {
- if (cellhd->depths <= 0)
- return (_("Illegal depths value"));
- }
-
- /* for lat/lon, check north,south. force east larger than west */
- if (cellhd->proj == PROJECTION_LL) {
- double epsilon_ns, epsilon_ew;
-
- /* TODO: find good thresholds */
- epsilon_ns = 1. / cellhd->rows * 0.001;
- epsilon_ew = .000001; /* epsilon_ew calculation doesn't work due to cellhd->cols update/global wraparound below */
-
- G_debug(3, "G_adjust_Cell_head: epsilon_ns: %g, epsilon_ew: %g",
- epsilon_ns, epsilon_ew);
-
- /* TODO: once working, change below G_warning to G_debug */
-
- /* fix rounding problems if input map slightly exceeds the world definition -180 90 180 -90 */
- if (cellhd->north > 90.0) {
- if (((cellhd->north - 90.0) < epsilon_ns) &&
- ((cellhd->north - 90.0) > GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of north boundary (%g>%g)"),
- cellhd->north - 90.0, epsilon_ns);
- cellhd->north = 90.0;
- }
- else
- return (_("Illegal latitude for North"));
- }
-
- if (cellhd->south < -90.0) {
- if (((cellhd->south + 90.0) < epsilon_ns) &&
- ((cellhd->south + 90.0) < GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of south boundary (%g>%g)"),
- cellhd->south + 90.0, epsilon_ns);
- cellhd->south = -90.0;
- }
- else
- return (_("Illegal latitude for South"));
- }
-
-#if 0
- /* DISABLED: this breaks global wrap-around */
-
- G_debug(3,
- "G_adjust_Cell_head3() cellhd->west: %f, devi: %g, eps: %g",
- cellhd->west, cellhd->west + 180.0, epsilon_ew);
-
- if ((cellhd->west < -180.0) && ((cellhd->west + 180.0) < epsilon_ew)
- && ((cellhd->west + 180.0) < GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of west boundary (%g>%g)"),
- cellhd->west + 180.0, epsilon_ew);
- cellhd->west = -180.0;
- }
-
- G_debug(3,
- "G_adjust_Cell_head3() cellhd->east: %f, devi: %g, eps: %g",
- cellhd->east, cellhd->east - 180.0, epsilon_ew);
-
- if ((cellhd->east > 180.0) && ((cellhd->east - 180.0) > epsilon_ew)
- && ((cellhd->east - 180.0) > GRASS_EPSILON)) {
- G_warning(_("Fixing subtle input data rounding error of east boundary (%g>%g)"),
- cellhd->east - 180.0, epsilon_ew);
- cellhd->east = 180.0;
- }
-#endif
-
- while (cellhd->east <= cellhd->west)
- cellhd->east += 360.0;
- }
-
- /* check the edge values */
- if (cellhd->north <= cellhd->south) {
- if (cellhd->proj == PROJECTION_LL)
- return (_("North must be north of South"));
- else
- return (_("North must be larger than South"));
- }
- if (cellhd->east <= cellhd->west)
- return (_("East must be larger than West"));
- if (cellhd->top <= cellhd->bottom)
- return (_("Top must be larger than Bottom"));
-
-
- /* compute rows and columns, if not set */
- if (!row_flag) {
- cellhd->rows =
- (cellhd->north - cellhd->south +
- cellhd->ns_res / 2.0) / cellhd->ns_res;
- if (cellhd->rows == 0)
- cellhd->rows = 1;
-
- cellhd->rows3 =
- (cellhd->north - cellhd->south +
- cellhd->ns_res3 / 2.0) / cellhd->ns_res3;
- if (cellhd->rows3 == 0)
- cellhd->rows3 = 1;
- }
- if (!col_flag) {
- cellhd->cols =
- (cellhd->east - cellhd->west +
- cellhd->ew_res / 2.0) / cellhd->ew_res;
- if (cellhd->cols == 0)
- cellhd->cols = 1;
-
- cellhd->cols3 =
- (cellhd->east - cellhd->west +
- cellhd->ew_res3 / 2.0) / cellhd->ew_res3;
- if (cellhd->cols3 == 0)
- cellhd->cols3 = 1;
- }
-
- if (!depth_flag) {
- cellhd->depths =
- (cellhd->top - cellhd->bottom +
- cellhd->tb_res / 2.0) / cellhd->tb_res;
- if (cellhd->depths == 0)
- cellhd->depths = 1;
-
- }
-
- if (cellhd->cols < 0 || cellhd->rows < 0 || cellhd->cols3 < 0 ||
- cellhd->rows3 < 0 || cellhd->depths < 0) {
- return (_("Invalid coordinates"));
- }
-
- /* (re)compute the resolutions */
- cellhd->ns_res = (cellhd->north - cellhd->south) / cellhd->rows;
- cellhd->ns_res3 = (cellhd->north - cellhd->south) / cellhd->rows3;
- cellhd->ew_res = (cellhd->east - cellhd->west) / cellhd->cols;
- cellhd->ew_res3 = (cellhd->east - cellhd->west) / cellhd->cols3;
- cellhd->tb_res = (cellhd->top - cellhd->bottom) / cellhd->depths;
-
- return NULL;
-}
Modified: grass/trunk/lib/gis/align_window.c
===================================================================
--- grass/trunk/lib/gis/align_window.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/align_window.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
/*!
* \brief Align two regions.
@@ -70,5 +71,5 @@
window->east -= window->ew_res;
}
- return G_adjust_Cell_head(window, 0, 0);
+ return Rast_adjust_Cell_head(window, 0, 0);
}
Deleted: grass/trunk/lib/gis/alloc_cell.c
===================================================================
--- grass/trunk/lib/gis/alloc_cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/alloc_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,164 +0,0 @@
-/*!
- * \file gis/alloc_cell.c
- *
- * \brief GIS Library - Raster allocation routines.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <math.h>
-#include <grass/gis.h>
-
-/* convert type "RASTER_MAP_TYPE" into index */
-#define F2I(map_type) \
- (map_type == CELL_TYPE ? 0 : (map_type == FCELL_TYPE ? 1 : 2))
-
-static const int type_size[3] = { sizeof(CELL), sizeof(FCELL), sizeof(DCELL) };
-
-/*!
- * \brief Returns size of a raster CELL in bytes.
- *
- * - If <i>data_type</i> is CELL_TYPE, returns sizeof(CELL)
- * - If <i>data_type</i> is FCELL_TYPE, returns sizeof(FCELL)
- * - If <i>data_type</i> is DCELL_TYPE, returns sizeof(DCELL)
- *
- * \param data_type raster type (CELL, FCELL, DCELL)
- *
- * \return raster type size
- */
-
-size_t G_raster_size(RASTER_MAP_TYPE data_type)
-{
- return (type_size[F2I(data_type)]);
-}
-
-/*!
- * \brief Allocate memory for a CELL type raster map.
- *
- * This routine allocates a buffer of type CELL just large enough to
- * hold one row of raster data based on the number of columns in the
- * active region.
- *
- \code
- CELL *cell;
- cell = G_allocate_cell_buf();
- \endcode
- *
- * If larger buffers are required, the routine G_malloc() can be used.
- * The routine is generally used with each open cell file.
- *
- * <b>Note:</b> G_allocate_raster_buf() or G_alloc_c_raster_buf() is
- * preferred over G_allocate_cell_buf().
- *
- * Prints error message and calls exit() on error.
- *
- * \return CELL * pointer to allocated buffer
- */
-CELL *G_allocate_cell_buf(void)
-{
- return (CELL *) G_calloc(G_window_cols() + 1, sizeof(CELL));
-}
-
-/*!
- * \brief Allocate memory for a raster map of given type
- *
- * Allocate an array of CELL, FCELL, or DCELL (depending on
- * <i>data_type</i>) based on the number of columns in the current
- * region.
- *
- * \param data_type raster type (CELL, FCELL, DCELL)
- *
- * \return pointer to allocated buffer
- */
-void *G_allocate_raster_buf(RASTER_MAP_TYPE data_type)
-{
- return (void *)G_calloc(G_window_cols() + 1, G_raster_size(data_type));
-}
-
-/*!
- * \brief Allocates memory for a raster map of type CELL.
- *
- * Allocate an array of CELL based on the number of columns in the
- * current region.
- *
- * \return pointer to allocated buffer
- */
-CELL *G_allocate_c_raster_buf(void)
-{
- return (CELL *) G_calloc(G_window_cols() + 1, sizeof(CELL));
-}
-
-/*!
- * \brief Allocates memory for a raster map of type FCELL.
- *
- * Allocate an array of FCELL based on the number of columns in the
- * current region.
- *
- * \return pointer to allocated buffer
- */
-FCELL *G_allocate_f_raster_buf(void)
-{
- return (FCELL *) G_calloc(G_window_cols() + 1, sizeof(FCELL));
-}
-
-/*!
- * \brief Allocates memory for a raster map of type DCELL.
- *
- * Allocate an array of DCELL based on the number of columns in the
- * current region.
- *
- * \return pointer to allocated buffer
- */
-DCELL *G_allocate_d_raster_buf(void)
-{
- return (DCELL *) G_calloc(G_window_cols() + 1, sizeof(DCELL));
-}
-
-/*!
- * \brief Allocates memory for a null buffer.
- *
- * Allocate an array of char based on the number of columns in the
- * current region.
- *
- * \return pointer to allocated buffer
- */
-char *G_allocate_null_buf(void)
-{
- return (char *)G_calloc(G_window_cols() + 1, sizeof(char));
-}
-
-/*!
- * \brief Allocates memory for null bits.
- *
- * Allocates an array of unsigned char based on <i>cols</i>.
- *
- * \param cols number of columns in region
- *
- * \return pointer to allocated buffer
- */
-unsigned char *G__allocate_null_bits(int cols)
-{
- return (unsigned char *)G_calloc(G__null_bitstream_size(cols) + 1,
- sizeof(unsigned char));
-}
-
-/*!
- * \brief Determines null bitstream size.
- *
- * \param cols number of columns
- *
- * \return -1 if <i>cols</i> is invalid (<= 0)
- * \return size of null bistream
- */
-int G__null_bitstream_size(int cols)
-{
- if (cols <= 0)
- return -1;
-
- return (cols / 8 + (cols % 8 != 0));
-}
Deleted: grass/trunk/lib/gis/auto_mask.c
===================================================================
--- grass/trunk/lib/gis/auto_mask.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/auto_mask.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,105 +0,0 @@
-
-/**
- * \file auto_mask.c
- *
- * \brief GIS Library - Auto masking routines.
- *
- * (C) 2001-2008 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author GRASS GIS Development Team
- *
- * \date 1999-2008
- */
-
-#include <stdlib.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include "G.h"
-
-
-/**
- * \brief Checks for auto masking.
- *
- * On first call, opens the mask file if declared and available and
- * allocates buffer for reading mask rows.
- * On second call, returns 0 or 1.
- *
- * \return 0 if mask unset or unavailable
- * \return 1 if mask set and available and ready to use
- */
-
-int G__check_for_auto_masking(void)
-{
- struct Cell_head cellhd;
-
- /* if mask is switched off (-2) return -2
- if G__.auto_mask is not set (-1) or set (>=0) recheck the MASK */
-
- if (G__.auto_mask < -1)
- return G__.auto_mask;
-
- /* if(G__.mask_fd > 0) G_free (G__.mask_buf); */
-
- /* look for the existence of the MASK file */
- G__.auto_mask = (G_find_cell("MASK", G_mapset()) != 0);
-
- if (G__.auto_mask <= 0)
- return 0;
-
- /* check MASK projection/zone against current region */
- if (G_get_cellhd("MASK", G_mapset(), &cellhd) >= 0) {
- if (cellhd.zone != G_zone() || cellhd.proj != G_projection()) {
- G__.auto_mask = 0;
- return 0;
- }
- }
-
- G_unopen_cell(G__.mask_fd);
- G__.mask_fd = G__open_cell_old("MASK", G_mapset());
- if (G__.mask_fd < 0) {
- G__.auto_mask = 0;
- G_warning(_("Unable to open automatic MASK file"));
- return 0;
- }
-
- /* G__.mask_buf = G_allocate_cell_buf(); */
-
- G__.auto_mask = 1;
-
- return 1;
-}
-
-
-/**
- * \brief Suppresses masking.
- *
- * \return
- */
-
-void G_suppress_masking(void)
-{
- if (G__.auto_mask > 0) {
- G_close_cell(G__.mask_fd);
- /* G_free (G__.mask_buf); */
- G__.mask_fd = -1;
- }
- G__.auto_mask = -2;
-}
-
-
-/**
- * \brief Unsuppresses masking.
- *
- * \return
- */
-
-void G_unsuppress_masking(void)
-{
- if (G__.auto_mask < -1) {
- G__.mask_fd = -1;
- G__check_for_auto_masking();
- }
-}
Deleted: grass/trunk/lib/gis/cats.c
===================================================================
--- grass/trunk/lib/gis/cats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,1488 +0,0 @@
-/*!
- * \file gis/cats.c
- *
- * \brief GIS Library - Raster categories management
- *
- * Code in this file works with category files. There are two formats:
- * Pre 3.0 direct category encoding form:
- *
- * 2 categories
- * Map Title
- * Elevation: 1000.00 to 1005.00 feet
- * Elevation: 1005.00 to 1010.00 feet
- * Elevation: 1010.00 to 1015.00 feet
- *
- * 3.0 format
- *
- * # 2 categories
- * Map Title
- * Elevation: $1.2 to $2.2 feet ## Format Statement
- * 5.0 1000 5.0 1005 ## Coefficients
- *
- * The coefficient line can be followed by explicit category labels
- * which override the format label generation.
- * 0:no data
- * 2: .
- * 5: . ## explicit category labels
- * 7: .
- * explicit labels can be also of the form:
- * 5.5:5:9 label description
- * or
- * 15:30 label description
- *
- * In the format line
- * $1 refers to the value num*5.0+1000 (ie, using the first 2 coefficients)
- * $2 refers to the value num*5.0+1005 (ie, using the last 2 coefficients)
- *
- * $1.2 will print $1 with 2 decimal places.
- *
- * Also, the form $?xxx$yyy$ translates into yyy if the category is 1, xxx
- * otherwise. The $yyy$ is optional. Thus
- *
- * $1 meter$?s
- *
- * will become: 1 meter (for category 1)
- * 2 meters (for category 2), etc.
- *
- * The format and coefficients above would be used to generate the
- * following statement in creation of the format appropriate category
- * string for category "num":
- *
- * sprintf(buff,"Elevation: %.2f to %.2f feet", num*5.0+1000, num*5.0*1005)
- *
- * Note: while both the format and coefficent lins must be present
- * a blank line for the fmt will effectively suppress automatic
- * label generation
- *
- * Note: quant rules of Categories structures are heavily dependent
- * on the fact that rules are stored in the same order they are entered.
- * since i-th rule and i-th label are entered at the same time, we
- * know that i-th rule maps fp range to i, thus we know for sure
- * that cats.labels[i] corresponds to i-th quant rule
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-static void get_cond(char **, char *, DCELL);
-static int get_fmt(char **, char *, int *);
-static int cmp(const void *, const void *);
-
-static int write_cats(const char *element, const char *name, struct Categories *cats);
-static CELL read_cats(const char *element,
- const char *name,
- const char *mapset, struct Categories * pcats, int full);
-
-static struct Categories save_cats;
-
-/*!
- * \brief Read raster category file
- *
- * \todo Remove, the function G_read_raster_cats()
- *
- * The category file for raster map <i>name</i> in <i>mapset</i> is
- * read into the <i>cats</i> structure. If there is an error reading
- * the category file, a diagnostic message is printed and -1 is
- * returned. Otherwise, 0 is returned.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] cats pointer to Cats structure
- *
- * \return -1 on error
- * \return 0 on success
- */
-int G_read_cats(const char *name,
- const char *mapset, struct Categories *pcats)
-{
- return G_read_raster_cats(name, mapset, pcats);
-}
-
-/*!
- * \brief Read raster category file
- *
- * The category file for raster map <i>name</i> in <i>mapset</i> is
- * read into the <i>cats</i> structure. If there is an error reading
- * the category file, a diagnostic message is printed and -1 is
- * returned. Otherwise, 0 is returned.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] cats pointer to Cats structure
- *
- * \return -1 on error
- * \return 0 on success
- */
-int G_read_raster_cats(const char *name,
- const char *mapset, struct Categories *pcats)
-{
- char *type;
-
- switch (read_cats("cats", name, mapset, pcats, 1)) {
- case -2:
- type = "missing";
- break;
- case -1:
- type = "invalid";
- break;
- default:
- return 0;
- }
-
- G_warning(_("Category support for <%s@%s> %s"),
- name, mapset, type);
- return -1;
-}
-
-/*!
- * \brief Read vector category file
- *
- * <b>Note:</b> This function works with <b>old</b> vector format.
-
- * The category file for vector map <i>name</i> in <i>mapset</i> is
- * read into the <i>cats</i> structure. If there is an error reading
- * the category file, a diagnostic message is printed and -1 is
- * returned. Otherwise, 0 is returned.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] cats pointer to Cats structure
- *
- * \return -1 on error
- * \return 0 on success
- */
-int G_read_vector_cats(const char *name,
- const char *mapset, struct Categories *pcats)
-{
- char *type;
-
- switch (read_cats("dig_cats", name, mapset, pcats, 1)) {
- case -2:
- type = "missing";
- break;
- case -1:
- type = "invalid";
- break;
- default:
- return 0;
- }
-
- G_warning(_("Category support for vector map <%s@%s> %s"),
- name, mapset, type);
- return -1;
-}
-
-/*!
- \brief Get number of categories
-
- \param name map name
- \param mapset mapset name
-
- \return -1 on error
- \return number of cats
-*/
-CELL G_number_of_cats(const char *name, const char *mapset)
-{
- struct Range range;
- CELL min, max;
-
- /* return the max category number */
- if (G_read_range(name, mapset, &range) < 0)
- return -1;
- G_get_range_min_max(&range, &min, &max);
- if (G_is_c_null_value(&max))
- max = 0;
- return max;
-}
-
-static CELL read_cats(const char *element,
- const char *name,
- const char *mapset, struct Categories * pcats, int full)
-{
- FILE *fd;
- char buff[1024];
- CELL cat;
- DCELL val1, val2;
- int old = 0, fp_map;
- long num = -1;
-
-
- if (strncmp(element, "dig", 3) == 0)
- fp_map = 0;
- else
- fp_map = G_raster_map_is_fp(name, mapset);
-
- if (!(fd = G_fopen_old(element, name, mapset)))
- return -2;
-
- /* Read the number of categories */
- if (G_getl(buff, sizeof buff, fd) == 0)
- goto error;
-
- if (sscanf(buff, "# %ld", &num) == 1)
- old = 0;
- else if (sscanf(buff, "%ld", &num) == 1)
- old = 1;
-
- if (!full) {
- fclose(fd);
- if (num < 0)
- return 0; /* coorect */
- return (CELL) num;
- }
-
- /* Read the title for the file */
- if (G_getl(buff, sizeof buff, fd) == 0)
- goto error;
- G_strip(buff);
- /* G_ascii_check(buff) ; */
-
- G_init_raster_cats(buff, pcats);
- if (num >= 0)
- pcats->num = num;
-
- if (!old) {
- char fmt[256];
- float m1, a1, m2, a2;
-
- if (G_getl(fmt, sizeof fmt, fd) == 0)
- goto error;
- /* next line contains equation coefficients */
- if (G_getl(buff, sizeof buff, fd) == 0)
- goto error;
- if (sscanf(buff, "%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
- goto error;
- G_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
- }
-
- /* Read all category names */
- for (cat = 0;; cat++) {
- char label[1024];
-
- if (G_getl(buff, sizeof buff, fd) == 0)
- break;
- if (old)
- G_set_cat(cat, buff, pcats);
- else {
- *label = 0;
- if (sscanf(buff, "%1s", label) != 1)
- continue;
- if (*label == '#')
- continue;
- *label = 0;
- /* for fp maps try to read a range of data */
- if (fp_map
- && sscanf(buff, "%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
- G_set_raster_cat(&val1, &val2, label, pcats, DCELL_TYPE);
- else if (sscanf(buff, "%d:%[^\n]", &cat, label) >= 1)
- G_set_raster_cat(&cat, &cat, label, pcats, CELL_TYPE);
- else if (sscanf(buff, "%lf:%[^\n]", &val1, label) >= 1)
- G_set_raster_cat(&val1, &val1, label, pcats, DCELL_TYPE);
- else
- goto error;
- }
- }
-
- fclose(fd);
- return 0;
- error:
- fclose(fd);
- return -1;
-}
-
-/*!
- * \brief Get title from category structure struct
- *
- * \todo Remove from GIS Library, replace by G_get_raster_cats_title().
- *
- * Map layers store a one-line title in the category structure as
- * well. This routine returns a pointer to the title contained in the
- * <i>cats</i> structure. A legal pointer is always returned. If the
- * map layer does not have a title, then a pointer to the empty string
- * "" is returned.
- *
- * \param cats pointer to Categories structure
- *
- * \return title
- * \return "" if missing
- */
-
-char *G_get_cats_title(const struct Categories *pcats)
-{
- return G_get_raster_cats_title(pcats);
-}
-
-/*!
- * \brief Get raster cats title
- *
- * Returns pointer to a string with title.
- *
- * \param pcats pointer to Categories structure
- *
- * \return title
- * \return "" if missing
- */
-
-char *G_get_raster_cats_title(const struct Categories *pcats)
-{
- return pcats->title ? pcats->title : "";
-}
-
-/*!
- * \brief Get a raster category label
- *
- * \todo Remove from GIS Library, replaced by G_get_c_raster_cat().
- *
- * This routine looks up category <i>num</i> in the <i>pcats</i>
- * structure and returns a pointer to a string which is the label for
- * the category. A legal pointer is always returned. If the category
- * does not exist in <i>pcats</i>, then a pointer to the empty string
- * "" is returned.
- *
- * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to G_get_cat() overwrite this
- * buffer.
- *
- * \param num cell value
- * \param pcats pointer to Categories structure
- *
- * \return pointer to category label
- * \return "" if category is not found
- */
-char *G_get_cat(CELL num, struct Categories *pcats)
-{
- return G_get_c_raster_cat(&num, pcats);
-}
-
-/*!
- * \brief Get a raster category label (CELL)
- *
- * This routine looks up category <i>rast</i> in the <i>pcats</i>
- * structure and returns a pointer to a string which is the label for
- * the category. A legal pointer is always returned. If the category
- * does not exist in <i>pcats</i>, then a pointer to the empty string
- * "" is returned.
- *
- * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to G_get_cat() overwrite this
- * buffer.
- *
- * \param rast cell value
- * \param pcats pointer to Categories structure
- *
- * \return pointer to category label
- * \return "" if category is not found
- */
-char *G_get_c_raster_cat(CELL * rast, struct Categories *pcats)
-{
- return G_get_raster_cat(rast, pcats, CELL_TYPE);
-}
-
-/*!
- * \brief Get a raster category label (FCELL)
- *
- * This routine looks up category <i>rast</i> in the <i>pcats</i>
- * structure and returns a pointer to a string which is the label for
- * the category. A legal pointer is always returned. If the category
- * does not exist in <i>pcats</i>, then a pointer to the empty string
- * "" is returned.
- *
- * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to G_get_cat() overwrite this
- * buffer.
- *
- * \param rast cell value
- * \param pcats pointer to Categories structure
- *
- * \return pointer to category label
- * \return "" if category is not found
- */
-char *G_get_f_raster_cat(FCELL * rast, struct Categories *pcats)
-{
- return G_get_raster_cat(rast, pcats, FCELL_TYPE);
-}
-
-/*!
- * \brief Get a raster category label (DCELL)
- *
- * This routine looks up category <i>rast</i> in the <i>pcats</i>
- * structure and returns a pointer to a string which is the label for
- * the category. A legal pointer is always returned. If the category
- * does not exist in <i>pcats</i>, then a pointer to the empty string
- * "" is returned.
- *
- * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to G_get_cat() overwrite this
- * buffer.
- *
- * \param rast cell value
- * \param pcats pointer to Categories structure
- *
- * \return pointer to category label
- * \return "" if category is not found
- */
-char *G_get_d_raster_cat(DCELL * rast, struct Categories *pcats)
-{
- return G_get_raster_cat(rast, pcats, DCELL_TYPE);
-}
-
-/*!
- * \brief Get a raster category label
- *
- * This routine looks up category <i>rast</i> in the <i>pcats</i>
- * structure and returns a pointer to a string which is the label for
- * the category. A legal pointer is always returned. If the category
- * does not exist in <i>pcats</i>, then a pointer to the empty string
- * "" is returned.
- *
- * <b>Warning:</b> The pointer that is returned points to a hidden
- * static buffer. Successive calls to G_get_cat() overwrite this
- * buffer.
- *
- * \param rast cell value
- * \param pcats pointer to Categories structure
- * \param data_type map type (CELL, FCELL, DCELL)
- *
- * \return pointer to category label
- * \return "" if category is not found
- */
-char *G_get_raster_cat(void *rast,
- struct Categories *pcats, RASTER_MAP_TYPE data_type)
-{
- static char label[1024];
- char *f, *l, *v;
- CELL i;
- DCELL val;
- float a[2];
- char fmt[30], value_str[30];
-
- if (G_is_null_value(rast, data_type)) {
- sprintf(label, "no data");
- return label;
- }
-
- /* first search the list of labels */
- *label = 0;
- val = G_get_raster_value_d(rast, data_type);
- i = G_quant_get_cell_value(&pcats->q, val);
-
- G_debug(5, "G_get_raster_cat(): val %lf found i %d", val, i);
-
- if (!G_is_c_null_value(&i) && i < pcats->ncats) {
- if (pcats->labels[i] != NULL)
- return pcats->labels[i];
- return label;
- }
-
- /* generate the label */
- if ((f = pcats->fmt) == NULL)
- return label;
-
- a[0] = (float)val *pcats->m1 + pcats->a1;
- a[1] = (float)val *pcats->m2 + pcats->a2;
-
- l = label;
- while (*f) {
- if (*f == '$') {
- f++;
- if (*f == '$')
- *l++ = *f++;
- else if (*f == '?') {
- f++;
- get_cond(&f, v = value_str, val);
- while (*v)
- *l++ = *v++;
- }
- else if (get_fmt(&f, fmt, &i)) {
- sprintf(v = value_str, fmt, a[i]);
- while (*v)
- *l++ = *v++;
- }
- else
- *l++ = '$';
- }
- else {
- *l++ = *f++;
- }
- }
- *l = 0;
- return label;
-}
-
-/*!
- * \brief Sets marks for all categories to 0.
- *
- * This initializes Categories structure for subsequest calls to
- * G_mark_raster_cats() for each row of data, where non-zero mark for
- * i-th label means that some of the cells in rast_row are labeled
- * with i-th label and fall into i-th data range. These marks help
- * determine from the Categories structure which labels were used and
- * which weren't.
- *
- * \param pcats pointer to Categories structure
- */
-void G_unmark_raster_cats(struct Categories *pcats)
-{
- int i;
-
- for (i = 0; i < pcats->ncats; i++)
- pcats->marks[i] = 0;
-}
-
-/*!
- * \brief Looks up the category label for each raster value (CELL).
- *
- * Looks up the category label for each raster value in the
- * <i>rast_row</i> and updates the marks for labels found.
- *
- * <b>Note:</b> Non-zero mark for i-th label stores the number of of
- * raster cells read so far which are labeled with i-th label and fall
- * into i-th data range.
- *
- * \param rast_row raster row to update stats
- * \param ncols number of columns
- * \param pcats pointer to Categories structure
- *
- */
-void G_mark_c_raster_cats(const CELL * rast_row,
- int ncols, struct Categories *pcats)
-{
- G_mark_raster_cats(rast_row, ncols, pcats, CELL_TYPE);
-}
-
-/*!
- * \brief Looks up the category label for each raster value (FCELL).
- *
- * Looks up the category label for each raster value in the
- * <i>rast_row</i> and updates the marks for labels found.
- *
- * <b>Note:</b> Non-zero mark for i-th label stores the number of of
- * raster cells read so far which are labeled with i-th label and fall
- * into i-th data range.
- *
- * \param rast_row raster row to update stats
- * \param ncols number of columns
- * \param pcats pointer to Categories structure
- *
- */
-void G_mark_f_raster_cats(const FCELL * rast_row,
- int ncols, struct Categories *pcats)
-{
- G_mark_raster_cats(rast_row, ncols, pcats, FCELL_TYPE);
-}
-
-/*!
- * \brief Looks up the category label for each raster value (DCELL).
- *
- * Looks up the category label for each raster value in the
- * <i>rast_row</i> and updates the marks for labels found.
- *
- * <b>Note:</b> Non-zero mark for i-th label stores the number of of
- * raster cells read so far which are labeled with i-th label and fall
- * into i-th data range.
- *
- * \param rast_row raster row to update stats
- * \param ncols number of columns
- * \param pcats pointer to Categories structure
- *
- */
-void G_mark_d_raster_cats(const DCELL * rast_row,
- int ncols, struct Categories *pcats)
-{
- G_mark_raster_cats(rast_row, ncols, pcats, DCELL_TYPE);
-}
-
-/*!
- * \brief Looks up the category label for each raster value (DCELL).
- *
- * Looks up the category label for each raster value in the
- * <i>rast_row</i> and updates the marks for labels found.
- *
- * <b>Note:</b> Non-zero mark for i-th label stores the number of of
- * raster cells read so far which are labeled with i-th label and fall
- * into i-th data range.
- *
- * \param rast_row raster row to update stats
- * \param ncols number of columns
- * \param pcats pointer to Categories structure
- *
- * \return -1 on error
- * \return 1 on success
- */
-int G_mark_raster_cats(const void *rast_row,
- int ncols, struct Categories *pcats,
- RASTER_MAP_TYPE data_type)
-{
- CELL i;
-
- while (ncols-- > 0) {
- i = G_quant_get_cell_value(&pcats->q,
- G_get_raster_value_d(rast_row, data_type));
- if (G_is_c_null_value(&i))
- continue;
- if (i > pcats->ncats)
- return -1;
- pcats->marks[i]++;
- rast_row = G_incr_void_ptr(rast_row, G_raster_size(data_type));
- }
- return 1;
-}
-
-/*!
- * \brief Rewind raster categories
- *
- * After call to this function G_get_next_marked_raster_cat() returns
- * the first marked cat label.
- *
- * \param pcats pointer to Categories structure
- */
-void G_rewind_raster_cats(struct Categories *pcats)
-{
- pcats->last_marked_rule = -1;
-}
-
-/*!
- \brief Get next marked raster categories (DCELL)
-
- \param pcats pointer to Categories structure
- \param rast1, rast2 cell values (raster range)
- \param[out] count count
-
- \return NULL if not found
- \return description if found
-*/
-char *G_get_next_marked_d_raster_cat(struct Categories *pcats,
- DCELL * rast1, DCELL * rast2,
- long *count)
-{
- char *descr = NULL;
- int found, i;
-
- found = 0;
- /* pcats->ncats should be == G_quant_nof_rules(&pcats->q) */
-
- G_debug(3, "last marked %d nrules %d\n", pcats->last_marked_rule, G_quant_nof_rules(&pcats->q));
-
- for (i = pcats->last_marked_rule + 1; i < G_quant_nof_rules(&pcats->q); i++) {
- descr = G_get_ith_d_raster_cat(pcats, i, rast1, rast2);
- G_debug(5, "%d %d", i, pcats->marks[i]);
- if (pcats->marks[i]) {
- found = 1;
- break;
- }
- }
-
- if (!found)
- return NULL;
-
- *count = pcats->marks[i];
- pcats->last_marked_rule = i;
- return descr;
-}
-
-/*!
- \brief Get next marked raster categories (CELL)
-
- \param pcats pointer to Categories structure
- \param rast1, rast2 cell values (raster range)
- \param[out] count count
-
- \return NULL if not found
- \return description if found
-*/
-char *G_get_next_marked_c_raster_cat(struct Categories *pcats,
- CELL * rast1, CELL * rast2,
- long *count)
-{
- return G_get_next_marked_raster_cat(pcats, rast1, rast2, count,
- CELL_TYPE);
-}
-
-/*!
- \brief Get next marked raster categories (FCELL)
-
- \param pcats pointer to Categories structure
- \param rast1, rast2 cell values (raster range)
- \param[out] count count
-
- \return NULL if not found
- \return description if found
-*/
-char *G_get_next_marked_f_raster_cat(struct Categories *pcats,
- FCELL * rast1, FCELL * rast2,
- long *count)
-{
- return G_get_next_marked_raster_cat(pcats, rast1, rast2, count,
- FCELL_TYPE);
-}
-
-/*!
- \brief Get next marked raster categories
-
- \param pcats pointer to Categories structure
- \param rast1, rast2 cell values (raster range)
- \param[out] count count
- \param data_type map type
-
- \return NULL if not found
- \return description if found
-*/
-char *G_get_next_marked_raster_cat(struct Categories *pcats,
- void *rast1, void *rast2,
- long *count, RASTER_MAP_TYPE data_type)
-{
- DCELL val1, val2;
- char *lab;
-
- lab = G_get_next_marked_d_raster_cat(pcats, &val1, &val2, count);
- G_set_raster_value_d(rast1, val1, data_type);
- G_set_raster_value_d(rast2, val2, data_type);
- return lab;
-}
-
-static int get_fmt(char **f, char *fmt, int *i)
-{
- char *ff;
-
- ff = *f;
- if (*ff == 0)
- return 0;
- if (*ff == '$') {
- *f = ff + 1;
- return 0;
- }
- switch (*ff++) {
- case '1':
- *i = 0;
- break;
- case '2':
- *i = 1;
- break;
- default:
- return 0;
- }
- *fmt++ = '%';
- *fmt++ = '.';
- if (*ff++ != '.') {
- *f = ff - 1;
- *fmt++ = '0';
- *fmt++ = 'f';
- *fmt = 0;
- return 1;
- }
- *fmt = '0';
- while (*ff >= '0' && *ff <= '9')
- *fmt++ = *ff++;
- *fmt++ = 'f';
- *fmt = 0;
- *f = ff;
- return 1;
-}
-
-static void get_cond(char **f, char *value, DCELL val)
-{
- char *ff;
-
- ff = *f;
- if (val == 1.) {
- while (*ff)
- if (*ff++ == '$')
- break;
- }
-
- while (*ff)
- if (*ff == '$') {
- ff++;
- break;
- }
- else
- *value++ = *ff++;
-
- if (val != 1.) {
- while (*ff)
- if (*ff++ == '$')
- break;
- }
- *value = 0;
- *f = ff;
-}
-
-
-/*!
- * \brief Set a raster category label
- *
- * \todo To be removed, replaced by G_set_c_raster_cat().
- *
- * The <i>label</i> is copied into the <i>pcats</i> structure for
- * category <i>num</i>.
- *
- * \param num raster cell
- * \param label category label
- * \param pcats pointer to Categories structure
- *
- * \return -1 on error
- * \return 0 if null value detected
- * \return 1 on success
- */
-int G_set_cat(CELL num, const char *label, struct Categories *pcats)
-{
- return G_set_c_raster_cat(&num, &num, label, pcats);
-}
-
-
-/*!
- * \brief Set a raster category label (CELL)
- *
- * Adds the label for range <i>rast1</i> through <i>rast2</i> in
- * category structure <i>pcats</i>.
- *
- * \param rast1, rast2 raster values (range)
- * \param label category label
- * \param pcats pointer to Categories structure
- *
- * \return -1 on error
- * \return 0 if null value detected
- * \return 1 on success
- */
-int G_set_c_raster_cat(const CELL * rast1, const CELL * rast2,
- const char *label, struct Categories *pcats)
-{
- return G_set_raster_cat(rast1, rast2, label, pcats, CELL_TYPE);
-}
-
-/*!
- * \brief Set a raster category label (FCELL)
- *
- * Adds the label for range <i>rast1</i> through <i>rast2</i> in
- * category structure <i>pcats</i>.
- *
- * \param rast1, rast2 raster values (range)
- * \param label category label
- * \param pcats pointer to Categories structure
- *
- * \return
- */
-int G_set_f_raster_cat(const FCELL * rast1, const FCELL * rast2,
- const char *label, struct Categories *pcats)
-{
- return G_set_raster_cat(rast1, rast2, label, pcats, FCELL_TYPE);
-}
-
-/*!
- * \brief Set a raster category label (DCELL)
- *
- * Adds the label for range <i>rast1</i> through <i>rast2</i> in
- * category structure <i>pcats</i>.
- *
- * \param rast1, rast2 raster values (range)
- * \param label category label
- * \param pcats pointer to Categories structure
- *
- * \return -1 on error
- * \return 0 if null value detected
- * \return 1 on success
- */
-int G_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
- const char *label, struct Categories *pcats)
-{
- long len;
- DCELL dtmp1, dtmp2;
- int i;
- char *descr;
-
- /* DEBUG fprintf(stderr,"G_set_d_raster_cat(rast1 = %p,rast2 = %p,label = '%s',pcats = %p)\n",
- rast1,rast2,label,pcats); */
- if (G_is_d_null_value(rast1))
- return 0;
- if (G_is_d_null_value(rast2))
- return 0;
- /* DEBUG fprintf (stderr, "G_set_d_raster_cat(): adding quant rule: %f %f %d %d\n", *rast1, *rast2, pcats->ncats, pcats->ncats); */
- /* the set_cat() functions are used in many places to reset the labels
- for the range (or cat) with existing label. In this case we don't
- want to store both rules with identical range even though the result
- of get_cat() will be correct, since it will use rule added later.
- we don't want to overuse memory and we don't want rules which are
- not used to be writen out in cats file. So we first look if
- the label for this range has been sen, and if it has, overwrite it */
-
- for (i = 0; i < pcats->ncats; i++) {
- descr = G_get_ith_d_raster_cat(pcats, i, &dtmp1, &dtmp2);
- if ((dtmp1 == *rast1 && dtmp2 == *rast2)
- || (dtmp1 == *rast2 && dtmp2 == *rast1)) {
- if (pcats->labels[i] != NULL)
- G_free(pcats->labels[i]);
- pcats->labels[i] = G_store(label);
- G_newlines_to_spaces(pcats->labels[i]);
- G_strip(pcats->labels[i]);
- return 1;
- }
- }
- /* when rule for this range does not exist */
- /* DEBUG fprintf (stderr, "G_set_d_raster_cat(): New rule: adding %d %p\n", i, pcats->labels); */
- G_quant_add_rule(&pcats->q, *rast1, *rast2, pcats->ncats, pcats->ncats);
- pcats->ncats++;
- if (pcats->nalloc < pcats->ncats) {
- /* DEBUG fprintf (stderr, "G_set_d_raster_cat(): need more space nalloc = %d ncats = %d\n", pcats->nalloc,pcats->ncats); */
- len = (pcats->nalloc + 256) * sizeof(char *);
- /* DEBUG fprintf (stderr, "G_set_d_raster_cat(): allocating %d labels(%d)\n", pcats->nalloc + 256,(int)len); */
- if (len != (int)len) { /* make sure len doesn't overflow int */
- pcats->ncats--;
- return -1;
- }
- /* DEBUG fprintf(stderr,"G_set_d_raster_cat(): pcats->nalloc = %d, pcats->labels = (%p), len = %d\n",pcats->nalloc,pcats->labels,(int)len); */
- if (pcats->nalloc) {
- /* DEBUG fprintf(stderr,"G_set_d_raster_cat(): Realloc-ing pcats->labels (%p)\n",pcats->labels); */
- pcats->labels =
- (char **)G_realloc((char *)pcats->labels, (int)len);
- }
- else {
- /* DEBUG fprintf(stderr,"G_set_d_raster_cat(): alloc-ing new labels pointer array\n"); */
- pcats->labels = (char **)G_malloc((int)len);
- }
- /* fflush(stderr); */
- /* DEBUG fprintf (stderr, "G_set_d_raster_cats(): allocating %d marks(%d)\n", pcats->nalloc + 256,(int)len); */
- len = (pcats->nalloc + 256) * sizeof(int);
- if (len != (int)len) { /* make sure len doesn't overflow int */
- pcats->ncats--;
- return -1;
- }
- if (pcats->nalloc)
- pcats->marks = (int *)G_realloc((char *)pcats->marks, (int)len);
- else
- pcats->marks = (int *)G_malloc((int)len);
- pcats->nalloc += 256;
- }
- /* DEBUG fprintf(stderr,"G_set_d_raster_cats(): store new label\n"); */
- pcats->labels[pcats->ncats - 1] = G_store(label);
- G_newlines_to_spaces(pcats->labels[pcats->ncats - 1]);
- G_strip(pcats->labels[pcats->ncats - 1]);
- /* DEBUG
- fprintf (stderr, "%d %s\n", pcats->ncats - 1, pcats->labels[pcats->ncats - 1]);
- */
- /* updates cats.num = max cat values. This is really just used in old
- raster programs, and I am doing it for backwards cmpatibility (Olga) */
- if ((CELL) * rast1 > pcats->num)
- pcats->num = (CELL) * rast1;
- if ((CELL) * rast2 > pcats->num)
- pcats->num = (CELL) * rast2;
- /* DEBUG fprintf(stderr,"G_set_d_raster_cat(): done\n"); */
- /* DEBUG fflush(stderr); */
- return 1;
-}
-
-
-/*!
- * \brief Set a raster category label (DCELL)
- *
- * Adds the label for range <i>rast1</i> through <i>rast2</i> in
- * category structure <i>pcats</i>.
- *
- * \param rast1, rast2 raster values (range)
- * \param label category label
- * \param pcats pointer to Categories structure
- * \param data_type map type
- *
- * \return -1 on error
- * \return 0 if null value detected
- * \return 1 on success
- */
-
-int G_set_raster_cat(const void *rast1, const void *rast2,
- const char *label,
- struct Categories *pcats, RASTER_MAP_TYPE data_type)
-{
- DCELL val1, val2;
-
- val1 = G_get_raster_value_d(rast1, data_type);
- val2 = G_get_raster_value_d(rast2, data_type);
- return G_set_d_raster_cat(&val1, &val2, label, pcats);
-}
-
-/*!
- * \brief Write raster category file
- *
- * \todo To be removed, replaced by G_write_raster_cats().
- *
- * Writes the category file for the raster map <i>name</i> in the
- * current mapset from the <i>cats</i> structure.
- *
- * \param name map name
- * \param cats pointer to Categories structure
- *
- * \return 1 on success
- * \return -1 is returned (no diagnostic is printed)
- */
-int G_write_cats(const char *name, struct Categories *cats)
-{
- return write_cats("cats", name, cats);
-}
-
-/*!
- * \brief Write raster category file
- *
- * \todo To be removed, replaced by G_write_raster_cats().
- *
- * Writes the category file for the raster map <i>name</i> in the
- * current mapset from the <i>cats</i> structure.
- *
- * \param name map name
- * \param cats pointer to Categories structure
- *
- * \return 1 on success
- * \return -1 is returned (no diagnostic is printed)
- */
-int G_write_raster_cats(const char *name, struct Categories *cats)
-{
- return write_cats("cats", name, cats);
-}
-
-/*!
- * \brief Write vector category file
- *
- * <b>Note:</b> Used for only old vector format!
- *
- * \param name map name
- * \param cats pointer to Categories structure
- *
- * \return 1 on success
- * \return -1 is returned (no diagnostic is printed)
- */
-int G_write_vector_cats(const char *name, struct Categories *cats)
-{
- return write_cats("dig_cats", name, cats);
-}
-
-static int write_cats(const char *element, const char *name, struct Categories *cats)
-{
- FILE *fd;
- int i, fp_map;
- char *descr;
- DCELL val1, val2;
- char str1[100], str2[100];
-
- if (!(fd = G_fopen_new(element, name)))
- return -1;
-
- /* write # cats - note # indicate 3.0 or later */
- fprintf(fd, "# %ld categories\n", (long)cats->num);
-
- /* title */
- fprintf(fd, "%s\n", cats->title != NULL ? cats->title : "");
-
- /* write format and coefficients */
- fprintf(fd, "%s\n", cats->fmt != NULL ? cats->fmt : "");
- fprintf(fd, "%.2f %.2f %.2f %.2f\n",
- cats->m1, cats->a1, cats->m2, cats->a2);
-
- /* if the map is integer or if this is a vector map, sort labels */
- if (strncmp(element, "dig", 3) == 0)
- fp_map = 0;
- else
- fp_map = G_raster_map_is_fp(name, G_mapset());
- if (!fp_map)
- G_sort_cats(cats);
-
- /* write the cat numbers:label */
- for (i = 0; i < G_quant_nof_rules(&cats->q); i++) {
- descr = G_get_ith_d_raster_cat(cats, i, &val1, &val2);
- if ((cats->fmt && cats->fmt[0])
- || (descr && descr[0])) {
- if (val1 == val2) {
- sprintf(str1, "%.10f", val1);
- G_trim_decimal(str1);
- fprintf(fd, "%s:%s\n", str1, descr != NULL ? descr : "");
- }
- else {
- sprintf(str1, "%.10f", val1);
- G_trim_decimal(str1);
- sprintf(str2, "%.10f", val2);
- G_trim_decimal(str2);
- fprintf(fd, "%s:%s:%s\n", str1, str2,
- descr != NULL ? descr : "");
- }
- }
- }
- fclose(fd);
- return (1);
-}
-
-/*!
- * \brief Get category description (DCELL)
- *
- * Returns i-th description and i-th data range from the list of
- * category descriptions with corresponding data ranges. end points of
- * data interval in <i>rast1</i> and <i>rast2</i>.
- *
- * \param pcats pointer to Categories structure
- * \param i index
- * \param rast1, rast2 raster values (range)
- *
- * \return "" on error
- * \return pointer to category description
- */
-char *G_get_ith_d_raster_cat(const struct Categories *pcats,
- int i, DCELL * rast1, DCELL * rast2)
-{
- int index;
-
- if (i > pcats->ncats) {
- G_set_d_null_value(rast1, 1);
- G_set_d_null_value(rast2, 1);
- return "";
- }
- G_quant_get_ith_rule(&pcats->q, i, rast1, rast2, &index, &index);
- return pcats->labels[index];
-}
-
-/*!
- * \brief Get category description (FCELL)
- *
- * Returns i-th description and i-th data range from the list of
- * category descriptions with corresponding data ranges. end points of
- * data interval in <i>rast1</i> and <i>rast2</i>.
- *
- * \param pcats pointer to Categories structure
- * \param i index
- * \param rast1, rast2 raster values (range)
- *
- * \return "" on error
- * \return pointer to category description
- */
-char *G_get_ith_f_raster_cat(const struct Categories *pcats,
- int i, void *rast1, void *rast2)
-{
- RASTER_MAP_TYPE data_type = FCELL_TYPE;
- char *tmp;
- DCELL val1, val2;
-
- tmp = G_get_ith_d_raster_cat(pcats, i, &val1, &val2);
- G_set_raster_value_d(rast1, val1, data_type);
- G_set_raster_value_d(rast2, val2, data_type);
- return tmp;
-}
-
-/*!
- * \brief Get category description (CELL)
- *
- * Returns i-th description and i-th data range from the list of
- * category descriptions with corresponding data ranges. end points of
- * data interval in <i>rast1</i> and <i>rast2</i>.
- *
- * \param pcats pointer to Categories structure
- * \param i index
- * \param rast1, rast2 raster values (range)
- *
- * \return "" on error
- * \return pointer to category description
- */
-char *G_get_ith_c_raster_cat(const struct Categories *pcats,
- int i, void *rast1, void *rast2)
-{
- RASTER_MAP_TYPE data_type = CELL_TYPE;
- char *tmp;
- DCELL val1, val2;
-
- tmp = G_get_ith_d_raster_cat(pcats, i, &val1, &val2);
- G_set_raster_value_d(rast1, val1, data_type);
- G_set_raster_value_d(rast2, val2, data_type);
- return tmp;
-}
-
-/*!
- * \brief Get category description
- *
- * Returns i-th description and i-th data range from the list of
- * category descriptions with corresponding data ranges. end points of
- * data interval in <i>rast1</i> and <i>rast2</i>.
- *
- * \param pcats pointer to Categories structure
- * \param i index
- * \param rast1, rast2 raster values (range)
- * \param data_type map type
- *
- * \return "" on error
- * \return pointer to category description
- */
-char *G_get_ith_raster_cat(const struct Categories *pcats, int i, void *rast1,
- void *rast2, RASTER_MAP_TYPE data_type)
-{
- char *tmp;
- DCELL val1, val2;
-
- tmp = G_get_ith_d_raster_cat(pcats, i, &val1, &val2);
- G_set_raster_value_d(rast1, val1, data_type);
- G_set_raster_value_d(rast2, val2, data_type);
- return tmp;
-}
-
-/*!
- * \brief Initialize category structure
- *
- * To construct a new category file, the structure must first be
- * initialized. This routine initializes the <i>cats</i> structure,
- * and copies the <i>title</i> into the structure. The number of
- * categories is set initially to <i>n</i>.
- *
- * For example:
- \code
- struct Categories cats;
- G_init_cats ((CELL)0, * "", &cats);
- \endcode
- *
- * \param num raster value
- * \param title title
- * \param pcats pointer to Categories structure
- */
-void G_init_cats(CELL num, const char *title, struct Categories *pcats)
-{
- G_init_raster_cats(title, pcats);
- pcats->num = num;
-}
-
-/*!
- * \brief Initialize category structure
- *
- * Same as existing G_init_raster_cats() only ncats argument is
- * missign. ncats has no meaning in new Categories structure and only
- * stores (int) largets data value for backwards compatibility.
- *
- * \param title title
- * \param pcats pointer to Categories structure
- */
-void G_init_raster_cats(const char *title, struct Categories *pcats)
-{
- G_set_raster_cats_title(title, pcats);
- pcats->labels = NULL;
- pcats->nalloc = 0;
- pcats->ncats = 0;
- pcats->num = 0;
- pcats->fmt = NULL;
- pcats->m1 = 0.0;
- pcats->a1 = 0.0;
- pcats->m2 = 0.0;
- pcats->a2 = 0.0;
- pcats->last_marked_rule = -1;
- G_quant_init(&pcats->q);
-}
-
-/*!
- * \brief Set title in category structure
- *
- * \todo To be removed, replaced by G_set_raster_cats_title().
- *
- * The <i>title</i> is copied into the <i>pcats</i> structure.
- *
- * \param title title
- * \param pcats pointer to Categories structure
- */
-void G_set_cats_title(const char *title, struct Categories *pcats)
-{
- G_set_raster_cats_title(title, pcats);
-}
-
-/*!
- * \brief Set title in category structure
- *
- * The <i>title</i> is copied into the <i>pcats</i> structure.
- *
- * \param title title
- * \param pcats pointer to Categories structure
- */
-void G_set_raster_cats_title(const char *title, struct Categories *pcats)
-{
- if (title == NULL)
- title = "";
- pcats->title = G_store(title);
- G_newlines_to_spaces(pcats->title);
- G_strip(pcats->title);
-}
-
-/*!
- \brief Set category fmt (?)
-
- \todo To be removed, replaced by G_set_raster_cats_fmt().
-
- \param fmt
- \param m1,
- \param a1,m2,a2
- \param pcats pointer to Categories structure
-*/
-void G_set_cats_fmt(const char *fmt, double m1, double a1, double m2,
- double a2, struct Categories *pcats)
-{
- G_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
-}
-
-/*!
- \brief Set category fmt (?)
-
- \todo To be removed, replaced by G_set_raster_cats_fmt().
-
- \param fmt
- \param m1,
- \param a1,m2,a2
- \param pcats pointer to Categories structure
-*/
-void G_set_raster_cats_fmt(const char *fmt, double m1, double a1, double m2,
- double a2, struct Categories *pcats)
-{
- pcats->m1 = m1;
- pcats->a1 = a1;
- pcats->m2 = m2;
- pcats->a2 = a2;
-
- pcats->fmt = G_store(fmt);
- G_newlines_to_spaces(pcats->fmt);
- G_strip(pcats->fmt);
-}
-
-/*!
- * \brief Free category structure memory
- *
- * \todo To be removed, replaced by G_free_raster_cats().
- *
- * Frees memory allocated by G_read_cats(), G_init_cats() and
- * G_set_cat().
- *
- * \param pcats pointer to Categories structure
- */
-void G_free_cats(struct Categories *pcats)
-{
- G_free_raster_cats(pcats);
-}
-
-/*!
- * \brief Free category structure memory
- *
- * \todo To be removed, replaced by G_free_raster_cats().
- *
- * Frees memory allocated by G_read_cats(), G_init_cats() and
- * G_set_cat().
- *
- * \param pcats pointer to Categories structure
- */
-void G_free_raster_cats(struct Categories *pcats)
-{
- int i;
-
- if (pcats->title != NULL) {
- G_free(pcats->title);
- pcats->title = NULL;
- }
- if (pcats->fmt != NULL) {
- G_free(pcats->fmt);
- pcats->fmt = NULL;
- }
- if (pcats->ncats > 0) {
- for (i = 0; i < pcats->ncats; i++)
- if (pcats->labels[i] != NULL)
- G_free(pcats->labels[i]);
- G_free(pcats->labels);
- G_free(pcats->marks);
- pcats->labels = NULL;
- }
- G_quant_free(&pcats->q);
- pcats->ncats = 0;
- pcats->nalloc = 0;
-}
-
-/*!
- * \brief Copy raster categories
- *
- * Allocates NEW space for quant rules and labels n <i>pcats_to</i>
- * and copies all info from <i>pcats_from</i> cats to
- * <i>pcats_to</i> cats.
- *
- * \param pcats_to pointer to destination Categories structure
- * \param pcats_from pointer to source Categories structure
- */
-void G_copy_raster_cats(struct Categories *pcats_to,
- const struct Categories *pcats_from)
-{
- int i;
- char *descr;
- DCELL d1, d2;
-
- G_init_raster_cats(pcats_from->title, pcats_to);
- for (i = 0; i < pcats_from->ncats; i++) {
- descr = G_get_ith_d_raster_cat(pcats_from, i, &d1, &d2);
- G_set_d_raster_cat(&d1, &d2, descr, pcats_to);
- }
-}
-
-/*!
- \brief Get number of raster categories
-
- \param pcats pointer to Categories structure
-
- \return number of categories
-*/
-int G_number_of_raster_cats(struct Categories *pcats)
-{
- return pcats->ncats;
-}
-
-/*!
- \brief Sort categories
-
- \param pcats pointer to Categories structure
-
- \return -1 on error (nothing to sort)
- \return 0 on success
-*/
-int G_sort_cats(struct Categories *pcats)
-{
- int *indexes, i, ncats;
- char *descr;
- DCELL d1, d2;
-
- if (pcats->ncats <= 1)
- return -1;
-
- ncats = pcats->ncats;
- G_debug(3, "G_sort_cats(): Copying to save cats buffer");
- G_copy_raster_cats(&save_cats, pcats);
- G_free_raster_cats(pcats);
-
- indexes = (int *)G_malloc(sizeof(int) * ncats);
- for (i = 0; i < ncats; i++)
- indexes[i] = i;
-
- qsort(indexes, ncats, sizeof(int), cmp);
- G_init_raster_cats(save_cats.title, pcats);
- for (i = 0; i < ncats; i++) {
- descr = G_get_ith_d_raster_cat(&save_cats, indexes[i], &d1, &d2);
- G_debug(4, " Write sorted cats, pcats = %p pcats->labels = %p",
- pcats, pcats->labels);
- G_set_d_raster_cat(&d1, &d2, descr, pcats);
- }
- G_free_raster_cats(&save_cats);
-
- return 0;
-}
-
-static int cmp(const void *aa, const void *bb)
-{
- const int *a = aa, *b = bb;
- DCELL min_rast1, min_rast2, max_rast1, max_rast2;
- CELL index;
-
- G_quant_get_ith_rule(&(save_cats.q), *a,
- &min_rast1, &max_rast1, &index, &index);
- G_quant_get_ith_rule(&(save_cats.q), *b,
- &min_rast2, &max_rast2, &index, &index);
- if (min_rast1 < min_rast2)
- return -1;
- if (min_rast1 > min_rast2)
- return 1;
- return 0;
-}
Deleted: grass/trunk/lib/gis/cell_stats.c
===================================================================
--- grass/trunk/lib/gis/cell_stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/cell_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,390 +0,0 @@
-/*!
- * \file gis/cell_stats.c
- *
- * \brief GIS Library - Raster cell statistics
- *
- * (C) 2001-2009 GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-#include <stdlib.h>
-
-#define INCR 10
-#define SHIFT 6
-
-static const int NCATS = 1 << SHIFT;
-
-#define NODE struct Cell_stats_node
-
-static int next_node(struct Cell_stats *);
-static void init_node(NODE *, int, int);
-
-/*!
- * \brief Initialize cell stats
- *
- * This routine, which must be called first, initializes the
- * Cell_stats structure.
- *
- * Set the count for NULL-values to zero.
- *
- * \param s pointer to Cell_stats structure
- */
-void G_init_cell_stats(struct Cell_stats *s)
-{
- s->N = 0;
- s->tlen = INCR;
- s->node = (NODE *) G_malloc(s->tlen * sizeof(NODE));
- s->null_data_count = 0;
-}
-
-/*!
- * \brief Sdd data to cell stats
- *
- * The <i>n</i> CELL values in the <i>data</i> array are inserted (and
- * counted) in the Cell_stats structure.
- *
- * Look for NULLs and update the NULL-value count.
- *
- * \param cell raster values
- * \param n number of values
- * \param s pointer to Cell_stats structure which holds cell stats info
- *
- * \return 1 on failure
- * \return 0 on success
- */
-int G_update_cell_stats(const CELL * cell, int n, struct Cell_stats *s)
-{
- CELL cat;
- int p, q;
- int idx, offset;
- int N;
- NODE *node, *pnode;
- NODE *new_node;
-
- if (n <= 0)
- return 1;
-
- node = s->node;
-
- /* first non-null node is special case */
- if ((N = s->N) == 0) {
- cat = *cell++;
- while (G_is_c_null_value(&cat)) {
- s->null_data_count++;
- cat = *cell++;
- n--;
- }
- if (n > 0) { /* if there are some non-null cells */
- N = 1;
- if (cat < 0) {
- idx = -((-cat) >> SHIFT) - 1;
- offset = cat + ((-idx) << SHIFT) - 1;
- }
- else {
- idx = cat >> SHIFT;
- offset = cat - (idx << SHIFT);
- }
- fflush(stderr);
- init_node(&node[1], idx, offset);
- node[1].right = 0;
- n--;
- }
- }
- while (n-- > 0) {
- cat = *cell++;
- if (G_is_c_null_value(&cat)) {
- s->null_data_count++;
- continue;
- }
- if (cat < 0) {
- idx = -((-cat) >> SHIFT) - 1;
- offset = cat + ((-idx) << SHIFT) - 1;
- }
- else {
- idx = cat >> SHIFT;
- offset = cat - (idx << SHIFT);
- }
-
- q = 1;
- while (q > 0) {
- pnode = &node[p = q];
- if (pnode->idx == idx) {
- pnode->count[offset]++;
- break;
- }
- if (pnode->idx > idx)
- q = pnode->left; /* go left */
- else
- q = pnode->right; /* go right */
- }
- if (q > 0)
- continue; /* found */
-
- /* new node */
- N++;
-
- /* grow the tree? */
- if (N >= s->tlen) {
- node =
- (NODE *) G_realloc((char *)node,
- sizeof(NODE) * (s->tlen += INCR));
- pnode = &node[p]; /* realloc moves node, must reassign pnode */
- }
-
- /* add node to tree */
- init_node(new_node = &node[N], idx, offset);
-
- if (pnode->idx > idx) {
- new_node->right = -p; /* create thread */
- pnode->left = N; /* insert left */
- }
- else {
- new_node->right = pnode->right; /* copy right link/thread */
- pnode->right = N; /* add right */
- }
- } /* while n-- > 0 */
- s->N = N;
- s->node = node;
-
- return 0;
-}
-
-static void init_node(NODE * node, int idx, int offset)
-{
- long *count;
- int i;
-
- count = node->count = (long *)G_calloc(i = NCATS, sizeof(long));
- while (i--)
- *count++ = 0;
- node->idx = idx;
- node->count[offset] = 1;
- node->left = 0;
-}
-
-
-/*!
- * \brief Random query of cell stats
- *
- * This routine allows a random query of the Cell_stats structure. The
- * <i>count</i> associated with the raster value <i>cat</i> is
- * set. The routine returns 1 if <i>cat<i> was found in the
- * structure, 0 otherwise.
- *
- * Allow finding the count for the NULL-value.
- *
- * \param cat raster value
- * \param[out] count count
- * \param s pointer to Cell_stats structure which holds cell stats info
- *
- * \return 1 if found
- * \return 0 if not found
- */
-int G_find_cell_stat(CELL cat, long *count, const struct Cell_stats *s)
-{
- int q;
- int idx;
- int offset;
-
- *count = 0;
- if (G_is_c_null_value(&cat)) {
- *count = s->null_data_count;
- return (*count != 0);
- }
-
- if (s->N <= 0)
- return 0;
-
- /*
- if (cat < 0)
- {
- idx = -(-cat/NCATS) - 1;
- offset = cat - idx*NCATS - 1;
- }
- else
- {
- idx = cat/NCATS;
- offset = cat - idx*NCATS;
- }
- */
- if (cat < 0) {
- idx = -((-cat) >> SHIFT) - 1;
- offset = cat + ((-idx) << SHIFT) - 1;
- }
- else {
- idx = cat >> SHIFT;
- offset = cat - (idx << SHIFT);
- }
-
- q = 1;
- while (q > 0) {
- if (s->node[q].idx == idx) {
- *count = s->node[q].count[offset];
- return (*count != 0);
- }
- if (s->node[q].idx > idx)
- q = s->node[q].left; /* go left */
- else
- q = s->node[q].right; /* go right */
- }
- return 0;
-}
-
-/*!
- * \brief Reset/rewind cell stats
- *
- * The structure <i>s</i> is rewound (i.e., positioned at the first
- * raster category) so that sorted sequential retrieval can begin.
- *
- * \param s pointer to Cell_stats structure which holds cell stats info
- *
- * \return 0
- */
-int G_rewind_cell_stats(struct Cell_stats *s)
-{
- int q;
-
- if (s->N <= 0)
- return 1;
- /* start at root and go all the way to the left */
- s->curp = 1;
- while ((q = s->node[s->curp].left))
- s->curp = q;
- s->curoffset = -1;
-
- return 0;
-}
-
-static int next_node(struct Cell_stats *s)
-{
- int q;
-
- /* go to the right */
- s->curp = s->node[s->curp].right;
-
- if (s->curp == 0) /* no more */
- return 0;
-
- if (s->curp < 0) { /* thread. stop here */
- s->curp = -(s->curp);
- return 1;
- }
-
- while ((q = s->node[s->curp].left)) /* now go all the way left */
- s->curp = q;
-
- return 1;
-}
-
-/*!
- * \brief Retrieve sorted cell stats
- *
- * Retrieves the next <i>cat, count</i> combination from the
- * structure. Returns 0 if there are no more items, non-zero if there
- * are more. For example:
- *
- \code
- struct Cell_stats s;
- CELL cat;
- long count;
-
- // updating <b>s</b> occurs here
-
- G_rewind_cell_stats(&s);
- while (G_next_cell_stat(&cat,&count,&s)
- fprintf(stdout, "%ld %ld\n", (long) cat, count);
- \endcode
- *
- * Do not return a record for the NULL-value
- *
- * \param cat raster value
- * \param[out] count
- * \param s pointer to Cell_stats structure which holds cell stats info
- *
- * \return 0 if there are no more items
- * \return non-zero if there are more
- */
-int G_next_cell_stat(CELL * cat, long *count, struct Cell_stats *s)
-{
- int idx;
-
- /* first time report stats for null */
- /* decided not to return stats for null in this function
- static int null_reported = 0;
- if(!null_reported && s->null_data_count > 0)
- {
- *count = s->null_data_count;
- G_set_c_null_value(&cat,1);
- null_reported = 1;
- return 1;
- }
- */
- if (s->N <= 0)
- return 0;
- for (;;) {
- s->curoffset++;
- if (s->curoffset >= NCATS) {
- if (!next_node(s))
- return 0;
- s->curoffset = -1;
- continue;
- }
- if ((*count = s->node[s->curp].count[s->curoffset])) {
- idx = s->node[s->curp].idx;
-
- /*
- if (idx < 0)
- *cat = idx*NCATS + s->curoffset+1;
- else
- *cat = idx*NCATS + s->curoffset;
- */
- if (idx < 0)
- *cat = -((-idx) << SHIFT) + s->curoffset + 1;
- else
- *cat = (idx << SHIFT) + s->curoffset;
-
- return 1;
- }
- }
-}
-
-
-/*!
- * \brief Get number of null values.
- *
- * Get a number of null values from stats structure.
- *
- * Note: when reporting values which appear in a map using
- * G_next_cell_stats(), to get stats for null, call
- * G_get_stats_for_null_value() first, since G_next_cell_stats() does
- * not report stats for null.
- *
- * \param count count
- * \param s pointer to Cell_stats structure which holds cell stats info
- */
-void G_get_stats_for_null_value(long *count, const struct Cell_stats *s)
-{
- *count = s->null_data_count;
-}
-
-/*!
- * \brief Free cell stats structure
- *
- * The memory associated with structure <i>s</i> is freed. This
- * routine may be called any time after calling G_init_cell_stats().
- *
- * \param s pointer to Cell_stats structure
- */
-void G_free_cell_stats(struct Cell_stats *s)
-{
- int i;
-
- for (i = 1; i <= s->N; i++)
- G_free(s->node[i].count);
- G_free(s->node);
-}
Deleted: grass/trunk/lib/gis/cell_title.c
===================================================================
--- grass/trunk/lib/gis/cell_title.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/cell_title.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,50 +0,0 @@
-
-/**************************************************************
- * char *G_get_cell_title (name, mapset)
- * char *name name of map file
- * char *mapset mapset containing name
- *
- * returns pointer to string containing cell title. (from cats file)
- *************************************************************/
-
-#include <grass/gis.h>
-
-
-/*!
- * \brief get raster map title
- *
- * If only the map layer title is needed, it is not necessary to read the
- * entire category file into memory. This routine gets the title for raster map
- * <b>name</b> in <b>mapset</b> directly from the category file, and returns
- * a pointer to the title. A legal pointer is always returned. If the map layer
- * does not have a title, then a pointer to the empty string "" is returned.
- *
- * \param name
- * \param mapset
- * \return char *
- */
-
-char *G_get_cell_title(const char *name, const char *mapset)
-{
- FILE *fd;
- int stat;
- char title[1024];
-
- stat = -1;
- fd = G_fopen_old("cats", name, mapset);
- if (fd) {
- stat = 1;
- if (!fgets(title, sizeof title, fd)) /* skip number of cats */
- stat = -1;
- else if (!G_getl(title, sizeof title, fd)) /* read title */
- stat = -1;
-
- fclose(fd);
- }
-
- if (stat < 0)
- *title = 0;
- else
- G_strip(title);
- return G_store(title);
-}
Deleted: grass/trunk/lib/gis/cellstats_eq.c
===================================================================
--- grass/trunk/lib/gis/cellstats_eq.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/cellstats_eq.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,74 +0,0 @@
-#include <grass/gis.h>
-int G_cell_stats_histo_eq(struct Cell_stats *statf, CELL min1, CELL max1, /* input range to be rescaled */
- CELL min2, CELL max2, /* output range */
- int zero, /* include zero if min1 <= 0 <= min2 ? */
- void (*func) (CELL, CELL, CELL))
-{
- long count, total;
- CELL prev = 0;
- CELL cat;
- CELL x;
- CELL newcat = 0;
- int first;
- double span, sum;
- double range2;
-
-
- if (min1 > max1 || min2 > max2)
- return 0;
-
- total = 0;
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf)) {
- if (cat < min1)
- continue;
- if (cat > max1)
- break;
- if (cat == 0 && !zero)
- continue;
-
- total += count;
- }
- if (total <= 0)
- return 0;
-
- range2 = max2 - min2 + 1;
- span = total / range2;
-
- first = 1;
- sum = 0;
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf)) {
- if (cat < min1)
- continue;
- if (cat > max1)
- break;
- if (cat == 0 && !zero)
- continue;
-
- x = (sum + (count / 2.0)) / span;
- if (x < 0)
- x = 0;
- x += min2;
- sum += count;
-
- if (first) {
- prev = cat;
- newcat = x;
- first = 0;
- }
- else if (newcat != x) {
- func(prev, cat - 1, newcat);
- newcat = x;
- prev = cat;
- }
- }
- if (!first) {
- func(prev, cat, newcat);
- if (!zero && min1 <= 0 && max1 >= 0)
- func((CELL) 0, (CELL) 0, (CELL) 0);
- }
-
- return first == 0;
-}
Deleted: grass/trunk/lib/gis/closecell.c
===================================================================
--- grass/trunk/lib/gis/closecell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/closecell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,502 +0,0 @@
-/*!
- * \file gis/closecell.c
- *
- * \brief GIS Library - Close raster file
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#ifdef __MINGW32__
-# include <windows.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include "G.h"
-
-#define FORMAT_FILE "f_format"
-#define QUANT_FILE "f_quant"
-#define NULL_FILE "null"
-
-static int close_old(int);
-static int close_new(int, int);
-
-static int write_fp_format(int fd);
-
-/*!
- * \brief Close a raster map
- *
- * The raster map opened on file descriptor <i>fd</i> is
- * closed. Memory allocated for raster processing is freed. If open
- * for writing, skeletal support files for the new raster map are
- * created as well.
- *
- * <b>Note:</b> If a module wants to explicitly write support files
- * (e.g., a specific color table) for a raster map it creates, it must
- * do so after the raster map is closed. Otherwise the close will
- * overwrite the support files. See \ref
- * Raster_Map_Layer_Support_Routines for routines which write raster
- * support files.
- *
- * If the map is a new floating point, move the <tt>.tmp</tt> file
- * into the <tt>fcell</tt> element, create an empty file in the
- * <tt>cell</tt> directory; write the floating-point range file; write
- * a default quantization file quantization file is set here to round
- * fp numbers (this is a default for now). create an empty category
- * file, with max cat = max value (for backwards compatibility). Move
- * the <tt>.tmp</tt> NULL-value bitmap file to the <tt>cell_misc</tt>
- * directory.
- *
- * \param fd file descriptor
- *
- * \return -1 on error
- * \return 1 on success
- */
-int G_close_cell(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- if (fd < 0 || fd >= G__.fileinfo_count || fcb->open_mode <= 0)
- return -1;
- if (fcb->open_mode == OPEN_OLD)
- return close_old(fd);
-
- return close_new(fd, 1);
-}
-
-/*!
- * \brief Unopen a raster map
- *
- * The raster map opened on file descriptor <i>fd</i> is
- * closed. Memory allocated for raster processing is freed. If open
- * for writing, the raster map is not created and the temporary file
- * created when the raster map was opened is removed (see \ref
- * Creating_and_Opening_New_Raster_Files). This routine is useful when
- * errors are detected and it is desired to not create the new raster
- * map. While it is true that the raster map will not be created if
- * the module exits without closing the file, the temporary file will
- * not be removed at module exit. GRASS database management will
- * eventually remove the temporary file, but the file can be quite
- * large and will take up disk space until GRASS does remove it. Use
- * this routine as a courtesy to the user.
- *
- * \param fd file descriptor
- *
- * \return -1 on error
- * \return 1 on success
- */
-int G_unopen_cell(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- if (fd < 0 || fd >= G__.fileinfo_count || fcb->open_mode <= 0)
- return -1;
- if (fcb->open_mode == OPEN_OLD)
- return close_old(fd);
- else
- return close_new(fd, 0);
-}
-
-static int close_old(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int i;
-
- /* if G__.auto_mask was only allocated for reading map rows to create
- non-existant null rows, and not for actuall mask, free G__.mask_row
- if(G__.auto_mask <=0)
- G_free (G__.mask_buf);
- This is obsolete since now the mask_bus is always allocated
- */
-
- if (fcb->gdal)
- G_close_gdal_link(fcb->gdal);
-
- for (i = 0; i < NULL_ROWS_INMEM; i++)
- G_free(fcb->NULL_ROWS[i]);
-
- if (fcb->cellhd.compressed)
- G_free(fcb->row_ptr);
- G_free(fcb->col_map);
- G_free(fcb->mapset);
- G_free(fcb->data);
- G_free(fcb->name);
- if (fcb->reclass_flag)
- G_free_reclass(&fcb->reclass);
- fcb->open_mode = -1;
-
- if (fcb->map_type != CELL_TYPE) {
- G_quant_free(&fcb->quant);
- xdr_destroy(&fcb->xdrstream);
- }
- close(fd);
-
- return 1;
-}
-
-static void write_support_files(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- struct Categories cats;
- struct History hist;
- CELL cell_min, cell_max;
- char path[GPATH_MAX];
-
- /* remove color table */
- G_remove_colors(fcb->name, "");
-
- /* create a history file */
- G_short_history(fcb->name, "raster", &hist);
- G_write_history(fcb->name, &hist);
-
- /* write the range */
- if (fcb->map_type == CELL_TYPE) {
- G_write_range(fcb->name, &fcb->range);
- G__remove_fp_range(fcb->name);
- }
- /*NOTE: int range for floating point maps is not written out */
- else { /* if(fcb->map_type != CELL_TYPE) */
-
- G_write_fp_range(fcb->name, &fcb->fp_range);
- G_construct_default_range(&fcb->range);
- /* this range will be used to add default rule to quant structure */
- }
-
- if (fcb->map_type != CELL_TYPE)
- fcb->cellhd.format = -1;
- else /* CELL map */
- fcb->cellhd.format = fcb->nbytes - 1;
-
- /* write header file */
- G_put_cellhd(fcb->name, &fcb->cellhd);
-
- /* if map is floating point write the quant rules, otherwise remove f_quant */
- if (fcb->map_type != CELL_TYPE) {
- /* DEFAULT RANGE QUANT
- G_get_fp_range_min_max(&fcb->fp_range, &dcell_min, &dcell_max);
- if(!G_is_d_null_value(&dcell_min) && !G_is_d_null_value(&dcell_max))
- {
- G_get_range_min_max(&fcb->range, &cell_min, &cell_max);
- G_quant_add_rule(&fcb->quant, dcell_min, dcell_max,
- cell_min, cell_max);
- }
- */
- G_quant_round(&fcb->quant);
- if (G_write_quant(fcb->name, fcb->mapset, &fcb->quant) < 0)
- G_warning(_("unable to write quant file!"));
- }
- else {
- /* remove cell_misc/name/f_quant */
- G__file_name_misc(path, "cell_misc", QUANT_FILE, fcb->name,
- fcb->mapset);
- remove(path);
- }
-
- /* create empty cats file */
- G_get_range_min_max(&fcb->range, &cell_min, &cell_max);
- if (G_is_c_null_value(&cell_max))
- cell_max = 0;
- G_init_cats(cell_max, (char *)NULL, &cats);
- G_write_cats(fcb->name, &cats);
- G_free_cats(&cats);
-
- /* write the histogram */
- /* only works for integer maps */
- if ((fcb->map_type == CELL_TYPE)
- && (fcb->want_histogram)) {
- G_write_histogram_cs(fcb->name, &fcb->statf);
- G_free_cell_stats(&fcb->statf);
- }
- else {
- G_remove_histogram(fcb->name);
- }
-}
-
-static int close_new_gdal(int fd, int ok)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- char path[GPATH_MAX];
- int stat = 1;
-
- if (ok) {
- int cell_fd;
-
- G_debug(1, "close %s GDAL", fcb->name);
-
- if (fcb->cur_row < fcb->cellhd.rows) {
- int row;
-
- G_zero_raster_buf(fcb->data, fcb->map_type);
- for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
- G_put_raster_row(fd, fcb->data, fcb->map_type);
- G_free(fcb->data);
- fcb->data = NULL;
- }
-
- /* create path : full null file name */
- G__make_mapset_element_misc("cell_misc", fcb->name);
- G__file_name_misc(path, "cell_misc", NULL_FILE, fcb->name,
- G_mapset());
- remove(path);
-
- /* write 0-length cell file */
- G__make_mapset_element("cell");
- G__file_name(path, "cell", fcb->name, fcb->mapset);
- cell_fd = creat(path, 0666);
- close(cell_fd);
-
- if (fcb->map_type != CELL_TYPE) { /* floating point map */
- if (write_fp_format(fd) != 0) {
- G_warning(_("Error writing floating point format file for map %s"),
- fcb->name);
- stat = -1;
- }
-
- /* write 0-length fcell file */
- G__make_mapset_element("fcell");
- G__file_name(path, "fcell", fcb->name, fcb->mapset);
- cell_fd = creat(path, 0666);
- close(cell_fd);
- }
- else {
- /* remove fcell/name file */
- G__file_name(path, "fcell", fcb->name, fcb->mapset);
- remove(path);
- /* remove cell_misc/name/f_format */
- G__file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
- fcb->mapset);
- remove(path);
- }
-
- if (G_close_gdal_write_link(fcb->gdal) < 0)
- stat = -1;
- }
- else {
- remove(fcb->gdal->filename);
- G_close_gdal_link(fcb->gdal);
- }
-
- /* NOW CLOSE THE FILE DESCRIPTOR */
- close(fd);
- fcb->open_mode = -1;
-
- if (fcb->data != NULL)
- G_free(fcb->data);
-
- if (ok)
- write_support_files(fd);
-
- G_free(fcb->name);
- G_free(fcb->mapset);
-
- if (fcb->map_type != CELL_TYPE)
- G_quant_free(&fcb->quant);
-
- return stat;
-}
-
-static int close_new(int fd, int ok)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int stat;
- char path[GPATH_MAX];
- int row, i;
- const char *CELL_DIR;
-
- if (fcb->gdal)
- return close_new_gdal(fd, ok);
-
- if (ok) {
- switch (fcb->open_mode) {
- case OPEN_NEW_COMPRESSED:
- G_debug(1, "close %s compressed", fcb->name);
- break;
- case OPEN_NEW_UNCOMPRESSED:
- G_debug(1, "close %s uncompressed", fcb->name);
- break;
- }
-
- if (fcb->cur_row < fcb->cellhd.rows) {
- G_zero_raster_buf(fcb->data, fcb->map_type);
- for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
- G_put_raster_row(fd, fcb->data, fcb->map_type);
- G_free(fcb->data);
- fcb->data = NULL;
- }
-
- /* create path : full null file name */
- G__make_mapset_element_misc("cell_misc", fcb->name);
- G__file_name_misc(path, "cell_misc", NULL_FILE, fcb->name,
- G_mapset());
- remove(path);
-
- if (fcb->null_cur_row > 0) {
- /* if temporary NULL file exists, write it into cell_misc/name/null */
- int null_fd;
-
- null_fd = G__open_null_write(fd);
- if (null_fd <= 0)
- return -1;
- if (null_fd < 1)
- return -1;
-
- /* first finish writing null file */
- /* write out the rows stored in memory */
- for (row = fcb->min_null_row; row < fcb->null_cur_row; row++)
- G__write_null_bits(null_fd,
- fcb->NULL_ROWS[row - fcb->min_null_row],
- row, fcb->cellhd.cols, fd);
-
- /* write missing rows */
- if (fcb->null_cur_row < fcb->cellhd.rows) {
- unsigned char *null_work_buf = G__allocate_null_bits(fcb->cellhd.cols);
- G__init_null_bits(null_work_buf, fcb->cellhd.cols);
- for (row = fcb->null_cur_row; row < fcb->cellhd.rows; row++)
- G__write_null_bits(null_fd, null_work_buf, row,
- fcb->cellhd.cols, fd);
- G_free(null_work_buf);
- }
- close(null_fd);
-
- if (rename(fcb->null_temp_name, path)) {
- G_warning(_("Unable to renae null file '%s'"),
- fcb->null_temp_name, path);
- stat = -1;
- }
- else {
- remove(fcb->null_temp_name);
- }
- }
- else {
- remove(fcb->null_temp_name);
- remove(path);
- } /* null_cur_row > 0 */
-
- if (fcb->open_mode == OPEN_NEW_COMPRESSED) { /* auto compression */
- fcb->row_ptr[fcb->cellhd.rows] = lseek(fd, 0L, SEEK_CUR);
- G__write_row_ptrs(fd);
- }
-
- if (fcb->map_type != CELL_TYPE) { /* floating point map */
- int cell_fd;
-
- if (write_fp_format(fd) != 0) {
- G_warning(_("Error writing floating point format file for map <%s>"),
- fcb->name);
- stat = -1;
- }
-
- /* now write 0-length cell file */
- G__make_mapset_element("cell");
- cell_fd =
- creat(G__file_name(path, "cell", fcb->name, fcb->mapset),
- 0666);
- close(cell_fd);
- CELL_DIR = "fcell";
- }
- else {
- /* remove fcell/name file */
- G__file_name(path, "fcell", fcb->name, fcb->mapset);
- remove(path);
- /* remove cell_misc/name/f_format */
- G__file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
- fcb->mapset);
- remove(path);
- CELL_DIR = "cell";
- close(fd);
- }
- } /* ok */
- /* NOW CLOSE THE FILE DESCRIPTOR */
-
- close(fd);
- fcb->open_mode = -1;
-
- if (fcb->data != NULL)
- G_free(fcb->data);
-
- if (fcb->null_temp_name != NULL) {
- G_free(fcb->null_temp_name);
- fcb->null_temp_name = NULL;
- }
-
- /* if the cell file was written to a temporary file
- * move this temporary file into the cell file
- * if the move fails, tell the user, but go ahead and create
- * the support files
- */
- stat = 1;
- if (ok && (fcb->temp_name != NULL)) {
- G__file_name(path, CELL_DIR, fcb->name, fcb->mapset);
- remove(path);
- if (rename(fcb->temp_name, path)) {
- G_warning(_("Unable to rename cell file '%s'"),
- fcb->temp_name, path);
- stat = -1;
- }
- else {
- remove(fcb->temp_name);
- }
- }
-
- if (fcb->temp_name != NULL) {
- G_free(fcb->temp_name);
- }
-
- if (ok)
- write_support_files(fd);
-
- G_free(fcb->name);
- G_free(fcb->mapset);
-
- for (i = 0; i < NULL_ROWS_INMEM; i++)
- G_free(fcb->NULL_ROWS[i]);
-
- if (fcb->map_type != CELL_TYPE)
- G_quant_free(&fcb->quant);
-
- return stat;
-}
-
-/* returns 0 on success, 1 on failure */
-static int write_fp_format(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- struct Key_Value *format_kv;
- char path[GPATH_MAX];
- int stat;
-
- if (fcb->map_type == CELL_TYPE) {
- G_warning(_("unable to write f_format file for CELL maps"));
- return 0;
- }
- format_kv = G_create_key_value();
- if (fcb->map_type == FCELL_TYPE)
- G_set_key_value("type", "float", format_kv);
- else
- G_set_key_value("type", "double", format_kv);
-
- G_set_key_value("byte_order", "xdr", format_kv);
-
- if (fcb->open_mode == OPEN_NEW_COMPRESSED)
- G_set_key_value("lzw_compression_bits", "-1", format_kv);
-
- G__make_mapset_element_misc("cell_misc", fcb->name);
- G__file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name, fcb->mapset);
- G_write_key_value_file(path, format_kv, &stat);
-
- G_free_key_value(format_kv);
-
- return stat;
-}
Deleted: grass/trunk/lib/gis/color_compat.c
===================================================================
--- grass/trunk/lib/gis/color_compat.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_compat.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,314 +0,0 @@
-/*!
- * \file gis/color_compat.c
- *
- * \brief GIS Library - Predefined color tables
- *
- * (C) 2007-2009 Glynn Clements and the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Glynn Clements <glynn at gclements.plus.com>
- */
-
-#include <grass/gis.h>
-
-/*!
- * \brief Make color wave (integer)
- *
- * Generates a color table with 3 sections: red only, green only, and
- * blue only, each increasing from none to full intensity and back
- * down to none. This table is good for continuous data like
- * elevation.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_wave_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "wave", min, max);
-}
-
-/*!
- * \brief Make color wave (floating-point)
- *
- * Generates a color table with 3 sections: red only, green only, and
- * blue only, each increasing from none to full intensity and back
- * down to none. This table is good for continuous data like
- * elevation.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_wave_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "wave", min, max);
-}
-
-/*!
- * \brief Create RYG color table (integer)
- *
- * Generates a color table red-yellow-green.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_ryg_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "ryg", min, max);
-}
-
-/*!
- * \brief Create RYG color table (floating-point)
- *
- * Generates a color table red-yellow-green.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_ryg_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "ryg", min, max);
-}
-
-/*!
- * \brief Make color ramp (integer)
- *
- * Generates a color table with 3 sections: red only, green only, and
- * blue only, each increasing from none to full intensity. This table
- * is good for continuous data, such as elevation.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_ramp_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "ramp", min, max);
-}
-
-/*!
- * \brief Make color ramp (floating-point)
- *
- * Generates a color table with 3 sections: red only, green only, and
- * blue only, each increasing from none to full intensity. This table
- * is good for continuous data, such as elevation.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_ramp_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "ramp", min, max);
-}
-
-/*!
- * \brief Make rainbow colors (integer)
- *
- * Generates a "shifted" rainbow color table - yellow to green to cyan
- * to blue to magenta to red. The color table is based on rainbow
- * colors. (Normal rainbow colors are red, orange, yellow, green,
- * blue, indigo, and violet.) This table is good for continuous data,
- * such as elevation.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_rainbow_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "rainbow", min, max);
-}
-
-/*!
- * \brief Make rainbow colors (floating-point)
- *
- * Generates a "shifted" rainbow color table - yellow to green to cyan
- * to blue to magenta to red. The color table is based on rainbow
- * colors. (Normal rainbow colors are red, orange, yellow, green,
- * blue, indigo, and violet.) This table is good for continuous data,
- * such as elevation.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_rainbow_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "rainbow", min, max);
-}
-
-/*!
- * \brief Create GYR color table (integer)
- *
- * Generates a color table green-yellow-red.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_gyr_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "gyr", min, max);
-}
-
-/*!
- * \brief Create GYR color table (floating-point)
- *
- * Generates a color table green-yellow-red.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_gyr_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "gyr", min, max);
-}
-
-/*!
- * \brief Make linear grey scale (integer)
- *
- * Generates a grey scale color table. Each color is a level of grey,
- * increasing from black to white.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_grey_scale_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "grey", min, max);
-}
-
-/*!
- * \brief Make linear grey scale (floating-point)
- *
- * Generates a grey scale color table. Each color is a level of grey,
- * increasing from black to white.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_grey_scale_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "grey", min, max);
-}
-
-/*!
- * \brief Create BYR color table (integer)
- *
- * Generates a color table blue-yellow-red.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_byr_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "byr", min, max);
-}
-
-/*!
- * \brief Create BYR color table (floating-point)
- *
- * Generates a color table blue-yellow-red.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_byr_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "byr", min, max);
-}
-
-/*!
- * \brief Create BGYR color table (integer)
- *
- * Generates a color table blue-green-yellow-red.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_bgyr_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "bgyr", min, max);
-}
-
-/*!
- * \brief Create BGYR color table (floating-point)
- *
- * Generates a color table blue-green-yellow-red.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_bgyr_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "bgyr", min, max);
-}
-
-/*!
- * \brief Create BYG color table (integer)
- *
- * Generates a color table blue-yellow-green.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_byg_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "byg", min, max);
-}
-
-/*!
- * \brief Create BYG color table (floating-point)
- *
- * Generates a color table blue-yellow-green.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_byg_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "byg", min, max);
-}
-
-/*!
- * \brief Make aspect colors (integer)
- *
- * Generates a color table for aspect data.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_aspect_colors(struct Colors *colors, CELL min, CELL max)
-{
- G_make_colors(colors, "aspect", min, max);
-}
-
-/*!
- * \brief Make aspect colors (floating-point)
- *
- * Generates a color table for aspect data.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param min minimum value
- * \param max maximum value
- */
-void G_make_aspect_fp_colors(struct Colors *colors, DCELL min, DCELL max)
-{
- G_make_fp_colors(colors, "aspect", min, max);
-}
Deleted: grass/trunk/lib/gis/color_free.c
===================================================================
--- grass/trunk/lib/gis/color_free.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_free.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,103 +0,0 @@
-/*!
- * \file gis/color_free.c
- *
- * \brief GIS Library - Free Colors structure
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <stdlib.h>
-#include <grass/gis.h>
-
-/*!
- * \brief Free color structure memory
- *
- * The dynamically allocated memory associated with the <i>colors</i>
- * structure is freed.
- *
- * <b>Note:</b> This routine may be used after G_read_colors() as well
- * as after G_init_colors().
- *
- * \param colors pointer to Colors structure
- */
-void G_free_colors(struct Colors *colors)
-{
- G__color_reset(colors);
- G_init_colors(colors);
-}
-
-/*!
- \brief Free color rules structure
-
- Note: Only for internal use.
-
- \param cp pointer to _Color_Info structure
-*/
-void G__color_free_rules(struct _Color_Info_ *cp)
-{
- struct _Color_Rule_ *rule, *next;
-
- for (rule = cp->rules; rule; rule = next) {
- next = rule->next;
- G_free(rule);
- }
- cp->rules = NULL;
-}
-
-/*!
- \brief Free color rules structure
-
- Note: Only for internal use.
-
- \param cp pointer to _Color_Info structure
-*/
-void G__color_free_lookup(struct _Color_Info_ *cp)
-{
- if (cp->lookup.active) {
- G_free(cp->lookup.red);
- G_free(cp->lookup.blu);
- G_free(cp->lookup.grn);
- G_free(cp->lookup.set);
- cp->lookup.active = 0;
- }
-}
-
-/*!
- \brief Free color rules structure
-
- Note: Only for internal use.
-
- \param cp pointer to _Color_Info structure
-*/
-void G__color_free_fp_lookup(struct _Color_Info_ *cp)
-{
- if (cp->fp_lookup.active) {
- G_free(cp->fp_lookup.vals);
- G_free(cp->fp_lookup.rules);
- cp->fp_lookup.active = 0;
- cp->fp_lookup.nalloc = 0;
- }
-}
-
-/*!
- \brief Reset colors structure
-
- Note: Only for internal use.
-
- This routine should NOT init the colors.
-
- \param colors pointer to Colors structure
-*/
-void G__color_reset(struct Colors *colors)
-{
- G__color_free_lookup(&colors->fixed);
- G__color_free_lookup(&colors->modular);
- G__color_free_rules(&colors->fixed);
- G__color_free_rules(&colors->modular);
- colors->version = 0;
-}
Deleted: grass/trunk/lib/gis/color_get.c
===================================================================
--- grass/trunk/lib/gis/color_get.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,193 +0,0 @@
-/*!
- * \file gis/color_get.c
- *
- * \brief GIS Library - Get colors from a raster map.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-
-/*!
- * \brief Get a category color.
- *
- * \todo To be removed, replaced by G_get_raster_color().
- *
- * The <i>red, green</i>, and <i>blue</i> intensities for the color
- * associated with category <i>n</i> are extracted from the
- * <i>colors</i> structure. The intensities will be in the range 0 -
- * 255. Also works for null cells.
- *
- * \param n cell to get color from
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param colors pointer to Colors structure which holds color info
- *
- * \return 1 if color is set
- * \return 0 if color is not set
- */
-int G_get_color(CELL n, int *red, int *grn, int *blu, struct Colors *colors)
-{
- CELL cat;
- unsigned char r, g, b, set;
-
- cat = n;
- G_lookup_colors(&cat, &r, &g, &b, &set, 1, colors);
-
- *red = (int)r;
- *grn = (int)g;
- *blu = (int)b;
-
- return (int)set;
-}
-
-/*!
- * \brief Gets color from raster map
- *
- * Looks up the rgb colors for <i>rast</i> in the color table
- * <i>colors</i>.
- *
- * \param rast raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param colors pointer to Colors structure which holds color info
- * \param map_type map type (CELL, FCELL, DCELL)
- *
- * \return 1 if color is set
- * \return 0 if color is not set
- */
-int G_get_raster_color(const void *rast,
- int *red, int *grn, int *blu,
- struct Colors *colors, RASTER_MAP_TYPE map_type)
-{
- unsigned char r, g, b, set;
-
- G_lookup_raster_colors(rast, &r, &g, &b, &set, 1, colors, map_type);
-
- *red = (int)r;
- *grn = (int)g;
- *blu = (int)b;
-
- return (int)set;
-}
-
-/*!
- * \brief Gets color from raster map (CELL)
- *
- * Looks up the rgb colors for <i>rast</i> in the color table
- * <i>colors</i>.
- *
- * \param rast raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param colors pointer to Colors structure which holds color info
- *
- * \return 1 if color is set
- * \return 0 if color is not set
- */
-int G_get_c_raster_color(const CELL * rast,
- int *red, int *grn, int *blu, struct Colors *colors)
-{
- return G_get_raster_color(rast, red, grn, blu, colors, CELL_TYPE);
-}
-
-/*!
- * \brief Gets color from raster map (FCELL)
- *
- * Looks up the rgb colors for <i>rast</i> in the color table
- * <i>colors</i>.
- *
- * \param rast raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param colors pointer to Colors structure which holds color info
- *
- * \return 1 if color is set
- * \return 0 if color is not set
- */
-int G_get_f_raster_color(const FCELL * rast,
- int *red, int *grn, int *blu, struct Colors *colors)
-{
- return G_get_raster_color(rast, red, grn, blu, colors, FCELL_TYPE);
-}
-
-/*!
- * \brief Gets color from raster map (DCELL)
- *
- * Looks up the rgb colors for <i>rast</i> in the color table
- * <i>colors</i>.
- *
- * \param rast raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param colors pointer to Colors structure which holds color info
- *
- * \return 1 if color is set
- * \return 0 if color is not set
- */
-int G_get_d_raster_color(const DCELL * rast,
- int *red, int *grn, int *blu, struct Colors *colors)
-{
- return G_get_raster_color(rast, red, grn, blu, colors, DCELL_TYPE);
-}
-
-/*!
- * \brief Gets color for null value.
- *
- * Puts the red, green, and blue components of <i>colors</i> for the
- * NULL-value into <i>red, grn, and blu</i>.
- *
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param colors pointer to Colors structure which holds color info
- */
-void G_get_null_value_color(int *red, int *grn, int *blu,
- const struct Colors *colors)
-{
- if (colors->null_set) {
- *red = (int)colors->null_red;
- *grn = (int)colors->null_grn;
- *blu = (int)colors->null_blu;
- }
- else if (colors->undef_set) {
- *red = (int)colors->undef_red;
- *grn = (int)colors->undef_grn;
- *blu = (int)colors->undef_blu;
- }
- else
- *red = *blu = *grn = 255; /* white */
-}
-
-/*!
- * \brief Gets default color.
- *
- * Puts the red, green, and blue components of the <tt>"default"</tt>
- * color into <i>red, grn, and blu</i>.
- *
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param colors pointer to Colors structure which holds color info
- */
-void G_get_default_color(int *red, int *grn, int *blu,
- const struct Colors *colors)
-{
- if (colors->undef_set) {
- *red = (int)colors->undef_red;
- *grn = (int)colors->undef_grn;
- *blu = (int)colors->undef_blu;
- }
- else
- *red = *blu = *grn = 255; /* white */
-}
Deleted: grass/trunk/lib/gis/color_hist.c
===================================================================
--- grass/trunk/lib/gis/color_hist.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_hist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,155 +0,0 @@
-/*!
- * \file gis/color_hist.c
- *
- * \brief GIS Library - histogram grey scale colors
- *
- * (C) 2007-2009 Glynn Clements and the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Glynn Clements <glynn at gclements.plus.com>
- */
-
-#include <math.h>
-#include <grass/gis.h>
-
-/*!
- * \brief Make histogram-stretched grey colors
- *
- * Generates a histogram contrast-stretched grey scale color table
- * that goes from the, histogram information in the Cell_stats
- * structure (see \ref Raster_Histograms).
- *
- * Color range is 0-255.
- *
- * \param colors pointer to Colors structure which holds color info
- * \param stalf pointer to Cell_stats structure which holds cell stats info
- */
-void G_make_histogram_eq_colors(struct Colors *colors,
- struct Cell_stats *statf)
-{
- long count, total;
- CELL prev = 0, cat;
- double span, sum;
- int first;
- int x, grey;
- int R, G, B;
-
- G_init_colors(colors);
-
- G_str_to_color(DEFAULT_BG_COLOR, &R, &G, &B);
- G_set_null_value_color(R, G, B, colors);
-
- total = 0;
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf))
- if (count > 0)
- total += count;
- if (total <= 0)
- return;
-
- span = total / 256.0;
- first = 1;
- grey = 0;
- sum = 0.0;
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf)) {
- if (count <= 0)
- continue;
- x = (sum + (count / 2.0)) / span;
- if (x < 0)
- x = 0;
- else if (x > 255)
- x = 255;
- sum += count;
- if (first) {
- prev = cat;
- grey = x;
- first = 0;
- }
- else if (grey != x) {
- G_add_color_rule(prev, grey, grey, grey, cat - 1, grey, grey,
- grey, colors);
- grey = x;
- prev = cat;
- }
- }
- if (!first) {
- G_add_color_rule(prev, grey, grey, grey, cat, grey, grey, grey,
- colors);
- }
-}
-
-/*!
- \brief Generates histogram with normalized log transformed grey scale.
-
- Generates histogram with normalized log transformed grey scale from
- cell stats structure info. Color range is 0-255.
-
- \param colors pointer to Colors structure which holds color info
- \param stalf pointer to Cell_stats structure which holds cell stats info
- \param min minimum value
- \param max maximum value
-*/
-void G_make_histogram_log_colors(struct Colors *colors,
- struct Cell_stats *statf, int min, int max)
-{
- long count, total;
- double lmin, lmax;
- CELL prev = 0, cat;
- int first;
- int x, grey;
- int R, G, B;
-
- G_init_colors(colors);
-
- G_str_to_color(DEFAULT_BG_COLOR, &R, &G, &B);
- G_set_null_value_color(R, G, B, colors);
-
- total = 0;
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf))
- if (count > 0)
- total += count;
- if (total <= 0)
- return;
-
- first = 1;
- grey = 0;
-
- lmin = log(min);
- lmax = log(max);
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf)) {
- if (count <= 0)
- continue;
-
- /* log transform normalized */
- x = (int)(255 * (log(cat) - lmin) / (lmax - lmin));
-
- if (x < 0)
- x = 0;
- else if (x > 255)
- x = 255;
- if (first) {
- prev = cat;
- grey = x;
- first = 0;
- }
- else if (grey != x) {
- G_add_color_rule(prev, grey, grey, grey, cat - 1, grey, grey,
- grey, colors);
- grey = x;
- prev = cat;
- }
- }
- if (!first) {
- G_add_color_rule(prev, grey, grey, grey, cat, grey, grey, grey,
- colors);
- }
-}
Deleted: grass/trunk/lib/gis/color_init.c
===================================================================
--- grass/trunk/lib/gis/color_init.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_init.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,49 +0,0 @@
-/*!
- * \file gis/color_init.c
- *
- * \brief GIS Library - Initialize Colors structure
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-
-/*!
- * \brief Initialize color structure
- *
- * The <i>colors</i> structure is initialized for subsequent calls
- * to G_add_color_rule() and G_set_color().
- *
- * \param colors pointer to Colors structure
- */
-void G_init_colors(struct Colors *colors)
-{
- colors->version = 0;
- colors->null_set = 0;
- colors->undef_set = 0;
- colors->shift = 0.0;
- colors->invert = 0;
- colors->cmin = 0;
- colors->is_float = 0;
- colors->cmax = -1;
- colors->fixed.min = 0;
- colors->fixed.max = -1;
- colors->fixed.rules = NULL;
- colors->fixed.n_rules = 0;
- colors->fixed.lookup.active = 0;
- colors->fixed.fp_lookup.active = 0;
- colors->fixed.fp_lookup.nalloc = 0;
- colors->modular.min = 0;
- colors->modular.max = -1;
- colors->modular.rules = NULL;
- colors->modular.n_rules = 0;
- colors->modular.lookup.active = 0;
- colors->modular.fp_lookup.active = 0;
- colors->modular.fp_lookup.nalloc = 0;
- colors->organizing = 0;
-}
Deleted: grass/trunk/lib/gis/color_insrt.c
===================================================================
--- grass/trunk/lib/gis/color_insrt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_insrt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,108 +0,0 @@
-/* This routine is public only because source is in different files.
- * It should NEVER be called directly.
- * It is used by G_add_color_rule() and G__read_old_colors().
- * These routines know when it is approriate to call this routine.
- */
-#include <grass/gis.h>
-#define umalloc(n) (unsigned char *) G_malloc((size_t)n)
-#define urealloc(s,n) (unsigned char *) G_realloc(s,(size_t)n)
-
-#define LIMIT(x) if (x < 0) x = 0; else if (x > 255) x = 255;
-
-int G__insert_color_into_lookup(CELL cat,
- int red, int grn, int blu,
- struct _Color_Info_ *cp)
-{
- long nalloc;
- long i;
- long newlen, curlen, gap;
-
- LIMIT(red);
- LIMIT(grn);
- LIMIT(blu);
-
- /* first color? */
- if (!cp->lookup.active) {
- cp->lookup.active = 1;
- cp->lookup.nalloc = 256;
- cp->lookup.red = umalloc(cp->lookup.nalloc);
- cp->lookup.grn = umalloc(cp->lookup.nalloc);
- cp->lookup.blu = umalloc(cp->lookup.nalloc);
- cp->lookup.set = umalloc(cp->lookup.nalloc);
- cp->max = cp->min = cat;
- }
-
- /* extend the color table? */
- else if (cat > cp->max) {
- curlen = cp->max - cp->min + 1;
- newlen = cat - cp->min + 1;
- nalloc = newlen;
- if (nalloc != (int)nalloc) /* check for int overflow */
- return -1;
-
- if (nalloc > cp->lookup.nalloc) {
- while (cp->lookup.nalloc < nalloc)
- cp->lookup.nalloc += 256;
- nalloc = cp->lookup.nalloc;
-
- cp->lookup.red = urealloc((char *)cp->lookup.red, nalloc);
- cp->lookup.grn = urealloc((char *)cp->lookup.grn, nalloc);
- cp->lookup.blu = urealloc((char *)cp->lookup.blu, nalloc);
- cp->lookup.set = urealloc((char *)cp->lookup.set, nalloc);
- }
-
- /* fill in gap with white */
- for (i = curlen; i < newlen; i++) {
- cp->lookup.red[i] = 255;
- cp->lookup.grn[i] = 255;
- cp->lookup.blu[i] = 255;
- cp->lookup.set[i] = 0;
- }
- cp->max = cat;
- }
- else if (cat < cp->min) {
- curlen = cp->max - cp->min + 1;
- newlen = cp->max - cat + 1;
- gap = newlen - curlen;
- nalloc = newlen;
- if (nalloc != (int)nalloc) /* check for int overflow */
- return -1;
-
- if (nalloc > cp->lookup.nalloc) {
- while (cp->lookup.nalloc < nalloc)
- cp->lookup.nalloc += 256;
- nalloc = cp->lookup.nalloc;
-
- cp->lookup.red = urealloc((char *)cp->lookup.red, nalloc);
- cp->lookup.grn = urealloc((char *)cp->lookup.grn, nalloc);
- cp->lookup.blu = urealloc((char *)cp->lookup.blu, nalloc);
- cp->lookup.set = urealloc((char *)cp->lookup.set, nalloc);
- }
-
- /* shift the table to make room in front */
- for (i = 1; i <= curlen; i++) {
- cp->lookup.red[newlen - i] = cp->lookup.red[curlen - i];
- cp->lookup.grn[newlen - i] = cp->lookup.grn[curlen - i];
- cp->lookup.blu[newlen - i] = cp->lookup.blu[curlen - i];
- cp->lookup.set[newlen - i] = cp->lookup.set[curlen - i];
- }
-
- /* fill in gap with white */
- for (i = 1; i < gap; i++) {
- cp->lookup.red[i] = 255;
- cp->lookup.grn[i] = 255;
- cp->lookup.blu[i] = 255;
- cp->lookup.set[i] = 0;
- }
- cp->min = cat;
- }
-
- /* set the color! */
- i = cat - cp->min;
- cp->lookup.red[i] = red;
- cp->lookup.grn[i] = grn;
- cp->lookup.blu[i] = blu;
- cp->lookup.set[i] = 1;
-
- return 1;
-}
Deleted: grass/trunk/lib/gis/color_invrt.c
===================================================================
--- grass/trunk/lib/gis/color_invrt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_invrt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +0,0 @@
-#include <grass/gis.h>
-
-void G_invert_colors(struct Colors *colors)
-{
- colors->invert = !colors->invert;
-}
Deleted: grass/trunk/lib/gis/color_look.c
===================================================================
--- grass/trunk/lib/gis/color_look.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_look.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,475 +0,0 @@
-/*!
- * \file gis/color_lookup.c
- *
- * \brief GIS Library - Lookup array of colors
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#include <math.h>
-#include <grass/gis.h>
-
-/*!
- * \brief Lookup an array of colors
- *
- * \todo To be removed, replaced by G_lookup_c_raster_colors().
- *
- * Extracts colors for an array of <i>cell</i> values. The colors
- * for the <i>n</i> values in the <i>cell</i> array are stored in
- * the <i>red, green</i>, and <i>blue</i> arrays. The values in the
- * <i>set</i> array will indicate if the corresponding <i>cell</i>
- * value has a color or not (1 means it does, 0 means it does not).
- *
- * The programmer must allocate the <i>red, green, blue</i>, and
- * <b>set</b> arrays to be at least dimension <i>n</i>.
- *
- * <b>Note:</b> The <i>red, green</i>, and <i>blue</i> intensities
- * will be in the range 0 - 255.
- *
- * Modified to return a color for NULL-values.
- *
- * \param cell raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param set array which indicates if color is set or not
- * \param n number of values
- * \param colors pointer to Colors structure which holds color info
- */
-void G_lookup_colors(const CELL * cell,
- unsigned char *red, unsigned char *grn,
- unsigned char *blu, unsigned char *set, int n,
- struct Colors *colors)
-{
- G_lookup_c_raster_colors(cell, red, grn, blu, set, n, colors);
-}
-
-/*!
- * \brief Lookup an array of colors
- *
- * Extracts colors for an array of <i>cell</i> values. The colors
- * for the <i>n</i> values in the <i>cell</i> array are stored in
- * the <i>red, green</i>, and <i>blue</i> arrays. The values in the
- * <i>set</i> array will indicate if the corresponding <i>cell</i>
- * value has a color or not (1 means it does, 0 means it does not).
- *
- * The programmer must allocate the <i>red, green, blue</i>, and
- * <b>set</b> arrays to be at least dimension <i>n</i>.
- *
- * <b>Note:</b> The <i>red, green</i>, and <i>blue</i> intensities
- * will be in the range 0 - 255.
- *
- * Modified to return a color for NULL-values.
- *
- * \param cell raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param set array which indicates if color is set or not
- * \param n number of values
- * \param colors pointer to Colors structure which holds color info
- */
-void G_lookup_c_raster_colors(const CELL * cell,
- unsigned char *red, unsigned char *grn,
- unsigned char *blu, unsigned char *set, int n,
- struct Colors *colors)
-{
- G__organize_colors(colors); /* make sure the lookup tables are in place */
-
- G_zero((char *)set, n * sizeof(unsigned char));
-
- /* first lookup the fixed colors */
- G__lookup_colors((void *)cell, red, grn, blu, set, n, colors, 0, 0,
- CELL_TYPE);
-
- /* now lookup unset colors using the modular rules */
- G__lookup_colors((void *)cell, red, grn, blu, set, n, colors, 1, 0,
- CELL_TYPE);
-}
-
-/*!
- * \brief Lookup an array of colors
- *
- * - If the <em>map_type</em> is CELL_TYPE, calls G_lookup_colors()
- * - If the <em>map_type</em> is FCELL_TYPE, calls G_lookup_f_raster_colors()
- * - If the <em>map_type</em> is DCELL_TYPE, calls G_lookup_d_raster_colors()
- *
- * \param raster raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param set array which indicates if color is set or not
- * \param n number of values
- * \param colors pointer to Colors structure which holds color info
- * \param map_type raster type (CELL, FCELL, DCELL)
- */
-void G_lookup_raster_colors(const void *raster,
- unsigned char *red, unsigned char *grn,
- unsigned char *blu, unsigned char *set, int n,
- struct Colors *colors, RASTER_MAP_TYPE map_type)
-{
- G__organize_colors(colors); /* make sure the lookup tables are in place */
- /* in case of float color rules, fp_lookup table is created */
-
- G_zero((char *)set, n * sizeof(unsigned char));
-
- /* first lookup the fixed colors */
- G__lookup_colors(raster, red, grn, blu, set, n, colors, 0, 0, map_type);
-
- /* now lookup unset colors using the modular rules */
- G__lookup_colors(raster, red, grn, blu, set, n, colors, 1, 0, map_type);
-}
-
-/*!
- * \brief Lookup an array of colors (FCELL)
- *
- * Converts the <em>n</em> floating-point values in the <em>fcell</em>
- * array to their <em>r,g,b</em> color components. Embedded
- * NULL-values are handled properly as well.
- *
- * \param fcell raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param set array which indicates if color is set or not
- * \param n number of values
- * \param colors pointer to Colors structure which holds color info
- */
-void G_lookup_f_raster_colors(const FCELL * fcell, unsigned char *red,
- unsigned char *grn, unsigned char *blu,
- unsigned char *set, int n, struct Colors *colors)
-{
- G__organize_colors(colors); /* make sure the lookup tables are in place */
- /* in case of float color rules, fp_lookup table is created */
-
- G_zero((char *)set, n * sizeof(unsigned char));
-
- /* first lookup the fixed colors */
- G__lookup_colors((void *)fcell, red, grn, blu, set, n, colors, 0, 0,
- FCELL_TYPE);
-
- /* now lookup unset colors using the modular rules */
- G__lookup_colors((void *)fcell, red, grn, blu, set, n, colors, 1, 0,
- FCELL_TYPE);
-}
-
-/*!
- * \brief Lookup an array of colors (DCELL)
- *
- * Converts the <em>n</em> double-precision values in the
- * <em>dcell</em> array to their <em>r,g,b</em> color
- * components. Embedded NULL-values are handled properly as well.
- *
- * \param dcell raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param set array which indicates if color is set or not
- * \param n number of values
- * \param colors pointer to Colors structure which holds color info
- */
-void G_lookup_d_raster_colors(const DCELL * dcell, unsigned char *red,
- unsigned char *grn, unsigned char *blu,
- unsigned char *set, int n, struct Colors *colors)
-{
- G__organize_colors(colors); /* make sure the lookup tables are in place */
- /* in case of float color rules, fp_lookup table is created */
-
- G_zero((char *)set, n * sizeof(unsigned char));
-
- /* first lookup the fixed colors */
- G__lookup_colors((void *)dcell, red, grn, blu, set, n, colors, 0, 0,
- DCELL_TYPE);
-
- /* now lookup unset colors using the modular rules */
- G__lookup_colors((void *)dcell, red, grn, blu, set, n, colors, 1, 0,
- DCELL_TYPE);
-}
-
-
-static int less_or_equal(double x, double y)
-{
- if (x <= y)
- return 1;
- else
- return 0;
-}
-
-static int less(double x, double y)
-{
- if (x < y)
- return 1;
- else
- return 0;
-}
-
-/*!
- * \brief Lookup an array of colors
- *
- * \param raster raster cell value
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param set array which indicates if color is set or not
- * \param n number of values
- * \param colors pointer to Colors structure which holds color info
- * \param mod
- * \param rules_only
- * \param data_type raster type (CELL, FCELL, DCELL)
- */
-void G__lookup_colors(const void *raster, unsigned char *red,
- unsigned char *grn, unsigned char *blu,
- unsigned char *set, int n, struct Colors *colors,
- int mod, int rules_only, RASTER_MAP_TYPE data_type)
-{
- struct _Color_Info_ *cp;
- struct _Color_Rule_ *rule;
- DCELL dmin, dmax, val, dmod = 0L, shift;
- CELL cat, min, max;
- const void *ptr, *last_ptr = NULL;
- int invert;
- int found, r, g, b;
- int cell_type;
- int lookup, max_ind, min_ind, try;
- int (*lower) ();
-
- if (mod)
- cp = &colors->modular;
- else
- cp = &colors->fixed;
-
- /* rules_only will be true only when called by G__organize_colors()
- * when building the integer lookup talbes from the rules,
- * so do not shift, invert, use lookup table or modulate cats.
- * these operations will happen when lookup is called by user code
- */
- /* we want min, max for cp, not min, max overall */
- dmin = cp->min;
- dmax = cp->max;
- min = (CELL) dmin;
- max = (CELL) dmax + 1;
-
- cell_type = (data_type == CELL_TYPE);
-
- if (rules_only) {
- shift = invert = lookup = mod = 0;
- }
- else {
- if (mod) {
- dmod = dmax - dmin;
- /* for integers color table we make a gap of 1 in order
- to make the same colors as before */
- if (cell_type)
- dmod += 1;
- }
-
- shift = colors->shift;
- invert = colors->invert;
- lookup = cp->lookup.active;
- }
-
- ptr = raster;
-
- for (; n-- > 0;
- ptr =
- G_incr_void_ptr(ptr, G_raster_size(data_type)), red++, grn++, blu++,
- *set++ = found) {
- /* if the cell is the same as last one, use the prev color values */
- if (ptr != raster && G_raster_cmp(ptr, last_ptr, data_type) == 0) {
- *red = *(red - 1);
- *blu = *(blu - 1);
- *grn = *(grn - 1);
- found = *(set - 1);
- last_ptr = ptr;
- continue;
- }
- val = G_get_raster_value_d(ptr, data_type);
- /* DEBUG fprintf (stderr, "val: %.4lf\n", val); */
- last_ptr = ptr;
-
- if (*set) {
- found = 1;
- continue;
- }
-
- if (G_is_null_value(ptr, data_type)) {
- /* returns integers, not unsigned chars */
- G_get_null_value_color(&r, &g, &b, colors);
- *red = r;
- *grn = g;
- *blu = b;
- found = 1;
- continue;
- }
-
- if (shift && val >= dmin && val <= dmax) {
- val += shift;
- while (val < dmin)
- val += dmax - dmin + 1;
- while (val > dmax)
- val -= dmax - dmin + 1;
- }
-
- /* invert non-null data around midpoint of range [min:max] */
- if (invert)
- val = dmin + dmax - val;
-
- if (mod) {
- if (dmod > 0) {
- val -= dmin;
- while (val < 0)
- val += dmod;
- val = val - dmod * floor(val / dmod);
- val += dmin;
- }
- else
- val = dmin;
- }
-
- cat = (CELL) val;
-
- found = 0;
-
- /* for non-null integers try to look them up in lookup table */
- /* note: lookup table exists only for integer maps, and we also must
- check if val is really integer */
-
- if (lookup && ((double)cat - val == 0.)) {
- if (cat >= min && cat <= max) {
- cat -= min;
- if (cp->lookup.set[cat]) {
- *red = cp->lookup.red[cat];
- *grn = cp->lookup.grn[cat];
- *blu = cp->lookup.blu[cat];
- found = 1;
- /*DEBUG
- fprintf (stderr, "lookup %d %.2lf %d %d %d\n\n", cat, val, *red, *grn, *blu);
- */
- }
- }
- }
-
- if (found)
- continue;
-
- /* if floating point lookup table is active, look up in there */
- if (cp->fp_lookup.active) {
- try = (cp->fp_lookup.nalloc - 1) / 2;
- min_ind = 0;
- max_ind = cp->fp_lookup.nalloc - 2;
- while (1) {
- /* when the rule for the interval is NULL, we exclude the end points.
- when it exists, we include the end-points */
- if (cp->fp_lookup.rules[try])
- lower = less;
- else
- lower = less_or_equal;
- /* DEBUG
- fprintf (stderr, "%d %d %d %lf %lf %lf\n", min_ind, try, max_ind,
- cp->fp_lookup.vals[try-1],
- val,
- cp->fp_lookup.vals[try]);
- */
-
- if (lower(cp->fp_lookup.vals[try + 1], val)) { /* recurse to the second half */
- min_ind = try + 1;
- /* must be still < nalloc-1, since number is within the range */
- try = (max_ind + min_ind) / 2;
- if (min_ind > max_ind) {
- rule = NULL;
- break;
- }
- continue;
- }
- if (lower(val, cp->fp_lookup.vals[try])) { /* recurse to the second half */
- max_ind = try - 1;
- /* must be still >= 0, since number is within the range */
- try = (max_ind + min_ind) / 2;
- if (max_ind < min_ind) {
- rule = NULL;
- break;
- }
- continue;
- }
- rule = cp->fp_lookup.rules[try];
- break;
- }
- }
- else {
- /* find the [low:high] rule that applies */
- for (rule = cp->rules; rule; rule = rule->next) {
- /* DEBUG
- fprintf (stderr, "%.2lf %.2lf %.2lf\n",
- val, rule->low.value, rule->high.value);
- */
- if (rule->low.value <= val && val <= rule->high.value)
- break;
- }
- }
-
- /* if found, perform linear interpolation from low to high.
- * else set colors to colors->undef or white if undef not set
- */
-
- if (rule) {
- G__interpolate_color_rule(val, red, grn, blu, rule);
- found = 1;
- }
- if (!found) {
- /* otherwise use default color */
- G_get_default_color(&r, &g, &b, colors);
- *red = r;
- *grn = g;
- *blu = b;
- }
- /* DEBUG
- if (rule)
- fprintf (stderr, "%.2lf %d %d %d %.2lf %d %d %d \n", rule->low.value , (int)rule->low.red, (int)rule->low.grn, (int)rule->low.blu, rule->high.value, (int)rule->high.red, (int)rule->high.grn, (int)rule->high.blu);
- fprintf (stderr, "rule found %d %.2lf %d %d %d\n\n", cat, val, *red, *grn, *blu);
- */
- }
-}
-
-/*!
- \brief Interpolate color rules
-
- \param val raster cell value
- \param[out] red red value
- \param[out] grn green value
- \param[out] blu blue value
- \param rule pointer to _Color_Rule which holds color rules info
-*/
-void G__interpolate_color_rule(DCELL val, unsigned char *red,
- unsigned char *grn, unsigned char *blu,
- const struct _Color_Rule_ *rule)
-{
- DCELL delta;
-
- if ((delta = rule->high.value - rule->low.value)) {
- val -= rule->low.value;
-
- *red =
- (int)(val * (double)((int)rule->high.red - (int)rule->low.red) /
- delta)
- + (int)rule->low.red;
- *grn =
- (int)(val * (double)((int)rule->high.grn - (int)rule->low.grn) /
- delta)
- + (int)rule->low.grn;
- *blu =
- (int)(val * (double)((int)rule->high.blu - (int)rule->low.blu) /
- delta)
- + (int)rule->low.blu;
- }
- else {
- *red = rule->low.red;
- *grn = rule->low.grn;
- *blu = rule->low.blu;
- }
-}
Deleted: grass/trunk/lib/gis/color_org.c
===================================================================
--- grass/trunk/lib/gis/color_org.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_org.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,145 +0,0 @@
-#include <grass/gis.h>
-#include <stdlib.h>
-
-#define LOOKUP_COLORS 2048
-
-static void organize_lookup(struct Colors *, int);
-static int organize_fp_lookup(struct Colors *, int);
-static int double_comp(const void *, const void *);
-
-void G__organize_colors(struct Colors *colors)
-{
- /* don't do anything if called recursively */
- if (!colors->organizing) {
- colors->organizing = 1;
-
- organize_lookup(colors, 0);
- organize_lookup(colors, 1);
-
- organize_fp_lookup(colors, 0);
- organize_fp_lookup(colors, 1);
-
- colors->organizing = 0;
- }
-}
-
-static int organize_fp_lookup(struct Colors *colors, int mod)
-{
- int i;
- DCELL val;
- struct _Color_Info_ *cp;
- struct _Color_Rule_ *rule;
-
- if (mod)
- cp = &colors->modular;
- else
- cp = &colors->fixed;
-
- /* if one of the lookup tables exist, don't do anything */
- if (cp->lookup.active || cp->fp_lookup.active)
- return 1;
- if (cp->n_rules == 0)
- return 1;
-
- cp->fp_lookup.vals = (DCELL *)
- G_calloc(cp->n_rules * 2, sizeof(DCELL));
- /* 2 endpoints for each rule */
- cp->fp_lookup.rules = (struct _Color_Rule_ **)
- G_calloc(cp->n_rules * 2, sizeof(struct _Color_Rule_ *));
-
- /* get the list of DCELL values from set of all lows and highs
- of all rules */
- /* NOTE: if low==high in a rule, the value appears twice in a list
- but if low==high of the previous, rule the value appears only once */
-
- i = 0;
- /* go through the list of rules from end to beginning,
- because rules are sored in reverse order of reading,
- and we want to read the in correct order, to ignore
- the same values in the end of rule and beginning of next rule */
-
- /* first go to the last rules */
- for (rule = cp->rules; rule->next; rule = rule->next) ;
- /* now traverse from the last to the first rule */
- for (; rule; rule = rule->prev) {
- /* check if the min is the same as previous maximum */
- if (i == 0 || rule->low.value != cp->fp_lookup.vals[i - 1])
- cp->fp_lookup.vals[i++] = rule->low.value;
- cp->fp_lookup.vals[i++] = rule->high.value;
- }
- cp->fp_lookup.nalloc = i;
-
- /* now sort the values */
- qsort((char *)cp->fp_lookup.vals, cp->fp_lookup.nalloc,
- sizeof(DCELL), &double_comp);
-
- /* now find the rule to apply inbetween each 2 values in a list */
- for (i = 0; i < cp->fp_lookup.nalloc - 1; i++) {
- val = (cp->fp_lookup.vals[i] + cp->fp_lookup.vals[i + 1]) / 2.;
- /* fprintf (stderr, "%lf %lf ", cp->fp_lookup.vals[i], cp->fp_lookup.vals[i+1]); */
-
- for (rule = cp->rules; rule; rule = rule->next)
- if (rule->low.value <= val && val <= rule->high.value)
- break;
- /* if(rule) fprintf (stderr, "%d %lf %lf %d\n", i, rule->low.value, rule->high.value, rule);
- else fprintf (stderr, "null\n");
- */
- cp->fp_lookup.rules[i] = rule;
- }
- cp->fp_lookup.active = 1;
-
- return 0;
-}
-
-static void organize_lookup(struct Colors *colors, int mod)
-{
- int i, n;
- CELL x;
- CELL cat[LOOKUP_COLORS];
- struct _Color_Info_ *cp;
-
- /* don't do anything if the color structure is float */
- if (colors->is_float)
- return;
-
- if (mod)
- cp = &colors->modular;
- else
- cp = &colors->fixed;
-
- if (cp->lookup.active)
- return;
-
- n = (CELL) cp->max - (CELL) cp->min + 1;
- if (n >= LOOKUP_COLORS || n <= 0)
- return;
-
- x = (CELL) cp->min;
- for (i = 0; i < n; i++)
- cat[i] = x++;;
-
- cp->lookup.nalloc = n;
- cp->lookup.red = (unsigned char *)G_malloc(n);
- cp->lookup.grn = (unsigned char *)G_malloc(n);
- cp->lookup.blu = (unsigned char *)G_malloc(n);
- cp->lookup.set = (unsigned char *)G_malloc(n);
-
- G_zero(cp->lookup.set, n * sizeof(unsigned char));
- G__lookup_colors((void *)cat,
- cp->lookup.red, cp->lookup.grn, cp->lookup.blu,
- cp->lookup.set, n, colors, mod, 1, CELL_TYPE);
-
- cp->lookup.active = 1;
-}
-
-static int double_comp(const void *xx, const void *yy)
-{
- const DCELL *x = xx, *y = yy;
-
- if (*x < *y)
- return -1;
- else if (*x == *y)
- return 0;
- else
- return 1;
-}
Deleted: grass/trunk/lib/gis/color_rand.c
===================================================================
--- grass/trunk/lib/gis/color_rand.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_rand.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,47 +0,0 @@
-#include <time.h> /* For time() */
-#include <stdio.h> /* For NULL */
-#include <stdlib.h> /* For rand() and srand() */
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-#define MAX_COLORS 1024
-#define DEVIATION 128
-
-
-/*!
- * \brief make random colors
- *
- * Generates random colors. Good as a first pass at a
- * color table for nominal data.
- *
- * \param colors
- * \param min
- * \param max
- * \return
- */
-
-void G_make_random_colors(struct Colors *colors, CELL min, CELL max)
-{
- unsigned char red, grn, blu;
- int count;
- CELL n;
-
- G_init_colors(colors);
- if (min > max)
- G_fatal_error(_("G_make_random_colors: min (%d) > max (%d)"),
- min, max);
-
- srand(time(NULL));
-
- count = MAX_COLORS - DEVIATION + rand() % DEVIATION;
- if (count > max - min + 1)
- count = max - min + 1;
-
- for (n = 1; n <= count; n++) {
- red = rand() & 0377;
- grn = rand() & 0377;
- blu = rand() & 0377;
- G_add_modular_color_rule(n, red, grn, blu, n, red, grn, blu, colors);
- }
- G_set_color_range(min, max, colors);
-}
Deleted: grass/trunk/lib/gis/color_range.c
===================================================================
--- grass/trunk/lib/gis/color_range.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,93 +0,0 @@
-/*!
- * \file gis/color_range.c
- *
- * \brief GIS Library - Color range functions.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <math.h>
-#include <grass/gis.h>
-
-/*!
- \brief Set color range (CELL version)
-
- \todo Rename to G_set_c_color_range() ?
-
- \param min,max minimum and maximum value
- \param colors pointer to Colors structure which holds color info
-*/
-void G_set_color_range(CELL min, CELL max, struct Colors *colors)
-{
- if (min < max) {
- colors->cmin = (DCELL) min;
- colors->cmax = (DCELL) max;
- }
- else {
- colors->cmin = (DCELL) max;
- colors->cmax = (DCELL) min;
- }
-}
-
-/*!
- \brief Set color range (DCELL version)
-
- \param min,max minimum and maximum value
- \param colors pointer to Colors structure which holds color info
-*/
-void G_set_d_color_range(DCELL min, DCELL max, struct Colors *colors)
-{
- if (min < max) {
- colors->cmin = min;
- colors->cmax = max;
- }
- else {
- colors->cmin = max;
- colors->cmax = min;
- }
-}
-
-/*!
- \brief Get color range values (CELL)
-
- \todo Rename to G_get_c_color_range() ?
-
- Returns min and max category in the range or huge numbers if the
- color table is defined on floating cell values and not on
- categories.
-
- \param[out] min,max minimum and maximum value
- \param colors pointer to Colors structure which holds color info
- */
-void G_get_color_range(CELL * min, CELL * max, const struct Colors *colors)
-{
- if (!colors->is_float) {
- *min = (CELL) floor(colors->cmin);
- *max = (CELL) ceil(colors->cmax);
- }
- else {
- *min = -255 * 255 * 255;
- *max = 255 * 255 * 255;
- }
-}
-
-/*!
- \brief Get color range values (DELL)
-
- Returns min and max category in the range or huge numbers if the
- color table is defined on floating cell values and not on
- categories.
-
- \param[out] min,max minimum and maximum value
- \param colors pointer to Colors structure which holds color info
- */
-void G_get_d_color_range(DCELL * min, DCELL * max, const struct Colors *colors)
-{
- *min = colors->cmin;
- *max = colors->cmax;
-}
Deleted: grass/trunk/lib/gis/color_read.c
===================================================================
--- grass/trunk/lib/gis/color_read.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_read.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,389 +0,0 @@
-/*!
- * \file gis/color_read.c
- *
- * \brief GIS Library - Read color table of raster map
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include <string.h>
-
-static int read_colors(const char *, const char *, const char *,
- struct Colors *);
-static int read_new_colors(FILE *, struct Colors *);
-static int read_old_colors(FILE *, struct Colors *);
-
-
-/*!
- * \brief Read raster map layer color table
- *
- * The color table for the raster map <i>name</i> in the specified
- * <i>mapset</i> is read into the <i>colors</i> structure. If the data
- * layer has no color table, a default color table is generated and 0
- * is returned. If there is an error reading the color table, a
- * diagnostic message is printed and -1 is returned. If the color
- * table is read ok, 1 is returned.
- *
- * This routine reads the rules from the color file. If the input
- * raster map is is a floating-point map it calls
- * G_mark_colors_as_fp().
- *
- * Note: If a secondary color file for map name <i>name</i> exists in
- * the current project, that color file is read. This allows the
- * user to define their own color lookup tables for cell maps found
- * in other mapsets.
- *
- * Warning message is printed if the color file is
- * missing or invalid.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] colors pointer to Colors structure
- *
- * \return -1 on error
- * \return 0 if missing, but default colors generated
- * \return 1 on success
- */
-int G_read_colors(const char *name, const char *mapset, struct Colors *colors)
-{
- int fp;
- char buf[GNAME_MAX];
- char *err;
- char xname[GNAME_MAX];
- struct Range range;
- struct FPRange drange;
- CELL min, max;
- DCELL dmin, dmax;
-
- fp = G_raster_map_is_fp(name, mapset);
- G_init_colors(colors);
-
- strcpy(xname, name);
- mapset = G_find_cell(xname, mapset);
- name = xname;
-
- if (fp)
- G_mark_colors_as_fp(colors);
-
- /* first look for secondary color table in current mapset */
- sprintf(buf, "colr2/%s", mapset);
- if (read_colors(buf, name, G_mapset(), colors) >= 0)
- return 1;
-
- /* now look for the regular color table */
- switch (read_colors("colr", name, mapset, colors)) {
- case -2:
- if (!fp) {
- if (G_read_range(name, mapset, &range) >= 0) {
- G_get_range_min_max(&range, &min, &max);
- if (!G_is_c_null_value(&min) && !G_is_c_null_value(&max))
- G_make_rainbow_colors(colors, min, max);
- return 0;
- }
- }
- else {
- if (G_read_fp_range(name, mapset, &drange) >= 0) {
- G_get_fp_range_min_max(&drange, &dmin, &dmax);
- if (!G_is_d_null_value(&dmin) && !G_is_d_null_value(&dmax))
- G_make_rainbow_fp_colors(colors, dmin, dmax);
- return 0;
- }
- }
- err = _("missing");
- break;
- case -1:
- err = _("invalid");
- break;
- default:
- return 1;
- }
-
- G_warning(_("Color support for <%s@%s> %s"), name, mapset,
- err);
- return -1;
-}
-
-static int read_colors(const char *element, const char *name,
- const char *mapset, struct Colors *colors)
-{
- FILE *fd;
- int stat;
- char buf[1024];
-
- if (!(fd = G_fopen_old(element, name, mapset)))
- return -2;
-
- /*
- * first line in 4.0 color files is %
- * otherwise it is pre 4.0
- */
- if (fgets(buf, sizeof buf, fd) == NULL) {
- fclose(fd);
- return -1;
- }
- fseek(fd, 0L, 0);
-
- G_strip(buf);
- if (*buf == '%') { /* 4.0 format */
- stat = read_new_colors(fd, colors);
- colors->version = 0; /* 4.0 format */
- }
- else {
- stat = read_old_colors(fd, colors);
- colors->version = -1; /* pre 4.0 format */
- }
- fclose(fd);
- return stat;
-}
-
-/* parse input lines with the following formats
- * val1:r:g:b val2:r:g:b
- * val:r:g:b (implies cat1==cat2)
- *
- * r:g:b can be just a single grey level
- * cat1:x cat2:y
- * cat:x
- *
- * optional lines are
- * invert invert color table
- * shift:n where n is the amount to shift the color table
- * nv:r:g:b color to use for NULL values
- * *:r:g:b color to use for undefined (beyond color rules)
- */
-static int read_new_colors(FILE * fd, struct Colors *colors)
-{
- double val1, val2;
- long cat1, cat2;
- int r1, g1, b1;
- int r2, g2, b2;
- char buf[1024];
- char word1[256], word2[256];
- int n, fp_rule;
- int null, undef;
- int modular;
- DCELL shift;
-
- if (fgets(buf, sizeof buf, fd) == NULL)
- return -1;
- G_strip(buf);
-
- if (sscanf(buf + 1, "%lf %lf", &val1, &val2) == 2)
- G_set_d_color_range((DCELL) val1, (DCELL) val2, colors);
-
- modular = 0;
- while (fgets(buf, sizeof buf, fd)) {
- null = undef = fp_rule = 0;
- *word1 = *word2 = 0;
- n = sscanf(buf, "%s %s", word1, word2);
- if (n < 1)
- continue;
-
- if (sscanf(word1, "shift:%lf", &shift) == 1
- || (strcmp(word1, "shift:") == 0 &&
- sscanf(word2, "%lf", &shift) == 1)) {
- G_shift_d_colors(shift, colors);
- continue;
- }
- if (strcmp(word1, "invert") == 0) {
- G_invert_colors(colors);
- continue;
- }
- if (strcmp(word1, "%%") == 0) {
- modular = !modular;
- continue;
- }
-
- switch (sscanf(word1, "nv:%d:%d:%d", &r1, &g1, &b1)) {
- case 1:
- null = 1;
- b1 = g1 = r1;
- break;
- case 3:
- null = 1;
- break;
- }
- if (!null)
- switch (sscanf(word1, "*:%d:%d:%d", &r1, &g1, &b1)) {
- case 1:
- undef = 1;
- b1 = g1 = r1;
- break;
- case 3:
- undef = 1;
- break;
- }
- if (!null && !undef)
- switch (sscanf(word1, "%ld:%d:%d:%d", &cat1, &r1, &g1, &b1)) {
- case 2:
- b1 = g1 = r1;
- break;
- case 4:
- break;
- default:
- if (sscanf(word1, "%lf:%d:%d:%d", &val1, &r1, &g1, &b1) == 4)
- fp_rule = 1;
- else if (sscanf(word1, "%lf:%d", &val1, &r1) == 2) {
- fp_rule = 1;
- b1 = g1 = r1;
- }
- else
- continue; /* other lines are ignored */
- }
- if (n == 2) {
- switch (sscanf(word2, "%ld:%d:%d:%d", &cat2, &r2, &g2, &b2)) {
- case 2:
- b2 = g2 = r2;
- if (fp_rule)
- val2 = (DCELL) cat2;
- break;
- case 4:
- if (fp_rule)
- val2 = (DCELL) cat2;
- break;
- default:
- if (sscanf(word2, "%lf:%d:%d:%d", &val2, &r2, &g2, &b2) == 4) {
- if (!fp_rule)
- val1 = (DCELL) cat1;
- fp_rule = 1;
- }
- else if (sscanf(word2, "%lf:%d", &val2, &r2) == 2) {
- if (!fp_rule)
- val1 = (DCELL) cat1;
- fp_rule = 1;
- b2 = g2 = r2;
- }
- else
- continue; /* other lines are ignored */
- }
- }
- else {
- if (!fp_rule)
- cat2 = cat1;
- else
- val2 = val1;
- r2 = r1;
- g2 = g1;
- b2 = b1;
- }
- if (null)
- G_set_null_value_color(r1, g1, b1, colors);
- else if (undef)
- G_set_default_color(r1, g1, b1, colors);
-
- else if (modular) {
- if (fp_rule)
- G_add_modular_d_raster_color_rule((DCELL *) & val1, r1, g1,
- b1, (DCELL *) & val2, r2,
- g2, b2, colors);
- else
- G_add_modular_color_rule((CELL) cat1, r1, g1, b1,
- (CELL) cat2, r2, g2, b2, colors);
- }
- else {
- if (fp_rule)
- G_add_d_raster_color_rule((DCELL *) & val1, r1, g1, b1,
- (DCELL *) & val2, r2, g2, b2,
- colors);
- else
- G_add_color_rule((CELL) cat1, r1, g1, b1,
- (CELL) cat2, r2, g2, b2, colors);
- }
- G_debug(3, "adding rule %d=%.2lf %d %d %d %d=%.2lf %d %d %d",
- cat1, val1, r1, g1, b1, cat2, val2, r2, g2, b2);
- }
- return 1;
-}
-
-static int read_old_colors(FILE * fd, struct Colors *colors)
-{
- char buf[256];
- long n;
- long min;
- float red_f, grn_f, blu_f;
- int red, grn, blu;
- int old;
- int zero;
-
- G_init_colors(colors);
- /*
- * first line in pre 3.0 color files is number of colors - ignore
- * otherwise it is #min first color, and the next line is for color 0
- */
- if (fgets(buf, sizeof buf, fd) == NULL)
- return -1;
-
- G_strip(buf);
- if (*buf == '#') { /* 3.0 format */
- old = 0;
- if (sscanf(buf + 1, "%ld", &min) != 1) /* first color */
- return -1;
- zero = 1;
- }
- else {
- old = 1;
- min = 0;
- zero = 0;
- }
-
- colors->cmin = min;
- n = min;
- while (fgets(buf, sizeof buf, fd)) {
- if (old) {
- if (sscanf(buf, "%f %f %f", &red_f, &grn_f, &blu_f) != 3)
- return -1;
-
- red = 256 * red_f;
- grn = 256 * grn_f;
- blu = 256 * blu_f;
- }
- else {
- switch (sscanf(buf, "%d %d %d", &red, &grn, &blu)) {
- case 1:
- blu = grn = red;
- break;
- case 2:
- blu = grn;
- break;
- case 3:
- break;
- default:
- return -1;
- }
- }
- if (zero) {
- G__insert_color_into_lookup((CELL) 0, red, grn, blu,
- &colors->fixed);
- zero = 0;
- }
- else
- G__insert_color_into_lookup((CELL) n++, red, grn, blu,
- &colors->fixed);
- }
- colors->cmax = n - 1;
-
- return 0;
-}
-
-/*!
- * \brief Mark colors as floating-point.
- *
- * Sets a flag in the <i>colors</i> structure that indicates that
- * these colors should only be looked up using floating-point raster
- * data (not integer data). In particular if this flag is set, the
- * routine G_get_colors_min_max() should return min=-255$^3$ and
- * max=255$^3$.
- *
- * \param colors pointer to Colors structure
- */
-void G_mark_colors_as_fp(struct Colors *colors)
-{
- colors->is_float = 1;
-}
Deleted: grass/trunk/lib/gis/color_remove.c
===================================================================
--- grass/trunk/lib/gis/color_remove.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_remove.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,44 +0,0 @@
-
-/****************************************************************************
- *
- * MODULE: gis library
- * AUTHOR(S): Glynn Clements <glynn at gclements.plus.com>
- * COPYRIGHT: (C) 2007 Glynn Clements
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- *****************************************************************************/
-
-#include <string.h>
-#include <stdio.h>
-#include <grass/gis.h>
-
-int G_remove_colors(const char *name, const char *mapset)
-{
- char element[GMAPSET_MAX + 6];
- char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
- int stat;
-
- if (G__name_is_fully_qualified(name, xname, xmapset)) {
- if (strcmp(xmapset, mapset) != 0)
- return -1;
- name = xname;
- }
-
- /* get rid of existing colr2, if any */
- sprintf(element, "colr2/%s", mapset);
- stat = G_remove(element, name);
-
- if (strcmp(mapset, G_mapset()) == 0)
- stat = G_remove("colr", name);
-
- return stat;
-}
Deleted: grass/trunk/lib/gis/color_rule.c
===================================================================
--- grass/trunk/lib/gis/color_rule.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_rule.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,440 +0,0 @@
-/*!
- * \file gis/color_rule.c
- *
- * \brief GIS Library - Color rules.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-
-#define LIMIT(x) if (x < 0) x = 0; else if (x > 255) x = 255;
-
-static void add_color_rule(const void *, int, int, int,
- const void *, int, int, int,
- struct _Color_Info_ *, int,
- DCELL *, DCELL *, RASTER_MAP_TYPE);
-
-
-/*!
- * \brief Adds the floating-point rule (DCELL version)
- *
- * See G_add_raster_color_rule() for details.
- *
- * \param v1 cell value
- * \param r1,g1,b1 color value
- * \param v2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- * \return
- */
-void G_add_d_raster_color_rule(const DCELL * val1, int r1, int g1, int b1,
- const DCELL * val2, int r2, int g2, int b2,
- struct Colors *colors)
-{
- add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->fixed,
- colors->version, &colors->cmin, &colors->cmax, DCELL_TYPE);
-}
-
-
-/*!
- * \brief Adds the floating-point rule (FCELL version)
- *
- * See G_add_raster_color_rule() for details.
- *
- * \param v1 cell value
- * \param r1,g1,b1 color value
- * \param v2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- * \return
- */
-void G_add_f_raster_color_rule(const FCELL * cat1, int r1, int g1, int b1,
- const FCELL * cat2, int r2, int g2, int b2,
- struct Colors *colors)
-{
- add_color_rule(cat1, r1, g1, b1, cat2, r2, g2, b2, &colors->fixed,
- colors->version, &colors->cmin, &colors->cmax, FCELL_TYPE);
-}
-
-
-/*!
- * \brief Adds the floating-point rule (CCELL version)
- *
- * See G_add_raster_color_rule() for details.
- *
- * \param v1 cell value
- * \param r1,g1,b1 color value
- * \param v2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- * \return
- */
-void G_add_c_raster_color_rule(const CELL * cat1, int r1, int g1, int b1,
- const CELL * cat2, int r2, int g2, int b2,
- struct Colors *colors)
-{
- add_color_rule(cat1, r1, g1, b1, cat2, r2, g2, b2, &colors->fixed,
- colors->version, &colors->cmin, &colors->cmax, CELL_TYPE);
-}
-
-
-/*!
- * \brief Adds the floating-point rule
- *
- * Adds the floating-point rule that the range [<em>v1,v2</em>] gets a
- * linear ramp of colors from [<em>r1,g1,b1</em>] to
- * [<em>r2,g2,b2</em>].
- * If either <em>v1</em> or <em>v2</em> is the NULL-value, this call is converted into
- * <tt>G_set_null_value_color (r1, g1, b1, colors)</tt>
- *
- * - If <em>map_type</em> is CELL_TYPE, calls G_add_c_raster_color_rule()
- * - If <em>map_type</em> is FCELL_TYPE, calls G_add_f_raster_color_rule()
- * - If <em>map_type</em> is DCELL_TYPE, calls G_add_d_raster_color_rule()
- *
- * \param v1 cell value
- * \param r1,g1,b1 color value
- * \param v2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- * \param data_type raster data type (CELL, FCELL, DCELL)
- * \return
- */
-
-void G_add_raster_color_rule(const void *val1, int r1, int g1, int b1,
- const void *val2, int r2, int g2, int b2,
- struct Colors *colors, RASTER_MAP_TYPE data_type)
-{
- add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->fixed,
- colors->version, &colors->cmin, &colors->cmax, data_type);
-}
-
-
-/*!
- * \brief Set colors rules
- *
- * This is the heart
- * and soul of the new color logic. It adds a color rule to the <b>colors</b>
- * structure. The colors defined by the red, green, and blue values
- * <b>r1,g1,b1</b> and <b>r2,g2,b2</b> are assigned to <b>cat1</b> and
- * <b>cat2</b> respectively. Colors for data values between <b>cat1</b> and
- * <b>cat2</b> are not stored in the structure but are interpolated when
- * queried by <i>G_lookup_colors</i> and<i>G_get_color.</i> The color
- * components <b>r1,g1,b1</b> and <b>r2,g2,b2</b> must be in the range
- * 0 -- 255.
- * For example, to create a linear grey scale for the range 200 -- 1000:
- *
- \code
- struct Colors colr;
- G_init_colors (&colr);
- G_add_color_rule ((CELL)200, 0,0,0, (CELL) 1000, 255,255,255);
- \endcode
- *
- * The programmer is encouraged to review \ref
- * Raster_Color_Table_Format how this routine fits into the 5.x raster
- * color logic.
- *
- * <b>Note:</b> The <i>colors</i> structure must have been initialized
- * by G_init_colors(). See \ref Predefined_Color_Tables for routines
- * to build some predefined color tables.
- *
- * \param cat1 cell value
- * \param r1,g1,b1 color value
- * \param cat2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- * \return
- */
-void G_add_color_rule(CELL cat1, int r1, int g1, int b1,
- CELL cat2, int r2, int g2,
- int b2, struct Colors *colors)
-{
- add_color_rule((void *)&cat1, r1, g1, b1, (void *)&cat2, r2, g2, b2,
- &colors->fixed, colors->version, &colors->cmin,
- &colors->cmax, CELL_TYPE);
-}
-
-/*!
- * \brief Add modular color rule (DCELL version)
- *
- * \param val1 cell value
- * \param r1,g1,b1 color value
- * \param val2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- *
- * \return -1 on failure
- * \return 1 on success
- */
-int G_add_modular_d_raster_color_rule(const DCELL * val1, int r1, int g1, int b1,
- const DCELL * val2, int r2, int g2, int b2,
- struct Colors *colors)
-{
- DCELL min, max;
-
- if (colors->version < 0)
- return -1; /* can't use this on 3.0 colors */
- min = colors->cmin;
- max = colors->cmax;
- add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->modular, 0,
- &colors->cmin, &colors->cmax, DCELL_TYPE);
- colors->cmin = min; /* don't reset these */
- colors->cmax = max;
-
- return 1;
-}
-
-/*!
- * \brief Add modular color rule (FCELL version)
- *
- * \param val1 cell value
- * \param r1,g1,b1 color value
- * \param val2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- *
- * \return -1 on failure
- * \return 1 on success
- */
-int G_add_modular_f_raster_color_rule(const FCELL * val1, int r1, int g1, int b1,
- const FCELL * val2, int r2, int g2, int b2,
- struct Colors *colors)
-{
- DCELL min, max;
-
- if (colors->version < 0)
- return -1; /* can;t use this on 3.0 colors */
- min = colors->cmin;
- max = colors->cmax;
- add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->modular, 0,
- &colors->cmin, &colors->cmax, FCELL_TYPE);
- colors->cmin = min; /* don't reset these */
- colors->cmax = max;
-
- return 1;
-}
-
-/*!
- * \brief Add modular color rule (CCELL version)
- *
- * \param val1 cell value
- * \param r1,g1,b1 color value
- * \param val2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- *
- * \return -1 on failure
- * \return 1 on success
- */
-int G_add_modular_c_raster_color_rule(const CELL * val1, int r1, int g1, int b1,
- const CELL * val2, int r2, int g2, int b2,
- struct Colors *colors)
-{
- return G_add_modular_color_rule(*val1, r1, g1, b1, *val2, r2, g2, b2,
- colors);
-}
-
-/*!
- * \brief Add modular color rule
- *
- * \todo Question: shouldn't this function call
- * G_add_modular_<data_type>_raster_color_rule() instead?
- *
- * \param val1 cell value
- * \param r1,g1,b1 color value
- * \param val2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- * \param data_type raster data type
- *
- * \return -1 on failure
- * \return 1 on success
- */
-int G_add_modular_raster_color_rule(
- const void *val1, int r1, int g1, int b1,
- const void *val2, int r2, int g2, int b2,
- struct Colors *colors, RASTER_MAP_TYPE data_type)
-{
- CELL min, max;
-
- if (colors->version < 0)
- return -1; /* can't use this on 3.0 colors */
- min = colors->cmin;
- max = colors->cmax;
- add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->modular, 0,
- &colors->cmin, &colors->cmax, data_type);
- colors->cmin = min; /* don't reset these */
- colors->cmax = max;
-
- return 1;
-}
-
-/*!
- * \brief Add modular color rule
- *
- * \todo This function seems to be same as
- * G_add_modular_raster_color_rule(). Can be removed?
- *
- * \param val1 cell value
- * \param r1,g1,b1 color value
- * \param val2 cell value
- * \param r2,g2,b2 color value
- * \param[in,out] colors pointer to color table structure
- * \param data_type raster data type
- *
- * \return -1 on failure
- * \return 1 on success
- */
-int G_add_modular_color_rule(CELL cat1, int r1, int g1,
- int b1, CELL cat2, int r2,
- int g2, int b2, struct Colors *colors)
-{
- CELL min, max;
-
- if (colors->version < 0)
- return -1; /* can;t use this on 3.0 colors */
- min = colors->cmin;
- max = colors->cmax;
- add_color_rule((void *)&cat1, r1, g1, b1, (void *)&cat2, r2, g2, b2,
- &colors->modular, 0, &colors->cmin, &colors->cmax,
- CELL_TYPE);
- colors->cmin = min; /* don't reset these */
- colors->cmax = max;
-
- return 1;
-}
-
-static void add_color_rule(const void *pt1, int r1, int g1, int b1,
- const void *pt2, int r2, int g2, int b2,
- struct _Color_Info_ *cp, int version, DCELL * cmin,
- DCELL * cmax, RASTER_MAP_TYPE data_type)
-{
- struct _Color_Rule_ *rule, *next;
- unsigned char red, grn, blu;
- DCELL min, max, val1, val2;
- CELL cat;
-
- val1 = G_get_raster_value_d(pt1, data_type);
- val2 = G_get_raster_value_d(pt2, data_type);
- /* allocate a low:high rule */
- rule = (struct _Color_Rule_ *)G_malloc(sizeof(*rule));
- rule->next = rule->prev = NULL;
-
- /* make sure colors are in the range [0,255] */
- LIMIT(r1);
- LIMIT(g1);
- LIMIT(b1);
- LIMIT(r2);
- LIMIT(g2);
- LIMIT(b2);
-
- /* val1==val2, use average color */
- /* otherwise make sure low < high */
- if (val1 == val2) {
- rule->low.value = rule->high.value = val1;
- rule->low.red = rule->high.red = (r1 + r2) / 2;
- rule->low.grn = rule->high.grn = (g1 + g2) / 2;
- rule->low.blu = rule->high.blu = (b1 + b2) / 2;
- }
- else if (val1 < val2) {
- rule->low.value = val1;
- rule->low.red = r1;
- rule->low.grn = g1;
- rule->low.blu = b1;
-
- rule->high.value = val2;
- rule->high.red = r2;
- rule->high.grn = g2;
- rule->high.blu = b2;
- }
- else {
- rule->low.value = val2;
- rule->low.red = r2;
- rule->low.grn = g2;
- rule->low.blu = b2;
-
- rule->high.value = val1;
- rule->high.red = r1;
- rule->high.grn = g1;
- rule->high.blu = b1;
- }
-
- /* keep track of the overall min and max, excluding null */
- if (G_is_d_null_value(&(rule->low.value)))
- return;
- if (G_is_d_null_value(&(rule->high.value)))
- return;
- min = rule->low.value;
- max = rule->high.value;
- if (min <= max) {
- if (cp->min > cp->max) {
- cp->min = min;
- cp->max = max;
- }
- else {
- if (cp->min > min)
- cp->min = min;
- if (cp->max < max)
- cp->max = max;
- }
- }
- if (*cmin > *cmax) {
- *cmin = cp->min;
- *cmax = cp->max;
- }
- else {
- if (*cmin > cp->min)
- *cmin = cp->min;
- if (*cmax < cp->max)
- *cmax = cp->max;
- }
-
- /* If version is old style (i.e., pre 4.0),
- * interpolate this rule from min to max
- * and insert each cat into the lookup table.
- * Then free the rule.
- * Otherwise, free the lookup table, if active.
- * G_organize_colors() will regenerate it
- * Link this rule into the list of rules
- */
-
- if (version < 0) {
- for (cat = (CELL) min; cat <= (CELL) max; cat++) {
- G__interpolate_color_rule((DCELL) cat, &red, &grn, &blu, rule);
- G__insert_color_into_lookup(cat, (int)red, (int)grn, (int)blu,
- cp);
- }
- G_free(rule);
- }
- else {
- if (cp->rules)
- cp->rules->prev = rule;
- rule->next = cp->rules;
- cp->rules = rule;
-
- /* prune the rules:
- * remove all rules that are contained by this rule
- */
- min = rule->low.value; /* mod 4.1 */
- max = rule->high.value; /* mod 4.1 */
- cp->n_rules++;
- for (rule = rule->next; rule; rule = next) {
- next = rule->next; /* has to be done here, not in for stmt */
- if (min <= rule->low.value && max >= rule->high.value) {
- if ((rule->prev->next = next)) /* remove from the list */
- next->prev = rule->prev;
- G_free(rule);
- cp->n_rules--;
- }
- }
-
- /* free lookup array, if allocated */
- G__color_free_lookup(cp);
- G__color_free_fp_lookup(cp);
- }
-}
Deleted: grass/trunk/lib/gis/color_rule_get.c
===================================================================
--- grass/trunk/lib/gis/color_rule_get.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_rule_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,123 +0,0 @@
-
-/**
- * \file color_rule_get.c
- *
- * \brief GIS Library - Get color rules.
- *
- * (C) 2001-2008 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author GRASS GIS Development Team
- *
- * \date 1999-2008
- */
-
-#include <grass/gis.h>
-
-/*!
- \brief Get both modular and fixed rules count
-
- \param colors pointer to color table structure
-
- \return number of rules in color table
- */
-int G_colors_count(const struct Colors *colors)
-{
- int count = 0;
- struct _Color_Rule_ *rule;
-
- if (colors->fixed.rules) {
- count++;
- rule = colors->fixed.rules;
-
- while (rule->next) {
- count++;
- rule = rule->next;
- }
- }
- if (colors->modular.rules) {
- count++;
- rule = colors->modular.rules;
-
- while (rule->next) {
- count++;
- rule = rule->next;
- }
- }
- return count;
-}
-
-/*!
- \brief Get color rule from both modular and fixed rules
-
- Rules are returned in the order as stored in the table (i.e. unexpected, high values first)
-
- \param val1 color value
- \param[out] r1,g1,b1 color value
- \param val2 color value
- \param[out] r2,g2,b2 color value
- \param colors pointer to color table structure
- \param rule rule index from 0 to G_color_count()-1
-
- \return 0 success
- \return 1 index out of range
- */
-int G_get_f_color_rule(DCELL * val1, unsigned char *r1, unsigned char *g1,
- unsigned char *b1, DCELL * val2, unsigned char *r2,
- unsigned char *g2, unsigned char *b2,
- const struct Colors *colors, int rule)
-{
- int index = -1;
- int found = 0;
- const struct _Color_Rule_ *rl;
-
- *val1 = *val2 = 0.0;
- *r1 = *g1 = *b1 = *r2 = *g2 = *b2 = 0;
-
- /* Find the rule */
- if (colors->fixed.rules) {
- rl = colors->fixed.rules;
- index++;
- if (index == rule)
- found = 1;
-
- while (!found && rl->next) {
- rl = rl->next;
- index++;
- if (index == rule)
- found = 1;
- }
- }
- if (!found && colors->modular.rules) {
- rl = colors->modular.rules;
- index++;
- if (index == rule)
- found = 1;
-
- while (!found && rl->next) {
- rl = rl->next;
- index++;
- if (index == rule)
- found = 1;
- }
- }
-
- if (!found)
- return 1;
-
- /* Set values */
- *val1 = rl->low.value;
- *val2 = rl->high.value;
-
- *r1 = rl->low.red;
- *g1 = rl->low.grn;
- *b1 = rl->low.blu;
-
- *r2 = rl->high.red;
- *g2 = rl->high.grn;
- *b2 = rl->high.blu;
-
- return 0;
-}
Deleted: grass/trunk/lib/gis/color_rules.c
===================================================================
--- grass/trunk/lib/gis/color_rules.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_rules.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,270 +0,0 @@
-
-/****************************************************************************
- *
- * MODULE: gis library
- * AUTHOR(S): Glynn Clements <glynn at gclements.plus.com>
- * COPYRIGHT: (C) 2007 Glynn Clements and the GRASS Development Team
- *
- * NOTE: Based upon r.colors/rules.c
- * The colors are stored in ./colors/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-struct rule
-{
- int set;
- int r, g, b;
- DCELL val;
-};
-
-enum rule_error
-{
- CR_OK = 0,
- CR_ERROR_SYNTAX,
- CR_ERROR_RGB,
- CR_ERROR_COLOR,
- CR_ERROR_PERCENT,
- CR_ERROR_VALUE,
-};
-
-int G_parse_color_rule(DCELL min, DCELL max, const char *buf,
- DCELL * val, int *r, int *g, int *b,
- int *norm, int *nval, int *dflt)
-{
- char value[80], color[80];
- double x;
- char c;
-
- *norm = *nval = *dflt = 0;
-
- if (sscanf(buf, "%s %[^\n]", value, color) != 2)
- return CR_ERROR_SYNTAX;
-
- G_chop(color);
-
- if (sscanf(color, "%d:%d:%d", r, g, b) == 3 ||
- sscanf(color, "%d %d %d", r, g, b) == 3) {
- if (*r < 0 || *r > 255 || *g < 0 || *g > 255 || *b < 0 || *b > 255)
- return CR_ERROR_RGB;
- }
- else {
- float fr, fg, fb;
-
- if (G_color_values(color, &fr, &fg, &fb) < 0)
- return CR_ERROR_COLOR;
-
- *r = (int)(fr * 255.99);
- *g = (int)(fg * 255.99);
- *b = (int)(fb * 255.99);
- }
-
- G_chop(value);
-
- if (G_strcasecmp(value, "default") == 0) {
- *dflt = 1;
- return CR_OK;
- }
-
- if (G_strcasecmp(value, "nv") == 0) {
- *nval = 1;
- return CR_OK;
- }
-
- if (sscanf(value, "%lf%c", &x, &c) == 2 && c == '%') {
- if (x < 0 || x > 100)
- return CR_ERROR_PERCENT;
-
- *val = min + (max - min) * (x / 100);
- *norm = 1;
- return CR_OK;
- }
-
- if (sscanf(value, "%lf", val) == 1) {
- *norm = 1;
- return CR_OK;
- }
-
- return CR_ERROR_VALUE;
-}
-
-const char *G_parse_color_rule_error(int code)
-{
- switch (code) {
- case CR_OK:
- return "";
- case CR_ERROR_SYNTAX:
- return _("syntax error");
- case CR_ERROR_RGB:
- return _("R/G/B not in range 0-255");
- case CR_ERROR_COLOR:
- return _("invalid color name");
- case CR_ERROR_PERCENT:
- return _("percentage not in range 0-100");
- case CR_ERROR_VALUE:
- return _("invalid value");
- default:
- return _("unknown error");
- }
-}
-
-int G_read_color_rule(void *closure, DCELL min, DCELL max,
- DCELL * val, int *r, int *g, int *b,
- int *norm, int *nval, int *dflt)
-{
- char buf[1024];
- FILE *fp = closure;
- int ret;
-
- *norm = *nval = *dflt = 0;
-
- for (;;) {
- if (!G_getl2(buf, sizeof(buf), fp))
- return 0;
-
- G_strip(buf);
- G_debug(5, "color buf = [%s]", buf);
-
- if (*buf == '\0')
- continue;
- if (*buf == '#')
- continue;
-
- ret =
- G_parse_color_rule(min, max, buf, val, r, g, b, norm, nval, dflt);
- if (ret == 0)
- return 1;
-
- G_fatal_error(_("bad rule (%s): [%s]"),
- G_parse_color_rule_error(ret), buf);
- }
-
- return 0;
-}
-
-int G_read_color_rules(struct Colors *colors, DCELL min, DCELL max,
- read_rule_fn * read_rule, void *closure)
-{
- struct rule *rule = NULL;
- int nrules = 0;
- struct rule dflt, null;
- int set, is_null, is_dflt, r, g, b;
- DCELL val;
- int n;
-
- if (!read_rule)
- read_rule = G_read_color_rule;
-
- G_init_colors(colors);
-
- /* initialization */
- dflt.r = dflt.g = dflt.b = dflt.set = 0;
- null.r = null.g = null.b = null.set = 0;
-
- while ((*read_rule)
- (closure, min, max, &val, &r, &g, &b, &set, &is_null, &is_dflt)) {
- struct rule *p;
-
- if (set) {
- n = nrules++;
- rule = G_realloc(rule, nrules * sizeof(struct rule));
- p = &rule[n];
- }
- else if (is_dflt)
- p = &dflt;
- else if (is_null)
- p = &null;
-
- p->r = r;
- p->g = g;
- p->b = b;
- p->set = 1;
- p->val = val;
- }
-
- if (nrules == 0)
- return 0;
-
- if (nrules == 1) {
- const struct rule *p = &rule[0];
-
- G_set_d_color(p->val, p->r, p->g, p->b, colors);
- }
-
- for (n = 1; n < nrules; n++) {
- struct rule *lo = &rule[n - 1];
- struct rule *hi = &rule[n];
-
- G_add_d_raster_color_rule(&lo->val, lo->r, lo->g, lo->b,
- &hi->val, hi->r, hi->g, hi->b, colors);
- }
-
- /* null value and default color set up, if rules are set up by user */
- if (null.set)
- G_set_null_value_color(null.r, null.g, null.b, colors);
-
- if (dflt.set)
- G_set_default_color(dflt.r, dflt.g, dflt.b, colors);
-
- return 1;
-}
-
-static int load_rules_file(struct Colors *colors, const char *path, DCELL min, DCELL max)
-{
- FILE *fp;
- int ret;
-
- fp = fopen(path, "r");
-
- if (!fp)
- return 0;
-
- ret = G_read_color_rules(colors, min, max, G_read_color_rule, (void *)fp);
-
- fclose(fp);
-
- return ret;
-}
-
-int G_load_colors(struct Colors *colors, const char *path, CELL min, CELL max)
-{
- return load_rules_file(colors, path, (DCELL) min, (DCELL) max);
-}
-
-int G_load_fp_colors(struct Colors *colors, const char *path, DCELL min, DCELL max)
-{
- return load_rules_file(colors, path, min, max);
-}
-
-static void load_rules_name(struct Colors *colors, const char *name, DCELL min, DCELL max)
-{
- char path[GPATH_MAX];
-
- sprintf(path, "%s/etc/colors/%s", G_gisbase(), name);
-
- if (!load_rules_file(colors, path, min, max))
- G_fatal_error(_("Unable to load color rules <%s>"), name);
-}
-
-void G_make_colors(struct Colors *colors, const char *name, CELL min, CELL max)
-{
- return load_rules_name(colors, name, (DCELL) min, (DCELL) max);
-}
-
-void G_make_fp_colors(struct Colors *colors, const char *name, DCELL min, DCELL max)
-{
- return load_rules_name(colors, name, min, max);
-}
Deleted: grass/trunk/lib/gis/color_set.c
===================================================================
--- grass/trunk/lib/gis/color_set.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_set.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,104 +0,0 @@
-/*!
- * \file gis/color_set.c
- *
- * \brief GIS Library - Set colors for raster maps.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-
-/*!
- * \brief Set a category color (CELL)
- *
- * The <i>red, green</i>, and <i>blue</i> intensities for the color
- * associated with category <i>cat</i> are set in the <i>colors</i>
- * structure. The intensities must be in the range 0 - 255. Values
- * below zero are set as zero, values above 255 are set as 255.
- *
- * <b>Warning: Use of this routine is discouraged because it defeats the new
- * color logic.</b>
- *
- * It is provided only for backward compatibility. Overuse can create
- * large color tables. G_add_color_rule() should be used whenever
- * possible.
- *
- * <b>Note:</b> The <i>colors</i> structure must have been
- * initialized by G_init_color().
- *
- * \param cat raster cell value
- * \param r red value
- * \param g green value
- * \param b blue value
- * \param colors pointer to Colors structure which holds color info
- */
-void G_set_color(CELL cat, int r, int g, int b, struct Colors *colors)
-{
- if (G_is_c_null_value(&cat))
- G_set_null_value_color(r, g, b, colors);
- else
- G_add_color_rule(cat, r, g, b, cat, r, g, b, colors);
-}
-
-/*!
- * \brief Set a category color (DCELL)
- *
- * See G_set_color() for detailed information.
- *
- * \param cat raster cell value
- * \param r red value
- * \param g green value
- * \param b blue value
- * \param colors pointer to Colors structure which holds color info
- */
-void G_set_d_color(DCELL val, int r, int g, int b, struct Colors *colors)
-{
- if (G_is_d_null_value(&val))
- G_set_null_value_color(r, g, b, colors);
- else
- G_add_d_raster_color_rule(&val, r, g, b, &val, r, g, b, colors);
-}
-
-/*!
- * \brief Set color for NULL-value
- *
- * Sets the color (in <i>colors</i>) for the NULL-value to
- * <i>red, green, blue</i>.
- *
- * \param red red value
- * \param grn green value
- * \param blu blue value
- * \param colors pointer to Colors structure which holds color info
- */
-void G_set_null_value_color(int red, int grn, int blu, struct Colors *colors)
-{
- colors->null_red = red;
- colors->null_grn = grn;
- colors->null_blu = blu;
- colors->null_set = 1;
-}
-
-/*!
- * \brief Set default color value
- *
- * Sets the default color (in <i>colors</i>) to <i>red, green,
- * blue</i>. This is the color for values which do not have an
- * explicit rule.
- *
- * \param red red value
- * \param grn green value
- * \param blu blue value
- * \param colors pointer to Colors structure which holds color info
- */
-void G_set_default_color(int red, int grn, int blu, struct Colors *colors)
-{
- colors->undef_red = red;
- colors->undef_grn = grn;
- colors->undef_blu = blu;
- colors->undef_set = 1;
-}
Deleted: grass/trunk/lib/gis/color_shift.c
===================================================================
--- grass/trunk/lib/gis/color_shift.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_shift.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,10 +0,0 @@
-#include <grass/gis.h>
-void G_shift_colors(int shift, struct Colors *colors)
-{
- colors->shift += (DCELL) shift;
-}
-
-void G_shift_d_colors(DCELL shift, struct Colors *colors)
-{
- colors->shift += shift;
-}
Deleted: grass/trunk/lib/gis/color_str.c
===================================================================
--- grass/trunk/lib/gis/color_str.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_str.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,150 +0,0 @@
-/*!
- \file color_str.c
-
- \brief GIS library - color management, named color to RGB triplet
-
- (C) 2001-2008 by the GRASS Development Team
-
- This program is free software under the
- GNU General Public License (>=v2).
- Read the file COPYING that comes with GRASS
- for details.
-
- \author Original author CERL
- */
-
-#include <string.h>
-
-#include <grass/gis.h>
-#include <grass/colors.h>
-
-/* The order in this table is important! It will be indexed by color number */
-static const struct color_rgb standard_colors_rgb[] = {
- {0, 0, 0}, /* This is a dummy value to make lookup easier */
- {0, 0, 0}, /* BLACK */
- {255, 0, 0}, /* RED */
- {0, 255, 0}, /* GREEN */
- {0, 0, 255}, /* BLUE */
- {255, 255, 0}, /* YELLOW */
- {0, 255, 255}, /* CYAN */
- {255, 0, 255}, /* MAGENTA */
- {255, 255, 255}, /* WHITE */
- {128, 128, 128}, /* GRAY */
- {255, 128, 0}, /* ORANGE */
- {100, 128, 255}, /* AQUA */
- {0, 128, 255}, /* INDIGO */
- {128, 0, 255}, /* VIOLET */
- {180, 77, 25} /* BROWN */
-};
-
-/* The order in this table has no meaning. */
-static const struct color_name standard_color_names[] = {
- {"black", BLACK},
- {"red", RED},
- {"green", GREEN},
- {"blue", BLUE},
- {"yellow", YELLOW},
- {"cyan", CYAN},
- {"magenta", MAGENTA},
- {"white", WHITE},
- {"grey", GREY},
- {"gray", GRAY},
- {"orange", ORANGE},
- {"aqua", AQUA},
- {"indigo", INDIGO},
- {"violet", VIOLET},
- {"purple", PURPLE},
- {"brown", BROWN}
-};
-
-/*!
- \brief Get number of named colors (RGB triplets)
-
- \return number of colors
- */
-int G_num_standard_colors(void)
-{
- return sizeof(standard_colors_rgb) / sizeof(standard_colors_rgb[0]);
-}
-
-/*!
- \brief Get RGB triplet of given color
-
- \param n color index
- */
-struct color_rgb G_standard_color_rgb(int n)
-{
- return standard_colors_rgb[n];
-}
-
-/*!
- \brief Get number of named colors (color names)
-
- \return number of colors
- */
-int G_num_standard_color_names(void)
-{
- return sizeof(standard_color_names) / sizeof(standard_color_names[0]);
-}
-
-/*!
- \brief Get color name
-
- \param n color index
- */
-const struct color_name *G_standard_color_name(int n)
-{
- return &standard_color_names[n];
-}
-
-/*!
- \brief Parse color string and set red,green,blue
-
- \param str color string
- \param[out] red red value
- \param[out] grn green value
- \param[out] blu blue value
-
- \return 1 OK
- \return 2 NONE
- \return 0 on error
- */
-int G_str_to_color(const char *str, int *red, int *grn, int *blu)
-{
- char buf[100];
- int num_names = G_num_standard_color_names();
- int i;
-
- strcpy(buf, str);
- G_chop(buf);
-
- G_debug(3, "G_str_to_color(): str = '%s'", buf);
-
- if (G_strcasecmp(buf, "NONE") == 0)
- return 2;
-
- if (sscanf(buf, "%d%*[,:; ]%d%*[,:; ]%d", red, grn, blu) == 3) {
- if (*red < 0 || *red > 255 ||
- *grn < 0 || *grn > 255 || *blu < 0 || *blu > 255)
- return 0;
-
- return 1;
- }
-
- /* Look for this color in the standard (preallocated) colors */
- for (i = 0; i < num_names; i++) {
- const struct color_name *name = &standard_color_names[i];
-
- if (G_strcasecmp(buf, name->name) == 0) {
- struct color_rgb rgb = standard_colors_rgb[name->number];
-
- *red = (int)rgb.r;
- *grn = (int)rgb.g;
- *blu = (int)rgb.b;
-
- return 1;
- }
- }
-
- return 0;
-}
Deleted: grass/trunk/lib/gis/color_write.c
===================================================================
--- grass/trunk/lib/gis/color_write.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_write.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,266 +0,0 @@
-/*!
- * \file gis/color_write.c
- *
- * \brief GIS Library - Write color table of raster map
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <grass/gis.h>
-
-#define PRECISION 30
-#define THRESHOLD .0000000000000000000000000000005 /* .5 * 10 ^(-30) */
-
-static void write_rules(FILE *, struct _Color_Rule_ *, DCELL, DCELL);
-static void write_new_colors(FILE *, struct Colors *);
-static void write_old_colors(FILE *, struct Colors *);
-static void forced_write_old_colors(FILE *, struct Colors *);
-static void format_min(char *, double);
-static void format_max(char *, double);
-
-/*!
- * \brief Write map layer color table
- *
- * The color table is written for the raster map <i>name</i> in the
- * specified <i>mapset</i> from the <i>colors</i> structure.
- *
- * If there is an error, -1 is returned. No diagnostic is
- * printed. Otherwise, 1 is returned.
- *
- * The <i>colors</i> structure must be created properly, i.e.,
- * G_init_colors() to initialize the structure and G_add_color_rule()
- * to set the category colors. These routines are called by
- * higher level routines which read or create entire color tables,
- * such as G_read_colors() or G_make_ramp_colors().
- *
- * <b>Note:</b> The calling sequence for this function deserves
- * special attention. The <i>mapset</i> parameter seems to imply that
- * it is possible to overwrite the color table for a raster map which
- * is in another mapset. However, this is not what actually
- * happens. It is very useful for users to create their own color
- * tables for raster maps in other mapsets, but without overwriting
- * other users' color tables for the same raster map. If <i>mapset</i>
- * is the current mapset, then the color file for <i>name</i> will be
- * overwritten by the new color table. But if <i>mapset</i> is not the
- * current mapset, then the color table is actually written in the
- * current mapset under the <tt>colr2</tt> element as:
- * <tt>colr2/mapset/name</tt>.
- *
- * The rules are written out using floating-point format, removing
- * trailing zeros (possibly producing integers). The flag marking the
- * colors as floating-point is <b>not</b> written.
- *
- * If the environment variable FORCE_GRASS3_COLORS is set (to anything at all)
- * then the output format is 3.0, even if the structure contains 4.0 rules.
- * This allows users to create 3.0 color files for export to sites which
- * don't yet have 4.0
- *
- * \param name map name
- * \param mapset mapset name
- * \param colors pointer to structure Colors which holds color info
- *
- * \return 1 on success
- * \return -1 on failure
- */
-int G_write_colors(const char *name, const char *mapset,
- struct Colors *colors)
-{
- char element[512];
- char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
- FILE *fd;
-
- if (G__name_is_fully_qualified(name, xname, xmapset)) {
- if (strcmp(xmapset, mapset) != 0)
- return -1;
- name = xname;
- }
- /*
- * if mapset is current mapset, remove colr2 file (created by pre 3.0 grass)
- * and then write original color table
- * else write secondary color table
- */
- sprintf(element, "colr2/%s", mapset);
- if (strcmp(mapset, G_mapset()) == 0) {
- G_remove(element, name); /* get rid of existing colr2, if any */
- strcpy(element, "colr");
- }
- if (!(fd = G_fopen_new(element, name)))
- return -1;
-
- G__write_colors(fd, colors);
- fclose(fd);
- return 1;
-}
-
-/*!
- * \brief Write map layer color table
- *
- * \param fd file descriptor
- * \param colors pointer to Colors structure which holds color info
- */
-void G__write_colors(FILE * fd, struct Colors *colors)
-{
- if (getenv("FORCE_GRASS3_COLORS"))
- forced_write_old_colors(fd, colors);
- else if (colors->version < 0)
- write_old_colors(fd, colors);
- else
- write_new_colors(fd, colors);
-}
-
-static void write_new_colors(FILE * fd, struct Colors *colors)
-{
- char str1[100], str2[100];
-
- format_min(str1, (double)colors->cmin);
- format_max(str2, (double)colors->cmax);
- fprintf(fd, "%% %s %s\n", str1, str2);
-
- if (colors->shift) {
- sprintf(str2, "%.10f", (double)colors->shift);
- G_trim_decimal(str2);
- fprintf(fd, "shift:%s\n", str2);
- }
- if (colors->invert)
- fprintf(fd, "invert\n");
-
- if (colors->null_set) {
- fprintf(fd, "nv:%d", colors->null_red);
- if (colors->null_red != colors->null_grn || colors->null_red
- != colors->null_blu)
- fprintf(fd, ":%d:%d", colors->null_grn, colors->null_blu);
- fprintf(fd, "\n");
- }
- if (colors->undef_set) {
- fprintf(fd, "*:%d", colors->undef_red);
- if (colors->undef_red != colors->undef_grn || colors->undef_red
- != colors->undef_blu)
- fprintf(fd, ":%d:%d", colors->undef_grn, colors->undef_blu);
- fprintf(fd, "\n");
- }
- if (colors->modular.rules) {
- fprintf(fd, "%s\n", "%%");
- write_rules(fd, colors->modular.rules, colors->cmin, colors->cmax);
- fprintf(fd, "%s\n", "%%");
- }
- if (colors->fixed.rules)
- write_rules(fd, colors->fixed.rules, colors->cmin, colors->cmax);
-}
-
-/* overall min and max data values in color table */
-static void write_rules(FILE * fd, struct _Color_Rule_ *crules, DCELL dmin, DCELL dmax)
-{
- struct _Color_Rule_ *rule;
- char str[100];
-
- /* find the end of the rules list */
- rule = crules;
- while (rule->next)
- rule = rule->next;
-
- /* write out the rules in reverse order */
- for (; rule; rule = rule->prev) {
- if (rule->low.value == dmin)
- format_min(str, (double)rule->low.value);
- else {
- sprintf(str, "%.10f", (double)rule->low.value);
- G_trim_decimal(str);
- }
- fprintf(fd, "%s:%d", str, (int)rule->low.red);
- if (rule->low.red != rule->low.grn || rule->low.red != rule->low.blu)
- fprintf(fd, ":%d:%d", rule->low.grn, rule->low.blu);
- /* even if low==high, write second end when the high is dmax */
- if (rule->high.value == dmax || rule->low.value != rule->high.value) {
- if (rule->high.value == dmax)
- format_max(str, (double)rule->high.value);
- else {
- sprintf(str, "%.10f", (double)rule->high.value);
- G_trim_decimal(str);
- }
- fprintf(fd, " %s:%d", str, (int)rule->high.red);
- if (rule->high.red != rule->high.grn ||
- rule->high.red != rule->high.blu)
- fprintf(fd, ":%d:%d", rule->high.grn, rule->high.blu);
- }
- fprintf(fd, "\n");
- }
-}
-
-static void write_old_colors(FILE * fd, struct Colors *colors)
-{
- int i, n;
-
- fprintf(fd, "#%ld first color\n", (long)colors->fixed.min);
- if (colors->null_set) {
- fprintf(fd, "%d %d %d\n",
- (int)colors->null_red,
- (int)colors->null_grn, (int)colors->null_blu);
- }
- else
- fprintf(fd, "255 255 255\n"); /* white */
-
- n = colors->fixed.max - colors->fixed.min + 1;
-
- for (i = 0; i < n; i++) {
- fprintf(fd, "%d", (int)colors->fixed.lookup.red[i]);
- if (colors->fixed.lookup.red[i] != colors->fixed.lookup.grn[i]
- || colors->fixed.lookup.red[i] != colors->fixed.lookup.blu[i])
- fprintf(fd, " %d %d",
- (int)colors->fixed.lookup.grn[i],
- (int)colors->fixed.lookup.blu[i]);
- fprintf(fd, "\n");
- }
-}
-
-static void forced_write_old_colors(FILE * fd, struct Colors *colors)
-{
- int red, grn, blu;
- CELL cat;
-
- fprintf(fd, "#%ld first color\n", (long)colors->cmin);
- G_get_color((CELL) 0, &red, &grn, &blu, colors);
- fprintf(fd, "%d %d %d\n", red, grn, blu);
-
- for (cat = colors->cmin; cat <= colors->cmax; cat++) {
- G_get_color(cat, &red, &grn, &blu, colors);
- fprintf(fd, "%d", red);
- if (red != grn || red != blu)
- fprintf(fd, " %d %d", grn, blu);
- fprintf(fd, "\n");
- }
-}
-
-static void format_min(char *str, double dval)
-{
- double dtmp;
-
- sprintf(str, "%.*f", PRECISION, dval);
- G_trim_decimal(str);
- sscanf(str, "%lf", &dtmp);
- if (dtmp != dval) { /* if no zeros after decimal point were trimmed */
- sprintf(str, "%.*f", PRECISION, dval - THRESHOLD);
- /* because precision is probably higher than PRECISION */
- }
-}
-
-static void format_max(char *str, double dval)
-{
- double dtmp;
-
- sprintf(str, "%.*f", PRECISION, dval);
- G_trim_decimal(str);
- sscanf(str, "%lf", &dtmp);
- if (dtmp != dval) { /* if no zeros after decimal point were trimmed */
- sprintf(str, "%.*f", PRECISION, dval + THRESHOLD);
- /* because precision is probably higher than PRECISION */
- }
-}
Deleted: grass/trunk/lib/gis/color_xform.c
===================================================================
--- grass/trunk/lib/gis/color_xform.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/color_xform.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,316 +0,0 @@
-
-/****************************************************************************
- *
- * MODULE: gis library
- * AUTHOR(S): Glynn Clements <glynn at gclements.plus.com>
- * COPYRIGHT: (C) 2007 Glynn Clements
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- *****************************************************************************/
-
-/**********************************************************************
- *
- * G_histogram_eq_colors (dst, src, statf)
- *
- * struct Colors *dst struct to hold new colors
- * struct Colors *src struct containing original colors
- * struct Cell_stats *statf cell stats info
- *
- * Generates histogram equalized version of an existing color table from
- * cell stats structure info.
- *
- **********************************************************************
- *
- * G_log_colors (dst, src, samples)
- *
- * struct Colors *dst struct to hold new colors
- * struct Colors *src struct containing original colors
- * int samples number of samples
- *
- * Generates logarithmically-scaled version of an existing color table.
- *
- **********************************************************************/
-#include <grass/gis.h>
-#include <math.h>
-
-/*!
- * \brief make histogram-stretched version of existing color table
- *
- * Generates a histogram
- * contrast-stretched color table that goes from the histogram
- * information in the Cell_stats structure <b>statf.</b> (See
- * Raster_Histograms).
- *
- * \param dst
- * \param src
- * \param statf
- * \return
- */
-
-void G_histogram_eq_colors(struct Colors *dst,
- struct Colors *src, struct Cell_stats *statf)
-{
- DCELL min, max;
- int red, grn, blu;
- long count, total, sum;
- CELL cat, prev;
- int first;
-
- G_init_colors(dst);
-
- G_get_d_color_range(&min, &max, src);
-
- G_get_default_color(&red, &grn, &blu, src);
- G_set_default_color(red, grn, blu, dst);
-
- G_get_null_value_color(&red, &grn, &blu, src);
- G_set_null_value_color(red, grn, blu, dst);
-
- total = 0;
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf))
- if (count > 0)
- total += count;
-
- if (total <= 0)
- return;
-
- sum = 0;
- prev = 0;
- first = 1;
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf)) {
- int red2, grn2, blu2;
- DCELL x;
-
- if (count <= 0)
- continue;
-
- x = min + (max - min) * (sum + count / 2.0) / total;
- G_get_d_raster_color(&x, &red2, &grn2, &blu2, src);
-
- if (!first)
- G_add_color_rule(prev, red, grn, blu, cat, red2, grn2, blu2, dst);
-
- sum += count;
- first = 0;
-
- prev = cat;
- red = red2;
- grn = grn2;
- blu = blu2;
- }
-}
-
-/*!
- * \brief make histogram-stretched version of existing color table (FP version)
- *
- * Generates a histogram
- * contrast-stretched color table that goes from the histogram
- * information in the FP_stats structure <b>statf.</b> (See
- * Raster_Histograms).
- *
- * \param dst
- * \param src
- * \param statf
- * \return void
- */
-
-void G_histogram_eq_colors_fp(struct Colors *dst,
- struct Colors *src, struct FP_stats *statf)
-{
- DCELL min, max;
- int red, grn, blu;
- unsigned long sum;
- DCELL val;
- int first;
- int i;
-
- G_init_colors(dst);
-
- G_get_d_color_range(&min, &max, src);
-
- G_get_default_color(&red, &grn, &blu, src);
- G_set_default_color(red, grn, blu, dst);
-
- G_get_null_value_color(&red, &grn, &blu, src);
- G_set_null_value_color(red, grn, blu, dst);
-
- if (!statf->total)
- return;
-
- sum = 0;
- first = 1;
-
- for (i = 0; i <= statf->count; i++) {
- int red2, grn2, blu2;
- DCELL val2, x;
-
- val2 = statf->min + (statf->max - statf->min) * i / statf->count;
- if (statf->geometric)
- val2 = exp(val2);
- if (statf->geom_abs)
- val2 = exp(val2) - 1;
- if (statf->flip)
- val2 = -val2;
- x = min + (max - min) * sum / statf->total;
- G_get_d_raster_color(&x, &red2, &grn2, &blu2, src);
-
- if (!first)
- G_add_d_raster_color_rule(&val, red, grn, blu, &val2, red2, grn2, blu2, dst);
- first = 0;
-
- if (i == statf->count)
- break;
-
- sum += statf->stats[i];
-
- val = val2;
- red = red2;
- grn = grn2;
- blu = blu2;
- }
-}
-
-/*!
- * \brief make logarithmically-scaled version of an existing color table
- *
- * \param dst
- * \param src
- * \param samples
- * \return
- */
-
-void G_log_colors(struct Colors *dst, struct Colors *src, int samples)
-{
- DCELL min, max;
- double lmin, lmax;
- int red, grn, blu;
- DCELL prev;
- int i;
-
- G_init_colors(dst);
-
- G_get_d_color_range(&min, &max, src);
-
- lmin = log(min);
- lmax = log(max);
-
- G_get_default_color(&red, &grn, &blu, src);
- G_set_default_color(red, grn, blu, dst);
-
- G_get_null_value_color(&red, &grn, &blu, src);
- G_set_null_value_color(red, grn, blu, dst);
-
- for (i = 0; i <= samples; i++) {
- int red2, grn2, blu2;
- double lx;
- DCELL x, y;
-
- y = min + (max - min) * i / samples;
- G_get_d_raster_color(&y, &red2, &grn2, &blu2, src);
-
- if (i == 0)
- x = min;
- else if (i == samples)
- x = max;
- else {
- lx = lmin + (lmax - lmin) * i / samples;
- x = exp(lx);
- }
-
- if (i > 0)
- G_add_d_raster_color_rule(&prev, red, grn, blu,
- &x, red2, grn2, blu2,
- dst);
-
- prev = x;
-
- red = red2;
- grn = grn2;
- blu = blu2;
- }
-}
-
-/*!
- * \brief make logarithmically-scaled version of an existing color table, allowing for signed values
- *
- * \param dst
- * \param src
- * \param samples
- * \return
- */
-
-void G_abs_log_colors(struct Colors *dst, struct Colors *src, int samples)
-{
- DCELL min, max;
- double lmin, lmax;
- DCELL amax, lamax;
- int red, grn, blu;
- DCELL prev;
- int i;
-
- G_init_colors(dst);
-
- G_get_d_color_range(&min, &max, src);
-
- lmin = log(fabs(min) + 1.0);
- lmax = log(fabs(max) + 1.0);
-
- amax = fabs(min) > fabs(max) ? fabs(min) : fabs(max);
- lamax = lmin > lmax ? lmin : lmax;
-
- G_get_default_color(&red, &grn, &blu, src);
- G_set_default_color(red, grn, blu, dst);
-
- G_get_null_value_color(&red, &grn, &blu, src);
- G_set_null_value_color(red, grn, blu, dst);
-
- for (i = 0; i <= samples; i++) {
- int red2, grn2, blu2;
- double lx;
- DCELL x, y;
-
- y = min + (max - min) * i / samples;
- G_get_d_raster_color(&y, &red2, &grn2, &blu2, src);
-
- if (i == 0)
- x = 1;
- else if (i == samples)
- x = amax;
- else {
- lx = 0 + lamax * i / samples;
- x = exp(lx);
- }
-
- if (i > 0) {
- DCELL x0 = prev, x1 = x;
- G_add_d_raster_color_rule(&x0, red, grn, blu,
- &x1, red2, grn2, blu2,
- dst);
- x0 = -x0;
- x1 = -x1;
- G_add_d_raster_color_rule(&x0, red, grn, blu,
- &x1, red2, grn2, blu2,
- dst);
- }
-
- prev = x;
-
- red = red2;
- grn = grn2;
- blu = blu2;
- }
-}
-
Modified: grass/trunk/lib/gis/debug.c
===================================================================
--- grass/trunk/lib/gis/debug.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/debug.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,8 +20,8 @@
#include <stdarg.h>
#include <grass/gis.h>
#include <grass/glocale.h>
-#include "G.h"
+#include "../raster/G.h"
static int initialized;
static int grass_debug_level;
Deleted: grass/trunk/lib/gis/format.c
===================================================================
--- grass/trunk/lib/gis/format.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/format.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,192 +0,0 @@
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <grass/config.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "G.h"
-
-/*!
-
- <h3>GRASS Raster Format</h3>
-
- Small example to illustrate the raster format:
-
- A file may contain the following 3x3 floating point matrix:
- \verbatim
- 10.000 20.000 30.000
- 20.000 40.000 50.000
- 30.000 50.000 60.000
- \endverbatim
-
- The header is a single byte, equal to sizeof(off_t) (typically 4 on a
- 32-bit platform, 8 on a 64-bit platform). Then, NROWS+1 offsets are
- written as off_t's (i.e. 4 or 8 bytes, depending upon platform) in
- big-endian (Motorola) byte order.
- <P>
- Thus, above example is actually interpreted as:
- \verbatim
- 4 sizeof(off_t)
- 0 0 0 17 offset of row 0
- 0 0 0 36 offset of row 1
- 0 0 0 55 offset of row 2
- 0 0 0 74 offset of end of data
- \endverbatim
-
- See G__write_row_ptrs() below for the code which writes this data.
- However, note that the row offsets are initially zero;
- they get overwritten later (if you are writing compressed data,
- you don't know how much space it will require until you've compressed
- it).
-
- As for the format of the actual row data, see put_fp_data() in
- src/libes/gis/put_row.c and RFC 1014 (the XDR specification):
- http://www.faqs.org/rfcs/rfc1014.html
-
- */
-
-/**********************************************************************
- *
- * G__check_format(int fd)
- *
- * Check to see if map with file descriptor "fd" is in compressed
- * format. If it is, the offset table at the beginning of the
- * file (which gives seek addresses into the file where code for
- * each row is found) is read into the File Control Buffer (FCB).
- * The compressed flag in the FCB is appropriately set.
- *
- * returns: 1 if row pointers were read successfully, -1 otherwise
- **********************************************************************/
-
-int G__check_format(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- unsigned char compress[4];
-
- /*
- * Check to see if the file is in compress mode
- * 4 possibilites
- * compressed flag in cellhd is negative (meaning pre 3.0 cell file)
- * compression flag is first 3 bytes of cell file
- * compression flag is 0 - not compressed
- * compression flag is 1 - compressed using RLE (int) or zlib (FP)
- * compression flag is 2 - compressed using zlib
- */
-
- if (fcb->cellhd.compressed < 0) {
- if (read(fd, compress, 3) != 3
- || compress[0] != 251 || compress[1] != 255 || compress[2] != 251)
- fcb->cellhd.compressed = 0;
- }
-
- if (!fcb->cellhd.compressed)
- return fd;
-
- /* allocate space to hold the row address array */
- fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
-
- /* read the row address array */
- return G__read_row_ptrs(fd);
-}
-
-int G__read_row_ptrs(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int nrows = fcb->cellhd.rows;
- unsigned char nbytes;
- unsigned char *buf, *b;
- int n;
- int row;
-
- /*
- * pre3.0 row addresses were written directly from the array of off_t's
- * (this makes them machine dependent)
- */
-
- if (fcb->cellhd.compressed < 0) {
- n = (nrows + 1) * sizeof(off_t);
- if (read(fd, fcb->row_ptr, n) != n)
- goto badread;
- return 1;
- }
-
- /*
- * 3.0 row address array is in a machine independent format
- * (warning - the format will work even if the sizeof(off_t) is
- * not the same from machine to machine, as long as the
- * actual values do not exceed the capability of the off_t)
- */
-
- if (read(fd, &nbytes, 1) != 1)
- goto badread;
- if (nbytes == 0)
- goto badread;
-
- n = (nrows + 1) * nbytes;
- buf = G_malloc(n);
- if (read(fd, buf, n) != n)
- goto badread;
-
- for (row = 0, b = buf; row <= nrows; row++) {
- off_t v = 0;
-
- for (n = 0; n < (int)nbytes; n++) {
- unsigned char c = *b++;
-
- if (nbytes > sizeof(off_t) && n < nbytes - sizeof(off_t) &&
- c != 0)
- goto badread;
-
- v <<= 8;
- v += c;
- }
-
- fcb->row_ptr[row] = v;
- }
-
- G_free(buf);
-
- return 1;
-
- badread:
- G_warning(_("Fail of initial read of compressed file [%s in %s]"),
- fcb->name, fcb->mapset);
- return -1;
-}
-
-int G__write_row_ptrs(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int nrows = fcb->cellhd.rows;
- int nbytes = sizeof(off_t);
- unsigned char *buf, *b;
- int len, row, result;
-
- lseek(fd, 0L, SEEK_SET);
-
- len = (nrows + 1) * nbytes + 1;
- b = buf = G_malloc(len);
- *b++ = nbytes;
-
- for (row = 0; row <= nrows; row++) {
- off_t v = fcb->row_ptr[row];
- int i;
-
- for (i = nbytes - 1; i >= 0; i--) {
- b[i] = v & 0xff;
- v >>= 8;
- }
-
- b += nbytes;
- }
-
- result = (write(fd, buf, len) == len);
- G_free(buf);
-
- return result;
-}
Deleted: grass/trunk/lib/gis/fpreclass.c
===================================================================
--- grass/trunk/lib/gis/fpreclass.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/fpreclass.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,719 +0,0 @@
-
-/**********************************************************************
- *
- * G_fpreclass_init (r)
- *
- * struct FPReclass *r;
- *
- * initializes new reclassification structure. calls
- * G_fpreclass_clear() before it returns.
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_reset (r)
- *
- * struct FPReclass *r;
- *
- * resets the number of defined rules to 0 and free's space allocated
- * for rules. calls G_fpreclass_clear ().
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_clear (r)
- *
- * struct FPReclass *r;
- *
- * resets the number of defined rules to 0. Resets default Min and Max
- * to be unknown. (see G_fpreclass_set_domain (), G_fpreclass_set_range ()).
- * deactivates default mapping.
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_set_domain (r, dLow, dHigh)
- *
- * struct FPReclass *r;
- * DCELL dLow, dHigh;
- *
- * defines the domain for the default mapping and
- * activates default mapping. (see G_fpreclass_perform_d ()).
- *
- * note: dHigh < dLow is valid.
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_set_range (r, low, high)
- *
- * struct FPReclass *r;
- * DCELL low, high;
- *
- * defines the range for the default mapping. does NOT
- * activate default mapping. (see G_fpreclass_perform_d ()).
- *
- **********************************************************************
- *
- * int
- * G_fpreclass_get_limits (r, dMin, dMax, rMin, rmax)
- *
- * const struct FPReclass *r;
- * DCELL *dMin, *dMax;
- * DCELL *rMin, *rmax;
- *
- * returns the minimum and maximum values of all the rules defined.
- *
- * returns: -1 if after G_fpreclass_init (), or any call to
- * G_fpreclass_clear () or G_fpreclass_reset () neither
- * G_fpreclass_add_rule () nor G_fpreclass_set_domain () is
- * used. in this case the returned minimum and maximum
- * range and domain values are undefined.
- * 0 if the default rule values are returned.domain values
- * are identical to those set with G_fpreclass_set_domain ().
- * range values are either reclassification internal default,
- * or the values set with G_fpreclass_set_range ().
- * 1 otherwise. in this case the values returned correspond
- * to the extreme values of the defined rules (they need
- * not be identical to the values set with
- * G_fpreclass_set_domain ()).
- *
- **********************************************************************
- *
- * int
- * G_fpreclass_nof_rules (r)
- *
- * const struct FPReclass *r;
- *
- * returns the number of reclassification rules defined. This number does
- * not include the 2 infinite intervals.
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_get_ith_rule (r, i, dLow, dHigh, rLow, rHigh)
- *
- * const struct FPReclass *r;
- * int i;
- * DCELL *dLow, *dHigh;
- * DCELL *rLow, *rHigh;
- *
- * returns the i'th reclassification rule, for
- * 0 <= i < G_fpreclass_nof_rules().
- * a larger value for i means that the rule has been added later.
- *
- **********************************************************************
- * void
- * G_fpreclass_set_neg_infinite_rule (r, dLeft, c)
- *
- * struct FPReclass *r;
- * DCELL dLeft;
- * DCELL c;
- *
- * defines a rule for values "dLeft" and smaller. values in this range
- * are mapped to "c" if none of the "finite" reclassification rules applies.
- *
- * **********************************************************************
- *
- * int
- * G_fpreclass_get_neg_infinite_rule (r, dLeft, c)
- *
- * const struct FPReclass *r;
- * DCELL *dLeft;
- * DCELL *c;
- *
- * returns in "dLeft" and "c" the rule values for the negative infinite
- * interval (see G_fpreclass_set_neg_infinite_rule ()).
- *
- * returns: 0 if this rule is not defined
- * 1 otherwise.
- *
- **********************************************************************
- * void
- * G_fpreclass_set_pos_infinite_rule (r, dRight, c)
- *
- * struct FPReclass *r;
- * DCELL dRight;
- * DCELL c;
- *
- * defines a rule for values "dRight" and larger. values in this range
- * are mapped to "c" if neither any of the "finite" reclassification
- * rules nor the negative infinite rule applies.
- *
- * **********************************************************************
- *
- * int
- * G_fpreclass_get_pos_infinite_rule (r, dRight, c)
- *
- * const struct FPReclass *r;
- * DCELL *dRight;
- * DCELL *c;
- *
- * returns in "dRight" and "c" the rule values for the positive infinite
- * interval (see G_fpreclass_set_pos_infinite_rule ()).
- *
- * returns: 0 if this rule is not defined
- * 1 otherwise.
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_reverse_rule_order (r)
- *
- * struct FPReclass *r;
- *
- * reverses the order in which the reclassification rules are stored. (see
- * also G_fpreclass_get_ith_rule () and G_fpreclass_perform_XY ()).
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_add_rule (r, dLow, dHigh, rLow, rHigh)
- *
- * struct FPReclass *r;
- * DCELL dLow, dHigh;
- * DCELL rLow, rHigh;
- *
- * adds a new rule to the set of reclassification rules. if dLow > dHigh
- * the rule will be stored with the low and high values interchanged.
- *
- * Note: currently no cleanup of rules is performed, i.e. redundant
- * rules are not removed.
- *
- **********************************************************************
- *
- * DCELL
- * G_fpreclass_get_cell_value (r, cellValue)
- *
- * const struct FPReclass *r;
- * DCELL *cellValue;
- *
- * returns the reclassified value corresponding to "cellValue".
- *
- * if several reclassification rules apply for cellValue, the one which has
- * been inserted latest (i.e. the one of them which is returned by
- * G_fpreclass_get_ith_rule() for the largest i) is used. if no such rule
- * applies the cellValue is first tested against the negative infinite
- * rule, and finally against the positive infinite rule. if none of
- * these rules apply, NO_DATA is returned. the actual value of NO_DATA
- * is found by calling G_set_d_null_value()
- *
- * if after G_fpreclass_init (), or any call to G_fpreclass_clear () or
- * G_fpreclass_reset () neither G_fpreclass_add_rule (),
- * G_fpreclass_set_neg_infinite_rule (),
- * G_fpreclass_set_pos_infinite_rule (), * nor G_fpreclass_set_domain ()
- * is used NO_DATA is returned independently of the cellValue.
- *
- * if G_fpreclass_set_domain () is called but no explicit reclassification
- * rule is set, the default mapping to the cell range set with
- * G_fpreclass_set_range () or, if the cell range is not set,
- * to the default CELL range [0,256 - 1] is applied.
- *
- **********************************************************************
- *
- * void
- * G_fpreclass_perform_XY (r, xcell, ycell, n)
- *
- * const struct FPReclass *r;
- * XCELL *xcell;
- * YCELL *ycell;
- * int n;
- *
- * "X" and "Y" in the function name can be any of "d", "f", or "i". These
- * correspond to "DCELL", "FCELL", and "CELL", respectively, and denote
- * the type of the domain and range values.
- *
- * returns in "ycell" the reclassified YCELL values corresponding to the
- * XCELL values stored in "xcell". the number of elements reclassified
- * is n. reclassification is performed by repeated application of
- * G_fpreclass_get_cell_value ().
- *
- **********************************************************************/
-
-/*--------------------------------------------------------------------------*/
-
-/*
- the reclassification table is stored as a linear array. rules are added
- starting from index 0. redundant rules are not eliminated. rules are tested
- from the highest index downto 0. there are two "infinite" rules. support is
- provided to reverse the order of the rules.
- */
-
-/*--------------------------------------------------------------------------*/
-
-#include <grass/gis.h>
-
-/*--------------------------------------------------------------------------*/
-
-#undef MIN
-#undef MAX
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
-#define NO_DEFAULT_RULE (! r->defaultDRuleSet)
-#define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
-#define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)
-#define NO_FINITE_RULE (r->nofRules <= 0)
-#define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
- NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
-
-#define DEFAULT_MIN ((DCELL) 1)
-#define DEFAULT_MAX ((DCELL) 255)
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_clear(struct FPReclass *r)
-{
- r->nofRules = 0;
- r->defaultDRuleSet = 0;
- r->defaultRRuleSet = 0;
- r->infiniteRightSet = r->infiniteLeftSet = 0;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_reset(struct FPReclass *r)
-{
- G_fpreclass_clear(r);
-
- if (r->maxNofRules > 0)
- G_free(r->table);
-
- r->maxNofRules = 0;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_init(struct FPReclass *r)
-{
- r->maxNofRules = 0;
- G_fpreclass_reset(r);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_set_domain(struct FPReclass *r, DCELL dLow, DCELL dHigh)
-{
- r->defaultDMin = dLow;
- r->defaultDMax = dHigh;
- r->defaultDRuleSet = 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_set_range(struct FPReclass *r, DCELL low, DCELL high)
-{
- r->defaultRMin = low;
- r->defaultRMax = high;
- r->defaultRRuleSet = 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-static void fpreclass_set_limits(struct FPReclass *r,
- DCELL dLow, DCELL dHigh,
- DCELL rLow, DCELL rHigh)
-{
- r->dMin = dLow;
- r->dMax = dHigh;
- r->rMin = rLow;
- r->rMax = rHigh;
-}
-
-/*--------------------------------------------------------------------------*/
-
-static void fpreclass_update_limits(struct FPReclass *r,
- DCELL dLow, DCELL dHigh,
- DCELL rLow, DCELL rHigh)
-{
- if (NO_EXPLICIT_RULE) {
- fpreclass_set_limits(r, dLow, dHigh, rLow, rHigh);
- return;
- }
-
- r->dMin = MIN(r->dMin, MIN(dLow, dHigh));
- r->dMax = MAX(r->dMax, MAX(dLow, dHigh));
- r->rMin = MIN(r->rMin, MIN(rLow, rHigh));
- r->rMax = MAX(r->rMax, MAX(rLow, rHigh));
-}
-
-/*--------------------------------------------------------------------------*/
-
-int G_fpreclass_get_limits(const struct FPReclass *r,
- DCELL * dMin, DCELL * dMax,
- DCELL * rMin, DCELL * rMax)
-{
- if (NO_EXPLICIT_RULE) {
- if (NO_DEFAULT_RULE)
- return -1;
-
- *dMin = r->defaultDMin;
- *dMax = r->defaultDMax;
-
- if (r->defaultRRuleSet) {
- *rMin = r->defaultRMin;
- *rMax = r->defaultRMax;
- }
- else {
- *rMin = DEFAULT_MIN;
- *rMax = DEFAULT_MAX;
- }
-
- return 0;
- }
-
- *dMin = r->dMin;
- *dMax = r->dMax;
- *rMin = r->rMin;
- *rMax = r->rMax;
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-int G_fpreclass_nof_rules(const struct FPReclass *r)
-{
- return r->nofRules;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_get_ith_rule(const struct FPReclass *r, int i,
- DCELL *dLow, DCELL *dHigh,
- DCELL *rLow, DCELL *rHigh)
-{
- *dLow = r->table[i].dLow;
- *dHigh = r->table[i].dHigh;
- *rLow = r->table[i].rLow;
- *rHigh = r->table[i].rHigh;
-}
-
-/*--------------------------------------------------------------------------*/
-
-static void fpreclass_table_increase(struct FPReclass *r)
-{
- if (r->nofRules < r->maxNofRules)
- return;
-
- if (r->maxNofRules == 0) {
- r->maxNofRules = 50;
- r->table = (struct FPReclass_table *)
- G_malloc(r->maxNofRules * sizeof(struct FPReclass_table));
- }
- else {
- r->maxNofRules += 50;
- r->table = (struct FPReclass_table *)
- G_realloc((char *)r->table,
- r->maxNofRules * sizeof(struct FPReclass_table));
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-void
-G_fpreclass_set_neg_infinite_rule(struct FPReclass *r, DCELL dLeft, DCELL c)
-{
- r->infiniteDLeft = dLeft;
- r->infiniteRLeft = c;
- fpreclass_update_limits(r, dLeft, dLeft, c, c);
- r->infiniteLeftSet = 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-int G_fpreclass_get_neg_infinite_rule(const struct FPReclass *r,
- DCELL *dLeft, DCELL *c)
-{
- if (r->infiniteLeftSet == 0)
- return 0;
-
- *dLeft = r->infiniteDLeft;
- *c = r->infiniteRLeft;
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_set_pos_infinite_rule(struct FPReclass *r, DCELL dRight, DCELL c)
-{
- r->infiniteDRight = dRight;
- r->infiniteRRight = c;
- fpreclass_update_limits(r, dRight, dRight, c, c);
- r->infiniteRightSet = 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-int G_fpreclass_get_pos_infinite_rule(const struct FPReclass *r,
- DCELL *dRight, DCELL *c)
-{
- if (r->infiniteRightSet == 0)
- return 0;
-
- *dRight = r->infiniteDRight;
- *c = r->infiniteRRight;
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_add_rule(struct FPReclass *r,
- DCELL dLow, DCELL dHigh,
- DCELL rLow, DCELL rHigh)
-{
- int i;
- struct FPReclass_table *p;
-
- fpreclass_table_increase(r);
-
- i = r->nofRules;
-
- p = &(r->table[i]);
- if (dHigh >= dLow) {
- p->dLow = dLow;
- p->dHigh = dHigh;
- p->rLow = rLow;
- p->rHigh = rHigh;
- }
- else {
- p->dLow = dHigh;
- p->dHigh = dLow;
- p->rLow = rHigh;
- p->rHigh = rLow;
- }
-
- fpreclass_update_limits(r, dLow, dHigh, rLow, rHigh);
-
- r->nofRules++;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_reverse_rule_order(struct FPReclass *r)
-{
- struct FPReclass_table tmp;
- struct FPReclass_table *pLeft, *pRight;
-
- pLeft = r->table;
- pRight = &(r->table[r->nofRules - 1]);
-
- while (pLeft < pRight) {
- tmp.dLow = pLeft->dLow;
- tmp.dHigh = pLeft->dHigh;
- tmp.rLow = pLeft->rLow;
- tmp.rHigh = pLeft->rHigh;
-
- pLeft->dLow = pRight->dLow;
- pLeft->dHigh = pRight->dHigh;
- pLeft->rLow = pRight->rLow;
- pLeft->rHigh = pRight->rHigh;
-
- pRight->dLow = tmp.dLow;
- pRight->dHigh = tmp.dHigh;
- pRight->rLow = tmp.rLow;
- pRight->rHigh = tmp.rHigh;
-
- pLeft++;
- pRight--;
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-static DCELL fpreclass_interpolate(
- DCELL dLow, DCELL dHigh,
- DCELL rLow, DCELL rHigh,
- DCELL dValue)
-{
- if (rLow == rHigh)
- return rLow;
- if (dLow == dHigh)
- return rLow;
-
- return ((dValue - dLow) / (dHigh - dLow) * (rHigh - rLow) + rLow);
-}
-
-/*--------------------------------------------------------------------------*/
-
-static DCELL fpreclass_get_default_cell_value(const struct FPReclass *r, DCELL cellVal)
-{
- DCELL tmp;
-
- G_set_d_null_value(&tmp, 1);
-
- if ((cellVal < MIN(r->defaultDMin, r->defaultDMax)) ||
- (cellVal > MAX(r->defaultDMin, r->defaultDMax)))
- return tmp;
-
- if (r->defaultRRuleSet)
- return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
- r->defaultRMin, r->defaultRMax, cellVal);
- else
- return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
- DEFAULT_MIN, DEFAULT_MAX, cellVal);
-}
-
-/*--------------------------------------------------------------------------*/
-
-DCELL G_fpreclass_get_cell_value(const struct FPReclass * r, DCELL cellVal)
-{
- DCELL tmp;
- const struct FPReclass_table *p;
-
- G_set_d_null_value(&tmp, 1);
- if (NO_EXPLICIT_RULE) {
-
- if (NO_DEFAULT_RULE)
- return tmp;
- return fpreclass_get_default_cell_value(r, cellVal);
- }
-
- if (!NO_FINITE_RULE)
- for (p = &(r->table[r->nofRules - 1]); p >= r->table; p--)
- if ((cellVal >= p->dLow) && (cellVal <= p->dHigh))
- return fpreclass_interpolate(p->dLow, p->dHigh, p->rLow,
- p->rHigh, cellVal);
-
- if ((!NO_LEFT_INFINITE_RULE) && (cellVal <= r->infiniteDLeft))
- return r->infiniteRLeft;
-
- if ((NO_RIGHT_INFINITE_RULE) || (cellVal < r->infiniteDRight))
- return tmp;
-
- return r->infiniteRRight;
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_di(const struct FPReclass *r,
- const DCELL *dcell, CELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, dcell++)
- if (!G_is_d_null_value(dcell))
- *cell++ = G_fpreclass_get_cell_value(r, *dcell);
- else
- G_set_c_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_df(const struct FPReclass *r,
- const DCELL *dcell, FCELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, dcell++)
- if (!G_is_d_null_value(dcell))
- *cell++ = G_fpreclass_get_cell_value(r, *dcell);
- else
- G_set_f_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_dd(const struct FPReclass *r,
- const DCELL *dcell, DCELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, dcell++)
- if (!G_is_d_null_value(dcell))
- *cell++ = G_fpreclass_get_cell_value(r, *dcell);
- else
- G_set_d_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_fi(const struct FPReclass *r,
- const FCELL *fcell, CELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, fcell++)
- if (!G_is_f_null_value(fcell))
- *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
- else
- G_set_c_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_ff(const struct FPReclass *r,
- const FCELL *fcell, FCELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, fcell++)
- if (!G_is_f_null_value(fcell))
- *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
- else
- G_set_f_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_fd(const struct FPReclass *r,
- const FCELL *fcell, DCELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, fcell++)
- if (!G_is_f_null_value(fcell))
- *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
- else
- G_set_d_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_ii(const struct FPReclass *r,
- const CELL *icell, CELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, icell++)
- if (!G_is_c_null_value(icell))
- *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
- else
- G_set_c_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_if(const struct FPReclass *r,
- const CELL *icell, FCELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, icell++)
- if (!G_is_c_null_value(icell))
- *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
- else
- G_set_f_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-void G_fpreclass_perform_id(const struct FPReclass *r,
- const CELL *icell, DCELL *cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, icell++)
- if (!G_is_c_null_value(icell))
- *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
- else
- G_set_d_null_value(cell++, 1);
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
Deleted: grass/trunk/lib/gis/gdal.c
===================================================================
--- grass/trunk/lib/gis/gdal.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/gdal.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,530 +0,0 @@
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <grass/config.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include "G.h"
-
-#ifndef HAVE_GDAL
-#undef GDAL_LINK
-#endif
-
-#ifdef GDAL_LINK
-
-#ifdef GDAL_DYNAMIC
-# if defined(__unix) || defined(__unix__)
-# include <dlfcn.h>
-# endif
-# ifdef _WIN32
-# include <windows.h>
-# endif
-#endif
-
-static void CPL_STDCALL (*pGDALAllRegister)(void);
-static void CPL_STDCALL (*pGDALClose)(GDALDatasetH);
-static GDALRasterBandH CPL_STDCALL (*pGDALGetRasterBand)(GDALDatasetH, int);
-static GDALDatasetH CPL_STDCALL (*pGDALOpen)(
- const char *pszFilename, GDALAccess eAccess);
-static CPLErr CPL_STDCALL (*pGDALRasterIO)(
- GDALRasterBandH hRBand, GDALRWFlag eRWFlag,
- int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize,
- void * pBuffer, int nBXSize, int nBYSize,GDALDataType eBDataType,
- int nPixelSpace, int nLineSpace);
-static GDALDriverH CPL_STDCALL (*pGDALGetDriverByName)(const char *);
-static const char * CPL_STDCALL (*pGDALGetMetadataItem)(GDALMajorObjectH, const char *, const char *);
-static GDALDatasetH CPL_STDCALL (*pGDALCreate)(GDALDriverH hDriver, const char *, int, int, int, GDALDataType, char **);
-static GDALDatasetH CPL_STDCALL (*pGDALCreateCopy)(GDALDriverH, const char *, GDALDatasetH, int, char **, GDALProgressFunc, void *);
-static CPLErr CPL_STDCALL (*pGDALSetRasterNoDataValue)(GDALRasterBandH, double);
-static CPLErr CPL_STDCALL (*pGDALSetGeoTransform)(GDALDatasetH, double *);
-static CPLErr CPL_STDCALL (*pGDALSetProjection)(GDALDatasetH, const char *);
-static const char * CPL_STDCALL (*pGDALGetDriverShortName)(GDALDriverH);
-static GDALDriverH CPL_STDCALL (*pGDALGetDatasetDriver)(GDALDatasetH);
-
-#if GDAL_DYNAMIC
-# if defined(__unix) && !defined(__unix__)
-# define __unix__ __unix
-# endif
-
-static void *library_h;
-
-static void *get_symbol(const char *name)
-{
- void *sym;
-
-# ifdef __unix__
- sym = dlsym(library_h, name);
-# endif
-# ifdef _WIN32
- sym = GetProcAddress((HINSTANCE) library_h, name);
-# endif
-
- if (!sym)
- G_fatal_error(_("Unable to locate symbol <%s>"), name);
-
- return sym;
-}
-
-static void try_load_library(const char *name)
-{
-# ifdef __unix__
- library_h = dlopen(name, RTLD_NOW);
-# endif
-# ifdef _WIN32
- library_h = LoadLibrary(name);
-# endif
-}
-
-static void load_library(void)
-{
- static const char * const candidates[] = {
-# ifdef __unix__
- "libgdal.1.1.so",
- "gdal.1.0.so",
- "gdal.so.1.0",
- "libgdal.so.1",
- "libgdal.so",
-# endif
-# ifdef _WIN32
- "gdal11.dll",
- "gdal.1.0.dll",
- "gdal.dll",
-# endif
- NULL
- };
- int i;
-
- for (i = 0; candidates[i]; i++) {
- try_load_library(candidates[i]);
- if (library_h)
- return;
- }
-
- G_fatal_error(_("Unable to load GDAL library"));
-}
-
-static void init_gdal(void)
-{
- load_library();
-
- pGDALAllRegister = get_symbol("GDALAllRegister");
- pGDALOpen = get_symbol("GDALOpen");
- pGDALClose = get_symbol("GDALClose");
- pGDALGetRasterBand = get_symbol("GDALGetRasterBand");
- pGDALRasterIO = get_symbol("GDALRasterIO");
- pGDALGetDriverByName = get_symbol("GDALGetDriverByName");
- pGDALGetMetadataItem = get_symbol("GDALGetMetadataItem");
- pGDALCreate = get_symbol("GDALCreate");
- pGDALCreateCopy = get_symbol("GDALCreateCopy");
- pGDALSetRasterNoDataValue = get_symbol("GDALSetRasterNoDataValue");
- pGDALSetGeoTransform = get_symbol("GDALSetGeoTransform");
- pGDALSetProjection = get_symbol("GDALSetProjection");
- pGDALGetDriverShortName = get_symbol("GDALGetDriverShortName");
- pGDALGetDatasetDriver = get_symbol("GDALGetDatasetDriver");
-}
-
-#else /* GDAL_DYNAMIC */
-
-static void init_gdal(void)
-{
- pGDALAllRegister = &GDALAllRegister;
- pGDALOpen = &GDALOpen;
- pGDALClose = &GDALClose;
- pGDALGetRasterBand = &GDALGetRasterBand;
- pGDALRasterIO = &GDALRasterIO;
- pGDALGetDriverByName = &GDALGetDriverByName;
- pGDALGetMetadataItem = &GDALGetMetadataItem;
- pGDALCreate = &GDALCreate;
- pGDALCreateCopy = &GDALCreateCopy;
- pGDALSetRasterNoDataValue = &GDALSetRasterNoDataValue;
- pGDALSetGeoTransform = &GDALSetGeoTransform;
- pGDALSetProjection = &GDALSetProjection;
- pGDALGetDriverShortName = &GDALGetDriverShortName;
- pGDALGetDatasetDriver = &GDALGetDatasetDriver;
-}
-
-#endif /* GDAL_DYNAMIC */
-
-#endif /* GDAL_LINK */
-
-void G_init_gdal(void)
-{
-#ifdef GDAL_LINK
- static int initialized;
-
- if (G_is_initialized(&initialized))
- return;
-
- init_gdal();
- (*pGDALAllRegister)();
- G_initialize_done(&initialized);
-#endif
-}
-
-struct GDAL_link *G_get_gdal_link(const char *name, const char *mapset)
-{
-#ifdef GDAL_LINK
- GDALDatasetH data;
- GDALRasterBandH band;
- GDALDataType type;
- RASTER_MAP_TYPE req_type;
-#endif
- const char *filename;
- int band_num;
- struct GDAL_link *gdal;
- RASTER_MAP_TYPE map_type;
- FILE *fp;
- struct Key_Value *key_val;
- const char *p;
- DCELL null_val;
- int hflip, vflip;
-
- if (!G_find_cell2(name, mapset))
- return NULL;
-
- map_type = G_raster_map_type(name, mapset);
- if (map_type < 0)
- return NULL;
-
- fp = G_fopen_old_misc("cell_misc", "gdal", name, mapset);
- if (!fp)
- return NULL;
- key_val = G_fread_key_value(fp);
- fclose(fp);
-
- if (!key_val)
- return NULL;
-
- filename = G_find_key_value("file", key_val);
- if (!filename)
- return NULL;
-
- p = G_find_key_value("band", key_val);
- if (!p)
- return NULL;
- band_num = atoi(p);
- if (!band_num)
- return NULL;
-
- p = G_find_key_value("null", key_val);
- if (!p)
- return NULL;
- if (strcmp(p, "none") == 0)
- G_set_d_null_value(&null_val, 1);
- else
- null_val = atof(p);
-
- hflip = G_find_key_value("hflip", key_val) ? 1 : 0;
- vflip = G_find_key_value("vflip", key_val) ? 1 : 0;
-
-#ifdef GDAL_LINK
- p = G_find_key_value("type", key_val);
- if (!p)
- return NULL;
- type = atoi(p);
-
- switch (type) {
- case GDT_Byte:
- case GDT_Int16:
- case GDT_UInt16:
- case GDT_Int32:
- case GDT_UInt32:
- req_type = CELL_TYPE;
- break;
- case GDT_Float32:
- req_type = FCELL_TYPE;
- break;
- case GDT_Float64:
- req_type = DCELL_TYPE;
- break;
- default:
- return NULL;
- }
-
- if (req_type != map_type)
- return NULL;
-
- G_init_gdal();
-
- data = (*pGDALOpen)(filename, GA_ReadOnly);
- if (!data)
- return NULL;
-
- band = (*pGDALGetRasterBand)(data, band_num);
- if (!band) {
- (*pGDALClose)(data);
- return NULL;
- }
-#endif
-
- gdal = G_calloc(1, sizeof(struct GDAL_link));
-
- gdal->filename = G_store(filename);
- gdal->band_num = band_num;
- gdal->null_val = null_val;
- gdal->hflip = hflip;
- gdal->vflip = vflip;
-#ifdef GDAL_LINK
- gdal->data = data;
- gdal->band = band;
- gdal->type = type;
-#endif
-
- return gdal;
-}
-
-struct GDAL_Options {
- const char *dir;
- const char *ext;
- const char *format;
- char **options;
-};
-
-static struct state {
- int initialized;
- struct GDAL_Options opts;
- struct Key_Value *projinfo, *projunits;
- char *srswkt;
-} state;
-
-static struct state *st = &state;
-
-static void read_gdal_options(void)
-{
- FILE *fp;
- struct Key_Value *key_val;
- const char *p;
-
- fp = G_fopen_old("", "GDAL", G_mapset());
- if (!fp)
- G_fatal_error(_("Unable to open GDAL file"));
- key_val = G_fread_key_value(fp);
- fclose(fp);
-
- p = G_find_key_value("directory", key_val);
- if (!p)
- p = "gdal";
- if (*p == '/')
- st->opts.dir = G_store(p);
- else;
- {
- char path[GPATH_MAX];
- G__file_name(path, p, "", G_mapset());
- st->opts.dir = G_store(path);
- if (access(path, 0) != 0)
- G__make_mapset_element(p);
- }
-
- p = G_find_key_value("extension", key_val);
- st->opts.ext = G_store(p ? p : "");
-
- p = G_find_key_value("format", key_val);
- st->opts.format = G_store(p ? p : "GTiff");
-
- p = G_find_key_value("options", key_val);
- st->opts.options = p ? G_tokenize(p, ",") : NULL;
-
- G_free_key_value(key_val);
-}
-
-struct GDAL_link *G_create_gdal_link(const char *name, RASTER_MAP_TYPE map_type)
-{
-#ifdef GDAL_LINK
- char path[GPATH_MAX];
- GDALDriverH driver;
- double transform[6];
- struct GDAL_link *gdal;
- FILE *fp;
- struct Key_Value *key_val;
- char buf[32];
-
-
- G_init_gdal();
-
- if (!G_is_initialized(&st->initialized)) {
- read_gdal_options();
- st->projinfo = G_get_projinfo();
- st->projunits = G_get_projunits();
-#if 0
- /* We cannot use GPJ_grass_to_wkt() here because that would create a
- circular dependency between libgis and libgproj */
- if (st->projinfo && st->projunits)
- st->srswkt = GPJ_grass_to_wkt(st->projinfo, st->projunits);
-#endif
- G_initialize_done(&st->initialized);
- }
-
- gdal = G_calloc(1, sizeof(struct GDAL_link));
-
- sprintf(path, "%s/%s%s", st->opts.dir, name, st->opts.ext);
- gdal->filename = G_store(path);
- gdal->band_num = 1;
- gdal->hflip = 0;
- gdal->vflip = 0;
-
- switch (map_type) {
- case CELL_TYPE:
- switch (G__.nbytes) {
- case 1:
- gdal->type = GDT_Byte;
- gdal->null_val = (DCELL) 0xFF;
- break;
- case 2:
- gdal->type = GDT_UInt16;
- gdal->null_val = (DCELL) 0xFFFF;
- break;
- case 3:
- case 4:
- gdal->type = GDT_Int32;
- gdal->null_val = (DCELL) 0x80000000U;
- break;
- }
- break;
- case FCELL_TYPE:
- gdal->type = GDT_Float32;
- G_set_d_null_value(&gdal->null_val, 1);
- break;
- case DCELL_TYPE:
- gdal->type = GDT_Float64;
- G_set_d_null_value(&gdal->null_val, 1);
- break;
- default:
- G_fatal_error(_("Invalid map type <%d>"), map_type);
- break;
- }
-
- driver = (*pGDALGetDriverByName)(st->opts.format);
- if (!driver)
- G_fatal_error(_("Unable to get <%s> driver"), st->opts.format);
-
- /* Does driver support GDALCreate ? */
- if ((*pGDALGetMetadataItem)(driver, GDAL_DCAP_CREATE, NULL))
- {
- gdal->data = (*pGDALCreate)(driver, gdal->filename, G__.window.cols, G__.window.rows,
- 1, gdal->type, st->opts.options);
- if (!gdal->data)
- G_fatal_error(_("Unable to create <%s> dataset using <%s> driver"),
- name, st->opts.format);
- }
- /* If not - create MEM driver for intermediate dataset.
- * Check if raster can be created at all (with GDALCreateCopy) */
- else if ((*pGDALGetMetadataItem)(driver, GDAL_DCAP_CREATECOPY, NULL)) {
- GDALDriverH mem_driver;
-
- G_message(_("Driver <%s> does not support direct writing. "
- "Using MEM driver for intermediate dataset."),
- st->opts.format);
-
- mem_driver = (*pGDALGetDriverByName)("MEM");
- if (!mem_driver)
- G_fatal_error(_("Unable to get in-memory raster driver"));
-
- gdal->data = (*pGDALCreate)(mem_driver, "", G__.window.cols, G__.window.rows,
- 1, gdal->type, st->opts.options);
- if (!gdal->data)
- G_fatal_error(_("Unable to create <%s> dataset using memory driver"),
- name);
- }
- else
- G_fatal_error(_("Driver <%s> does not support creating rasters"),
- st->opts.format);
-
- gdal->band = (*pGDALGetRasterBand)(gdal->data, gdal->band_num);
-
- (*pGDALSetRasterNoDataValue)(gdal->band, gdal->null_val);
-
- /* Set Geo Transform */
- transform[0] = G__.window.west;
- transform[1] = G__.window.ew_res;
- transform[2] = 0.0;
- transform[3] = G__.window.north;
- transform[4] = 0.0;
- transform[5] = -G__.window.ns_res;
-
- if ((*pGDALSetGeoTransform)(gdal->data, transform) >= CE_Failure)
- G_warning(_("Unable to set geo transform"));
-
- if (st->srswkt)
- if ((*pGDALSetProjection)(gdal->data, st->srswkt) == CE_Failure)
- G_warning(_("Unable to set projection"));
-
- fp = G_fopen_new_misc("cell_misc", "gdal", name);
- if (!fp)
- G_fatal_error(_("Unable to create cell_misc/%s/gdal file"), name);
-
- key_val = G_create_key_value();
-
- G_set_key_value("file", gdal->filename, key_val);
-
- sprintf(buf, "%d", gdal->band_num);
- G_set_key_value("band", buf, key_val);
-
- sprintf(buf, "%.22g", gdal->null_val);
- G_set_key_value("null", buf, key_val);
-
- sprintf(buf, "%d", gdal->type);
- G_set_key_value("type", buf, key_val);
-
- if (G_fwrite_key_value(fp, key_val) < 0)
- G_fatal_error(_("Error writing cell_misc/%s/gdal file"), name);
-
- G_free_key_value(key_val);
-
- fclose(fp);
-
- return gdal;
-#else
- return NULL;
-#endif
-}
-
-void G_close_gdal_link(struct GDAL_link *gdal)
-{
-#ifdef GDAL_LINK
- (*pGDALClose)(gdal->data);
-#endif
- G_free(gdal->filename);
- G_free(gdal);
-}
-
-int G_close_gdal_write_link(struct GDAL_link *gdal)
-{
- int stat = 1;
-#ifdef GDAL_LINK
- GDALDriverH src_drv = (*pGDALGetDatasetDriver)(gdal->data);
-
- if (G_strcasecmp((*pGDALGetDriverShortName)(src_drv), "MEM") == 0) {
- GDALDriverH dst_drv = (*pGDALGetDriverByName)(st->opts.format);
- GDALDatasetH dst = (*pGDALCreateCopy)(dst_drv, gdal->filename, gdal->data, FALSE,
- st->opts.options, NULL, NULL);
- if (!dst) {
- G_warning(_("Unable to create output file <%s> using driver <%s>"),
- gdal->filename, st->opts.format);
- stat = -1;
- }
- (*pGDALClose)(dst);
- }
-
- (*pGDALClose)(gdal->data);
-
-#endif
- G_free(gdal->filename);
- G_free(gdal);
-
- return stat;
-}
-
-#ifdef GDAL_LINK
-CPLErr G_gdal_raster_IO(
- GDALRasterBandH band, GDALRWFlag rw_flag,
- int x_off, int y_off, int x_size, int y_size,
- void *buffer, int buf_x_size, int buf_y_size, GDALDataType buf_type,
- int pixel_size, int line_size)
-{
- return (*pGDALRasterIO)(
- band, rw_flag, x_off, y_off, x_size, y_size,
- buffer, buf_x_size, buf_y_size, buf_type,
- pixel_size, line_size);
-}
-#endif
Deleted: grass/trunk/lib/gis/get_cellhd.c
===================================================================
--- grass/trunk/lib/gis/get_cellhd.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/get_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,95 +0,0 @@
-/*!
- \file gis/get_cellhd.c
-
- \brief GIS library - Read raster map header
-
- (C) 2001-2009 by the GRASS Development Team
-
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
-
- \author Original author CERL
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-/*!
- \brief Read the raster header
-
- The raster header for the raster map <i>name</i> in the specified
- <i>mapset</i> is read into the <i>cellhd</i> structure. If there is
- an error reading the raster header file, a diagnostic message is
- printed and -1 is returned. Otherwise, 0 is returned.
-
- <b>Note</b>:a warning message for errors encountered.
-
- Cell header files may contain either grid cell header information or
- reclass information. If it is a reclass file, it will specify the
- map and mapset names of the actual grid cell file being
- reclassed. G_get_cellhd(), upon reading reclass information will go
- read the cell header information for the referenced file. Only one
- reference is allowed.
-
- \param name name of map
- \param mapset mapset that map belongs to
- \param[out] cellhd structure to hold cell header info
-
- \return 0 on success
- \return -1 on error
- */
-int G_get_cellhd(const char *name, const char *mapset,
- struct Cell_head *cellhd)
-{
- FILE *fd;
- int is_reclass;
- char real_name[GNAME_MAX], real_mapset[GMAPSET_MAX];
- char buf[1024];
- char *tail;
-
- /*
- is_reclass = G_is_reclass (name, mapset, real_name, real_mapset);
- if (is_reclass < 0)
- {
- sprintf (buf,"Can't read header file for [%s in %s]\n", name, mapset);
- tail = buf + strlen(buf);
- strcpy (tail, "It is a reclass file, but with an invalid format");
- G_warning(buf);
- return -1;
- }
- */
- is_reclass = (G_is_reclass(name, mapset, real_name, real_mapset) > 0);
- if (is_reclass) {
- fd = G_fopen_old("cellhd", real_name, real_mapset);
- if (fd == NULL) {
- sprintf(buf,
- _("Unable to read header file for raster map <%s@%s>."),
- name, mapset);
- tail = buf + strlen(buf);
- sprintf(tail, _(" It is a reclass of raster map <%s@%s> "),
- real_name, real_mapset);
- tail = buf + strlen(buf);
- if (!G_find_cell(real_name, real_mapset))
- sprintf(tail, _("which is missing."));
- else
- sprintf(tail, _("whose header file can't be opened."));
- G_warning ("%s", buf);
- return -1;
- }
- }
- else {
- fd = G_fopen_old("cellhd", name, mapset);
- if (fd == NULL) {
- G_warning(_("Unable to open header file for raster map <%s@%s>"),
- name, mapset);
- return -1;
- }
- }
-
- G__read_Cell_head(fd, cellhd, 1);
- fclose(fd);
-
- return 0;
-}
Deleted: grass/trunk/lib/gis/get_row.c
===================================================================
--- grass/trunk/lib/gis/get_row.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/get_row.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,1220 +0,0 @@
-/*!
- \file gis/get_row.c
-
- \brief GIS library - Get raster row
-
- (C) 2003-2009 by the GRASS Development Team
-
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
-
- \author Original author CERL
- */
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <rpc/types.h> /* need this for sgi */
-#include <rpc/xdr.h>
-
-#include <grass/config.h>
-#include <grass/glocale.h>
-
-#include "G.h"
-
-#define NULL_FILE "null"
-
-static int embed_nulls(int, void *, int, RASTER_MAP_TYPE, int, int);
-
-static int compute_window_row(int fd, int row, int *cellRow)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- double f;
- int r;
-
- /* check for row in window */
- if (row < 0 || row >= G__.window.rows) {
- G_warning(_("Reading raster map <%s@%s> request for row %d is outside region"),
- fcb->name, fcb->mapset, row);
-
- return -1;
- }
-
- /* convert window row to cell file row */
- f = row * fcb->C1 + fcb->C2;
- r = (int)f;
- if (f < r) /* adjust for rounding up of negatives */
- r--;
-
- if (r < 0 || r >= fcb->cellhd.rows)
- return 0;
-
- *cellRow = r;
-
- return 1;
-}
-
-static void do_reclass_int(int fd, void *cell, int null_is_zero)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- CELL *c = cell;
- CELL *reclass_table = fcb->reclass.table;
- CELL min = fcb->reclass.min;
- CELL max = fcb->reclass.max;
- int i;
-
- for (i = 0; i < G__.window.cols; i++) {
- if (G_is_c_null_value(&c[i])) {
- if (null_is_zero)
- c[i] = 0;
- continue;
- }
-
- if (c[i] < min || c[i] > max) {
- if (null_is_zero)
- c[i] = 0;
- else
- G_set_c_null_value(&c[i], 1);
- continue;
- }
-
- c[i] = reclass_table[c[i] - min];
-
- if (null_is_zero && G_is_c_null_value(&c[i]))
- c[i] = 0;
- }
-}
-
-static int read_data_fp_compressed(int fd, int row, unsigned char *data_buf,
- int *nbytes)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- off_t t1 = fcb->row_ptr[row];
- off_t t2 = fcb->row_ptr[row + 1];
- size_t readamount = t2 - t1;
- size_t bufsize = fcb->cellhd.cols * fcb->nbytes;
-
- if (lseek(fd, t1, SEEK_SET) < 0)
- return -1;
-
- *nbytes = fcb->nbytes;
-
- if ((size_t) G_zlib_read(fd, readamount, data_buf, bufsize) != bufsize)
- return -1;
-
- return 0;
-}
-
-static void rle_decompress(unsigned char *dst, const unsigned char *src,
- int nbytes, int size)
-{
- int pairs = size / (nbytes + 1);
- int i;
-
- for (i = 0; i < pairs; i++) {
- int repeat = *src++;
- int j;
-
- for (j = 0; j < repeat; j++) {
- memcpy(dst, src, nbytes);
- dst += nbytes;
- }
-
- src += nbytes;
- }
-}
-
-static int read_data_compressed(int fd, int row, unsigned char *data_buf,
- int *nbytes)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- off_t t1 = fcb->row_ptr[row];
- off_t t2 = fcb->row_ptr[row + 1];
- ssize_t readamount = t2 - t1;
- unsigned char *cmp;
- int n;
-
- if (lseek(fd, t1, SEEK_SET) < 0)
- return -1;
-
- cmp = G__alloca(readamount);
-
- if (read(fd, cmp, readamount) != readamount) {
- G__freea(cmp);
- return -1;
- }
-
- /* Now decompress the row */
- if (fcb->cellhd.compressed > 0) {
- /* one byte is nbyte count */
- n = *nbytes = *cmp++;
- readamount--;
- }
- else
- /* pre 3.0 compression */
- n = *nbytes = fcb->nbytes;
-
- if (fcb->cellhd.compressed < 0 || readamount < n * fcb->cellhd.cols) {
- if (fcb->cellhd.compressed == 2)
- G_zlib_expand(cmp, readamount, data_buf, n * fcb->cellhd.cols);
- else
- rle_decompress(data_buf, cmp, n, readamount);
- }
- else
- memcpy(data_buf, cmp, readamount);
-
- G__freea(cmp);
-
- return 0;
-}
-
-static int read_data_uncompressed(int fd, int row, unsigned char *data_buf,
- int *nbytes)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- ssize_t bufsize = fcb->cellhd.cols * fcb->nbytes;
-
- *nbytes = fcb->nbytes;
-
- if (lseek(fd, (off_t) row * bufsize, SEEK_SET) == -1)
- return -1;
-
- if (read(fd, data_buf, bufsize) != bufsize)
- return -1;
-
- return 0;
-}
-
-#ifdef HAVE_GDAL
-static int read_data_gdal(int fd, int row, unsigned char *data_buf, int *nbytes)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- unsigned char *buf;
- CPLErr err;
-
- *nbytes = fcb->nbytes;
-
- if (fcb->gdal->vflip)
- row = fcb->cellhd.rows - 1 - row;
-
- buf = fcb->gdal->hflip
- ? G__alloca(fcb->cellhd.cols * fcb->cur_nbytes)
- : data_buf;
-
- err = G_gdal_raster_IO(
- fcb->gdal->band, GF_Read, 0, row, fcb->cellhd.cols, 1, buf,
- fcb->cellhd.cols, 1, fcb->gdal->type, 0, 0);
-
- if (fcb->gdal->hflip) {
- int i;
-
- for (i = 0; i < fcb->cellhd.cols; i++)
- memcpy(data_buf + i * fcb->cur_nbytes,
- buf + (fcb->cellhd.cols - 1 - i) * fcb->cur_nbytes,
- fcb->cur_nbytes);
- G__freea(buf);
- }
-
- return err == CE_None ? 0 : -1;
-}
-#endif
-
-static int read_data(int fd, int row, unsigned char *data_buf, int *nbytes)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
-#ifdef HAVE_GDAL
- if (fcb->gdal)
- return read_data_gdal(fd, row, data_buf, nbytes);
-#endif
-
- if (!fcb->cellhd.compressed)
- return read_data_uncompressed(fd, row, data_buf, nbytes);
-
- /* map is in compressed form */
-
- if (fcb->map_type == CELL_TYPE)
- return read_data_compressed(fd, row, data_buf, nbytes);
- else
- return read_data_fp_compressed(fd, row, data_buf, nbytes);
-}
-
-/* copy cell file data to user buffer translated by window column mapping */
-static void cell_values_int(int fd, const unsigned char *data,
- const COLUMN_MAPPING * cmap, int nbytes,
- void *cell, int n)
-{
- CELL *c = cell;
- COLUMN_MAPPING cmapold = 0;
- int big = (size_t) nbytes >= sizeof(CELL);
- int i;
-
- for (i = 0; i < n; i++) {
- const unsigned char *d;
- int neg;
- CELL v;
- int j;
-
- if (!cmap[i]) {
- c[i] = 0;
- continue;
- }
-
- if (cmap[i] == cmapold) {
- c[i] = c[i - 1];
- continue;
- }
-
- d = data + (cmap[i] - 1) * nbytes;
-
- if (big && (*d & 0x80)) {
- neg = 1;
- v = *d++ & 0x7f;
- }
- else {
- neg = 0;
- v = *d++;
- }
-
- for (j = 1; j < nbytes; j++)
- v = (v << 8) + *d++;
-
- c[i] = neg ? -v : v;
-
- cmapold = cmap[i];
- }
-}
-
-static void cell_values_float(int fd, const unsigned char *data,
- const COLUMN_MAPPING * cmap, int nbytes,
- void *cell, int n)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- FCELL *c = cell;
- COLUMN_MAPPING cmapold = 0;
- XDR *xdrs = &fcb->xdrstream;
- int i;
-
- /* xdr stream is initialized to read from */
- /* fcb->data in 'opencell.c' */
- xdr_setpos(xdrs, 0);
-
- for (i = 0; i < n; i++) {
- if (!cmap[i]) {
- c[i] = 0;
- continue;
- }
-
- if (cmap[i] == cmapold) {
- c[i] = c[i - 1];
- continue;
- }
-
- if (cmap[i] < cmapold) {
- xdr_setpos(xdrs, 0);
- cmapold = 0;
- }
-
- while (cmapold++ != cmap[i]) /* skip */
- if (!xdr_float(xdrs, &c[i]))
- G_fatal_error(_("cell_values_float: xdr_float failed for index %d"),
- i);
-
- cmapold--;
- }
-}
-
-static void cell_values_double(int fd, const unsigned char *data,
- const COLUMN_MAPPING * cmap, int nbytes,
- void *cell, int n)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- DCELL *c = cell;
- COLUMN_MAPPING cmapold = 0;
- XDR *xdrs = &fcb->xdrstream;
- int i;
-
- /* xdr stream is initialized to read from */
- /* fcb->data in 'opencell.c' */
- xdr_setpos(xdrs, 0);
-
- for (i = 0; i < n; i++) {
- if (!cmap[i]) {
- c[i] = 0;
- continue;
- }
-
- if (cmap[i] == cmapold) {
- c[i] = c[i - 1];
- continue;
- }
-
- if (cmap[i] < cmapold) {
- xdr_setpos(xdrs, 0);
- cmapold = 0;
- }
-
- while (cmapold++ != cmap[i]) /* skip */
- if (!xdr_double(xdrs, &c[i]))
- G_fatal_error(_("cell_values_double: xdr_double failed for index %d"),
- i);
-
- cmapold--;
- }
-}
-
-#ifdef HAVE_GDAL
-static void gdal_values_int(int fd, const unsigned char *data,
- const COLUMN_MAPPING *cmap, int nbytes,
- CELL *cell, int n)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- const unsigned char *d;
- COLUMN_MAPPING cmapold = 0;
- int i;
-
- for (i = 0; i < n; i++) {
- if (!cmap[i]) {
- cell[i] = 0;
- continue;
- }
-
- if (cmap[i] == cmapold) {
- cell[i] = cell[i-1];
- continue;
- }
-
- d = data + (cmap[i] - 1) * nbytes;
-
- switch (fcb->gdal->type) {
- case GDT_Byte: cell[i] = *(GByte *)d; break;
- case GDT_Int16: cell[i] = *(GInt16 *)d; break;
- case GDT_UInt16: cell[i] = *(GUInt16 *)d; break;
- case GDT_Int32: cell[i] = *(GInt32 *)d; break;
- case GDT_UInt32: cell[i] = *(GUInt32 *)d; break;
- default:
- /* shouldn't happen */
- G_set_c_null_value(&cell[i], 1);
- break;
- }
-
- cmapold = cmap[i];
- }
-}
-
-static void gdal_values_float(int fd, const float *data,
- const COLUMN_MAPPING *cmap, int nbytes,
- FCELL *cell, int n)
-{
- COLUMN_MAPPING cmapold = 0;
- int i;
-
- for (i = 0; i < n; i++) {
- if (!cmap[i]) {
- cell[i] = 0;
- continue;
- }
-
- if (cmap[i] == cmapold) {
- cell[i] = cell[i-1];
- continue;
- }
-
- cell[i] = data[cmap[i] - 1];
-
- cmapold = cmap[i];
- }
-}
-
-static void gdal_values_double(int fd, const double *data,
- const COLUMN_MAPPING *cmap, int nbytes,
- DCELL *cell, int n)
-{
- COLUMN_MAPPING cmapold = 0;
- int i;
-
- for (i = 0; i < n; i++) {
- if (!cmap[i]) {
- cell[i] = 0;
- continue;
- }
-
- if (cmap[i] == cmapold) {
- cell[i] = cell[i-1];
- continue;
- }
-
- cell[i] = data[cmap[i] - 1];
-
- cmapold = cmap[i];
- }
-}
-#endif
-
-/* transfer_to_cell_XY takes bytes from fcb->data, converts these bytes with
- the appropriate procedure (e.g. XDR or byte reordering) into type X
- values which are put into array work_buf.
- finally the values in work_buf are converted into
- type Y and put into 'cell'.
- if type X == type Y the intermediate step of storing the values in
- work_buf might be ommited. check the appropriate function for XY to
- determine the procedure of conversion.
- */
-static void transfer_to_cell_XX(int fd, void *cell)
-{
- static void (*cell_values_type[3]) () = {
- cell_values_int, cell_values_float, cell_values_double};
-#ifdef HAVE_GDAL
- static void (*gdal_values_type[3]) () = {
- gdal_values_int, gdal_values_float, gdal_values_double};
-#endif
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
-#ifdef HAVE_GDAL
- if (fcb->gdal)
- (gdal_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
- fcb->cur_nbytes, cell,
- G__.window.cols);
- else
-#endif
- (cell_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
- fcb->cur_nbytes, cell,
- G__.window.cols);
-}
-
-static void transfer_to_cell_fi(int fd, void *cell)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
- int i;
-
- transfer_to_cell_XX(fd, work_buf);
-
- for (i = 0; i < G__.window.cols; i++)
- ((CELL *) cell)[i] = (fcb->col_map[i] == 0)
- ? 0
- : G_quant_get_cell_value(&fcb->quant, work_buf[i]);
-
- G__freea(work_buf);
-}
-
-static void transfer_to_cell_di(int fd, void *cell)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
- int i;
-
- transfer_to_cell_XX(fd, work_buf);
-
- for (i = 0; i < G__.window.cols; i++)
- ((CELL *) cell)[i] = (fcb->col_map[i] == 0)
- ? 0
- : G_quant_get_cell_value(&fcb->quant, work_buf[i]);
-
- G__freea(work_buf);
-}
-
-static void transfer_to_cell_if(int fd, void *cell)
-{
- CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
- int i;
-
- transfer_to_cell_XX(fd, work_buf);
-
- for (i = 0; i < G__.window.cols; i++)
- ((FCELL *) cell)[i] = work_buf[i];
-
- G__freea(work_buf);
-}
-
-static void transfer_to_cell_df(int fd, void *cell)
-{
- DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
- int i;
-
- transfer_to_cell_XX(fd, work_buf);
-
- for (i = 0; i < G__.window.cols; i++)
- ((FCELL *) cell)[i] = work_buf[i];
-
- G__freea(work_buf);
-}
-
-static void transfer_to_cell_id(int fd, void *cell)
-{
- CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
- int i;
-
- transfer_to_cell_XX(fd, work_buf);
-
- for (i = 0; i < G__.window.cols; i++)
- ((DCELL *) cell)[i] = work_buf[i];
-
- G__freea(work_buf);
-}
-
-static void transfer_to_cell_fd(int fd, void *cell)
-{
- FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
- int i;
-
- transfer_to_cell_XX(fd, work_buf);
-
- for (i = 0; i < G__.window.cols; i++)
- ((DCELL *) cell)[i] = work_buf[i];
-
- G__freea(work_buf);
-}
-
-/*
- * works for all map types and doesn't consider
- * null row corresponding to the requested row
- */
-static int get_map_row_nomask(int fd, void *rast, int row,
- RASTER_MAP_TYPE data_type)
-{
- static void (*transfer_to_cell_FtypeOtype[3][3])() = {
- {transfer_to_cell_XX, transfer_to_cell_if, transfer_to_cell_id},
- {transfer_to_cell_fi, transfer_to_cell_XX, transfer_to_cell_fd},
- {transfer_to_cell_di, transfer_to_cell_df, transfer_to_cell_XX}
- };
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int r;
- int rowStatus;
-
- rowStatus = compute_window_row(fd, row, &r);
-
- if (rowStatus <= 0) {
- fcb->cur_row = -1;
- G_zero_raster_buf(rast, data_type);
- return rowStatus;
- }
-
- /* read cell file row if not in memory */
- if (r != fcb->cur_row) {
- fcb->cur_row = r;
-
- if (read_data(fd, fcb->cur_row, fcb->data, &fcb->cur_nbytes) < 0) {
- G_zero_raster_buf(rast, data_type);
-
- if (!fcb->io_error) {
- if (fcb->cellhd.compressed)
- G_warning(_("Error reading compressed map <%s@%s>, row %d"),
- fcb->name, fcb->mapset, r);
- else
- G_warning(_("Error reading map <%s@%s>, row %d"),
- fcb->name, fcb->mapset, r);
-
- fcb->io_error = 1;
- }
- return -1;
- }
- }
-
- (transfer_to_cell_FtypeOtype[fcb->map_type][data_type]) (fd, rast);
-
- return 1;
-}
-
-static int get_map_row_no_reclass(int fd, void *rast, int row,
- RASTER_MAP_TYPE data_type, int null_is_zero,
- int with_mask)
-{
- int stat;
-
- stat = get_map_row_nomask(fd, rast, row, data_type);
- if (stat < 0)
- return stat;
-
- stat = embed_nulls(fd, rast, row, data_type, null_is_zero, with_mask);
- if (stat < 0)
- return stat;
-
- return 1;
-}
-
-static int get_map_row(int fd, void *rast, int row, RASTER_MAP_TYPE data_type,
- int null_is_zero, int with_mask)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int size = G_raster_size(data_type);
- CELL *temp_buf = NULL;
- void *buf;
- int type;
- int stat;
- int i;
-
- if (fcb->reclass_flag && data_type != CELL_TYPE) {
- temp_buf = G__alloca(G__.window.cols * sizeof(CELL));
- buf = temp_buf;
- type = CELL_TYPE;
- }
- else {
- buf = rast;
- type = data_type;
- }
-
- stat = get_map_row_no_reclass(fd, buf, row, type, null_is_zero, with_mask);
- if (stat < 0) {
- if (temp_buf)
- G__freea(temp_buf);
- return stat;
- }
-
- if (!fcb->reclass_flag)
- return 1;
-
- /* if the map is reclass table, get and
- reclass CELL row and copy results to needed type */
-
- do_reclass_int(fd, buf, null_is_zero);
-
- if (data_type == CELL_TYPE)
- return 1;
-
- for (i = 0; i < G__.window.cols; i++) {
- G_set_raster_value_c(rast, temp_buf[i], data_type);
- rast = G_incr_void_ptr(rast, size);
- }
-
- G__freea(temp_buf);
-
- return 1;
-}
-
-/*!
- * \brief Read raster row without masking (this routine is deprecated)
- *
- * This routine reads the specified <em>row</em> from the raster map
- * open on file descriptor <em>fd</em> into the <em>buf</em> buffer
- * like G_get_map_row() does. The difference is that masking is
- * suppressed. If the user has a mask set, G_get_map_row() will apply
- * the mask but G_get_map_row_nomask() will ignore it. This routine
- * prints a diagnostic message and returns -1 if there is an error
- * reading the raster map. Otherwise a nonnegative value is returned.
- *
- * <b>Note.</b> Ignoring the mask is not generally acceptable. Users
- * expect the mask to be applied. However, in some cases ignoring the
- * mask is justified. For example, the GRASS modules
- * <i>r.describe</i>, which reads the raster map directly to report
- * all data values in a raster map, and <i>r.slope.aspect</i>, which
- * produces slope and aspect from elevation, ignore both the mask and
- * the region. However, the number of GRASS modules which do this
- * should be minimal. See Mask for more information about the mask.
- *
- * <b>This routine is deprecated! Use G_get_raster_row_nomask()
- * instead.</b>
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_map_row_nomask(int fd, CELL * buf, int row)
-{
- return get_map_row(fd, buf, row, CELL_TYPE, 1, 0);
-}
-
-/*!
- * \brief Read raster row without masking
- *
- * Same as G_get_raster_row() except no masking occurs.
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- * \param data_type data type
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_raster_row_nomask(int fd, void *buf, int row,
- RASTER_MAP_TYPE data_type)
-{
- return get_map_row(fd, buf, row, data_type, 0, 0);
-}
-
-/*!
- * \brief Read raster row without masking (CELL type)
- *
- * Same as G_get_c_raster_row() except no masking occurs.
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- * \param data_type data type
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_c_raster_row_nomask(int fd, CELL * buf, int row)
-{
- return G_get_raster_row_nomask(fd, buf, row, CELL_TYPE);
-}
-
-/*!
- * \brief Read raster row without masking (FCELL type)
- *
- * Same as G_get_f_raster_row() except no masking occurs.
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- * \param data_type data type
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_f_raster_row_nomask(int fd, FCELL * buf, int row)
-{
- return G_get_raster_row_nomask(fd, buf, row, FCELL_TYPE);
-}
-
-/*!
- * \brief Read raster row without masking (DCELL type)
- *
- * Same as G_get_d_raster_row() except no masking occurs.
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- * \param data_type data type
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_d_raster_row_nomask(int fd, DCELL * buf, int row)
-{
- return G_get_raster_row_nomask(fd, buf, row, DCELL_TYPE);
-}
-
-/*!
- * \brief Get raster row (this routine is deprecated!)
- *
- * If the map is floating-point, quantize the floating-point values to
- * integer using the quantization rules established for the map when
- * the map was opened for reading (this quantization is read from
- * cell_misc/name/f_quant file, but can be reset after opening raster
- * map by G_set_quant_rules()). NULL values are converted to zeros.
- *
- * <b>This routine is deprecated! Use G_get_raster_row() instead.</b>
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_map_row(int fd, CELL * buf, int row)
-{
- return get_map_row(fd, buf, row, CELL_TYPE, 1, 1);
-}
-
-/*!
- * \brief Get raster row
- *
- * If <em>data_type</em> is
- * - CELL_TYPE, calls G_get_c_raster_row()
- * - FCELL_TYPE, calls G_get_f_raster_row()
- * - DCELL_TYPE, calls G_get_d_raster_row()
- *
- * Reads appropriate information into the buffer <em>buf</em> associated
- * with the requested row <em>row</em>. <em>buf</em> is associated with the
- * current window.
- *
- * Note, that the type of the data in <em>buf</em> (say X) is independent of
- * the type of the data in the file described by <em>fd</em> (say Y).
- *
- * - Step 1: Read appropriate raw map data into a intermediate buffer.
- * - Step 2: Convert the data into a CPU readable format, and subsequently
- * resample the data. the data is stored in a second intermediate
- * buffer (the type of the data in this buffer is Y).
- * - Step 3: Convert this type Y data into type X data and store it in
- * buffer "buf". Conversion is performed in functions
- * "transfer_to_cell_XY". (For details of the conversion between
- * two particular types check the functions).
- * - Step 4: read or simmulate null value row and zero out cells corresponding
- * to null value cells. The masked out cells are set to null when the
- * mask exists. (the MASK is taken care of by null values
- * (if the null file doesn't exist for this map, then the null row
- * is simulated by assuming that all zero are nulls *** in case
- * of G_get_raster_row() and assuming that all data is valid
- * in case of G_get_f/d_raster_row(). In case of deprecated function
- * G_get_map_row() all nulls are converted to zeros (so there are
- * no embedded nulls at all). Also all masked out cells become zeros.
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- * \param data_type data type
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_raster_row(int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
-{
- return get_map_row(fd, buf, row, data_type, 0, 1);
-}
-
-/*!
- * \brief Get raster row (CELL type)
- *
- * Reads a row of raster data and leaves the NULL values intact. (As
- * opposed to the deprecated function G_get_map_row() which
- * converts NULL values to zero.)
- *
- * <b>NOTE.</b> When the raster map is old and null file doesn't
- * exist, it is assumed that all 0-cells are no-data. When map is
- * floating point, uses quant rules set explicitly by
- * G_set_quant_rules() or stored in map's quant file to convert floats
- * to integers.
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_c_raster_row(int fd, CELL * buf, int row)
-{
- return G_get_raster_row(fd, buf, row, CELL_TYPE);
-}
-
-/*!
- * \brief Get raster row (FCELL type)
- *
- * Read a row from the raster map open on <em>fd</em> into the
- * <tt>float</tt> array <em>fcell</em> performing type conversions as
- * necessary based on the actual storage type of the map. Masking,
- * resampling into the current region. NULL-values are always
- * embedded in <tt>fcell</tt> (<em>never converted to a value</em>).
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_f_raster_row(int fd, FCELL * buf, int row)
-{
- return G_get_raster_row(fd, buf, row, FCELL_TYPE);
-}
-
-/*!
- * \brief Get raster row (DCELL type)
- *
- * Same as G_get_f_raster_row() except that the array <em>dcell</em>
- * is <tt>double</tt>.
- *
- * \param fd file descriptor for the opened raster map
- * \param buf buffer for the row to be placed into
- * \param row data row desired
- *
- * \return 1 on success
- * \return 0 row requested not within window
- * \return -1 on error
- */
-int G_get_d_raster_row(int fd, DCELL * buf, int row)
-{
- return G_get_raster_row(fd, buf, row, DCELL_TYPE);
-}
-
-static int open_null_read(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- const char *name, *mapset, *dummy;
- int null_fd;
-
- if (fcb->null_file_exists == 0)
- return -1;
-
- if (fcb->reclass_flag) {
- name = fcb->reclass.name;
- mapset = fcb->reclass.mapset;
- }
- else {
- name = fcb->name;
- mapset = fcb->mapset;
- }
-
- dummy = G_find_file2_misc("cell_misc", NULL_FILE, name, mapset);
-
- if (!dummy) {
- /* G_warning("unable to find [%s]",path); */
- fcb->null_file_exists = 0;
- return -1;
- }
-
- null_fd = G_open_old_misc("cell_misc", NULL_FILE, name, mapset);
- if (null_fd < 0)
- return -1;
-
- fcb->null_file_exists = 1;
-
- return null_fd;
-}
-
-static int read_null_bits(int null_fd, unsigned char *flags, int row,
- int cols, int fd)
-{
- off_t offset;
- ssize_t size;
- int R;
-
- if (compute_window_row(fd, row, &R) <= 0) {
- G__init_null_bits(flags, cols);
- return 1;
- }
-
- if (null_fd < 0)
- return -1;
-
- size = G__null_bitstream_size(cols);
- offset = (off_t) size *R;
-
- if (lseek(null_fd, offset, SEEK_SET) < 0) {
- G_warning(_("Error reading null row %d"), R);
- return -1;
- }
-
- if (read(null_fd, flags, size) != size) {
- G_warning(_("Error reading null row %d"), R);
- return -1;
- }
-
- return 1;
-}
-
-static void get_null_value_row_nomask(int fd, char *flags, int row)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int i, j, null_fd;
-
- if (row > G__.window.rows || row < 0) {
- G_warning(_("Reading raster map <%s@%s> request for row %d is outside region"),
- fcb->name, fcb->mapset, row);
- }
-
- if ((fcb->min_null_row > row) ||
- (fcb->min_null_row + NULL_ROWS_INMEM - 1 < row))
- /* the null row row is not in memory */
- {
- unsigned char *null_work_buf = G__alloca(
- G__null_bitstream_size(fcb->cellhd.cols));
-
- /* read in NULL_ROWS_INMEM rows from null file
- so that the requested row is between fcb->min_null_row
- and fcb->min_null_row + NULL_ROWS_INMEM */
-
- fcb->min_null_row = (row / NULL_ROWS_INMEM) * NULL_ROWS_INMEM;
-
- null_fd = open_null_read(fd);
-
- for (i = 0; i < NULL_ROWS_INMEM; i++) {
- /* G__.window.rows doesn't have to be a multiple of NULL_ROWS_INMEM */
- if (i + fcb->min_null_row >= G__.window.rows)
- break;
-
- if (read_null_bits(null_fd, null_work_buf,
- i + fcb->min_null_row, fcb->cellhd.cols,
- fd) < 0) {
- if (fcb->map_type == CELL_TYPE) {
- /* If can't read null row, assume that all map 0's are nulls */
- CELL *mask_buf = G__alloca(G__.window.cols * sizeof(CELL));
-
- get_map_row_nomask(fd, mask_buf, i + fcb->min_null_row,
- CELL_TYPE);
- for (j = 0; j < G__.window.cols; j++)
- flags[j] = (mask_buf[j] == 0);
-
- G__freea(mask_buf);
- }
- else { /* fp map */
-
- /* if can't read null row, assume that all data is valid */
- G_zero(flags, sizeof(char) * G__.window.cols);
- /* the flags row is ready now */
- }
- } /*if no null file */
- else {
- /* copy null row to flags row translated by window column mapping */
- /* the fcb->NULL_ROWS[row-fcb->min_null_row] has G__.window.cols bits, */
- /* the null_work_buf has size fcb->cellhd.cols */
- for (j = 0; j < G__.window.cols; j++) {
- if (!fcb->col_map[j])
- flags[j] = 1;
- else
- flags[j] = G__check_null_bit(null_work_buf,
- fcb->col_map[j] - 1,
- fcb->cellhd.cols);
- }
- }
- /* remember the null row for i for the future reference */
-
- /*bf-We should take of the size - or we get
- zeros running on their own after flags convertions -A.Sh. */
- fcb->NULL_ROWS[i] = G_realloc(fcb->NULL_ROWS[i],
- G__null_bitstream_size(G__.window.
- cols) + 1);
- if (fcb->NULL_ROWS[i] == NULL)
- G_fatal_error("get_null_value_row_nomask: %s",
- _("Unable to realloc buffer"));
-
- G__convert_01_flags(flags, fcb->NULL_ROWS[i], G__.window.cols);
-
- } /* for loop */
-
- if (null_fd > 0)
- close(null_fd);
-
- G__freea(null_work_buf);
- } /* row is not in memory */
-
- /* copy null file data translated by column mapping to user null row */
- /* the user requested flags row is of size G__.window.cols */
- G__convert_flags_01(flags, fcb->NULL_ROWS[row - fcb->min_null_row],
- G__.window.cols);
-}
-
-/*--------------------------------------------------------------------------*/
-
-#ifdef HAVE_GDAL
-
-static void get_null_value_row_gdal(int fd, char *flags, int row)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- DCELL *tmp_buf = G_allocate_d_raster_buf();
- int i;
-
- if (get_map_row_nomask(fd, tmp_buf, row, DCELL_TYPE) <= 0) {
- memset(flags, 1, G__.window.cols);
- G_free(tmp_buf);
- return;
- }
-
- for (i = 0; i < G__.window.cols; i++)
- /* note: using == won't work if the null value is NaN */
- flags[i] = memcmp(&tmp_buf[i], &fcb->gdal->null_val, sizeof(DCELL)) == 0;
-
- G_free(tmp_buf);
-}
-
-#endif
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static void embed_mask(char *flags, int row)
-{
- CELL *mask_buf = G__alloca(G__.window.cols * sizeof(CELL));
- int i;
-
- if (G__.auto_mask <= 0)
- return;
-
- if (get_map_row_nomask(G__.mask_fd, mask_buf, row, CELL_TYPE) < 0) {
- G__freea(mask_buf);
- return;
- }
-
- if (G__.fileinfo[G__.mask_fd].reclass_flag)
- do_reclass_int(G__.mask_fd, mask_buf, 1);
-
- for (i = 0; i < G__.window.cols; i++)
- if (mask_buf[i] == 0)
- flags[i] = 1;
-
- G__freea(mask_buf);
-}
-
-static void get_null_value_row(int fd, char *flags, int row, int with_mask)
-{
-#ifdef HAVE_GDAL
- struct fileinfo *fcb = &G__.fileinfo[fd];
- if (fcb->gdal)
- get_null_value_row_gdal(fd, flags, row);
- else
-#endif
- get_null_value_row_nomask(fd, flags, row);
-
- if (with_mask)
- embed_mask(flags, row);
-}
-
-static int embed_nulls(int fd, void *buf, int row, RASTER_MAP_TYPE map_type,
- int null_is_zero, int with_mask)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- char *null_buf;
- int i;
-
- /* this is because without null file the nulls can be only due to 0's
- in data row or mask */
- if (null_is_zero && !fcb->null_file_exists
- && (G__.auto_mask <= 0 || !with_mask))
- return 1;
-
- null_buf = G__alloca(G__.window.cols);
-
- get_null_value_row(fd, null_buf, row, with_mask);
-
- for (i = 0; i < G__.window.cols; i++) {
- /* also check for nulls which might be already embedded by quant
- rules in case of fp map. */
- if (null_buf[i] || G_is_null_value(buf, map_type)) {
- /* G__set_[f/d]_null_value() sets it to 0 is the embedded mode
- is not set and calls G_set_[f/d]_null_value() otherwise */
- G__set_null_value(buf, 1, null_is_zero, map_type);
- }
- buf = G_incr_void_ptr(buf, G_raster_size(map_type));
- }
-
- G__freea(null_buf);
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*!
- \brief Read or simmulate null value row
-
- Read or simmulate null value row and set the cells corresponding
- to null value to 1. The masked out cells are set to null when the
- mask exists. (the MASK is taken care of by null values
- (if the null file doesn't exist for this map, then the null row
- is simulated by assuming that all zeros in raster map are nulls.
- Also all masked out cells become nulls.
-
- \param fd file descriptor for the opened map
- \param buf buffer for the row to be placed into
- \param row data row desired
-
- \return 1
- */
-int G_get_null_value_row(int fd, char *flags, int row)
-{
- get_null_value_row(fd, flags, row, 1);
-
- return 1;
-}
Deleted: grass/trunk/lib/gis/get_row_colr.c
===================================================================
--- grass/trunk/lib/gis/get_row_colr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/get_row_colr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,69 +0,0 @@
-/*!
- * \file gis/get_row_colr.c
- *
- * \brief GIS Library - Get raster row (colors)
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#include <grass/gis.h>
-#include "G.h"
-
-/*!
- * \brief Reads a row of raster data and converts it to RGB.
- *
- * Reads a row of raster data and converts it to red, green and blue
- * components according to the <em>colors</em> parameter. This
- * provides a convenient way to treat a raster layer as a color image
- * without having to explictly cater for each of <tt>CELL</tt>,
- * <tt>FCELL</tt> and <tt>DCELL</tt> types.
- *
- * \param fd field descriptor
- * \param row row number
- * \param colors pointer to Colors structure which holds color info
- * \param[out] red red value
- * \param[out] grn green value
- * \param[out] blu blue value
- * \param[out] nul null value
- *
- * \return -1 on error
- * \return 0 on success
- */
-int G_get_raster_row_colors(int fd, int row, struct Colors *colors,
- unsigned char *red, unsigned char *grn,
- unsigned char *blu, unsigned char *nul)
-{
- int cols = G_window_cols();
- int type = G_get_raster_map_type(fd);
- int size = G_raster_size(type);
- void *array;
- unsigned char *set;
- void *p;
- int i;
-
- array = G__alloca(cols * size);
-
- if (G_get_raster_row(fd, array, row, type) < 0) {
- G__freea(array);
- return -1;
- }
-
- if (nul)
- for (i = 0, p = array; i < cols; i++, p = G_incr_void_ptr(p, size))
- nul[i] = G_is_null_value(p, type);
-
- set = G__alloca(cols);
-
- G_lookup_raster_colors(array, red, grn, blu, set, cols, colors, type);
-
- G__freea(array);
- G__freea(set);
-
- return 0;
-}
Modified: grass/trunk/lib/gis/get_window.c
===================================================================
--- grass/trunk/lib/gis/get_window.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/get_window.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,10 +12,13 @@
*/
#include <stdlib.h>
-#include "G.h"
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
+#include "../raster/G.h"
+
static struct state {
int initialized;
struct Cell_head dbwindow;
@@ -56,7 +59,7 @@
if (regvar) {
char **tokens = G_tokenize(regvar, ";");
- err = G__read_Cell_head_array(tokens, &st->dbwindow, 0);
+ err = Rast__read_Cell_head_array(tokens, &st->dbwindow, 0);
G_free_tokens(tokens);
}
else {
@@ -125,7 +128,7 @@
if (!fp)
return G_store(_("is not set"));
- err = G__read_Cell_head(fp, window, 0);
+ err = Rast__read_Cell_head(fp, window, 0);
fclose(fp);
if (err) {
Modified: grass/trunk/lib/gis/gisinit.c
===================================================================
--- grass/trunk/lib/gis/gisinit.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/gisinit.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,9 +22,11 @@
#include <locale.h>
#include <grass/gis.h>
-#include "G.h"
+#include <grass/Rast.h>
#include <grass/glocale.h>
+#include "../raster/G.h"
+
struct G__ G__;
static int initialized = 0; /** Is set when engine is initialized */
@@ -139,12 +141,12 @@
G_init_env();
G_init_logging();
G__init_window();
- G__check_for_auto_masking();
+ Rast__check_for_auto_masking();
G_init_locale();
G_init_debug();
G_verbose();
G_init_tempfile();
- G_init_gdal();
+ Rast_init_gdal();
G_get_list_of_mapsets();
G__home();
G__machine_name();
Deleted: grass/trunk/lib/gis/histo_eq.c
===================================================================
--- grass/trunk/lib/gis/histo_eq.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/histo_eq.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,77 +0,0 @@
-
-/**************************************************************
-* G_histogram_eq (histo, map, min, max)
-*
-* struct Histogram *histo; histogram as returned by G_read_histogram()
-* unsigned char **map; equalized category mapping
-* CELL *min, *max; min,max category for map
-*
-* perform histogram equalization
-* inputs are histo, output is map,min,max
-****************************************************************/
-#include <grass/gis.h>
-
-void G_histogram_eq(const struct Histogram *histo,
- unsigned char **map, CELL *min, CELL *max)
-{
- int i;
- int x;
- CELL cat, prev;
- double total;
- double sum;
- double span;
- int ncats;
- long count;
- unsigned char *xmap;
- int len;
- int first, last;
-
- ncats = G_get_histogram_num(histo);
- if (ncats == 1) {
- *min = *max = G_get_histogram_cat(0, histo);
- *map = xmap = (unsigned char *)G_malloc(1);
- *xmap = 0;
- return;
- }
- if ((*min = G_get_histogram_cat(first = 0, histo)) == 0)
- *min = G_get_histogram_cat(++first, histo);
- if ((*max = G_get_histogram_cat(last = ncats - 1, histo)) == 0)
- *max = G_get_histogram_cat(--last, histo);
- len = *max - *min + 1;
- *map = xmap = (unsigned char *)G_malloc(len);
-
- total = 0;
- for (i = first; i <= last; i++) {
- if (G_get_histogram_cat(i, histo) == 0)
- continue;
- count = G_get_histogram_count(i, histo);
- if (count > 0)
- total += count;
- }
- if (total <= 0) {
- for (i = 0; i < len; i++)
- xmap[i] = 0;
- return;
- }
-
- span = total / 256;
-
- sum = 0.0;
- cat = *min - 1;
- for (i = first; i <= last; i++) {
- prev = cat + 1;
- cat = G_get_histogram_cat(i, histo);
- count = G_get_histogram_count(i, histo);
- if (count < 0 || cat == 0)
- count = 0;
- x = (sum + (count / 2.0)) / span;
- if (x < 0)
- x = 0;
- else if (x > 255)
- x = 255;
- sum += count;
-
- while (prev++ <= cat)
- *xmap++ = x;
- }
-}
Deleted: grass/trunk/lib/gis/histogram.c
===================================================================
--- grass/trunk/lib/gis/histogram.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/histogram.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,454 +0,0 @@
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include <stdlib.h>
-
-
-#define LIST struct Histogram_list
-
-static FILE *fopen_histogram_new(const char *);
-static int cmp(const void *, const void *);
-static int cmp_count(const void *, const void *);
-
-
-/*!
- * \brief initializes the histogram structure
- *
- * initializes the histogram structure for calls to G_set_histogram()
- * and G_add_histogram()
- * \param histogram
- * \return
- */
-
-void G_init_histogram(struct Histogram *histogram)
-{
- histogram->num = 0;
- histogram->list = NULL;
-}
-
-
-/*!
- * \brief read the histogram information
- *
- * Reads the histogram information associated with map layer "map"
- * in mapset "mapset" into the structure "histogram".
- *
- * note: a warning message is printed if the file is missing or incorrect
- * \param name: name of map
- * \param mapset: mapset that map belongs to
- * \param histogram: struct for histogram
- * \return 1 if successful,
- * 0 if no histogram file,
- * -1 on fail
- */
-
-int G_read_histogram(const char *name, const char *mapset,
- struct Histogram *histogram)
-{
- FILE *fd = NULL;
- long cat;
- long count;
- char buf[200];
-
- G_init_histogram(histogram);
-
- if (G_find_file2_misc("cell_misc", "histogram", name, mapset) == NULL) {
- G_warning(_("Histogram for [%s in %s] missing (run r.support)"), name,
- mapset);
-
- return 0;
- }
-
- fd = G_fopen_old_misc("cell_misc", "histogram", name, mapset);
- if (!fd) {
- G_warning(_("Can't read histogram for [%s in %s]"), name, mapset);
-
- return -1;
- }
-
- while (fgets(buf, sizeof buf, fd)) {
- if (sscanf(buf, "%ld:%ld", &cat, &count) != 2) {
- G_free_histogram(histogram);
- fclose(fd);
- G_warning(_("Invalid histogram file for [%s in %s]"), name,
- mapset);
-
- return -1;
- }
- G_extend_histogram((CELL) cat, count, histogram);
- }
- fclose(fd);
-
- if (histogram->num == 0) {
- G_warning(_("Invalid histogram file for [%s in %s]"), name, mapset);
-
- return -1;
- }
-
- G_sort_histogram(histogram);
-
- return 1;
-}
-
-
-/*!
- * \brief Writes the histogram information
- *
- * Writes the histogram information associated with map layer "name"
- * \param name: name of map
- * \param histogram: struct for histogram
- * \return 1 if successful,
- * -1 on fail
- */
-
-int G_write_histogram(const char *name, const struct Histogram *histogram)
-{
- FILE *fd;
- int n;
- LIST *list;
-
- fd = fopen_histogram_new(name);
- if (fd == NULL)
- return -1;
-
- list = histogram->list;
- for (n = 0; n < histogram->num; n++) {
- if (list[n].count)
- fprintf(fd, "%ld:%ld\n", (long)list[n].cat, list[n].count);
- }
- fclose(fd);
-
- return 1;
-}
-
-
-/*!
- * \brief Writes the histogram based on cell statistics to file
- *
- * \param name: name of map
- * \param statf: cell statistics
- * \return 1 on success
- * -1 on failure
- */
-
-int G_write_histogram_cs(const char *name, struct Cell_stats *statf)
-{
- FILE *fd;
- CELL cat;
- long count;
-
- fd = fopen_histogram_new(name);
- if (fd == NULL)
- return -1;
-
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf)) {
- if (count > 0)
- fprintf(fd, "%ld:%ld\n", (long)cat, count);
- }
- fclose(fd);
-
- return 1;
-}
-
-
-/*!
- * \brief Creates histogram based on cell statistics
- *
- * \param statf: cell statistics
- * \param histogram: raster histogram
- * \return
- */
-void G_make_histogram_cs(struct Cell_stats *statf, struct Histogram *histogram)
-{
- CELL cat;
- long count;
-
- G_init_histogram(histogram);
- G_rewind_cell_stats(statf);
- while (G_next_cell_stat(&cat, &count, statf))
- G_add_histogram(cat, count, histogram);
-
- G_sort_histogram(histogram);
-}
-
-
-/*!
- * \brief Sorts the histogram in ascending order by counts then category
- *
- * Sorts the histogram in ascending order by counts then category.
- * No combining is done.
- * \param histogram: struct for histogram
- * \return 1 if successful,
- * -1 on fail
- */
-int G_get_histogram_num(const struct Histogram *histogram)
-{
- return histogram->num;
-}
-
-
-/*!
- * \brief Returns cat for the nth element in the histogram
- *
- * Returns cat for the nth element in the histogram
- * \param histogram: struct for histogram
- * \return CELL
- */
-CELL G_get_histogram_cat(int n, const struct Histogram * histogram)
-{
- if (n < 0 || n >= histogram->num)
- return 0;
-
- return histogram->list[n].cat;
-}
-
-
-/*!
- * \brief Returns count for the nth element in the histogram
- *
- * Returns count for the nth element in the histogram
- * \param n: nth element
- * \param histogram: struct for histogram
- * \return count
- */
-long G_get_histogram_count(int n, const struct Histogram *histogram)
-{
- if (n < 0 || n >= histogram->num)
- return 0;
-
- return histogram->list[n].count;
-}
-
-
-/*!
- * \brief Frees memory allocated for the histogram
- *
- * frees the memory allocated for the histogram
- * \param histogram: struct for histogram
- * \return
- */
-void G_free_histogram(struct Histogram *histogram)
-{
- if (histogram->num > 0)
- G_free(histogram->list);
- histogram->num = 0;
- histogram->list = NULL;
-}
-
-/*!
- * \brief Sorts the histogram
- *
- * Sorts the histogram in ascending order by category,
- * combining (by adding) elements that have the same category.
- * \param histogram: struct for histogram
- * \return 0 if successful,
- * 1 on fail
- */
-int G_sort_histogram(struct Histogram *histogram)
-{
- int a, b, n;
- LIST *list;
-
- /* if histogram only has 1 entry, nothing to do */
- if ((n = histogram->num) <= 1)
- return 1;
-
- list = histogram->list;
-
- /* quick check to see if sorting needed */
- for (a = 1; a < n; a++)
- if (list[a - 1].cat >= list[a].cat)
- break;
- if (a >= n)
- return 1;
-
- /* sort */
- qsort(list, n, sizeof(LIST), &cmp);
-
- /* sum duplicate entries */
- for (a = 0, b = 1; b < n; b++) {
- if (list[a].cat != list[b].cat) {
- a++;
- list[a].count = list[b].count;
- list[a].cat = list[b].cat;
- }
- else {
- list[a].count += list[b].count;
- }
- }
- histogram->num = a + 1;
-
- return 0;
-}
-
-
-static int cmp(const void *aa, const void *bb)
-{
- const LIST *a = aa, *b = bb;
-
- if (a->cat < b->cat)
- return -1;
-
- if (a->cat > b->cat)
- return 1;
-
- return 0;
-}
-
-/*!
- * \brief Sorts the histogram by counts
- *
- * Sorts the histogram in ascending order by counts then category.
- * No combining is done.
- * \param histogram: struct for histogram
- * \return 0 if successful,
- * 1 on fail
- */
-int G_sort_histogram_by_count(struct Histogram *histogram)
-{
- int n;
- LIST *list;
-
- /* if histogram only has 1 entry, nothing to do */
- if ((n = histogram->num) <= 1)
- return 1;
-
- list = histogram->list;
-
- /* sort */
- qsort(list, n, sizeof(LIST), &cmp_count);
-
- return 0;
-}
-
-
-static int cmp_count(const void *aa, const void *bb)
-{
- const LIST *a = aa, *b = bb;
-
- if (a->count < b->count)
- return -1;
-
- if (a->count > b->count)
- return 1;
-
- if (a->cat < b->cat)
- return -1;
-
- if (a->cat > b->cat)
- return 1;
-
- return 0;
-}
-
-static FILE *fopen_histogram_new(const char *name)
-{
- FILE *fd;
-
- fd = G_fopen_new_misc("cell_misc", "histogram", name);
- if (fd == NULL)
- G_warning(_("can't create histogram for [%s in %s]"), name,
- G_mapset());
-
- return fd;
-}
-
-
-/*!
- * \brief Removes the histogram
- *
- * Removes the histogram information associated with map layer "name"
- * \param name: name of map
- * \return
- */
-
-void G_remove_histogram(const char *name)
-{
- G_remove_misc("cell_misc", "histogram", name);
-}
-
-
-/*!
- * \brief adds count to the histogram value for cat
- *
- * adds count to the histogram value for cat
- * \param cat: category
- * \param count
- * \param histogram: struct for histogram
- * \return 0 if successful,
- * 1 on fail
- */
-int G_add_histogram(CELL cat, long count, struct Histogram *histogram)
-{
- int i;
-
- for (i = 0; i < histogram->num; i++) {
- if (histogram->list[i].cat == cat) {
- histogram->list[i].count += count;
- return 1;
- }
- }
- G_extend_histogram(cat, count, histogram);
-
- return 0;
-}
-
-
-/*!
- * \brief sets the histogram value for cat to count
- *
- * sets the histogram value for cat to count
- * \param cat: category
- * \param count
- * \param histogram: struct for histogram
- * \return 0 if successful,
- * 1 on fail
- */
-int G_set_histogram(CELL cat, long count, struct Histogram *histogram)
-{
- int i;
-
- for (i = 0; i < histogram->num; i++) {
- if (histogram->list[i].cat == cat) {
- histogram->list[i].count = count;
- return 1;
- }
- }
- G_extend_histogram(cat, count, histogram);
-
- return 0;
-}
-
-
-/*!
- * \brief Extends histogram struct to accomodate a new value
- *
- * \param cat: category
- * \param count
- * \param histogram: struct for histogram
- * \return
- */
-void G_extend_histogram(CELL cat, long count, struct Histogram *histogram)
-{
- histogram->num++;
- histogram->list =
- (LIST *) G_realloc(histogram->list,
- histogram->num * sizeof(LIST));
- histogram->list[histogram->num - 1].cat = cat;
- histogram->list[histogram->num - 1].count = count;
-}
-
-
-/*!
- * \brief Zero out histogram struct
- *
- * \param histogram: struct for histogram
- * \return
- */
-void G_zero_histogram(struct Histogram *histogram)
-{
- int i;
-
- for (i = 0; i < histogram->num; i++)
- histogram->list[i].count = 0;
-}
Deleted: grass/trunk/lib/gis/history.c
===================================================================
--- grass/trunk/lib/gis/history.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/history.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,271 +0,0 @@
-/*!
- * \file gis/history.c
- *
- * \brief GIS Library - History management
- *
- * (C) 2001-2009 GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-static void print_history_error(const char *, const char *, FILE *);
-
-/*!
- * \brief Read raster history file
- *
- * This routine reads the history file for the raster map <i>name</i>
- * in <i>mapset</i> into the <i>hist</i> structure.
- *
- * A diagnostic message is printed and -1 is returned if there is an
- * error reading the history file. Otherwise, 0 is returned.
- *
- * \param name map name
- * \param mapset mapset name
- * \param hist pointer to History structure which holds history info
- *
- * \return -1 on error
- * \return 0 on success
- */
-int G_read_history(const char *name, const char *mapset, struct History *hist)
-{
- FILE *fd;
-
- G_zero(hist, sizeof(struct History));
- fd = G_fopen_old("hist", name, mapset);
- if (!fd) {
- print_history_error(name, mapset, fd);
- return -1;
- }
-
- if (!G_getl(hist->mapid, sizeof(hist->mapid), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->mapid);
-
- if (!G_getl(hist->title, sizeof(hist->title), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->title);
-
- if (!G_getl(hist->mapset, sizeof(hist->mapset), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->mapset);
-
- if (!G_getl(hist->creator, sizeof(hist->creator), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->creator);
-
- if (!G_getl(hist->maptype, sizeof(hist->maptype), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->maptype);
-
- if (!G_getl(hist->datsrc_1, sizeof(hist->datsrc_1), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->datsrc_1);
-
- if (!G_getl(hist->datsrc_2, sizeof(hist->datsrc_2), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->datsrc_2);
-
- if (!G_getl(hist->keywrd, sizeof(hist->keywrd), fd)) {
- print_history_error(name, mapset, fd);
- return -1;
- }
- G_ascii_check(hist->keywrd);
-
- hist->edlinecnt = 0;
- while ((hist->edlinecnt < MAXEDLINES) &&
- (G_getl
- (hist->edhist[hist->edlinecnt], sizeof(hist->edhist[0]), fd))) {
- G_ascii_check(hist->edhist[hist->edlinecnt]);
- hist->edlinecnt++;
- }
-
- fclose(fd);
-
- return 0;
-}
-
-void print_history_error(const char *name, const char *mapset, FILE *fd)
-{
- if (fd != NULL)
- fclose(fd);
-
- if (mapset) {
- G_warning(_("Unable to get history information for <%s@%s>"),
- name, mapset);
- }
- else { /* write */
- G_warning(_("Unable to write history information for <%s>"), name);
- }
-}
-
-/*!
- * \brief Write raster history file
- *
- * This routine writes the history file for the raster map
- * <i>name</i> in the current mapset from the <i>hist</i> structure.
- *
- * A diagnostic message is printed and -1 is returned if there is an
- * error writing the history file. Otherwise, 0 is returned.
- *
- * <b>Note:</b> The <i>hist</i> structure should first be initialized
- * using G_short_history().
- *
- * \param name map name
- * \param[out] hist pointer to History structure which holds history info
- *
- * \return -1 on error
- * \return 0 on success
- */
-int G_write_history(const char *name, struct History *hist)
-{
- FILE *fd;
- int i;
-
- fd = G_fopen_new("hist", name);
- if (!fd) {
- print_history_error(name, NULL, fd);
- return -1;
- }
-
- fprintf(fd, "%s\n", hist->mapid);
- fprintf(fd, "%s\n", hist->title);
- fprintf(fd, "%s\n", hist->mapset);
- fprintf(fd, "%s\n", hist->creator);
- fprintf(fd, "%s\n", hist->maptype);
- fprintf(fd, "%s\n", hist->datsrc_1);
- fprintf(fd, "%s\n", hist->datsrc_2);
- fprintf(fd, "%s\n", hist->keywrd);
-
- for (i = 0; i < hist->edlinecnt; i++)
- fprintf(fd, "%s\n", hist->edhist[i]);
-
- fclose(fd);
-
- return 0;
-}
-
-/*!
- * \brief Initialize history structure
- *
- * This routine initializes the <i>hist</i> structure, recording the
- * date, user, module name and the raster map <i>name</i>
- * structure. The <i>type</i> is an anachronism from earlier versions
- * of GRASS and should be specified as "raster".
- *
- * <b>Note:</b> This routine only initializes the data structure. It
- * does not write the history file.
- *
- * \param name map name
- * \param type map type
- * \param hist pointer to History structure which holds history info
- */
-void G_short_history(const char *name, const char *type, struct History *hist)
-{
- strncpy(hist->mapid, G_date(), RECORD_LEN);
- strncpy(hist->title, name, RECORD_LEN);
- strncpy(hist->mapset, G_mapset(), RECORD_LEN);
- strncpy(hist->creator, G_whoami(), RECORD_LEN);
- strncpy(hist->maptype, type, RECORD_LEN);
-
- sprintf(hist->keywrd, _("generated by %s"), G_program_name());
- strcpy(hist->datsrc_1, "");
- strcpy(hist->datsrc_2, "");
- hist->edlinecnt = 0;
-}
-
-/*!
- * \brief Save command line to raster history structure
- *
- * This routine takes an existing (run G_short_history first() history
- * structure and adds the command line to the end of the comments
- * array, as cleaned & expanded by the parser.
- *
- * History file is limited to [80]x[50], as defined in include/gis.h
- *
- * - First version had for loops of [i][j] character assignments and ending
- * nulls, but using the string libraries is cleaner and less bug prone.
- * - Second version had white space detection, intelligent wrapping, and
- * indentation of continued lines, but this proved a pain in the neck for
- * things like r.patch which can have long strings without any
- * parser-acceptable breaks.
- * - This is MK-III, simplified, but that's good: it's cut & paste-able.
- *
- * Note: use G_write_history() to write the structure.
- *
- * Sample Usage:
- * \code
- * struct History history;
- * G_short_history(rasterfile, "raster", &history);
- * G_command_history(&history);
- * G_write_history(rasterfile, &history);
- * \endcode
- *
- * \param hist pointer to History structure which holds history info
- *
- * \return 0 on success
- * \return 1 on failure (history file full, no change)
- * \return 2 on failure (history file full, added as much as we could)
- */
-int G_command_history(struct History *hist)
-{
- int j, cmdlen;
- char *cmdlin;
-
- cmdlin = G_recreate_command();
- cmdlen = strlen(cmdlin);
-
- if (hist->edlinecnt > MAXEDLINES - 2) {
- G_warning(_("Not enough room in history file to record command line"));
- return 1;
- }
-
- if (hist->edlinecnt > 0) { /* add a blank line if preceding history exists */
- strcpy(hist->edhist[hist->edlinecnt], "");
- hist->edlinecnt++;
- }
-
- if (cmdlen < 70) { /* ie if it will fit on a single line */
- sprintf(hist->edhist[hist->edlinecnt], G_recreate_command());
- hist->edlinecnt++;
- }
- else { /* multi-line required */
- j = 0; /* j is the current position in the command line string */
- while ((cmdlen - j) > 70) {
- strncpy(hist->edhist[hist->edlinecnt], &cmdlin[j], 68);
- hist->edhist[hist->edlinecnt][68] = '\0';
- strcat(hist->edhist[hist->edlinecnt], "\\");
- j += 68;
- hist->edlinecnt++;
- if (hist->edlinecnt > MAXEDLINES - 2) {
- G_warning(_("Not enough room in history file for command line (truncated)"));
- return 2;
- }
- }
- if ((cmdlen - j) > 0) { /* ie anything left */
- strcpy(hist->edhist[hist->edlinecnt], &cmdlin[j]);
- hist->edlinecnt++;
- }
- }
- return 0;
-}
Deleted: grass/trunk/lib/gis/interp.c
===================================================================
--- grass/trunk/lib/gis/interp.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/interp.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,36 +0,0 @@
-
-#include <grass/gis.h>
-
-DCELL G_interp_linear(double u, DCELL c0, DCELL c1)
-{
- return u * (c1 - c0) + c0;
-}
-
-DCELL G_interp_bilinear(double u, double v,
- DCELL c00, DCELL c01, DCELL c10, DCELL c11)
-{
- DCELL c0 = G_interp_linear(u, c00, c01);
- DCELL c1 = G_interp_linear(u, c10, c11);
-
- return G_interp_linear(v, c0, c1);
-}
-
-DCELL G_interp_cubic(double u, DCELL c0, DCELL c1, DCELL c2, DCELL c3)
-{
- return (u * (u * (u * (c3 - 3 * c2 + 3 * c1 - c0) +
- (-c3 + 4 * c2 - 5 * c1 + 2 * c0)) + (c2 - c0)) + 2 * c1) / 2;
-}
-
-DCELL G_interp_bicubic(double u, double v,
- DCELL c00, DCELL c01, DCELL c02, DCELL c03,
- DCELL c10, DCELL c11, DCELL c12, DCELL c13,
- DCELL c20, DCELL c21, DCELL c22, DCELL c23,
- DCELL c30, DCELL c31, DCELL c32, DCELL c33)
-{
- DCELL c0 = G_interp_cubic(u, c00, c01, c02, c03);
- DCELL c1 = G_interp_cubic(u, c10, c11, c12, c13);
- DCELL c2 = G_interp_cubic(u, c20, c21, c22, c23);
- DCELL c3 = G_interp_cubic(u, c30, c31, c32, c33);
-
- return G_interp_cubic(v, c0, c1, c2, c3);
-}
Deleted: grass/trunk/lib/gis/mask_info.c
===================================================================
--- grass/trunk/lib/gis/mask_info.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/mask_info.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,70 +0,0 @@
-/*
- *************************************************************
- * char * G_mask_info ()
- *
- * returns a printable text of mask information
- *
- ************************************************************
- * G__mask_info (name, mapset)
- *
- * char name[GNAME_MAX], mapset[GMAPSET_MAX];
- *
- * function:
- * determine the status off the automatic masking
- * and the name of the cell file which forms the mask
- *
- * (the mask file is actually MASK in the current mapset,
- * but is usually a reclassed cell file, and the reclass
- * name and mapset are returned)
- *
- * returns:
- * -1 no masking (name, mapset undefined)
- * name, mapset are undefined
- *
- * 1 mask file present, masking on
- * name, mapset hold mask file name, mapset
- *
- ***************************************************************/
-
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-char *G_mask_info(void)
-{
- char text[GNAME_MAX + GMAPSET_MAX + 16];
- char name[GNAME_MAX];
- char mapset[GMAPSET_MAX];
-
- switch (G__mask_info(name, mapset)) {
- case 1:
- sprintf(text, _("<%s> in mapset <%s>"), name, mapset);
- break;
- case -1:
- strcpy(text, _("none"));
- break;
- default:
- strcpy(text, _("not known"));
- break;
- }
-
- return G_store(text);
-}
-
-int G__mask_info(char *name, char *mapset)
-{
- char rname[GNAME_MAX], rmapset[GMAPSET_MAX];
-
- strcpy(name, "MASK");
- strcpy(mapset, G_mapset());
-
- if (!G_find_cell(name, mapset))
- return -1;
-
- if (G_is_reclass(name, mapset, rname, rmapset) > 0) {
- strcpy(name, rname);
- strcpy(mapset, rmapset);
- }
-
- return 1;
-}
Deleted: grass/trunk/lib/gis/maskfd.c
===================================================================
--- grass/trunk/lib/gis/maskfd.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/maskfd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,29 +0,0 @@
-/*!
- * \file gis/maskfd.c
- *
- * \brief GIS Library - Mask functions.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-#include "G.h"
-
-/*!
- * \brief Test for MASK.
- *
- * \return -1 if no MASK
- * \return file descriptor if MASK
- */
-
-int G_maskfd(void)
-{
- G__check_for_auto_masking();
-
- return G__.auto_mask > 0 ? G__.mask_fd : -1;
-}
Deleted: grass/trunk/lib/gis/null_val.c
===================================================================
--- grass/trunk/lib/gis/null_val.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/null_val.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,506 +0,0 @@
-/*!
- * \file gis/null_value.c
- *
- * \brief GIS Library - NULL value management
- *
- * To provide functionality to handle NULL values for data types CELL,
- * FCELL, and DCELL. May need more...
- *
- * (C) 2001-2009 GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author unknown - probably CERL
- * \author Justin Hickey - Thailand - jhickey at hpcc.nectec.or.th
- */
-
-/* System include files */
-#include <string.h>
-
-/* Grass and local include files */
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-static void EmbedGivenNulls(void *, char *, RASTER_MAP_TYPE, int);
-
-/*!
- \brief To insert null values into a map. Needs more.....
-
- \param cell raster values
- \param nulls raster null values
- \param map_type type of raster - CELL, FCELL, DCELL
- \param ncols number of columns
-*/
-void EmbedGivenNulls(void *cell, char *nulls, RASTER_MAP_TYPE map_type,
- int ncols)
-{
- CELL *c;
- FCELL *f;
- DCELL *d;
- int i;
-
- c = (CELL *) cell;
- f = (FCELL *) cell;
- d = (DCELL *) cell;
-
- for (i = 0; i < ncols; i++) {
- if (nulls[i]) {
- switch (map_type) {
- case CELL_TYPE:
- G_set_c_null_value((CELL *) (c + i), 1);
- break;
-
- case FCELL_TYPE:
- G_set_f_null_value((FCELL *) (f + i), 1);
- break;
-
- case DCELL_TYPE:
- G_set_d_null_value((DCELL *) (d + i), 1);
- break;
-
- default:
- G_warning(_("EmbedGivenNulls: wrong data type"));
- }
- }
- }
-}
-
-/*!
- \brief To set one or more raster values to null.
-
- It also sets null to zero if null_is_zero is TRUE.
-
- \param rast pointer to values to set to null
- \param numVals number of values to set to null
- \param null_is_zero flag to indicate if NULL = 0
- \param data_type type of raster - CELL, FCELL, DCELL
-*/
-void G__set_null_value(void *rast, int numVals, int null_is_zero,
- RASTER_MAP_TYPE data_type)
-{
- if (null_is_zero) {
- G_zero((char *)rast, numVals * G_raster_size(data_type));
- return;
- }
-
- G_set_null_value(rast, numVals, data_type);
-}
-
-/*!
- \brief To set one or more raster values to null.
-
- \param buf pointer to values to set to null
- \param numVals number of values to set to null
- \param data_type type of raster - CELL, FCELL, DCELL
-*/
-void G_set_null_value(void *buf, int numVals, RASTER_MAP_TYPE data_type)
-{
- switch (data_type) {
- case CELL_TYPE:
- G_set_c_null_value((CELL *) buf, numVals);
- break;
-
- case FCELL_TYPE:
- G_set_f_null_value((FCELL *) buf, numVals);
- break;
-
- case DCELL_TYPE:
- G_set_d_null_value((DCELL *) buf, numVals);
- break;
-
- default:
- G_warning(_("G_set_null_value: wrong data type!"));
- }
-}
-
-/*!
- \brief To set a number of CELL raster values to NULL.
-
- \param cellVals pointer to CELL values to set to null
- \param numVals number of values to set to null
-*/
-void G_set_c_null_value(CELL *cellVals, int numVals)
-{
- int i; /* counter */
-
- for (i = 0; i < numVals; i++)
- cellVals[i] = (int) 0x80000000;
-}
-
-/*!
- \brief To set a number of FCELL raster values to NULL.
-
- \param fcellVals pointer to FCELL values to set to null
- \param numVals number of values to set to null
-*/
-void G_set_f_null_value(FCELL *fcellVals, int numVals)
-{
- static const unsigned char null_bits[4] = {
- 0xFF, 0xFF, 0xFF, 0xFF};
- int i;
-
- for (i = 0; i < numVals; i++)
- memcpy(&fcellVals[i], null_bits, sizeof(null_bits));
-}
-
-/*!
- \brief To set a number of DCELL raster values to NULL.
-
- \param dcellVals pointer to DCELL values to set to null
- \param numVals number of values to set to null
-*/
-void G_set_d_null_value(DCELL *dcellVals, int numVals)
-{
- static const unsigned char null_bits[8] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
- int i;
-
- for (i = 0; i < numVals; i++)
- memcpy(&dcellVals[i], null_bits, sizeof(null_bits));
-}
-
-/*!
- \brief To check if a raster value is set to NULL
-
- - If the <em>data_type</em> is CELL_TYPE, calls G_is_c_null_value()
- - If the <em>data_type</em> is FCELL_TYPE, calls G_is_f_null_value()
- - If the <em>data_type</em> is DCELL_TYPE, calls G_is_d_null_value()
-
- \param rast raster value to check
- \param data_type type of raster - CELL, FCELL, DCELL
-
- \return TRUE if raster value is NULL
- \return FALSE otherwise
- */
-int G_is_null_value(const void *rast, RASTER_MAP_TYPE data_type)
-{
- switch (data_type) {
- case CELL_TYPE:
- return (G_is_c_null_value((CELL *) rast));
-
- case FCELL_TYPE:
- return (G_is_f_null_value((FCELL *) rast));
-
- case DCELL_TYPE:
- return (G_is_d_null_value((DCELL *) rast));
-
- default:
- G_warning("G_is_null_value: wrong data type!");
- return FALSE;
- }
-}
-
-/*!
- \brief To check if a CELL raster value is set to NULL
-
- Returns 1 if <em>cell</em> is NULL, 0 otherwise. This will test if the
- value <em>cell</em> is the largest <tt>int</tt>.
-
- \param cellVal CELL raster value to check
-
- \return TRUE if CELL raster value is NULL
- \return FALSE otherwise
-*/
-int G_is_c_null_value(const CELL * cellVal)
-{
- /* Check if the CELL value matches the null pattern */
- return *cellVal == (CELL) 0x80000000;
-}
-
-/*!
- \brief To check if a FCELL raster value is set to NULL
-
- Returns 1 if <em>fcell</em> is NULL, 0 otherwise. This will test if
- the value <em>fcell</em> is a NaN. It isn't good enough to test for
- a particular NaN bit pattern since the machine code may change this
- bit pattern to a different NaN. The test will be
-
- \code
- if(fcell==0.0) return 0;
- if(fcell>0.0) return 0;
- if(fcell<0.0) return 0;
- return 1;
- \endcode
-
- or (as suggested by Mark Line)
- \code
- return (fcell != fcell);
- \endcode
-
- \param fcellVal FCELL raster value to check
-
- \return TRUE if FCELL raster value is NULL
- \return FALSE otherwise
-*/
-int G_is_f_null_value(const FCELL * fcellVal)
-{
- return *fcellVal != *fcellVal;
-}
-
-/*!
- \brief To check if a DCELL raster value is set to NULL
-
- Returns 1 if <em>dcell</em> is NULL, 0 otherwise. This will test if
- the value <em>dcell</em> is a NaN. Same test as in
- G_is_f_null_value().
-
- \param dcellVal DCELL raster value to check
-
- \return TRUE if DCELL raster value is NULL
- \return FALSE otherwise
-*/
-int G_is_d_null_value(const DCELL * dcellVal)
-{
- return *dcellVal != *dcellVal;
-}
-
-/*!
- \brief To insert null values into a map.
-
- - If the <em>data_type</em> is CELL_TYPE, calls G_insert_c_null_values()
- - If the <em>data_type</em> is FCELL_TYPE, calls G_insert_f_null_values()
- - If the <em>data_type</em> is DCELL_TYPE, calls G_insert_d_null_values()
-
- \param rast pointer raster values
- \param null_row null row
- \param ncols number of columns
- \param data_type type of raster - CELL, FCELL, DCELL
- */
-void G_insert_null_values(void *rast, char *null_row, int ncols,
- RASTER_MAP_TYPE data_type)
-{
- EmbedGivenNulls(rast, null_row, data_type, ncols);
-}
-
-/*!
- \brief To insert null values into an integer raster map (CELL)
-
- For each of the <em>count</em> <em>flags</em> which is true(!=0),
- set the corresponding <em>cell</em> to the NULL value.
-
- \param rast pointer raster values
- \param null_row null row
- \param ncols number of columns
-*/
-void G_insert_c_null_values(CELL * cellVal, char *null_row, int ncols)
-{
- EmbedGivenNulls((void *)cellVal, null_row, CELL_TYPE, ncols);
-}
-
-/*!
- \brief To insert null values into an floating-point raster map (FCELL)
-
- \param fcellVal pointer raster values
- \param null_row null row
- \param ncols number of columns
-*/
-void G_insert_f_null_values(FCELL * fcellVal, char *null_row, int ncols)
-{
- EmbedGivenNulls((void *)fcellVal, null_row, FCELL_TYPE, ncols);
-}
-
-/*!
- \brief To insert null values into an floating-point raster map (FCELL)
-
- For each for the <em>count</em> <em>flag</em> which is true(!=0), set
- the corresponding <em>dcell</em> to the NULL value.
-
- \param dcellVal pointer raster values
- \param null_row null row
- \param ncols number of columns
-*/
-void G_insert_d_null_values(DCELL * dcellVal, char *null_row, int ncols)
-{
- EmbedGivenNulls((void *)dcellVal, null_row, DCELL_TYPE, ncols);
-}
-
-/*!
- \brief Check NULL
-
- Note: Only for internal use.
-
- \param flags ?
- \param bit_num ?
- \param n ?
-
- \return -1 on error
-*/
-int G__check_null_bit(const unsigned char *flags, int bit_num, int n)
-{
- int ind;
- int offset;
-
- /* find the index of the unsigned char in which this bit appears */
- ind = G__null_bitstream_size(bit_num + 1) - 1;
-
- /* find how many unsigned chars the buffer with bit_num+1 (counting from 0
- has and subtract 1 to get unsigned char index */
- if (ind > G__null_bitstream_size(n) - 1) {
- G_warning("G__check_null_bit: Unable to access index %d. "
- "Size of flags is %d (bit # is %d)",
- ind, G__null_bitstream_size(n) - 1, bit_num);
- return -1;
- }
-
- offset = (ind + 1) * 8 - bit_num - 1;
-
- return ((flags[ind] & ((unsigned char)1 << offset)) != 0);
-}
-
-/*!
- \brief Given array of 0/1 of length n starting from column.
-
- Note: Only for internal use.
-
- Given array of 0/1 of length n starting from column set the
- corresponding bits of flags; total number of bits in flags is ncols.
-
- \param zero_ones
- \param flags
- \param col
- \param n
- \param ncols
-
- \return 0
- \return 1
-*/
-int G__set_flags_from_01_random(const char *zero_ones, unsigned char *flags,
- int col, int n, int ncols)
-{
- unsigned char v;
- int count;
- int size;
- int i, k;
-
- if (col == 0 && n == ncols) {
- G__convert_01_flags(zero_ones, flags, n);
- return 0;
- }
-
- count = 0;
- size = G__null_bitstream_size(ncols);
-
- for (i = 0; i < size; i++) {
- v = 0;
- k = 8;
-
- while (k-- > 0) {
- if (count >= col && count < (col + n)) {
- v = v | ((unsigned char)zero_ones[count - col] << k);
- }
- else if (count < ncols) {
- v = v |
- ((unsigned char)G__check_null_bit(flags, count, ncols) << k);
- }
-
- /* otherwise keep this bit the same as it was */
- count++;
- }
-
- flags[i] = v;
- }
-
- return 1;
-}
-
-/*!
- \brief ?
-
- Note: Only for internal use.
-
- \param zero_ones
- \param flags
- \param n
-*/
-void G__convert_01_flags(const char *zero_ones, unsigned char *flags, int n)
-{
- unsigned char *v;
- int count;
- int size;
- int i, k;
-
- /* pad the flags with 0's to make size multiple of 8 */
- v = flags;
- size = G__null_bitstream_size(n);
- count = 0;
-
- for (i = 0; i < size; i++) {
- *v = 0;
- k = 8;
-
- while (k-- > 0) {
- if (count < n) {
- *v = *v | ((unsigned char)zero_ones[count] << k);
- }
-
- count++;
- }
-
- v++;
- }
-}
-
-/*!
- \brief ?
-
- Note: Only for internal use.
-
- \param zero_ones
- \param flags
- \param n
- */
-void G__convert_flags_01(char *zero_ones, const unsigned char *flags, int n)
-{
- const unsigned char *v;
- int count;
- int size;
- int i, k;
-
- count = 0;
- v = flags;
- size = G__null_bitstream_size(n);
-
- for (i = 0; i < size; i++) {
- k = 8;
-
- while (k-- > 0) {
- if (count < n) {
- zero_ones[count] = ((*v & ((unsigned char)1 << k)) != 0);
- count++;
- }
- }
-
- v++;
- }
-}
-
-/*!
- \brief ?
-
- Note: Only for internal use.
-
- \param flags
- \param cols
- */
-void G__init_null_bits(unsigned char *flags, int cols)
-{
- unsigned char *v;
- int size;
- int i;
-
- /* pad the flags with 0's to make size multiple of 8 */
- v = flags;
- size = G__null_bitstream_size(cols);
-
- for (i = 0; i < size; i++) {
- if ((i + 1) * 8 <= cols) {
- *v = (unsigned char)255;
- }
- else {
- *v = (unsigned char)255 << ((i + 1) * 8 - cols);
- }
-
- v++;
- }
-}
Deleted: grass/trunk/lib/gis/opencell.c
===================================================================
--- grass/trunk/lib/gis/opencell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/opencell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,970 +0,0 @@
-/*!
- * \file gis/opencell.c
- *
- * \brief GIS Library - Open raster file
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <grass/config.h>
-#include "G.h"
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-#define FORMAT_FILE "f_format"
-
-static struct fileinfo *new_fileinfo(int fd)
-{
- int oldsize = G__.fileinfo_count;
- int newsize = oldsize;
- int i;
-
- if (fd < oldsize)
- return &G__.fileinfo[fd];
-
- newsize *= 2;
- if (newsize <= fd)
- newsize = fd + 20;
-
- G__.fileinfo = G_realloc(G__.fileinfo, newsize * sizeof(struct fileinfo));
-
- /* Mark all cell files as closed */
- for (i = oldsize; i < newsize; i++) {
- memset(&G__.fileinfo[i], 0, sizeof(struct fileinfo));
- G__.fileinfo[i].open_mode = -1;
- }
-
- G__.fileinfo_count = newsize;
-
- return &G__.fileinfo[fd];
-}
-
-
-/*!
- * \brief Open raster file
- *
- * Arrange for the NULL-value bitmap to be read as well as the raster
- * map. If no NULL-value bitmap exists, arrange for the production of
- * NULL-values based on zeros in the raster map. If the map is
- * floating-point, arrange for quantization to integer for
- * G_get_c_raster_row(), et. al., by reading the quantization rules
- * for the map using G_read_quant(). If the programmer wants to read
- * the floating point map using uing quant rules other than the ones
- * stored in map's quant file, he/she should call G_set_quant_rules()
- * after the call to G_open_cell_old().
- *
- * \param name map name
- * \param open_mode mode
- * \param map_type map type (CELL, FCELL, DCELL)
- *
- * \return open file descriptor ( >= 0) if successful
- * \return negative integer if error
- */
-
-static int G__open_raster_new(const char *name, int open_mode,
- RASTER_MAP_TYPE map_type);
-
-/*!
- \brief Open an existing integer raster map (cell)
-
- Opens the existing cell file <i>name</i> in the <i>mapset</i> for
- reading by G_get_raster_row() with mapping into the current window.
-
- This routine opens the raster map <i>name</i> in <i>mapset</i> for
- reading. A nonnegative file descriptor is returned if the open is
- successful. Otherwise a diagnostic message is printed and a negative
- value is returned. This routine does quite a bit of work. Since
- GRASS users expect that all raster maps will be resampled into the
- current region, the resampling index for the raster map is prepared
- by this routine after the file is opened. The resampling is based on
- the active module region (see also \ref The_Region}. Preparation
- required for reading the various raster file formats (see \ref
- Raster_File_Format for an explanation of the various raster file
- formats) is also done.
-
- Diagnostics: warning message printed if open fails.
-
- \param name map name
- \param mapset mapset name where raster map <i>name</i> lives
-
- \return nonnegative file descriptor (int)
- \return -1 on failure
- */
-int G_open_cell_old(const char *name, const char *mapset)
-{
- int fd;
-
- if ((fd = G__open_cell_old(name, mapset)) < 0) {
- G_warning(_("Unable to open raster map <%s@%s>"), name, mapset);
- return fd;
- }
-
- /* turn on auto masking, if not already on */
- G__check_for_auto_masking();
- /*
- if(G__.auto_mask <= 0)
- G__.mask_buf = G_allocate_cell_buf();
- now we don't ever free it!, so no need to allocate it (Olga)
- */
- /* mask_buf is used for reading MASK file when mask is set and
- for reading map rows when the null file doesn't exist */
-
- return fd;
-}
-
-/*! \brief Lower level function, open cell files, supercell files,
- and the MASK file.
-
- Actions:
- - opens the named cell file, following reclass reference if
- named layer is a reclass layer.
- - creates the required mapping between the data and the window
- for use by the get_map_row family of routines.
-
- Diagnostics: Errors other than actual open failure will cause a
- diagnostic to be delivered thru G_warning() open failure messages
- are left to the calling routine since the masking logic will want to
- issue a different warning.
-
- Note: This routine does NOT open the MASK layer. If it did we would
- get infinite recursion. This routine is called to open the mask by
- G__check_for_auto_masking() which is called by G_open_cell_old().
-
- \param name map name
- \param mapset mapset of cell file to be opened
-
- \return open file descriptor
- \return -1 if error
-*/
-int G__open_cell_old(const char *name, const char *mapset)
-{
- struct fileinfo *fcb;
- int fd;
- char *cell_dir;
- const char *r_name;
- const char *r_mapset;
- struct Cell_head cellhd;
- int CELL_nbytes = 0; /* bytes per cell in CELL map */
- int INTERN_SIZE;
- int reclass_flag, i;
- int MAP_NBYTES;
- RASTER_MAP_TYPE MAP_TYPE;
- struct Reclass reclass;
- char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
- struct GDAL_link *gdal;
-
- /* make sure window is set */
- G__init_window();
-
- G__unqualified_name(name, mapset, xname, xmapset);
- name = xname;
- mapset = xmapset;
-
- if (!G_find_cell2(name, mapset)) {
- G_warning(_("Unable to find <%s@%s>"), name, mapset);
- return -1;
- }
-
- /* Check for reclassification */
- reclass_flag = G_get_reclass(name, mapset, &reclass);
-
- switch (reclass_flag) {
- case 0:
- r_name = name;
- r_mapset = mapset;
- break;
- case 1:
- r_name = reclass.name;
- r_mapset = reclass.mapset;
- if (G_find_cell2(r_name, r_mapset) == NULL) {
- G_warning(_("Unable to open raster map <%s@%s> since it is a reclass "
- "of raster map <%s@%s> which does not exist"),
- name, mapset, r_name, r_mapset);
- return -1;
- }
- break;
- default: /* Error reading cellhd/reclass file */
- return -1;
- }
-
- /* read the cell header */
- if (G_get_cellhd(r_name, r_mapset, &cellhd) < 0)
- return -1;
-
- /* now check the type */
- MAP_TYPE = G_raster_map_type(r_name, r_mapset);
- if (MAP_TYPE < 0)
- return -1;
-
- if (MAP_TYPE == CELL_TYPE)
- /* set the number of bytes for CELL map */
- {
- CELL_nbytes = cellhd.format + 1;
- if (CELL_nbytes < 1) {
- G_warning(_("Raster map <%s@%s>: format field in header file invalid"),
- r_name, r_mapset);
- return -1;
- }
- }
-
- if (cellhd.proj != G__.window.proj) {
- G_warning(_("Raster map <%s@%s> is in different projection than current region. "
- "Found raster map <%s@%s>, should be <%s>."),
- name, mapset, name, G__projection_name(cellhd.proj),
- G__projection_name(G__.window.proj));
- return -1;
- }
- if (cellhd.zone != G__.window.zone) {
- G_warning(_("Raster map <%s@%s> is in different zone (%d) than current region (%d)"),
- name, mapset, cellhd.zone, G__.window.zone);
- return -1;
- }
-
- /* when map is int warn if too large cell size */
- if (MAP_TYPE == CELL_TYPE && (unsigned int) CELL_nbytes > sizeof(CELL)) {
- G_warning(_("Raster map <%s@%s>: bytes per cell (%d) too large"),
- name, mapset, CELL_nbytes);
- return -1;
- }
-
- /* record number of bytes per cell */
- if (MAP_TYPE == FCELL_TYPE) {
- cell_dir = "fcell";
- INTERN_SIZE = sizeof(FCELL);
- MAP_NBYTES = XDR_FLOAT_NBYTES;
- }
- else if (MAP_TYPE == DCELL_TYPE) {
- cell_dir = "fcell";
- INTERN_SIZE = sizeof(DCELL);
- MAP_NBYTES = XDR_DOUBLE_NBYTES;
- }
- else { /* integer */
-
- cell_dir = "cell";
- INTERN_SIZE = sizeof(CELL);
- MAP_NBYTES = CELL_nbytes;
- }
-
- gdal = G_get_gdal_link(r_name, r_mapset);
- if (gdal) {
-#ifdef HAVE_GDAL
- /* dummy descriptor to reserve the fileinfo slot */
- fd = open(G_DEV_NULL, O_RDONLY);
-#else
- G_warning(_("map <%s@%s> is a GDAL link but GRASS is compiled without GDAL support"),
- r_name, r_mapset);
- return -1;
-#endif
- }
- else
- /* now actually open file for reading */
- fd = G_open_old(cell_dir, r_name, r_mapset);
-
- if (fd < 0)
- return -1;
-
- fcb = new_fileinfo(fd);
-
- fcb->map_type = MAP_TYPE;
-
- /* Save cell header */
- G_copy((char *)&fcb->cellhd, (char *)&cellhd, sizeof(cellhd));
-
- /* allocate null bitstream buffers for reading null rows */
- for (i = 0; i < NULL_ROWS_INMEM; i++)
- fcb->NULL_ROWS[i] = G__allocate_null_bits(G__.window.cols);
- /* initialize : no NULL rows in memory */
- fcb->min_null_row = (-1) * NULL_ROWS_INMEM;
-
- /* mark closed */
- fcb->open_mode = -1;
-
- /* save name and mapset */
- fcb->name = G_store(name);
- fcb->mapset = G_store(mapset);
-
- /* mark no data row in memory */
- fcb->cur_row = -1;
- /* fcb->null_cur_row is not used for reading, only for writing */
- fcb->null_cur_row = -1;
-
- /* if reclass, copy reclass structure */
- if ((fcb->reclass_flag = reclass_flag))
- G_copy(&fcb->reclass, &reclass, sizeof(reclass));
-
- fcb->gdal = gdal;
- if (!gdal)
- /* check for compressed data format, making initial reads if necessary */
- if (G__check_format(fd) < 0) {
- close(fd); /* warning issued by check_format() */
- return -1;
- }
-
- /* create the mapping from cell file to window */
- G__create_window_mapping(fd);
-
- /*
- * allocate the data buffer
- * number of bytes per cell is cellhd.format+1
- */
-
- /* for reading fcb->data is allocated to be fcb->cellhd.cols * fcb->nbytes
- (= XDR_FLOAT/DOUBLE_NBYTES) */
- fcb->data = (unsigned char *)G_calloc(fcb->cellhd.cols, MAP_NBYTES);
-
- /* initialize/read in quant rules for float point maps */
- if (fcb->map_type != CELL_TYPE) {
- if (fcb->reclass_flag)
- G_read_quant(fcb->reclass.name, fcb->reclass.mapset,
- &(fcb->quant));
- else
- G_read_quant(fcb->name, fcb->mapset, &(fcb->quant));
- }
-
- /* now mark open for read: this must follow create_window_mapping() */
- fcb->open_mode = OPEN_OLD;
- fcb->io_error = 0;
- fcb->map_type = MAP_TYPE;
- fcb->nbytes = MAP_NBYTES;
- fcb->null_file_exists = -1;
-
- if (fcb->map_type != CELL_TYPE)
- xdrmem_create(&fcb->xdrstream, (caddr_t) fcb->data,
- (u_int) (fcb->nbytes * fcb->cellhd.cols), XDR_DECODE);
-
- return fd;
-}
-
-/*!
- \brief Opens a new cell file in a database (compressed)
-
- Opens a new cell file <i>name</i> in the current mapset for writing
- by G_put_raster_row().
-
- The file is created and filled with no data it is assumed that the
- new cell file is to conform to the current window.
-
- The file must be written sequentially. Use G_open_cell_new_random()
- for non sequential writes.
-
- Note: the open actually creates a temporary file G_close_cell() will
- move the temporary file to the cell file and write out the necessary
- support files (cellhd, cats, hist, etc.).
-
- Diagnostics: warning message printed if open fails
-
- Warning: calls to G_set_window() made after opening a new cell file
- may create confusion and should be avoided the new cell file will be
- created to conform to the window at the time of the open.
-
- \param name map name
-
- \return open file descriptor ( >= 0) if successful
- \return negative integer if error
-*/
-int G_open_cell_new(const char *name)
-{
- return G__open_raster_new(name, OPEN_NEW_COMPRESSED, CELL_TYPE);
-}
-
-/*!
- \brief Opens a new cell file in a database (uncompressed)
-
- See also G_open_cell_new().
-
- \param name map name
-
- \return open file descriptor ( >= 0) if successful
- \return negative integer if error
-*/
-int G_open_cell_new_uncompressed(const char *name)
-{
- return G__open_raster_new(name, OPEN_NEW_UNCOMPRESSED, CELL_TYPE);
-}
-
-/*!
- \brief Save histogram for newly create raster map (cell)
-
- If newly created cell files should have histograms, set flag=1
- otherwise set flag=0. Applies to subsequent opens.
-
- \param flag flag indicator
-*/
-void G_want_histogram(int flag)
-{
- G__.want_histogram = flag;
-}
-
-/*!
- \brief Sets the format for subsequent opens on new integer cell files
- (uncompressed and random only).
-
- Warning: subsequent put_row calls will only write n+1 bytes per
- cell. If the data requires more, the cell file will be written
- incorrectly (but with n+1 bytes per cell)
-
- When writing float map: format is -1
-
- \param n format
-*/
-void G_set_cell_format(int n)
-/* sets the format for integer raster map */
-{
- G__.nbytes = n + 1;
- if (G__.nbytes <= 0)
- G__.nbytes = 1;
- if (G__.nbytes > sizeof(CELL))
- G__.nbytes = sizeof(CELL);
-}
-
-/*!
- \brief Get cell value format
-
- \param v cell
-
- \return cell format
-*/
-int G_cellvalue_format(CELL v)
-{
- unsigned int i;
-
- if (v >= 0)
- for (i = 0; i < sizeof(CELL); i++)
- if (!(v /= 256))
- return i;
- return sizeof(CELL) - 1;
-}
-
-/*!
- \brief Opens new fcell file in a database
-
- Opens a new floating-point map <i>name</i> in the current mapset for
- writing. The type of the file (i.e. either double or float) is
- determined and fixed at this point. The default is FCELL_TYPE. In
- order to change this default
-
- Use G_set_fp_type() where type is one of DCELL_TYPE or FCELL_TYPE.
-
- See warnings and notes for G_open_cell_new().
-
- \param name map name
-
- \return nonnegative file descriptor (int)
- \return -1 on error
-*/
-int G_open_fp_cell_new(const char *name)
-{
- return G__open_raster_new(name, OPEN_NEW_COMPRESSED, G__.fp_type);
-}
-
-/*!
- \brief Opens new fcell file in a database (uncompressed)
-
- See G_open_fp_cell_new() for details.
-
- \param name map name
-
- \return nonnegative file descriptor (int)
- \return -1 on error
-*/
-int G_open_fp_cell_new_uncompressed(const char *name)
-{
- return G__open_raster_new(name, OPEN_NEW_UNCOMPRESSED, G__.fp_type);
-}
-
-#ifdef HAVE_GDAL
-static int G__open_raster_new_gdal(char *map, char *mapset, RASTER_MAP_TYPE map_type)
-{
- int fd;
- struct fileinfo *fcb;
- int i;
-
- /* dummy descriptor to reserve the fileinfo slot */
- fd = open("/dev/null", O_RDONLY);
- if (fd < 0)
- return -1;
-
- fcb = new_fileinfo(fd);
-
- /* mark closed */
- fcb->map_type = map_type;
- fcb->open_mode = -1;
-
- fcb->gdal = G_create_gdal_link(map, map_type);
- if (!fcb->gdal)
- return -1;
-
- fcb->cellhd = G__.window;
- fcb->cellhd.compressed = 0;
- fcb->nbytes = G_raster_size(fcb->map_type);
- /* for writing fcb->data is allocated to be G__.window.cols *
- sizeof(CELL or DCELL or FCELL) */
- fcb->data = G_calloc(G__.window.cols, fcb->nbytes);
-
- fcb->name = map;
- fcb->mapset = mapset;
- fcb->cur_row = 0;
-
- fcb->row_ptr = NULL;
- fcb->temp_name = NULL;
- fcb->null_temp_name = NULL;
- fcb->null_cur_row = 0;
- fcb->min_null_row = 0;
- for (i = 0; i < NULL_ROWS_INMEM; i++)
- fcb->NULL_ROWS[i] = NULL;
-
- if (fcb->map_type != CELL_TYPE)
- G_quant_init(&(fcb->quant));
-
- /* init cell stats */
- /* now works only for int maps */
- if (fcb->map_type == CELL_TYPE)
- if ((fcb->want_histogram = G__.want_histogram))
- G_init_cell_stats(&fcb->statf);
-
- /* init range and if map is double/float init d/f_range */
- G_init_range(&fcb->range);
-
- if (fcb->map_type != CELL_TYPE)
- G_init_fp_range(&fcb->fp_range);
-
- /* mark file as open for write */
- fcb->open_mode = OPEN_NEW_UNCOMPRESSED;
- fcb->io_error = 0;
-
- return fd;
-}
-#endif /* HAVE_GDAL */
-
-static int G__open_raster_new(const char *name, int open_mode,
- RASTER_MAP_TYPE map_type)
-{
- char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
- struct fileinfo *fcb;
- int i, null_fd, fd;
- char *tempname;
- char *map;
- char *mapset;
- const char *cell_dir;
- int nbytes;
-
- switch (map_type) {
- case CELL_TYPE:
- cell_dir = "cell";
- nbytes = G__.nbytes;
- break;
- case FCELL_TYPE:
- nbytes = XDR_FLOAT_NBYTES;
- cell_dir = "fcell";
- break;
- case DCELL_TYPE:
- nbytes = XDR_DOUBLE_NBYTES;
- cell_dir = "fcell";
- break;
- default:
- G_fatal_error(_("Invalid map type <%d>"), map_type);
- break;
- }
-
- if (G__unqualified_name(name, G_mapset(), xname, xmapset) < 0)
- G_fatal_error(_("Raster map <%s> is not in the current mapset (%s)"),
- name, G_mapset());
- map = G_store(xname);
- mapset = G_store(xmapset);
-
- /* check for legal grass name */
- if (G_legal_filename(map) < 0) {
- G_warning(_("<%s> is an illegal file name"), map);
- return -1;
- }
-
- /* make sure window is set */
- G__init_window();
-
-#ifdef HAVE_GDAL
- if (G_find_file2("", "GDAL", G_mapset()))
- return G__open_raster_new_gdal(map, mapset, map_type);
-#endif
-
- /* open a tempfile name */
- tempname = G_tempfile();
- fd = creat(tempname, 0666);
- if (fd < 0) {
- G_warning(_("G__open_raster_new(): no temp files available"));
- G_free(mapset);
- G_free(tempname);
- G_free(map);
- return -1;
- }
-
- fcb = new_fileinfo(fd);
- /*
- * since we are bypassing the normal open logic
- * must create the cell element
- */
- G__make_mapset_element(cell_dir);
-
- /* mark closed */
- fcb->map_type = map_type;
- fcb->open_mode = -1;
- fcb->gdal = NULL;
-
- /* for writing fcb->data is allocated to be G__.window.cols *
- sizeof(CELL or DCELL or FCELL) */
- fcb->data = (unsigned char *)G_calloc(G__.window.cols,
- G_raster_size(fcb->map_type));
-
- /*
- * copy current window into cell header
- * set format to cell/supercell
- * for compressed writing
- * allocate space to hold the row address array
- */
- G_copy((char *)&fcb->cellhd, (char *)&G__.window, sizeof(fcb->cellhd));
-
- if (open_mode == OPEN_NEW_COMPRESSED && fcb->map_type == CELL_TYPE) {
- fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
- G_zero(fcb->row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));
- G__write_row_ptrs(fd);
- fcb->cellhd.compressed = G__.compression_type;
-
- fcb->nbytes = 1; /* to the minimum */
- }
- else {
- fcb->nbytes = nbytes;
- if (open_mode == OPEN_NEW_COMPRESSED) {
- fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
- G_zero(fcb->row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));
- G__write_row_ptrs(fd);
- fcb->cellhd.compressed = G__.compression_type;
- }
- else
- fcb->cellhd.compressed = 0;
-
- if (fcb->map_type != CELL_TYPE) {
- G_quant_init(&(fcb->quant));
- }
- }
-
- /* save name and mapset, and tempfile name */
- fcb->name = map;
- fcb->mapset = mapset;
- fcb->temp_name = tempname;
-
- /* next row to be written (in order) is zero */
- fcb->cur_row = 0;
-
- /* open a null tempfile name */
- tempname = G_tempfile();
- null_fd = creat(tempname, 0666);
- if (null_fd < 0) {
- G_warning(_("G__open_raster_new(): no temp files available"));
- G_free(tempname);
- G_free(fcb->name);
- G_free(fcb->mapset);
- G_free(fcb->temp_name);
- close(fd);
- return -1;
- }
-
- fcb->null_temp_name = tempname;
- close(null_fd);
-
- /* next row to be written (in order) is zero */
- fcb->null_cur_row = 0;
-
- /* allocate null bitstream buffers for writing */
- for (i = 0; i < NULL_ROWS_INMEM; i++)
- fcb->NULL_ROWS[i] = G__allocate_null_bits(fcb->cellhd.cols);
- fcb->min_null_row = (-1) * NULL_ROWS_INMEM;
-
- /* init cell stats */
- /* now works only for int maps */
- if (fcb->map_type == CELL_TYPE)
- if ((fcb->want_histogram = G__.want_histogram))
- G_init_cell_stats(&fcb->statf);
-
- /* init range and if map is double/float init d/f_range */
- G_init_range(&fcb->range);
-
- if (fcb->map_type != CELL_TYPE)
- G_init_fp_range(&fcb->fp_range);
-
- /* mark file as open for write */
- fcb->open_mode = open_mode;
- fcb->io_error = 0;
-
- return fd;
-}
-
-/*!
- \brief Set raster map floating-point data format.
-
- This controls the storage type for floating-point maps. It affects
- subsequent calls to G_open_fp_map_new(). The <i>type</i> must be
- one of FCELL_TYPE (float) or DCELL_TYPE (double). The use of this
- routine by applications is discouraged since its use would override
- user preferences.
-
- \param type raster data type
-
- \return 1 on success
- \return -1 on error
-*/
-int G_set_fp_type(RASTER_MAP_TYPE map_type)
-{
- switch (map_type) {
- case FCELL_TYPE:
- case DCELL_TYPE:
- G__.fp_type = map_type;
- return 1;
- default:
- G_warning(_("G_set_fp_type(): can only be called with FCELL_TYPE or DCELL_TYPE"));
- return -1;
- }
-}
-
-/*!
- \brief Check if raster map is floating-point
-
- Returns true (1) if raster map <i>name</i> in <i>mapset</i>
- is a floating-point dataset; false(0) otherwise.
-
- \param name map name
- \param mapset mapset name
-
- \return 1 floating-point
- \return 0 int
-*/
-int G_raster_map_is_fp(const char *name, const char *mapset)
-{
- char path[GPATH_MAX];
- const char *xmapset;
-
- xmapset = G_find_cell2(name, mapset);
- if (!xmapset) {
- G_warning(_("Unable to find <%s@%s>"), name, mapset);
- return -1;
- }
- G__file_name(path, "fcell", name, xmapset);
- if (access(path, 0) == 0)
- return 1;
- G__file_name(path, "g3dcell", name, xmapset);
- if (access(path, 0) == 0)
- return 1;
-
- return 0;
-}
-
-/*!
- \brief Determine raster data type
-
- Determines if the raster map is floating point or integer. Returns
- DCELL_TYPE for double maps, FCELL_TYPE for float maps, CELL_TYPE for
- integer maps, -1 if error has occured
-
- \param name map name
- \param mapset mapset where map <i>name</i> lives
-
- \return raster data type
-*/
-RASTER_MAP_TYPE G_raster_map_type(const char *name, const char *mapset)
-{
- char path[GPATH_MAX];
- const char *xmapset;
-
- xmapset = G_find_cell2(name, mapset);
- if (!xmapset) {
- if (mapset && *mapset)
- G_warning(_("Raster map <%s> not found in mapset <%s>"), name, mapset);
- else
- G_warning(_("Raster map <%s> not found"), name);
- return -1;
- }
- G__file_name(path, "fcell", name, xmapset);
-
- if (access(path, 0) == 0)
- return G__check_fp_type(name, xmapset);
-
- G__file_name(path, "g3dcell", name, xmapset);
-
- if (access(path, 0) == 0)
- return DCELL_TYPE;
-
- return CELL_TYPE;
-}
-
-/*!
- \brief Determine raster type from descriptor
-
- Determines if the raster map is floating point or integer. Returns
- DCELL_TYPE for double maps, FCELL_TYPE for float maps, CELL_TYPE for
- integer maps, -1 if error has occured
-
- \param fd file descriptor
-
- \return raster data type
- */
-RASTER_MAP_TYPE G_get_raster_map_type(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- return fcb->map_type;
-}
-
-/*!
- \brief Determines whether the floating points cell file has double or float type
-
- \param name map name
- \param mapset mapset where map <i>name</i> lives
-
- \return raster type (fcell, dcell)
-*/
-RASTER_MAP_TYPE G__check_fp_type(const char *name, const char *mapset)
-{
- char path[GPATH_MAX];
- struct Key_Value *format_keys;
- int in_stat;
- const char *str, *str1;
- RASTER_MAP_TYPE map_type;
- const char *xmapset;
-
- xmapset = G_find_cell2(name, mapset);
- if (!xmapset) {
- G_warning(_("Unable to find <%s@%s>"), name, mapset);
- return -1;
- }
- G__file_name_misc(path, "cell_misc", FORMAT_FILE, name, xmapset);
-
- if (access(path, 0) != 0) {
- G_warning(_("Unable to find '%s'"), path);
- return -1;
- }
- format_keys = G_read_key_value_file(path, &in_stat);
- if (in_stat != 0) {
- G_warning(_("Unable to open '%s'"), path);
- return -1;
- }
- if ((str = G_find_key_value("type", format_keys)) != NULL) {
- if (strcmp(str, "double") == 0)
- map_type = DCELL_TYPE;
- else if (strcmp(str, "float") == 0)
- map_type = FCELL_TYPE;
- else {
- G_warning(_("Invalid type: field '%s' in file '%s'"),
- str, path);
- G_free_key_value(format_keys);
- return -1;
- }
- }
- else {
- G_free_key_value(format_keys);
- return -1;
- }
-
- if ((str1 = G_find_key_value("byte_order", format_keys)) != NULL) {
- if (strcmp(str1, "xdr") != 0)
- G_warning(_("Raster map <%s> is not xdr: byte_order: %s"),
- name, str);
- /* here read and translate byte order if not using xdr */
- }
- G_free_key_value(format_keys);
- return map_type;
-}
-
-/*!
- \brief Opens a new raster map
-
- Opens a new raster map of type <i>wr_type</i>
-
- See warnings and notes for G_open_cell_new().
-
- Supported data types:
- - CELL_TYPE
- - FCELL_TYPE
- - DCELL_TYPE
-
- On CELL_TYPE calls G_open_cell_new() otherwise G_open_fp_cell_new().
-
- \param name map name
- \param wr_type raster data type
-
- \return nonnegative file descriptor (int)
- \return -1 on error
-*/
-int G_open_raster_new(const char *name, RASTER_MAP_TYPE wr_type)
-{
- return G__open_raster_new(name, OPEN_NEW_COMPRESSED, wr_type);
-}
-
-/*!
- \brief Opens a new raster map (uncompressed)
-
- See G_open_raster_new().
-
- \param name map name
- \param wr_type raster data type
-
- \return nonnegative file descriptor (int)
- \return -1 on error
-*/
-int G_open_raster_new_uncompressed(const char *name, RASTER_MAP_TYPE wr_type)
-{
- return G__open_raster_new(name, OPEN_NEW_UNCOMPRESSED, wr_type);
-}
-
-/*!
- \brief Sets quant translation rules for raster map opened for
- reading.
-
- Returned by G_open_cell_old(). After calling this function,
- G_get_c_raster_row() and G_get_map_row() will use rules defined by q
- (instead of using rules defined in map's quant file) to convert floats to
- ints.
-
- \param fd file descriptor (cell file)
- \param q pointer to Quant structure
-
- \return 0 success
- \return -1 failure
-*/
-int G_set_quant_rules(int fd, struct Quant *q)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- CELL cell;
- DCELL dcell;
- struct Quant_table *p;
-
- if (fcb->open_mode != OPEN_OLD) {
- G_warning(_("G_set_quant_rules() can be called only for "
- "raster maps opened for reading"));
- return -1;
- }
- /* copy all info from q to fcb->quant) */
- G_quant_init(&fcb->quant);
- if (q->truncate_only) {
- G_quant_truncate(&fcb->quant);
- return 0;
- }
- for (p = &(q->table[q->nofRules - 1]); p >= q->table; p--)
- G_quant_add_rule(&fcb->quant, p->dLow, p->dHigh, p->cLow, p->cHigh);
- if (G_quant_get_neg_infinite_rule(q, &dcell, &cell) > 0)
- G_quant_set_neg_infinite_rule(&fcb->quant, dcell, cell);
- if (G_quant_get_pos_infinite_rule(q, &dcell, &cell) > 0)
- G_quant_set_pos_infinite_rule(&fcb->quant, dcell, cell);
-
- return 0;
-}
Deleted: grass/trunk/lib/gis/put_cellhd.c
===================================================================
--- grass/trunk/lib/gis/put_cellhd.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/put_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,42 +0,0 @@
-/*!
- * \file gis/put_cellhd.c
- *
- * \brief GIS Library - Write raster header.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-/*!
- \brief Writes the raster file header.
-
- Writes the cell file header information associated with map layer "map"
- into current mapset from the structure "cellhd".
-
- \param name name of map
- \param cellhd structure holding cell header info
-
- \return 0 on success
- \return -1 on failure
-*/
-int G_put_cellhd(const char *name, struct Cell_head *cellhd)
-{
- FILE *fd;
-
- if (!(fd = G_fopen_new("cellhd", name))) {
- G_warning(_("Unable to create header file for <%s>"), name);
- return -1;
- }
-
- G__write_Cell_head(fd, cellhd, 1);
- fclose(fd);
-
- return 0;
-}
Deleted: grass/trunk/lib/gis/put_row.c
===================================================================
--- grass/trunk/lib/gis/put_row.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/put_row.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,877 +0,0 @@
-
-/**********************************************************************
- *
- * G_put_[c/f/d]_raster_row(fd, buf)
- * int fd file descriptor of the opened map
- * [F/D]CELL *buf buffer holding row info to be written
- *
- * Writes the next row for the cell file opened on 'fd' from 'buf'
- * All writes go into NEW files that exactly match the current window.
- * The file must have been opened with G_open_cell_new()
- * and be written sequentially, ie no skipping rows
- *
- * when the null values are embeded into the data, corresponding cells are
- * changed to 0's and the corresponding null value row is written into null
- * file.
- *
- * *** NOTE ***
- * A map cannot be copied using G_get_raster_row() and G_put_raster_row().
- * The former resamples the data of the original map into a row buffer
- * that matches the current window. The later writes out rows associated
- * with the window.
- *
- * returns: 1 if successful
- * -1 on fail
- *
- * Keeps track of the minimum and maximum cell value for use in updating
- * the range file upon close of the cell file.
- * HOWEVER when nulls are not embeded, the cells are considered 0's as far
- * as updating range is concerned, even if the corresponding cell is null
- * in the resulting null file, so programmer should be carefult to set all
- * the null values using G_set_null_value() or G_insert_[d/f_]null_values()
- *
- **********************************************************************
- *
- * G_put_map_row(fd, buf)
- * int fd file descriptor of the opened map
- * CELL *buf buffer holding row info to be written
- *
- * Writes the next row for the cell file opened on 'fd' from 'buf'
- * All writes go into NEW files that exactly match the current window.
- * The file must have been opened with G_open_cell_new()
- * and be written sequentially, ie no skipping rows
- *
- * NULLS are written into null bitmap file for all cells which are zero,
- * and cells which have null value (these cells are converted to 0's before
- * writing)
- *
- * *** NOTE ***
- * A map cannot be copied using G_get_map_row() and G_put_map_row().
- * The former resamples the data of the original map into a row buffer
- * that matches the current window. The later writes out rows associated
- * with the window.
- *
- * returns: 1 if successful
- * -1 on fail
- *
- * Keeps track of the minimum and maximum cell value for use in updating
- * the range file upon close of the cell file.
- *
- ***********************************************************************
- *
- * put_null_value_row(fd, buf)
- * int fd File descriptor where data is to be written
- * char *buf Buffer holding null data
- *
- * converts a buffer of zero's and ones to bitstream and stores this
- * bitstream in memory. (the null rows from memory are written into null
- * file after the limit is reached, and the place for new null rows
- * to be kept in memory is freed. Should not be used by application
- * programs.
- *
- * returns: 0 if successful
- * -1 on fail
- **********************************************************************/
-
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <grass/config.h>
-
-#include "G.h"
-#include <grass/glocale.h>
-
-static int put_raster_data(int, char *, const void *, int, int, int,
- RASTER_MAP_TYPE);
-static int put_data(int, char *, const CELL *, int, int, int);
-static int check_open(const char *, int);
-static void write_error(int, int);
-static int same(const unsigned char *, const unsigned char *, int);
-static void set_file_pointer(int, int);
-static int put_fp_data(int, char *, const void *, int, int, RASTER_MAP_TYPE);
-static int put_null_data(int, const char *, int);
-static int convert_and_write_if(int, const CELL *);
-static int convert_and_write_id(int, const CELL *);
-static int convert_and_write_df(int, const DCELL *);
-static int convert_and_write_fd(int, const FCELL *);
-static int put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type,
- int zeros_r_nulls);
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static int put_null_value_row(int fd, const char *buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- if (fcb->gdal)
- G_fatal_error(_("GDAL output doesn't support writing null rows separately"));
-
- switch (put_null_data(fd, buf, fcb->null_cur_row)) {
- case -1:
- return -1;
- case 0:
- return 1;
- }
-
- fcb->null_cur_row++;
-
- return 1;
-}
-
-int G_put_map_row(int fd, const CELL * buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- if (fcb->map_type != CELL_TYPE) {
- G_fatal_error(_("G_put_map_row: %s is not integer! Use G_put_[f/d]_raster_row()!"),
- fcb->name);
- return -1;
- }
-
- return put_raster_row(fd, buf, CELL_TYPE, 1);
-}
-
-int G_put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type)
-{
- return put_raster_row(fd, buf, data_type, 0);
-}
-
-int G_put_c_raster_row(int fd, const CELL * buf)
-{
- return G_put_raster_row(fd, buf, CELL_TYPE);
-}
-
-int G_put_f_raster_row(int fd, const FCELL * buf)
-{
- return G_put_raster_row(fd, buf, FCELL_TYPE);
-}
-
-int G_put_d_raster_row(int fd, const DCELL * buf)
-{
- return G_put_raster_row(fd, buf, DCELL_TYPE);
-}
-
-/*--------------------------------------------------------------------------*/
-
-static int check_open(const char *me, int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- switch (fcb->open_mode) {
- case OPEN_OLD:
- G_warning(_("%s: map [%s] not open for write - request ignored"), me,
- fcb->name);
- break;
- case OPEN_NEW_COMPRESSED:
- case OPEN_NEW_UNCOMPRESSED:
- return 1;
- break;
- default:
- G_warning(_("%s: unopened file descriptor - request ignored"), me);
- break;
- }
-
- return 0;
-}
-
-static void write_error(int fd, int row)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- if (fcb->io_error)
- return;
-
- G_warning(_("map [%s] - unable to write row %d"), fcb->name, row);
-
- fcb->io_error = 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-static int write_data(int fd, int row, unsigned char *buf, int n)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- ssize_t nwrite = fcb->nbytes * n;
-
- if (write(fd, buf, nwrite) != nwrite) {
- write_error(fd, row);
- return -1;
- }
-
- return 0;
-}
-
-static int write_data_compressed(int fd, int row, unsigned char *buf, int n)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int nwrite = fcb->nbytes * n;
-
- if (G_zlib_write(fd, buf, nwrite) < 0) {
- write_error(fd, row);
- return -1;
- }
-
- return 0;
-}
-
-/*--------------------------------------------------------------------------*/
-
-static void set_file_pointer(int fd, int row)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- fcb->row_ptr[row] = lseek(fd, 0L, SEEK_CUR);
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static int convert_float(XDR * xdrs, char *null_buf, const FCELL * rast,
- int row, int n)
-{
- int i;
-
- for (i = 0; i < n; i++) {
- FCELL f;
-
- /* substitute embeded null vals by 0's */
- if (G_is_f_null_value(&rast[i])) {
- f = 0.;
- null_buf[i] = 1;
- }
- else
- f = rast[i];
-
- if (!xdr_float(xdrs, &f)) {
- G_warning(_("xdr_float failed for index %d of row %d"), i, row);
- return -1;
- }
- }
-
- return 0;
-}
-
-static int convert_double(XDR * xdrs, char *null_buf, const DCELL * rast,
- int row, int n)
-{
- int i;
-
- for (i = 0; i < n; i++) {
- DCELL d;
-
- /* substitute embeded null vals by 0's */
- if (G_is_d_null_value(&rast[i])) {
- d = 0.;
- null_buf[i] = 1;
- }
- else
- d = rast[i];
-
- if (!xdr_double(xdrs, &d)) {
- G_warning(_("xdr_double failed for index %d of row %d"), i, row);
- return -1;
- }
- }
-
- return 0;
-}
-
-/*--------------------------------------------------------------------------*/
-
-/* writes data to fcell file for either full or partial rows */
-
-static int put_fp_data(int fd, char *null_buf, const void *rast,
- int row, int n, RASTER_MAP_TYPE data_type)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int compressed = (fcb->open_mode == OPEN_NEW_COMPRESSED);
- XDR *xdrs = &fcb->xdrstream;
- char *work_buf;
-
- if (row < 0 || row >= fcb->cellhd.rows)
- return 0;
-
- if (n <= 0)
- return 0;
-
- work_buf = G__alloca(G__.window.cols * fcb->nbytes + 1);
-
- if (compressed)
- set_file_pointer(fd, row);
-
- xdrmem_create(xdrs, work_buf,
- (unsigned int) fcb->nbytes * fcb->cellhd.cols, XDR_ENCODE);
- xdr_setpos(xdrs, 0);
-
- if (data_type == FCELL_TYPE) {
- if (convert_float(xdrs, null_buf, rast, row, n) < 0) {
- G__freea(work_buf);
- return -1;
- }
- }
- else {
- if (convert_double(xdrs, null_buf, rast, row, n) < 0) {
- G__freea(work_buf);
- return -1;
- }
- }
-
- xdr_destroy(&fcb->xdrstream);
-
- if (compressed) {
- if (write_data_compressed(fd, row, work_buf, n) == -1) {
- G__freea(work_buf);
- return -1;
- }
- }
- else if (write_data(fd, row, work_buf, n) == -1) {
- G__freea(work_buf);
- return -1;
- }
-
- G__freea(work_buf);
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static void convert_int(unsigned char *wk, char *null_buf, const CELL * rast,
- int n, int len, int zeros_r_nulls)
-{
- int i;
-
- /* transform CELL data into non-machine dependent multi-byte format */
-
- for (i = 0; i < n; i++) {
- CELL v = rast[i];
- int neg;
- int k;
-
- /* substitute embeded null vals by 0's */
- if (G_is_c_null_value(&v)) {
- v = 0;
- null_buf[i] = 1;
- }
- else if (zeros_r_nulls && !v)
- null_buf[i] = 1;
-
- /* negatives */
- if (v < 0) {
- neg = 1;
- v = -v;
- }
- else
- neg = 0;
-
- /* copy byte by byte */
- for (k = len - 1; k >= 0; k--) {
- wk[k] = v & 0xff;
- v >>= 8;
- }
-
- /* set negative bit in first byte */
- if (neg)
- wk[0] |= 0x80;
-
- wk += len;
- }
-}
-
-static int count_bytes(const unsigned char *wk, int n, int len)
-{
- int i, j;
-
- for (i = 0; i < len - 1; i++)
- for (j = 0; j < n; j++)
- if (wk[j * len + i] != 0)
- return len - i;
-
- return 1;
-}
-
-static void trim_bytes(unsigned char *wk, int n, int slen, int trim)
-{
- unsigned char *wk2 = wk;
- int i, j;
-
- for (i = 0; i < n; i++) {
- for (j = 0; j < trim; j++)
- wk++;
- for (; j < slen; j++)
- *wk2++ = *wk++;
- }
-}
-
-static int same(const unsigned char *x, const unsigned char *y, int n)
-{
- return (memcmp(x, y, n) == 0);
-}
-
-static int count_run(const unsigned char *src, int n, int nbytes)
-{
- const unsigned char *cur = src + nbytes;
- int i;
-
- for (i = 1; i < n; i++) {
- if (i == 255 || !same(cur, src, nbytes))
- return i;
-
- cur += nbytes;
- }
-
- return n;
-}
-
-static int rle_compress(unsigned char *dst, unsigned char *src, int n,
- int nbytes)
-{
- int nwrite = 0;
- int total = nbytes * n;
-
- while (n > 0) {
- int count;
-
- nwrite += nbytes + 1;
- if (nwrite >= total)
- return 0;
-
- count = count_run(src, n, nbytes);
-
- *dst++ = count;
- memcpy(dst, src, nbytes);
- dst += nbytes;
-
- src += count * nbytes;
- n -= count;
- }
-
- return nwrite;
-}
-
-static int zlib_compress(unsigned char *dst, unsigned char *src, int n,
- int nbytes)
-{
- int total = nbytes * n;
- int nwrite = G_zlib_compress(src, total, dst, total);
-
- return (nwrite >= total) ? 0 : nwrite;
-}
-
-/*--------------------------------------------------------------------------*/
-
-static int put_data(int fd, char *null_buf, const CELL *cell,
- int row, int n, int zeros_r_nulls)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int compressed = fcb->cellhd.compressed;
- int len = compressed ? sizeof(CELL) : fcb->nbytes;
- unsigned char *work_buf, *wk;
- ssize_t nwrite;
-
- if (row < 0 || row >= fcb->cellhd.rows)
- return 0;
-
- if (n <= 0)
- return 0;
-
- work_buf = G__alloca(G__.window.cols * sizeof(CELL) + 1);
- wk = work_buf;
-
- if (compressed)
- set_file_pointer(fd, row);
-
- if (compressed)
- wk++;
-
- convert_int(wk, null_buf, cell, n, len, zeros_r_nulls);
-
- if (compressed) {
- unsigned char *wk = work_buf + 1;
- int nbytes = count_bytes(wk, n, len);
- unsigned char *compressed_buf;
- int total;
-
- if (fcb->nbytes < nbytes)
- fcb->nbytes = nbytes;
-
- /* first trim away zero high bytes */
- if (nbytes < len)
- trim_bytes(wk, n, len, len - nbytes);
-
- total = nbytes * n;
- compressed_buf = G__alloca(total + 1);
-
- compressed_buf[0] = work_buf[0] = nbytes;
-
- /* then compress the data */
- nwrite = compressed == 1
- ? rle_compress(compressed_buf + 1, work_buf + 1, n,
- nbytes)
- : zlib_compress(compressed_buf + 1, work_buf + 1, n,
- nbytes);
-
- if (nwrite > 0) {
- nwrite++;
-
- if (write(fd, compressed_buf, nwrite) != nwrite) {
- write_error(fd, row);
- G__freea(compressed_buf);
- G__freea(work_buf);
- return -1;
- }
- }
- else {
- nwrite = nbytes * n + 1;
- if (write(fd, work_buf, nwrite) != nwrite) {
- write_error(fd, row);
- G__freea(compressed_buf);
- G__freea(work_buf);
- return -1;
- }
- }
-
- G__freea(compressed_buf);
- }
- else {
- nwrite = fcb->nbytes * n;
-
- if (write(fd, work_buf, nwrite) != nwrite) {
- write_error(fd, row);
- G__freea(work_buf);
- return -1;
- }
- }
-
- G__freea(work_buf);
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-static int put_data_gdal(int fd, const void *rast, int row, int n,
- int zeros_r_nulls, RASTER_MAP_TYPE map_type)
-{
-#ifdef HAVE_GDAL
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int size = G_raster_size(map_type);
- DCELL null_val = fcb->gdal->null_val;
- const void *src;
- void *work_buf, *dst;
- GDALDataType datatype;
- CPLErr err;
- int i;
-
- if (row < 0 || row >= fcb->cellhd.rows)
- return 0;
-
- if (n <= 0)
- return 0;
-
- work_buf = G__alloca(n * size);
-
- switch (map_type) {
- case CELL_TYPE: datatype = GDT_Int32; break;
- case FCELL_TYPE: datatype = GDT_Float32; break;
- case DCELL_TYPE: datatype = GDT_Float64; break;
- }
-
- src = rast;
- dst = work_buf;
-
- for (i = 0; i < n; i++) {
- if (G_is_null_value(src, map_type) || zeros_r_nulls && !*(CELL *)src)
- G_set_raster_value_d(dst, null_val, map_type);
- else
- memcpy(dst, src, size);
- src = G_incr_void_ptr(src, size);
- dst = G_incr_void_ptr(dst, size);
- }
-
- err = G_gdal_raster_IO(fcb->gdal->band, GF_Write, 0, row, n, 1, work_buf,
- n, 1, datatype, 0, 0);
-
- G__freea(work_buf);
-
- return err == CE_None ? 1 : -1;
-#else
- return -1;
-#endif
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static int put_raster_data(int fd, char *null_buf, const void *rast,
- int row, int n,
- int zeros_r_nulls, RASTER_MAP_TYPE map_type)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
-
- if (fcb->gdal)
- return put_data_gdal(fd, rast, row, n, zeros_r_nulls, map_type);
-
- return (map_type == CELL_TYPE)
- ? put_data(fd, null_buf, rast, row, n, zeros_r_nulls)
- : put_fp_data(fd, null_buf, rast, row, n, map_type);
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static int put_null_data(int fd, const char *flags, int row)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int null_fd, i;
-
- if (fcb->min_null_row + NULL_ROWS_INMEM <= row) {
- /* the row is out of the range of rows stored in memory */
- /* write out all the rows kept in memory, and initialize memory
- for keeping new NULL_ROWS_INMEM rows */
-
- if (fcb->min_null_row >= 0) {
- null_fd = G__open_null_write(fd);
- if (null_fd < 0)
- return -1;
-
- for (i = 0; i < NULL_ROWS_INMEM; i++) {
- /* fcb->cellhd.rows doesn't have to be a miultiple of NULL_ROWS_INMEM */
- if (i + fcb->min_null_row >= fcb->cellhd.rows)
- break;
-
- if (G__write_null_bits(null_fd, fcb->NULL_ROWS[i],
- i + fcb->min_null_row,
- fcb->cellhd.cols, fd) < 0)
- return -1;
-
- } /* done writing out memory rows */
- if (null_fd >= 0)
- close(null_fd);
- }
-
- /* now initialize memory to store new NULL_ROWS_INMEM rows */
- fcb->min_null_row = fcb->min_null_row + NULL_ROWS_INMEM;
- /* init memory to store next NULL_ROWS_INMEM rows */
- }
-
- /* remember the null row for i for the future writing */
- G__convert_01_flags(flags, fcb->NULL_ROWS[row - fcb->min_null_row],
- fcb->cellhd.cols);
-
- return 1;
-}
-
-int G__open_null_write(int fd)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- int null_fd;
-
- if (access(fcb->null_temp_name, 0) != 0) {
- G_warning(_("unable to find a temporary null file %s"),
- fcb->null_temp_name);
- return -1;
- }
-
- null_fd = open(fcb->null_temp_name, O_WRONLY);
- if (null_fd < 0)
- return -1;
-
- return null_fd;
-}
-
-int G__write_null_bits(int null_fd, const unsigned char *flags, int row,
- int cols, int fd)
-{
- off_t offset;
- size_t size;
-
- size = G__null_bitstream_size(cols);
- offset = (off_t) size *row;
-
- if (lseek(null_fd, offset, SEEK_SET) < 0) {
- G_warning(_("error writing null row %d"), row);
- return -1;
- }
-
- if (write(null_fd, flags, size) != size) {
- G_warning(_("error writing null row %d"), row);
- return -1;
- }
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static int convert_and_write_if(int fd, const CELL * buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- FCELL *p = (FCELL *) fcb->data;
- int i;
-
- for (i = 0; i < fcb->cellhd.cols; i++)
- if (G_is_c_null_value(&buf[i]))
- G_set_f_null_value(&p[i], 1);
- else
- p[i] = (FCELL) buf[i];
-
- return G_put_f_raster_row(fd, p);
-}
-
-static int convert_and_write_df(int fd, const DCELL * buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- FCELL *p = (FCELL *) fcb->data;
- int i;
-
- for (i = 0; i < fcb->cellhd.cols; i++)
- if (G_is_d_null_value(&buf[i]))
- G_set_f_null_value(&p[i], 1);
- else
- p[i] = (FCELL) buf[i];
-
- return G_put_f_raster_row(fd, p);
-}
-
-static int convert_and_write_id(int fd, const CELL * buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- DCELL *p = (DCELL *) fcb->data;
- int i;
-
- for (i = 0; i < fcb->cellhd.cols; i++)
- if (G_is_c_null_value(&buf[i]))
- G_set_d_null_value(&p[i], 1);
- else
- p[i] = (DCELL) buf[i];
-
- return G_put_d_raster_row(fd, p);
-}
-
-static int convert_and_write_fd(int fd, const FCELL * buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- DCELL *p = (DCELL *) fcb->data;
- int i;
-
- for (i = 0; i < fcb->cellhd.cols; i++)
- if (G_is_f_null_value(&buf[i]))
- G_set_d_null_value(&p[i], 1);
- else
- p[i] = (DCELL) buf[i];
-
- return G_put_d_raster_row(fd, p);
-}
-
-static int convert_and_write_fi(int fd, const FCELL * buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- CELL *p = (CELL *) fcb->data;
- int i;
-
- for (i = 0; i < fcb->cellhd.cols; i++)
- if (G_is_f_null_value(&buf[i]))
- G_set_c_null_value(&p[i], 1);
- else
- p[i] = (CELL) buf[i];
-
- return G_put_c_raster_row(fd, p);
-}
-
-static int convert_and_write_di(int fd, const DCELL * buf)
-{
- struct fileinfo *fcb = &G__.fileinfo[fd];
- CELL *p = (CELL *) fcb->data;
- int i;
-
- for (i = 0; i < fcb->cellhd.cols; i++)
- if (G_is_d_null_value(&buf[i]))
- G_set_c_null_value(&p[i], 1);
- else
- p[i] = (CELL) buf[i];
-
- return G_put_c_raster_row(fd, p);
-}
-
-/*--------------------------------------------------------------------------*/
-
-static int put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type,
- int zeros_r_nulls)
-{
- static int (*convert_and_write_FtypeOtype[3][3])() = {
- {NULL, convert_and_write_if, convert_and_write_id},
- {convert_and_write_fi, NULL, convert_and_write_fd},
- {convert_and_write_di, convert_and_write_df, NULL}
- };
- struct fileinfo *fcb = &G__.fileinfo[fd];
- char *null_buf;
- int stat;
-
- if (!check_open("put_raster_row", fd))
- return -1;
-
- if (fcb->map_type != data_type)
- return convert_and_write_FtypeOtype[data_type][fcb->map_type] (fd,
- buf);
-
- null_buf = G__alloca(fcb->cellhd.cols);
- G_zero(null_buf, fcb->cellhd.cols);
-
- switch (put_raster_data(
- fd, null_buf, buf, fcb->cur_row, fcb->cellhd.cols,
- zeros_r_nulls, data_type)) {
- case -1:
- G__freea(null_buf);
- return -1;
- case 0:
- G__freea(null_buf);
- return 1;
- }
-
- /* only for integer maps */
- if (data_type == CELL_TYPE) {
- if (fcb->want_histogram)
- G_update_cell_stats(buf, fcb->cellhd.cols, &fcb->statf);
- G__row_update_range(buf, fcb->cellhd.cols, &fcb->range,
- zeros_r_nulls);
- }
- else
- G_row_update_fp_range(buf, fcb->cellhd.cols, &fcb->fp_range,
- data_type);
-
- fcb->cur_row++;
-
- /* write the null row for the data row */
- if (fcb->gdal)
- stat = 0;
- else
- stat = put_null_value_row(fd, null_buf);
- G__freea(null_buf);
- return stat;
-}
Deleted: grass/trunk/lib/gis/put_title.c
===================================================================
--- grass/trunk/lib/gis/put_title.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/put_title.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,81 +0,0 @@
-
-/**************************************************************
- * G_put_cell_title (name, title)
- * char *name name of map file
- * char *title new title
- *
- * changes the title for the cell file 'name' in current mapset
- *
- * returns 1 if ok, -1 if error
- *************************************************************/
-
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-int G_put_cell_title(const char *name, const char *title)
-{
- const char *mapset;
- FILE *in, *out;
- char *tempfile;
- int line;
- char buf[1024];
-
- mapset = G_mapset();
- in = out = 0;
- in = G_fopen_old("cats", name, mapset);
- if (!in) {
- G_warning (_("category information for [%s] in [%s]"
- " missing or invalid"),
- name, mapset);
- return -1;
- }
-
- tempfile = G_tempfile();
- out = fopen(tempfile, "w");
- if (!out) {
- fclose(in);
- G_warning (_("G_put_title - can't create a temp file"));
- return -1;
- }
-
- for (line = 0; G_getl(buf, sizeof buf, in); line++) {
- if (line == 1) {
- strcpy(buf, title);
- G_strip(buf);
- }
- fprintf(out, "%s\n", buf);
- }
- fclose(in);
- fclose(out);
-
- /* must be #cats line, title line, and label for cat 0 */
- if (line < 3) {
- G_warning (_("category information for [%s] in [%s] invalid"),
- name, mapset);
- return -1;
- }
-
- in = fopen(tempfile, "r");
- if (!in) {
- G_warning (_("G_put_title - can't reopen temp file"));
- return -1;
- }
-
- out = G_fopen_new("cats", name);
- if (!out) {
- fclose(in);
- G_warning (_("can't write category information for [%s] in [%s]"),
- name, mapset);
- return -1;
- }
-
- while (fgets(buf, sizeof buf, in))
- fprintf(out, "%s", buf);
-
- fclose(in);
- fclose(out);
- remove(tempfile);
-
- return 1;
-}
Deleted: grass/trunk/lib/gis/quant.c
===================================================================
--- grass/trunk/lib/gis/quant.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/quant.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,791 +0,0 @@
-/*!
- * \file gis/quant.c
- *
- * \brief GIS Library - Quantization rules.
- *
- * The quantization table is stored as a linear array. rules are added
- * starting from index 0. redundant rules are not eliminated. rules
- * are tested from the highest index downto 0. there are two
- * "infinite" rules. support is provided to reverse the order of the
- * rules.
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#include <stdlib.h>
-#include <grass/gis.h>
-
-static int double_comp(const void *, const void *);
-
-#define USE_LOOKUP 1
-#define MAX_LOOKUP_TABLE_SIZE 2048
-#define NO_DATA (G_set_c_null_value (&tmp, 1), (CELL) tmp)
-
-#undef MIN
-#undef MAX
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
-#define NO_LEFT_INFINITE_RULE (! q->infiniteLeftSet)
-#define NO_RIGHT_INFINITE_RULE (! q->infiniteRightSet)
-#define NO_FINITE_RULE (q->nofRules <= 0)
-#define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
- NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
-
-/*!
- \brief Resets the number of defined rules and number of infinite rules to 0
-
- \param q pointer to Quant structure to be reset
-*/
-void G_quant_clear(struct Quant *q)
-{
- q->nofRules = 0;
- q->infiniteRightSet = q->infiniteLeftSet = 0;
-}
-
-/*!
- \brief Resets and frees allocated memory
-
- Resets the number of defined rules to 0 and free's space allocated
- for rules. Calls G_quant_clear().
-
- \param q pointer to Quant structure to be reset
-*/
-void G_quant_free(struct Quant *q)
-{
- G_quant_clear(q);
-
- if (q->maxNofRules > 0)
- G_free(q->table);
- if (q->fp_lookup.active) {
- G_free(q->fp_lookup.vals);
- G_free(q->fp_lookup.rules);
- q->fp_lookup.nalloc = 0;
- q->fp_lookup.active = 0;
- }
- q->maxNofRules = 0;
-}
-
-/*!
- * \brief Organized fp_lookup table.
- *
- * Organizes fp_lookup table for faster (logarithmic) lookup time
- * G_quant_organize_fp_lookup() creates a list of min and max for
- * each quant rule, sorts this list, and stores the pointer to quant
- * rule that should be used inbetween any 2 numbers in this list.
- * Also it stores extreme points for 2 infinite rules, if exist.
- * After the call to G_quant_organize_fp_lookup()
- * instead of linearly searching through list of rules to find
- * a rule to apply, quant lookup will perform a binary search
- * to find an interval containing floating point value, and then use
- * the rule associated with this interval.
- * when the value doesn't fall within any interval, check for the
- * infinite rules.
- *
- * \param q pointer to Quant structure which holds quant rules info
- *
- * \return 1 on success
- */
-int G__quant_organize_fp_lookup(struct Quant *q)
-{
- int i;
- DCELL val;
- CELL tmp;
- struct Quant_table *p;
-
- if (q->nofRules * 2 > MAX_LOOKUP_TABLE_SIZE)
- return -1;
- if (q->nofRules == 0)
- return -1;
- q->fp_lookup.vals = (DCELL *)
- G_calloc(q->nofRules * 2, sizeof(DCELL));
- /* 2 endpoints for each rule */
- q->fp_lookup.rules = (struct Quant_table **)
- G_calloc(q->nofRules * 2, sizeof(struct Quant_table *));
-
- /* first we organize finite rules into a table */
- if (!NO_FINITE_RULE) {
- i = 0;
- /* get the list of DCELL values from set of all dLows and dHighs
- of all rules */
- /* NOTE: if dLow==DHigh in a rule, the value appears twice in a list
- but if dLow==DHigh of the previous, rule the value appears only once */
-
- for (p = &(q->table[q->nofRules - 1]); p >= q->table; p--) {
- /* check if the min is the same as previous maximum */
- if (i == 0 || p->dLow != q->fp_lookup.vals[i - 1])
- q->fp_lookup.vals[i++] = p->dLow;
- q->fp_lookup.vals[i++] = p->dHigh;
- }
- q->fp_lookup.nalloc = i;
-
- /* now sort the values */
- qsort((char *)q->fp_lookup.vals, q->fp_lookup.nalloc,
- sizeof(DCELL), double_comp);
-
- /* now find the rule to apply inbetween each 2 values in a list */
- for (i = 0; i < q->fp_lookup.nalloc - 1; i++) {
- /*debug
- fprintf (stderr, "%lf %lf ", q->fp_lookup.vals[i], q->fp_lookup.vals[i+1]);
- */
- val = (q->fp_lookup.vals[i] + q->fp_lookup.vals[i + 1]) / 2.;
- q->fp_lookup.rules[i] =
- G__quant_get_rule_for_d_raster_val(q, val);
- /* debug
- if(q->fp_lookup.rules[i])
- fprintf (stderr, "%lf %lf %d %d\n", q->fp_lookup.rules[i]->dLow, q->fp_lookup.rules[i]->dHigh, q->fp_lookup.rules[i]->cLow, q->fp_lookup.rules[i]->cHigh);
- else fprintf (stderr, "null\n");
- */
-
- }
- } /* organizing finite rules */
-
- if (!NO_LEFT_INFINITE_RULE) {
- q->fp_lookup.inf_dmin = q->infiniteDLeft;
- q->fp_lookup.inf_min = q->infiniteCLeft;
- }
- else {
- if (q->fp_lookup.nalloc)
- q->fp_lookup.inf_dmin = q->fp_lookup.vals[0];
- q->fp_lookup.inf_min = NO_DATA;
- }
-
- if (!NO_RIGHT_INFINITE_RULE) {
- if (q->fp_lookup.nalloc)
- q->fp_lookup.inf_dmax = q->infiniteDRight;
- q->fp_lookup.inf_max = q->infiniteCRight;
- }
- else {
- q->fp_lookup.inf_dmax = q->fp_lookup.vals[q->fp_lookup.nalloc - 1];
- q->fp_lookup.inf_max = NO_DATA;
- }
- q->fp_lookup.active = 1;
- return 1;
-}
-
-/*!
- * \brief Initialize the structure
- *
- * Initializes the <i>q</i> struct.
- *
- * \param quant pointer to Quant structure to be initialized
- */
-void G_quant_init(struct Quant *quant)
-{
- quant->fp_lookup.active = 0;
- quant->maxNofRules = 0;
- quant->truncate_only = 0;
- quant->round_only = 0;
- G_quant_clear(quant);
-}
-
-/*!
- \brief Returns wether or not quant rules are set to truncate map
-
- \param quant pointer to Quant structure which holds quant rules info
-
- \return 1 if truncate is enable
- \return 0 if not truncated
-*/
-int G_quant_is_truncate(const struct Quant *quant)
-{
- return quant->truncate_only;
-}
-
-/*!
- \brief Returns wether or not quant rules are set to round map
- \param quant pointer to Quant structure which holds quant rules info
-
- \return 1 is round
- \return 0 not round
-*/
-int G_quant_is_round(const struct Quant *quant)
-{
- return quant->round_only;
-}
-
-/*!
- * \brief Sets the quant rules to perform simple truncation on floats.
- *
- * Sets the quant for <i>q</i> rules to perform simple truncation on
- * floats.
- *
- * \param quant pointer to Quant structure which holds quant rules info
- */
-void G_quant_truncate(struct Quant *quant)
-{
- quant->truncate_only = 1;
-}
-
-/*!
- * \brief Sets the quant rules to perform simple rounding on floats.
- *
- * Sets the quant for <i>q</i> rules to perform simple rounding on
- * floats.
- *
- * \param quant pointer to Quant structure which holds quant rules info
- */
-void G_quant_round(struct Quant *quant)
-{
- quant->round_only = 1;
-}
-
-static void quant_set_limits(struct Quant *q,
- DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
-{
- q->dMin = dLow;
- q->dMax = dHigh;
- q->cMin = cLow;
- q->cMax = cHigh;
-}
-
-static void quant_update_limits(struct Quant *q,
- DCELL dLow, DCELL dHigh,
- CELL cLow, DCELL cHigh)
-{
- if (NO_EXPLICIT_RULE) {
- quant_set_limits(q, dLow, dHigh, cLow, cHigh);
- return;
- }
-
- q->dMin = MIN(q->dMin, MIN(dLow, dHigh));
- q->dMax = MAX(q->dMax, MAX(dLow, dHigh));
- q->cMin = MIN(q->cMin, MIN(cLow, cHigh));
- q->cMax = MAX(q->cMax, MAX(cLow, cHigh));
-}
-
-/*!
- * \brief Returns the minimum and maximum cell and dcell values of all
- * the ranges defined.
- *
- * Extracts the minimum and maximum floating-point and integer values
- * from all the rules (except the "infinite" rules) in <i>q</i> into
- * <i>dmin</i>, <i>dmax</i>, <i>cmin</i>, and <i>cmax</i>.
- *
- * \param quant pointer to Quant structure which holds quant rules info
- * \param[out] dmin minimum fp value
- * \param[out] dmax maximum fp value
- * \param[out] cmin minimum value
- * \param[out] cmax maximum value
- *
- * \return -1 if q->truncate or q->round are true or after
- * G_quant_init (), or any call to G_quant_clear () or G_quant_free()
- * no explicit rules have been added. In this case the returned
- * minimum and maximum CELL and DCELL values are null.
- * \return 1 if there are any explicit rules
- * \return 0 if there are no explicit rules (this includes cases when
- * q is set to truncate or round map), and sets <i>dmin</i>,
- * <i>dmax</i>, <i>cmin</i>, and <i>cmax</i> to NULL.
- */
-int G_quant_get_limits(const struct Quant *q,
- DCELL * dMin, DCELL * dMax, CELL * cMin, CELL * cMax)
-{
- if (NO_EXPLICIT_RULE) {
- G_set_c_null_value(cMin, 1);
- G_set_c_null_value(cMax, 1);
- G_set_d_null_value(dMin, 1);
- G_set_d_null_value(dMax, 1);
- return -1;
- }
-
- *dMin = q->dMin;
- *dMax = q->dMax;
- *cMin = q->cMin;
- *cMax = q->cMax;
-
- return 1;
-}
-
-/*!
- \brief Returns the number of quantization rules defined.
-
- This number does not include the 2 infinite intervals.
-
- \param q pointer to Quant structure which holds quant rules info
-
- \return number of quantization rules
-*/
-int G_quant_nof_rules(const struct Quant *q)
-{
- return q->nofRules;
-}
-
-/*!
- \brief Returns the i'th quantization rule.
-
- For 0 <= i < G_quant_nof_rules(). A larger value for i means that
- the rule has been added later.
-
- \param q pointer to Quant structure which holds quant rules info
- \param i index
- \param[out] dLow minimum fp value
- \param[out] dHigh maximum fp value
- \param[out] cLow minimum value
- \param[out] cHigh maximum value
-*/
-void G_quant_get_ith_rule(const struct Quant *q,
- int i,
- DCELL * dLow, DCELL * dHigh,
- CELL * cLow, CELL * cHigh)
-{
- *dLow = q->table[i].dLow;
- *dHigh = q->table[i].dHigh;
- *cLow = q->table[i].cLow;
- *cHigh = q->table[i].cHigh;
-}
-
-static void quant_table_increase(struct Quant *q)
-{
- if (q->nofRules < q->maxNofRules)
- return;
-
- if (q->maxNofRules == 0) {
- q->maxNofRules = 50;
- q->table = (struct Quant_table *)
- G_malloc(q->maxNofRules * sizeof(struct Quant_table));
- }
- else {
- q->maxNofRules += 50;
- q->table = (struct Quant_table *)
- G_realloc((char *)q->table,
- q->maxNofRules * sizeof(struct Quant_table));
- }
-}
-
-/*!
- \brief Defines a rule for values "dLeft" and smaller.
-
- Values in this range are mapped to "c" if none of the "finite"
- quantization rules applies.
-
- \param q pointer to Quant structure which holds quant rules info
-
- \param dLeft fp value
- \param c value
-*/
-void G_quant_set_neg_infinite_rule(struct Quant *q, DCELL dLeft, CELL c)
-{
- q->infiniteDLeft = dLeft;
- q->infiniteCLeft = c;
- quant_update_limits(q, dLeft, dLeft, c, c);
-
- /* update lookup table */
- if (q->fp_lookup.active) {
- q->fp_lookup.inf_dmin = q->infiniteDLeft;
- q->fp_lookup.inf_min = q->infiniteCLeft;
- }
- q->infiniteLeftSet = 1;
-}
-
-/*!
- \brief Returns in "dLeft" and "c" the rule values.
-
- For the negative infinite interval (see G_quant_set_neg_infinite_rule()).
-
- \param q pointer to Quant structure which holds quant rules info
- \param[out] dLeft fp value
- \param[out] c value
-
- \return 0 if this rule is not defined
- \return 1 otherwise
-*/
-int G_quant_get_neg_infinite_rule(const struct Quant *q,
- DCELL * dLeft, CELL * c)
-{
- if (q->infiniteLeftSet == 0)
- return 0;
-
- *dLeft = q->infiniteDLeft;
- *c = q->infiniteCLeft;
-
- return 1;
-}
-
-/*!
- \brief Defines a rule for values "dRight" and larger.
-
- Values in this range are mapped to "c" if none of the "finite"
- quantization rules or the negative infinite rule applies.
-
- \param q pointer to Quant structure which holds quant rules info
- \param dRight fp value
- \param c value
-*/
-void G_quant_set_pos_infinite_rule(struct Quant *q, DCELL dRight, CELL c)
-{
- q->infiniteDRight = dRight;
- q->infiniteCRight = c;
- quant_update_limits(q, dRight, dRight, c, c);
-
- /* update lookup table */
- if (q->fp_lookup.active) {
- q->fp_lookup.inf_dmax = q->infiniteDRight;
- q->fp_lookup.inf_max = q->infiniteCRight;
- }
- q->infiniteRightSet = 1;
-}
-
-/*!
- \brief Returns in "dRight" and "c" the rule values.
-
- For the positive infinite interval (see G_quant_set_pos_infinite_rule()).
-
- \param q pointer to Quant structure which holds quant rules info
- \param[out] dRight fp value
- \param[out] c value
-
- \return 0 if this rule is not defined
- \return 1 otherwise
-*/
-int G_quant_get_pos_infinite_rule(const struct Quant *q,
- DCELL * dRight, CELL * c)
-{
- if (q->infiniteRightSet == 0)
- return 0;
-
- *dRight = q->infiniteDRight;
- *c = q->infiniteCRight;
-
- return 1;
-}
-
-/*!
- \brief Adds a new rule to the set of quantization rules.
-
- If dLow < dHigh the rule will be stored with the low and high values
- interchanged.
-
- Note: currently no cleanup of rules is performed, i.e. redundant
- rules are not removed. This can't be changed because Categories
- structure HEAVILY depends of quant rules stored in exactly the same
- order they are entered. So if the cleanup or rearrangement is done in
- the future make a flag for add_rule wether or not to do it, then
- quant will not set this flag.
-
- \param q pointer to Quant structure which holds quant rules info
- \param dLow minimum fp value
- \param dHigh maximum fp value
- \param cLow minimum value
- \param cHigh maximum value
-*/
-void G_quant_add_rule(struct Quant *q,
- DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
-{
- int i;
- struct Quant_table *p;
-
- quant_table_increase(q);
-
- i = q->nofRules;
-
- p = &(q->table[i]);
- if (dHigh >= dLow) {
- p->dLow = dLow;
- p->dHigh = dHigh;
- p->cLow = cLow;
- p->cHigh = cHigh;
- }
- else {
- p->dLow = dHigh;
- p->dHigh = dLow;
- p->cLow = cHigh;
- p->cHigh = cLow;
- }
-
- /* destroy lookup table, it has to be rebuilt */
- if (q->fp_lookup.active) {
- G_free(q->fp_lookup.vals);
- G_free(q->fp_lookup.rules);
- q->fp_lookup.active = 0;
- q->fp_lookup.nalloc = 0;
- }
-
- quant_update_limits(q, dLow, dHigh, cLow, cHigh);
-
- q->nofRules++;
-}
-
-/*!
- \brief Rreverses the order in which the qunatization rules are stored.
-
- See also G_quant_get_ith_rule() and G_quant_perform_d()).
-
- \param q pointer to Quant rules which holds quant rules info
-*/
-void G_quant_reverse_rule_order(struct Quant *q)
-{
- struct Quant_table tmp;
- struct Quant_table *pLeft, *pRight;
-
- pLeft = q->table;
- pRight = &(q->table[q->nofRules - 1]);
-
- while (pLeft < pRight) {
- tmp.dLow = pLeft->dLow;
- tmp.dHigh = pLeft->dHigh;
- tmp.cLow = pLeft->cLow;
- tmp.cHigh = pLeft->cHigh;
-
- pLeft->dLow = pRight->dLow;
- pLeft->dHigh = pRight->dHigh;
- pLeft->cLow = pRight->cLow;
- pLeft->cHigh = pRight->cHigh;
-
- pRight->dLow = tmp.dLow;
- pRight->dHigh = tmp.dHigh;
- pRight->cLow = tmp.cLow;
- pRight->cHigh = tmp.cHigh;
-
- pLeft++;
- pRight--;
- }
-}
-
-static CELL quant_interpolate(DCELL dLow, DCELL dHigh,
- CELL cLow, CELL cHigh, DCELL dValue)
-{
- if (cLow == cHigh)
- return cLow;
- if (dLow == dHigh)
- return cLow;
-
- return (CELL) ((dValue - dLow) / (dHigh - dLow) * (DCELL) (cHigh - cLow) +
- (DCELL) cLow);
-}
-
-static int less_or_equal(double x, double y)
-{
- if (x <= y)
- return 1;
- else
- return 0;
-}
-
-static int less(double x, double y)
-{
- if (x < y)
- return 1;
- else
- return 0;
-}
-
-/*!
- * \brief
- *
- *
- * Returns a CELL category for the floating-point <i>value</i> based
- * on the quantization rules in <i>q</i>. The first rule found that
- * applies is used. The rules are searched in the reverse order they
- * are added to <i>q</i>. If no rule is found, the <i>value</i>
- * is first tested against the negative infinite rule, and finally
- * against the positive infinite rule. If none of these rules apply,
- * the NULL-value is returned.
- *
- * <b>Note:</b> See G_quant_organize_fp_lookup() for details on how
- * the values are looked up from fp_lookup table when it is
- * active. Right now fp_lookup is automatically organized during the
- * first call to G_quant_get_cell_value().
- *
- * \param q pointer to Quant structure which holds quant rules info
- * \param dcellValue fp cell value
- *
- * \return cell value (integer)
- */
-CELL G_quant_get_cell_value(struct Quant * q, DCELL dcellVal)
-{
- CELL tmp;
- DCELL dtmp;
- int try, min_ind, max_ind;
- struct Quant_table *p;
- int (*lower) ();
-
- dtmp = dcellVal;
- /* I know the functions which call me already check for null values,
- but I am a public function, and can be called from outside */
- if (G_is_d_null_value(&dtmp))
- return NO_DATA;
-
- if (q->truncate_only)
- return (CELL) dtmp;
-
- if (q->round_only) {
- if (dcellVal > 0)
- return (CELL) (dcellVal + .5);
- return (CELL) (dcellVal - .5);
- }
-
- if (NO_EXPLICIT_RULE)
- return NO_DATA;
- if (NO_EXPLICIT_RULE)
- return NO_DATA;
-
- if (USE_LOOKUP &&
- (q->fp_lookup.active || G__quant_organize_fp_lookup(q) > 0)) {
- /* first check if values fall within range */
- /* if value is below the range */
- if (dcellVal < q->fp_lookup.vals[0]) {
- if (dcellVal <= q->fp_lookup.inf_dmin)
- return q->fp_lookup.inf_min;
- else
- return NO_DATA;
- }
- /* if value is below above range */
- if (dcellVal > q->fp_lookup.vals[q->fp_lookup.nalloc - 1]) {
- if (dcellVal >= q->fp_lookup.inf_dmax)
- return q->fp_lookup.inf_max;
- else
- return NO_DATA;
- }
- /* make binary search to find which interval our value belongs to
- and apply the rule for this interval */
- try = (q->fp_lookup.nalloc - 1) / 2;
- min_ind = 0;
- max_ind = q->fp_lookup.nalloc - 2;
- while (1) {
- /* DEBUG
- fprintf (stderr, "%d %d %d\n", min_ind, max_ind, try);
- */
- /* when the ruke for the interval is NULL, we exclude the end points.
- when it exists, we include the end-points */
- if (q->fp_lookup.rules[try])
- lower = less;
- else
- lower = less_or_equal;
-
- if (lower(q->fp_lookup.vals[try + 1], dcellVal)) { /* recurse to the second half */
- min_ind = try + 1;
- /* must be still < nalloc-1, since number is within the range */
- try = (max_ind + min_ind) / 2;
- continue;
- }
- if (lower(dcellVal, q->fp_lookup.vals[try])) { /* recurse to the second half */
- max_ind = try - 1;
- /* must be still >= 0, since number is within the range */
- try = (max_ind + min_ind) / 2;
- continue;
- }
- /* the value fits into the interval! */
- p = q->fp_lookup.rules[try];
- if (p)
- return quant_interpolate(p->dLow, p->dHigh, p->cLow, p->cHigh,
- dcellVal);
- /* otherwise when finite rule for this interval doesn't exist */
- else { /* first check if maybe infinite rule applies */
- if (dcellVal <= q->fp_lookup.inf_dmin)
- return q->fp_lookup.inf_min;
- if (dcellVal >= q->fp_lookup.inf_dmax)
- return q->fp_lookup.inf_max;
- else
- return NO_DATA;
- }
- } /* while */
- } /* looking up in fp_lookup */
-
- if (!NO_FINITE_RULE) {
- p = G__quant_get_rule_for_d_raster_val(q, dcellVal);
- if (!p)
- return NO_DATA;
- return quant_interpolate(p->dLow, p->dHigh, p->cLow, p->cHigh,
- dcellVal);
- }
-
- if ((!NO_LEFT_INFINITE_RULE) && (dcellVal <= q->infiniteDLeft))
- return q->infiniteCLeft;
-
- if ((NO_RIGHT_INFINITE_RULE) || (dcellVal < q->infiniteDRight))
- return NO_DATA;
-
- return q->infiniteCRight;
-}
-
-/*!
- \brief Returns in "cell" the quantized CELL values.
-
- Returns in "cell" the quantized CELL values corresponding to the
- DCELL values stored in "dcell". the number of elements quantized
- is n. quantization is performed by repeated application of
- G_quant_get_cell_value().
-
- \param q pointer to Quant structure which holds quant rules info
- \param dcell pointer to fp cell values array
- \param[out] cell pointer cell values array
- \param n number of cells
-*/
-void G_quant_perform_d(struct Quant *q,
- const DCELL * dcell, CELL * cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, dcell++)
- if (!G_is_d_null_value(dcell))
- *cell++ = G_quant_get_cell_value(q, *dcell);
- else
- G_set_c_null_value(cell++, 1);
-}
-
-/*!
- \brief Same as G_quant_perform_d(), except the type.
-
- \param q pointer to Quant structure which holds quant rules info
- \param fcell pointer to fp cell values array
- \param[out] cell pointer cell values array
- \param n number of cells
-*/
-void G_quant_perform_f(struct Quant *q,
- const FCELL * fcell, CELL * cell, int n)
-{
- int i;
-
- for (i = 0; i < n; i++, fcell++)
- if (!G_is_f_null_value(fcell))
- *cell++ = G_quant_get_cell_value(q, (DCELL) * fcell);
- else
- G_set_c_null_value(cell++, 1);
-}
-
-static int double_comp(const void *xx, const void *yy)
-{
- const DCELL *x = xx;
- const DCELL *y = yy;
-
- if (G_is_d_null_value(x))
- return 0;
- if (*x < *y)
- return -1;
- else if (*x == *y)
- return 0;
- else
- return 1;
-}
-
-/*!
- \brief Returns quant rule which will be applied.
-
- Returns quant rule which will be applied when looking up the integer
- quant value for val (used when organizing fp_lookup).
-
- \param q pointer to Quant structure which holds quant rules info
- \param val fp cell value
-
- \return pointer to the Quant_table (color rule)
- \return NULL otherwise
-*/
-struct Quant_table *G__quant_get_rule_for_d_raster_val(const struct Quant *q,
- DCELL val)
-{
- const struct Quant_table *p;
-
- for (p = &(q->table[q->nofRules - 1]); p >= q->table; p--)
- if ((val >= p->dLow) && (val <= p->dHigh))
- break;
- if (p >= q->table)
- return (struct Quant_table *)p;
- else
- return (struct Quant_table *)NULL;
-}
Deleted: grass/trunk/lib/gis/quant_io.c
===================================================================
--- grass/trunk/lib/gis/quant_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/quant_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,316 +0,0 @@
-
-/**********************************************************************
- *
- * int
- * G__quant_import (name, mapset, quant)
- *
- * char *name;
- * char *mapset;
- * struct Quant *quant;
- *
- * reads quantization rules for "name" in "mapset" and stores them
- * in the quantization structure "quant". If the map is in another
- * mapset, first checks for quant2 table for this map in current
- * mapset.
- *
- * returns: -2 if raster map is of type integer.
- * -1 if (! G__name_is_fully_qualified ()).
- * 0 if quantization file does not exist, or the file is empty,
- * 1 if non-empty quantization file exists.
- * read.
- *
- * note: in the case of negative return value, the result of using the
- * quantization structure is not defined.
- * in case of return value 0, calls to G_quant_perform_d ()
- * and G_quant_perform_f () return NO_DATA (see description of
- * G_quant_perform_d () for more details). in case of
- * return values 2 and 3, the explicit rule for quant is set:
- * floating range is mapped to integer range.
- *
- * note: use G_quant_init () to allocate and initialize the quantization
- * staructure quant before the first usage of G_quant_import ().
- *
- * note: this function uses G_quant_free () to clear all previously
- * stored rules in quant.
- *
- **********************************************************************
- *
- * int
- * G__quant_export (name, mapset, quant)
- *
- * char *name, *mapset;
- * struct Quant *quant;
- *
- * writes the quantization rules stored in "quant" for "name" . if the
- * mapset is the same as the current mapset, the quant file is created
- * in cell_misc/name directory, otherwise it is created in quant2/mapset
- * directory, much like writing colors for map in another mapset.
- * The rules are written in decreasing order
- * of priority (i.e. rules added earlier are written later).
- *
- * returns: -1 if (! G__name_is_fully_qualified) or file could not be
- * opened.
- * 1 otherwise.
- *
- * note: if no rules are defined an empty file is created.
- *
- **********************************************************************/
-
-/*--------------------------------------------------------------------------*/
-
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include <string.h>
-
-/*--------------------------------------------------------------------------*/
-
-#define QUANT_FILE_NAME "f_quant"
-
-/*--------------------------------------------------------------------------*/
-
-static int quant_parse_file(FILE *, struct Quant *);
-
-#if 0
-static int
-/* redundant: integer range doesn't exist now: it is defined by
- the quant rules */
-quant_load_range(struct Quant *quant, const char *name, const char *mapset)
-{
- struct FPRange fprange;
- struct Range range;
- char buf[300];
- DCELL dMin, dMax;
- CELL min, max;
-
- if (G_read_fp_range(name, mapset, &fprange) <= 0)
- return 0;
- G_get_fp_range_min_max(&fprange, &dMin, &dMax);
- if (G_is_d_null_value(&dMin) || G_is_d_null_value(&dMax)) {
- G_warning (_("The floating data range for %s@%s is empty"),
- name, mapset);
- return -3;
- }
-
- if (G_read_range(name, mapset, &range) < 0)
- return 0;
- G_get_range_min_max(&range, &min, &max);
- if (G_is_c_null_value(&min) && G_is_c_null_value(&max)) {
- G_warning (_("The integer data range for %s@%s is empty"),
- name, mapset);
- return -3;
- }
-
- G_quant_add_rule(quant, dMin, dMax, min, max);
-
- return 1;
-}
-#endif
-
-/*--------------------------------------------------------------------------*/
-
-int G__quant_import(const char *name, const char *mapset, struct Quant *quant)
-{
- char buf[1024];
- char *err;
- char xname[GNAME_MAX], xmapset[GMAPSET_MAX], element[GNAME_MAX + 7];
- int parsStat;
- FILE *fd;
-
- G_quant_free(quant);
-
- if (G_raster_map_type(name, mapset) == CELL_TYPE) {
- G_warning (_("G__quant_import: attempt to open quantization"
- " table for CELL_TYPE file [%s] in mapset {%s]"),
- name, mapset);
- return -2;
- }
-
- if (G__name_is_fully_qualified(name, xname, xmapset)) {
- if (strcmp(xmapset, mapset) != 0)
- return -1;
- name = xname;
- }
-
- /* first check if quant2/mapset/name exists in the current mapset */
- sprintf(element, "quant2/%s", mapset);
- if ((fd = G_fopen_old(element, name, G_mapset()))) {
- parsStat = quant_parse_file(fd, quant);
- fclose(fd);
- if (parsStat)
- return 1;
- sprintf(buf,
- "quantization file in quant2 for [%s] in mapset [%s] is empty",
- name, mapset);
- }
-
- /* now try reading regular : cell_misc/name/quant file */
- if (!(fd = G_fopen_old_misc("cell_misc", QUANT_FILE_NAME, name, mapset))) {
-
- /* int range doesn't exist anymore if (quant_load_range (quant, name, mapset)>0) return 3; */
- err = "missing";
-
- }
- else {
- parsStat = quant_parse_file(fd, quant);
- fclose(fd);
-
- if (parsStat)
- return 1;
- /* int range doesn't exist anymore if (quant_load_range (quant, name, mapset)>0) return 2; */
-
- err = "empty";
- }
-
- G_warning (_("quantization file [%s] in mapset [%s] %s"),
- name, mapset, err);
-
- return 0;
-}
-
-/*--------------------------------------------------------------------------*/
-
-/* parse input lines with the following formats
- *
- * d_high:d_low:c_high:c_low
- * d_high:d_low:c_val (i.e. c_high == c_low)
- * *:d_val:c_val (interval [inf, d_val]) (**)
- * d_val:*:c_val (interval [d_val, inf]) (**)
- *
- * all other lines are ignored
- *
- * (**) only the first appearances in the file are considered.
- *
- */
-
-/*--------------------------------------------------------------------------*/
-
-static int quant_parse_file(FILE * fd, struct Quant *quant)
-{
- CELL cLow, cHigh;
- DCELL dLow, dHigh;
- char buf[1024];
- int foundNegInf = 0, foundPosInf = 0;
-
- while (fgets(buf, sizeof(buf), fd)) {
- if (strncmp(buf, "truncate", 8) == 0) {
- quant->truncate_only = 1;
- return 1;
- }
- if (strncmp(buf, "round", 5) == 0) {
- quant->round_only = 1;
- return 1;
- }
- switch (sscanf(buf, "%lf:%lf:%d:%d", &dLow, &dHigh, &cLow, &cHigh)) {
- case 3:
- G_quant_add_rule(quant, dLow, dHigh, cLow, cLow);
- break;
- case 4:
- G_quant_add_rule(quant, dLow, dHigh, cLow, cHigh);
- break;
- default:
- switch (sscanf(buf, "*:%lf:%d", &dLow, &cLow)) {
- case 2:
- if (!foundNegInf) {
- G_quant_set_neg_infinite_rule(quant, dLow, cLow);
- foundNegInf = 1;
- }
- break;
- default:
- switch (sscanf(buf, "%lf:*:%d", &dLow, &cLow)) {
- case 2:
- if (!foundPosInf) {
- G_quant_set_pos_infinite_rule(quant, dLow, cLow);
- foundPosInf = 1;
- }
- break;
- default:
- continue; /* other lines are ignored */
- }
- }
- }
- }
-
- if (G_quant_nof_rules(quant) > 0)
- G_quant_reverse_rule_order(quant);
-
- return ((G_quant_nof_rules(quant) > 0) ||
- (G_quant_get_neg_infinite_rule(quant, &dLow, &cLow) > 0) ||
- (G_quant_get_pos_infinite_rule(quant, &dLow, &cLow) > 0));
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-static void quant_write(FILE * fd, const struct Quant *quant)
-{
- DCELL dLow, dHigh;
- CELL cLow, cHigh;
- int i;
-
- if (quant->truncate_only) {
- fprintf(fd, "truncate");
- return;
- }
- if (quant->round_only) {
- fprintf(fd, "round");
- return;
- }
- if (G_quant_get_neg_infinite_rule(quant, &dLow, &cLow) > 0)
- fprintf(fd, "*:%.20g:%d\n", dLow, cLow);
-
- if (G_quant_get_pos_infinite_rule(quant, &dLow, &cLow) > 0)
- fprintf(fd, "%.20g:*:%d\n", dLow, cLow);
-
- for (i = G_quant_nof_rules(quant) - 1; i >= 0; i--) {
- G_quant_get_ith_rule(quant, i, &dLow, &dHigh, &cLow, &cHigh);
- fprintf(fd, "%.20g:%.20g:%d", dLow, dHigh, cLow);
- if (cLow != cHigh)
- fprintf(fd, ":%d", cHigh);
- fprintf(fd, "\n");
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-int
-G__quant_export(const char *name, const char *mapset,
- const struct Quant *quant)
-{
- char element[GNAME_MAX + 7];
- char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
- FILE *fd;
-
- if (G__name_is_fully_qualified(name, xname, xmapset)) {
- if (strcmp(xmapset, mapset) != 0)
- return -1;
- name = xname;
- }
-
- if (strcmp(G_mapset(), mapset) == 0) {
- G_remove_misc("cell_misc", QUANT_FILE_NAME, name);
- G__make_mapset_element_misc("cell_misc", name);
- if (!(fd = G_fopen_new_misc("cell_misc", QUANT_FILE_NAME, name)))
- return -1;
- }
- else {
- sprintf(element, "quant2/%s", mapset);
- G_remove(element, name);
- G__make_mapset_element(element);
- if (!(fd = G_fopen_new(element, name)))
- return -1;
- }
-
-
-
- quant_write(fd, quant);
- fclose(fd);
-
- return 1;
-}
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
Deleted: grass/trunk/lib/gis/quant_rw.c
===================================================================
--- grass/trunk/lib/gis/quant_rw.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/quant_rw.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,227 +0,0 @@
-/*!
- * \file gis/quant_rw.c
- *
- * \brief GIS Library - Quantization rules (read/write).
- *
- * (C) 1999-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- * \author USACERL and many others
- */
-
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-/*!
- \brief Writes the quant rules.
-
- Writes the quant rules which indicate that all floating numbers
- should be truncated instead of applying any quant rules from
- floats to integers.
-
- \param name map name
- \param mapset mapset name
-
- \return -1 on error
- \return 1 on success
-*/
-int G_truncate_fp_map(const char *name, const char *mapset)
-{
- struct Quant quant;
-
- G_quant_init(&quant);
- G_quant_truncate(&quant);
- /* quantize the map */
- if (G_write_quant(name, mapset, &quant) < 0) {
- G_warning(_("Unable to write quant rules for raster map <%s>"),
- name);
- return -1;
- }
- return 1;
-}
-
-/*!
- \brief Writes the quant rules.
-
- Writes the quant rules which indicate that all floating numbers
- should be rounded instead of applying any quant rules from
- floats to integers.
-
- \param name map name
- \param mapset mapset name
-
- \return -1 on error
- \return 1 on success
-*/
-int G_round_fp_map(const char *name, const char *mapset)
-{
- struct Quant quant;
-
- G_quant_init(&quant);
- G_quant_round(&quant);
- /* round the map */
- if (G_write_quant(name, mapset, &quant) < 0) {
- G_warning(_("Unable to write quant rules for raster map <%s>"),
- name);
- return -1;
- }
- return 1;
-}
-
-/*!
- * \brief Write quant rules (f_quant) for floating-point raster map.
- *
- * Writes the <tt>f_quant</tt> file for the raster map <em>name</em>
- * with one rule. The rule is generated using the floating-point range
- * in <tt>f_range</tt> producing the integer range
- * [<em>cmin,cmax</em>].
- *
- * Make a rule for map <name> that maps floating range (d_min, d_max)
- * into integer range (min, max)
- * This function is useful when the quant rule doesn't depend of the
- * range of produced float data, for example the slope map whould
- * want to have a quant rule: 0.0, 90.0 -> 0 , 90
- * no matter what the min and max slope of this map is.
-
- * \param name map name
- * \param mapset mapset name
- * \param cmin minimum value
- * \param cmax maximum value
- *
- * \return -1 on error
- * \return 1 on success
- */
-int G_quantize_fp_map(const char *name, const char *mapset,
- CELL min, CELL max)
-{
- DCELL d_min, d_max;
- struct FPRange fp_range;
-
- if (G_read_fp_range(name, mapset, &fp_range) < 0) {
- G_warning(_("Unable to read fp range for raster map <%s>"),
- G_fully_qualified_name(name, mapset));
- return -1;
- }
- G_get_fp_range_min_max(&fp_range, &d_min, &d_max);
- if (G_is_d_null_value(&d_min) || G_is_d_null_value(&d_max)) {
- G_warning(_("Raster map <%s> is empty"),
- G_fully_qualified_name(name, mapset));
- return -1;
- }
- return G_quantize_fp_map_range(name, mapset, d_min, d_max, min, max);
-}
-
-/*!
- * \brief Write quant rules (f_quant) for floating-point raster map.
- *
- * Writes the <tt>f_quant</tt> file for the raster map
- * <em>name</em> with one rule. The rule is generated using the floating-point
- * range [<em>dmin,dmax</em>] and the integer range
- * [<em>min,max</em>].
- * This routine differs from the one above in that the application controls the
- * floating-point range. For example, r.slope.aspect will use this routine to
- * quantize the slope map from [0.0, 90.0] to [0,
- * 90] even if the range of slopes is not 0-90. The aspect map would be
- * quantized from [0.0, 360.0] to [0, 360].
- *
- * Make a rule for map <name> that maps floating range (d_min, d_max)
- * into integer range (min, max)
- * This function is useful when the quant rule doesn't depend of the
- * range of produced float data, for example the slope map whould
- * want to have a quant rule: 0.0, 90.0 -> 0 , 90
- * no matter what the min and max slope of this map is.
- *
- * \param name map name
- * \param mapset mapset name
- * \param d_min minimum fp value
- * \param d_max maximum fp value
- * \param min minimum value
- * \param max maximum value
- *
- * \return -1 on error
- * \return 1 on success
- */
-int G_quantize_fp_map_range(const char *name, const char *mapset,
- DCELL d_min, DCELL d_max, CELL min, CELL max)
-{
- struct Quant quant;
-
- G_quant_init(&quant);
- G_quant_add_rule(&quant, d_min, d_max, min, max);
- /* quantize the map */
- if (G_write_quant(name, mapset, &quant) < 0) {
- G_warning(_("Unable to write quant rules for raster map <%s>"),
- name);
- return -1;
- }
- return 1;
-}
-
-/*!
- * \brief Writes the quant rule table for the raster map
- *
- * Writes the <tt>f_quant</tt> file for the raster map <em>name</em>
- * from <em>q</em>. if mapset==G_mapset() i.e. the map is in current
- * mapset, then the original quant file in cell_misc/map/f_quant is
- * written. Otherwise <em>q</em> is written into quant2/mapset/name
- * (much like colr2 element). This results in map at mapset being read
- * using quant rules stored in <em>q</em> from G_mapset(). See
- * G_read_quant() for detailes.
- *
- * \param name map name
- * \param mapset mapset name
- * \param quant pointer to Quant structure which hold quant rules info
- *
- * \return -1 on error
- * \return 1 on success
- */
-int G_write_quant(const char *name, const char *mapset,
- const struct Quant *quant)
-{
- CELL cell_min, cell_max;
- DCELL d_min, d_max;
-
- if (G_raster_map_type(name, mapset) == CELL_TYPE) {
- G_warning(_("Unable to write quant rules: raster map <%s> is integer"),
- name);
- return -1;
- }
-
- G_quant_get_limits(quant, &d_min, &d_max, &cell_min, &cell_max);
-
- /* first actually write the rules */
- if (G__quant_export(name, mapset, quant) < 0) {
- G_warning (_("Unable to write quant rules for raster map <%s>"),
- name);
- return -1;
- }
-
- return 1;
-}
-
-/*!
- * \brief
- *
- * Reads quantization rules for <i>name</i> in <i>mapset</i> and
- * stores them in the quantization structure. If the map is in another
- * mapset, first checks for quant2 table for this map in current
- * mapset.
- * \param name
- * \param mapset
- * \param q
- *
- * \return -2 if raster map is of type integer
- * \return -1 if (!G__name_is_fully_qualified())
- * \return 0 if quantization file does not exist, or the file is empty or has wrong format
- * \return 1 if non-empty quantization file exists
- *
- */
-int G_read_quant(const char *name, const char *mapset, struct Quant *quant)
-{
- G_quant_init(quant);
- return G__quant_import(name, mapset, quant);
-}
Deleted: grass/trunk/lib/gis/range.c
===================================================================
--- grass/trunk/lib/gis/range.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,600 +0,0 @@
-/*!
- * \file gis/range.c
- *
- * \brief GIS Library - Raster range file management
- *
- * (C) 2001-2009 GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <unistd.h>
-#include <rpc/types.h> /* need this for sgi */
-#include <rpc/xdr.h>
-#include "G.h"
-#include <grass/glocale.h>
-
-#define DEFAULT_CELL_MIN 1
-#define DEFAULT_CELL_MAX 255
-
-/*!
- \brief Remove floating-point range
-
- Note: For internal use only.
-
- \param name map name
-*/
-void G__remove_fp_range(const char *name)
-{
- G_remove_misc("cell_misc", "f_range", name);
-}
-
-/*!
- * \brief Construct default range
- *
- * Sets the integer range to [1,255]
- *
- * \param[out] r pointer to Range structure which holds range info
- */
-void G_construct_default_range(struct Range *range)
-{
- G_update_range(DEFAULT_CELL_MIN, range);
- G_update_range(DEFAULT_CELL_MAX, range);
-}
-
-/*!
- * \brief Read floating-point range
- *
- * Read the floating point range file <i>drange</i>. This file is
- * written in binary using XDR format.
- *
- * An empty range file indicates that the min, max are undefined. This
- * is a valid case, and the result should be an initialized range
- * struct with no defined min/max. If the range file is missing and
- * the map is a floating-point map, this function will create a
- * default range by calling G_construct_default_range().
- *
- * \param name map name
- * \param mapset mapset name
- * \param drange pointer to FPRange structure which holds fp range
- *
- * \return 1 on success
- * \return 2 range is empty
- * \return -1 on error
- */
-int G_read_fp_range(const char *name, const char *mapset,
- struct FPRange *drange)
-{
- struct Range range;
- int fd;
- char xdr_buf[100];
- DCELL dcell1, dcell2;
- XDR xdr_str;
-
- G_init_fp_range(drange);
-
- if (G_raster_map_type(name, mapset) == CELL_TYPE) {
- /* if map is integer
- read integer range and convert it to double */
-
- if (G_read_range(name, mapset, &range) >= 0) {
- /* if the integer range is empty */
- if (range.first_time)
- return 2;
-
- G_update_fp_range((DCELL) range.min, drange);
- G_update_fp_range((DCELL) range.max, drange);
- return 1;
- }
- return -1;
- }
-
- fd = -1;
-
- if (G_find_file2_misc("cell_misc", "f_range", name, mapset)) {
- fd = G_open_old_misc("cell_misc", "f_range", name, mapset);
- if (fd < 0) {
- G_warning(_("Unable to read fp range file for <%s@%s>"),
- name, mapset);
- return -1;
- }
-
- if (read(fd, xdr_buf, 2 * XDR_DOUBLE_NBYTES) != 2 * XDR_DOUBLE_NBYTES)
- return 2;
-
- xdrmem_create(&xdr_str, xdr_buf, (u_int) XDR_DOUBLE_NBYTES * 2,
- XDR_DECODE);
-
- /* if the f_range file exists, but empty */
- if (!xdr_double(&xdr_str, &dcell1) || !xdr_double(&xdr_str, &dcell2)) {
- if (fd)
- close(fd);
- G_warning(_("Unable to read fp range file for <%s@%s>"),
- name, mapset);
- return -1;
- }
-
- G_update_fp_range(dcell1, drange);
- G_update_fp_range(dcell2, drange);
- close(fd);
- }
-
- return 1;
-}
-
-/*!
- * \brief Read raster range (CELL)
- *
- * This routine reads the range information for the raster map
- * <i>name</i> in <i>mapset</i> into the <i>range</i> structure.
- *
- * A diagnostic message is printed and -1 is returned if there is an error
- * reading the range file. Otherwise, 0 is returned.
- *
- * Old range file (those with 4 numbers) should treat zeros in this
- * file as NULL-values. New range files (those with just 2 numbers)
- * should treat these numbers as real data (zeros are real data in
- * this case). An empty range file indicates that the min, max are
- * undefined. This is a valid case, and the result should be an
- * initialized range struct with no defined min/max. If the range file
- * is missing and the map is a floating-point map, this function will
- * create a default range by calling G_construct_default_range().
- *
- * \param name map name
- * \param mapset mapset name
- * \param range pointer to Range structure which holds range info
- *
- * \return -1 on error
- * \return 1 on success
- * \return 2 if range is empty
- * \return 3 if raster map is floating-point, get range from quant rules
- */
-int G_read_range(const char *name, const char *mapset, struct Range *range)
-{
- FILE *fd;
- CELL x[4];
- char buf[200];
- int n, count;
- struct Quant quant;
- struct FPRange drange;
-
- G_init_range(range);
- fd = NULL;
-
- /* if map is not integer, read quant rules, and get limits */
- if (G_raster_map_type(name, mapset) != CELL_TYPE) {
- DCELL dmin, dmax;
-
- if (G_read_quant(name, mapset, &quant) < 0) {
- G_warning(_("Unable to read quant rules for raster map <%s@%s>"),
- name, mapset);
- return -1;
- }
- if (G_quant_is_truncate(&quant) || G_quant_is_round(&quant)) {
- if (G_read_fp_range(name, mapset, &drange) >= 0) {
- G_get_fp_range_min_max(&drange, &dmin, &dmax);
- if (G_quant_is_truncate(&quant)) {
- x[0] = (CELL) dmin;
- x[1] = (CELL) dmax;
- }
- else { /* round */
-
- if (dmin > 0)
- x[0] = (CELL) (dmin + .5);
- else
- x[0] = (CELL) (dmin - .5);
- if (dmax > 0)
- x[1] = (CELL) (dmax + .5);
- else
- x[1] = (CELL) (dmax - .5);
- }
- }
- else
- return -1;
- }
- else
- G_quant_get_limits(&quant, &dmin, &dmax, &x[0], &x[1]);
-
- G_update_range(x[0], range);
- G_update_range(x[1], range);
- return 3;
- }
-
- if (G_find_file2_misc("cell_misc", "range", name, mapset)) {
- fd = G_fopen_old_misc("cell_misc", "range", name, mapset);
- if (!fd) {
- G_warning(_("Unable to read range file for <%s@%s>"),
- name, mapset);
- return -1;
- }
-
- /* if range file exists but empty */
- if (!fgets(buf, sizeof buf, fd))
- return 2;
-
- x[0] = x[1] = x[2] = x[3] = 0;
- count = sscanf(buf, "%d%d%d%d", &x[0], &x[1], &x[2], &x[3]);
-
- /* if wrong format */
- if (count <= 0) {
- if (fd)
- fclose(fd);
-
- G_warning(_("Unable to read range file for <%s@%s>"),
- name, mapset);
- return -1;
- }
-
- for (n = 0; n < count; n++) {
- /* if count==4, the range file is old (4.1) and 0's in it
- have to be ignored */
- if (count < 4 || x[n])
- G_update_range((CELL) x[n], range);
- }
- fclose(fd);
- }
-
- return 1;
-}
-
-/*!
- * \brief Write raster range file
- *
- * This routine writes the range information for the raster map
- * <i>name</i> in the current mapset from the <i>range</i> structure.
- * A diagnostic message is printed and -1 is returned if there is an
- * error writing the range file. Otherwise, 0 is returned.
- *
- * This routine only writes 2 numbers (min,max) to the range
- * file, instead of the 4 (pmin,pmax,nmin,nmax) previously written.
- * If there is no defined min,max, an empty file is written.
- *
- * \param name map name
- * \param range pointer to Range structure which holds range info
- *
- * \return -1 on error (or raster map is floating-point)
- * \return 0 on success
- */
-int G_write_range(const char *name, const struct Range *range)
-{
- FILE *fd;
-
- if (G_raster_map_type(name, G_mapset()) != CELL_TYPE) {
- G_remove_misc("cell_misc", "range", name); /* remove the old file with this name */
- G_warning(_("Unable to write range file for <%s>"),
- name);
- return -1;
- }
-
- fd = G_fopen_new_misc("cell_misc", "range", name);
- if (!fd) {
- G_remove_misc("cell_misc", "range", name); /* remove the old file with this name */
- G_warning(_("Unable to write range file for <%s>"),
- name);
- return -1;
- }
-
- /* if range hasn't been updated */
- if (range->first_time) {
- fclose(fd);
- return 0;
- }
-
- fprintf(fd, "%ld %ld\n", (long)range->min, (long)range->max);
- fclose(fd);
-
- return 0;
-}
-
-/*!
- * \brief Write raster range file (floating-point)
- *
- * Write the floating point range file <tt>f_range</tt>. This file is
- * written in binary using XDR format. If there is no defined min/max
- * in <em>range</em>, an empty <tt>f_range</tt> file is created.
- *
- * \param name map name
- * \param range pointer to FPRange which holds fp range info
- *
- * \return 0 on success
- * \return -1 on error
- */
-int G_write_fp_range(const char *name, const struct FPRange *range)
-{
- int fd;
- char xdr_buf[100];
- XDR xdr_str;
-
- fd = G_open_new_misc("cell_misc", "f_range", name);
- if (fd < 0) {
- G_remove_misc("cell_misc", "f_range", name);
- G_warning(_("Unable to write range file for <%s>"),
- name);
- return -1;
- }
-
- /* if range hasn't been updated, write empty file meaning Nulls */
- if (range->first_time) {
- close(fd);
- return 0;
- }
-
- xdrmem_create(&xdr_str, xdr_buf, (u_int) XDR_DOUBLE_NBYTES * 2,
- XDR_ENCODE);
-
- if (!xdr_double(&xdr_str, (double *)&(range->min))) {
- G_remove_misc("cell_misc", "f_range", name);
- G_warning(_("Unable to write range file for <%s>"),
- name);
- return -1;
- }
-
- if (!xdr_double(&xdr_str, (double *)&(range->max))) {
- G_remove_misc("cell_misc", "f_range", name);
- G_warning(_("Unable to write range file for <%s>"),
- name);
- return -1;
- }
-
- write(fd, xdr_buf, XDR_DOUBLE_NBYTES * 2);
- close(fd);
-
- return 0;
-}
-
-/*!
- * \brief Update range structure (CELL)
- *
- * Compares the <i>cat</i> value with the minimum and maximum values
- * in the <i>range</i> structure, modifying the range if <i>cat</i>
- * extends the range.
- *
- * NULL-values must be detected and ignored.
- *
- * \param cat raster value
- * \param range pointer to Range structure which holds range info
- */
-void G_update_range(CELL cat, struct Range *range)
-{
- if (!G_is_c_null_value(&cat)) {
- if (range->first_time) {
- range->first_time = 0;
- range->min = cat;
- range->max = cat;
- return;
- }
- if (cat < range->min)
- range->min = cat;
- if (cat > range->max)
- range->max = cat;
- }
-}
-
-/*!
- * \brief Update range structure (floating-point)
- *
- * Compares the <i>cat</i> value with the minimum and maximum values
- * in the <i>range</i> structure, modifying the range if <i>cat</i>
- * extends the range.
- *
- * NULL-values must be detected and ignored.
- *
- * \param val raster value
- * \param range pointer to Range structure which holds range info
- */
-void G_update_fp_range(DCELL val, struct FPRange *range)
-{
- if (!G_is_d_null_value(&val)) {
- if (range->first_time) {
- range->first_time = 0;
- range->min = val;
- range->max = val;
- return;
- }
- if (val < range->min)
- range->min = val;
- if (val > range->max)
- range->max = val;
- }
-}
-
-/*!
- * \brief Update range structure based on raster row (CELL)
- *
- * This routine updates the <i>range</i> data just like
- * G_update_range(), but for <i>n</i> values from the <i>cell</i>
- * array.
- *
- * \param cell raster values
- * \param n number of values
- * \param range pointer to Range structure which holds range info
- */
-void G_row_update_range(const CELL *cell, int n, struct Range *range)
-{
- G__row_update_range(cell, n, range, 0);
-}
-
-/*!
- * \brief Update range structure based on raster row
- *
- * Note: for internal use only.
- *
- * \param cell raster values
- * \param n number of values
- * \param range pointer to Range structure which holds range info
- * \param ignore_zeros ignore zeros
- */
-void G__row_update_range(const CELL *cell, int n,
- struct Range *range, int ignore_zeros)
-{
- CELL cat;
-
- while (n-- > 0) {
- cat = *cell++;
- if (G_is_c_null_value(&cat) || (ignore_zeros && !cat))
- continue;
- if (range->first_time) {
- range->first_time = 0;
- range->min = cat;
- range->max = cat;
- continue;
- }
- if (cat < range->min)
- range->min = cat;
- if (cat > range->max)
- range->max = cat;
- }
-}
-
-/*!
- * \brief Update range structure based on raster row (floating-point)
- *
- * This routine updates the <i>range</i> data just like
- * G_update_range(), but for <i>n</i> values from the <i>cell</i>
- * array.
- *
- * \param cell raster values
- * \param n number of values
- * \param range pointer to Range structure which holds range info
- * \param data_type raster type (CELL, FCELL, DCELL)
- */
-void G_row_update_fp_range(const void *rast, int n,
- struct FPRange *range, RASTER_MAP_TYPE data_type)
-{
- DCELL val = 0L;
-
- while (n-- > 0) {
- switch (data_type) {
- case CELL_TYPE:
- val = (DCELL) * ((CELL *) rast);
- break;
- case FCELL_TYPE:
- val = (DCELL) * ((FCELL *) rast);
- break;
- case DCELL_TYPE:
- val = *((DCELL *) rast);
- break;
- }
-
- if (G_is_null_value(rast, data_type)) {
- rast = G_incr_void_ptr(rast, G_raster_size(data_type));
- continue;
- }
- if (range->first_time) {
- range->first_time = 0;
- range->min = val;
- range->max = val;
- }
- else {
- if (val < range->min)
- range->min = val;
- if (val > range->max)
- range->max = val;
- }
-
- rast = G_incr_void_ptr(rast, G_raster_size(data_type));
- }
-}
-
-/*!
- * \brief Initialize range structure
- *
- * Initializes the <i>range</i> structure for updates by
- * G_update_range() and G_row_update_range().
- *
- * Must set a flag in the range structure that indicates that no
- * min/max have been defined - probably a <tt>"first"</tt> boolean
- * flag.
- *
- * \param range pointer to Range structure which holds range info
- */
-void G_init_range(struct Range *range)
-{
- G_set_c_null_value(&(range->min), 1);
- G_set_c_null_value(&(range->max), 1);
- range->first_time = 1;
-}
-
-/*!
- * \brief Get range min and max
- *
- * The mininum and maximum CELL values are extracted from the
- * <i>range</i> structure.
- *
- * If the range structure has no defined min/max (first!=0) there will
- * not be a valid range. In this case the min and max returned must be
- * the NULL-value.
- *
- * \param range pointer to Range structure which holds range info
- * \param[out] min minimum value
- * \param[out] max maximum value
- */
-void G_get_range_min_max(const struct Range *range, CELL * min, CELL * max)
-{
- if (range->first_time) {
- G_set_c_null_value(min, 1);
- G_set_c_null_value(max, 1);
- }
- else {
- if (G_is_c_null_value(&(range->min)))
- G_set_c_null_value(min, 1);
- else
- *min = range->min;
-
- if (G_is_c_null_value(&(range->max)))
- G_set_c_null_value(max, 1);
- else
- *max = range->max;
- }
-}
-
-/*!
- * \brief Initialize fp range
- *
- * Must set a flag in the range structure that indicates that no
- * min/max have been defined - probably a <tt>"first"</tt> boolean
- * flag.
- *
- * \param range pointer to FPRange which holds fp range info
- */
-void G_init_fp_range(struct FPRange *range)
-{
- G_set_d_null_value(&(range->min), 1);
- G_set_d_null_value(&(range->max), 1);
- range->first_time = 1;
-}
-
-/*!
- * \brief Get minumum and maximum value from fp range
- *
- * Extract the min/max from the range structure <i>range</i>. If the
- * range structure has no defined min/max (first!=0) there will not be
- * a valid range. In this case the min and max returned must be the
- * NULL-value.
- *
- * \param range pointer to FPRange which holds fp range info
- * \param[out] min minimum value
- * \param[out] max maximum value
- */
-void G_get_fp_range_min_max(const struct FPRange *range,
- DCELL *min, DCELL *max)
-{
- if (range->first_time) {
- G_set_d_null_value(min, 1);
- G_set_d_null_value(max, 1);
- }
- else {
- if (G_is_d_null_value(&(range->min)))
- G_set_d_null_value(min, 1);
- else
- *min = range->min;
-
- if (G_is_d_null_value(&(range->max)))
- G_set_d_null_value(max, 1);
- else
- *max = range->max;
- }
-}
Deleted: grass/trunk/lib/gis/raster.c
===================================================================
--- grass/trunk/lib/gis/raster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,320 +0,0 @@
-/*!
- * \file gis/raster.c
- *
- * \brief GIS Library - Raster cell value routines.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <stdlib.h>
-#include <grass/gis.h>
-
-/*!
- * \brief Advance void pointer
- *
- * Advances void pointer by <i>size</i> bytes. Returns new pointer
- * value.
- *
- * Useful in raster row processing loops, substitutes
- *
- \code
- CELL *cell;
- cell += n;
- \endcode
- *
- * Now
- \code
- rast = G_incr_void_ptr(rast, G_raster_size(data_type))
- \endcode
- *
- * (where rast is void* and <i>data_type</i> is RASTER_MAP_TYPE can be
- * used instead of rast++.)
- *
- * Very useful to generalize the row processing - loop i.e.
- * \code
- * void * buf_ptr += G_raster_size(data_type)
- * \endcode
- *
- * \param ptr pointer
- * \param size buffer size
- *
- * \return pointer to the data
- */
-void *G_incr_void_ptr(const void *ptr, const size_t size)
-{
- /* assuming that the size of unsigned char is 1 */
- return (void *)((const unsigned char *)ptr + size);
-}
-
-/*!
- * \brief Compares raster values.
- *
- * \param v1,v2 values to be compared
- * \param data_type raster type (CELL, FCELL, DCELL)
- *
- * \return 1 if p > q or only q is null value
- * \return -1 if p < q or only p is null value
- * \return 0 if p == q or p==q==null value
- */
-int G_raster_cmp(const void *v1, const void *v2, RASTER_MAP_TYPE data_type)
-{
- if (G_is_null_value(v1, data_type)) {
- if (G_is_null_value(v2, data_type))
- return 0;
- else
- return -1;
- }
- else if (G_is_null_value(v2, data_type))
- return 1;
-
- switch (data_type) {
- case CELL_TYPE:
- if (*((const CELL *)v1) > *((const CELL *)v2))
- return 1;
- else if (*((const CELL *)v1) == *((const CELL *)v2))
- return 0;
- else
- return -1;
- case FCELL_TYPE:
- if (*((const FCELL *)v1) > *((const FCELL *)v2))
- return 1;
- else if (*((const FCELL *)v1) == *((const FCELL *)v2))
- return 0;
- else
- return -1;
- case DCELL_TYPE:
- if (*((const DCELL *)v1) > *((const DCELL *)v2))
- return 1;
- else if (*((const DCELL *)v1) == *((const DCELL *)v2))
- return 0;
- else
- return -1;
- }
-
- return 0;
-}
-
-/*!
- * \brief Copies raster values.
- *
- * If v2 is null value, sets v2 to null value.
- *
- * \param v1, v2 raster values
- * \param n ?
- * \param data_type raster type (CELL, FCELL, DCELL)
- */
-void G_raster_cpy(void *v1, const void *v2, int n, RASTER_MAP_TYPE data_type)
-{
- G_copy(v1, v2, n * G_raster_size(data_type));
-}
-
-/*!
- * \brief Places a CELL raster value
- *
- * If G_is_c_null_value() is true, sets p to null value. Converts CELL
- * val to data_type (type of p) and stores result in p. Used for
- * assigning CELL values to raster cells of any type.
- *
- * \param rast pointer to raster cell value
- * \param cval value to set
- * \param data_type raster type (CELL, FCELL, DCELL)
- */
-void G_set_raster_value_c(void *rast, CELL cval, RASTER_MAP_TYPE data_type)
-{
- CELL c;
-
- c = cval;
- if (G_is_c_null_value(&c)) {
- G_set_null_value(rast, 1, data_type);
- return;
- }
- switch (data_type) {
- case CELL_TYPE:
- *((CELL *) rast) = cval;
- break;
- case FCELL_TYPE:
- *((FCELL *) rast) = (FCELL) cval;
- break;
- case DCELL_TYPE:
- *((DCELL *) rast) = (DCELL) cval;
- break;
- }
-}
-
-/*!
- * \brief Places a FCELL raster value
- *
- * If G_is_f_null_value() is true, sets p to null value. Converts
- * FCELL val to data_type (type of p) and stores result in p. Used for
- * assigning FCELL values to raster cells of any type.
- *
- * \param rast pointer to raster cell value
- * \param fval value to set
- * \param data_type raster type (CELL, FCELL, DCELL)
- */
-void G_set_raster_value_f(void *rast, FCELL fval, RASTER_MAP_TYPE data_type)
-{
- FCELL f;
-
- f = fval;
- if (G_is_f_null_value(&f)) {
- G_set_null_value(rast, 1, data_type);
- return;
- }
- switch (data_type) {
- case CELL_TYPE:
- *((CELL *) rast) = (CELL) fval;
- break;
- case FCELL_TYPE:
- *((FCELL *) rast) = fval;
- break;
- case DCELL_TYPE:
- *((DCELL *) rast) = (DCELL) fval;
- break;
- }
-}
-
-
-/*!
- * \brief Places a DCELL raster value
- *
- * If G_is_d_null_value() is true, sets p to null value. Converts
- * DCELL val to data_type (type of p) and stores result in p. Used for
- * assigning DCELL values to raster cells of any type.
- *
- * \param rast pointer to raster cell value
- * \param fval value to set
- * \param data_type raster type (CELL, FCELL, DCELL)
- */
-void G_set_raster_value_d(void *rast, DCELL dval, RASTER_MAP_TYPE data_type)
-{
- DCELL d;
-
- d = dval;
- if (G_is_d_null_value(&d)) {
- G_set_null_value(rast, 1, data_type);
- return;
- }
- switch (data_type) {
- case CELL_TYPE:
- *((CELL *) rast) = (CELL) dval;
- break;
- case FCELL_TYPE:
- *((FCELL *) rast) = (FCELL) dval;
- break;
- case DCELL_TYPE:
- *((DCELL *) rast) = dval;
- break;
- }
-}
-
-/*!
- * \brief Retrieves the value of give type from pointer p
- *
- * Retrieves the value of type data_type from pointer p, converts it
- * to CELL type and returns the result. If null value is stored in p,
- * returns CELL null value.
- *
- * Used for retrieving CELL values from raster cells of any type.
- *
- * Note: when data_type != CELL_TYPE, no quantization is used, only
- * type conversion.
- *
- * \param rast pointer to raster cell value
- * \param data_type raster type (CELL, FCELL, DCELL)
- *
- * \return raster value
- */
-CELL G_get_raster_value_c(const void *rast, RASTER_MAP_TYPE data_type)
-{
- CELL c;
-
- if (G_is_null_value(rast, data_type)) {
- G_set_c_null_value(&c, 1);
- return c;
- }
- switch (data_type) {
- case CELL_TYPE:
- return *((const CELL *)rast);
- case FCELL_TYPE:
- return (CELL) *((const FCELL *)rast);
- case DCELL_TYPE:
- return (CELL) *((const DCELL *)rast);
- }
-
- return 0;
-}
-
-/*!
- * \brief Retrieves the value of given raster type from pointer p (FCELL)
- *
- * Retrieves the value of type data_type from pointer p, converts it
- * to FCELL type and returns the result. If null value is stored in p,
- * returns FCELL null value.
- *
- * Used for retrieving FCELL values from raster cells of any type.
- *
- * \param rast pointer to raster cell value
- * \param data_type raster type (CELL, FCELL, DCELL)
- *
- * \return raster value
- */
-FCELL G_get_raster_value_f(const void *rast, RASTER_MAP_TYPE data_type)
-{
- FCELL f;
-
- if (G_is_null_value(rast, data_type)) {
- G_set_f_null_value(&f, 1);
- return f;
- }
- switch (data_type) {
- case CELL_TYPE:
- return (FCELL) * ((const CELL *)rast);
- case FCELL_TYPE:
- return *((const FCELL *)rast);
- case DCELL_TYPE:
- return (FCELL) * ((const DCELL *)rast);
- }
-
- return 0;
-}
-
-
-/*!
- * \brief Retrieves the value of given type from pointer p (DCELL)
- *
- * Retrieves the value of type data_type from pointer p, converts it
- * to DCELL type and returns the result. If null value is stored in p,
- * returns DCELL null value.
-
- * Used for retrieving DCELL values from raster cells of any type.
- *
- * \param rast pointer to raster cell value
- * \param data_type raster type (CELL, FCELL, DCELL)
- *
- * \return raster value
- */
-DCELL G_get_raster_value_d(const void *rast, RASTER_MAP_TYPE data_type)
-{
- DCELL d;
-
- if (G_is_null_value(rast, data_type)) {
- G_set_d_null_value(&d, 1);
- return d;
- }
- switch (data_type) {
- case CELL_TYPE:
- return (DCELL) * ((const CELL *)rast);
- case FCELL_TYPE:
- return (DCELL) * ((const FCELL *)rast);
- case DCELL_TYPE:
- return *((const DCELL *)rast);
- }
-
- return 0;
-}
Deleted: grass/trunk/lib/gis/raster_metadata.c
===================================================================
--- grass/trunk/lib/gis/raster_metadata.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/raster_metadata.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,152 +0,0 @@
-/* raster_metadata.c
- *
- * PURPOSE: functions to read and write raster "units" and "vertical datum"
- * meta-data info
- *
- * Copyright (C) 2007 by Hamish Bowman, and the GRASS Development Team
- * Author(s): Hamish Bowman, Dunedin, New Zealand
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- */
-#include <stdio.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-
-/*!
- * \brief Get a raster map's units metadata string
- *
- * Read the raster's units metadata file and put string in str
- *
- * \param name
- * \param mapset
- * \param *str string to be populated with data
- * \return 0 on success
- * \return -1, EOF (fclose() result) on error
- */
-int G_read_raster_units(const char *name, const char *mapset, char *str)
-{
- return G__raster_misc_read_line("units", name, mapset, str);
-}
-
-
-/*!
- * \brief Write a string to a raster map's units metadata file
- *
- * Map must exist in the current mapset.
- *
- * \param name
- * \param *str string containing data to be written
- * \return 0 on success
- * \return -1, EOF (fclose() result) on error
- */
-int G_write_raster_units(const char *name, const char *str)
-{
- return G__raster_misc_write_line("units", name, str);
-}
-
-
-/*!
- * \brief Get a raster map's vertical datum metadata string
- *
- * Read the raster's vertical datum metadata file and put string in str
- *
- * \param name
- * \param mapset
- * \param *str string to be populated with data
- * \return 0 on success
- * \return -1, EOF (fclose() result) on error
- */
-int G_read_raster_vdatum(const char *name, const char *mapset, char *str)
-{
- return G__raster_misc_read_line("vertical_datum", name, mapset, str);
-}
-
-
-/*!
- * \brief Write a string into a raster's vertical datum metadata file
- *
- * Map must exist in the current mapset.
- *
- * \param name
- * \param *str string containing data to be written
- * \return 0 on success
- * \return -1, EOF (fclose() result) on error
- */
-int G_write_raster_vdatum(const char *name, const char *str)
-{
- return G__raster_misc_write_line("vertical_datum", name, str);
-}
-
-
-
-/*!
- * \brief Read the first line of a file in cell_misc/
- *
- * Read the first line of data from a cell_misc/ meta-data file.
- *
- * \param element metadata component filename
- * \param name
- * \param mapset
- * \param *str string to be populated with data
- * \return 0 on success
- * \return -1, EOF (fclose() result) on error
- */
-int G__raster_misc_read_line(const char *elem, const char *name,
- const char *mapset, char *str)
-{
- FILE *fd;
- char buff[GNAME_MAX];
-
- buff[0] = '\0';
-
- if (G_find_file2_misc("cell_misc", elem, name, mapset) == NULL)
- return -1;
-
- fd = G_fopen_old_misc("cell_misc", elem, name, mapset);
- if (!fd) {
- G_warning(_("Can't read %s for [%s in %s]"), elem, name, mapset);
- return -1;
- }
- if (G_getl2(buff, sizeof(buff) - 1, fd) == 0) {
- /* file is empty */
- return fclose(fd);
- }
-
- strcpy(str, buff);
-
- return fclose(fd);
-}
-
-
-/*!
- * \brief Write a line to a raster map metadata file
- *
- * Write (including overwrite) a string into a raster map's metadata file
- * found in in cell_misc/ in the current mapset.
- *
- * \param element metadata component filename
- * \param name
- * \param *str string containing data to be written
- * \return 0 on success
- * \return -1, EOF (fclose() result) on error
- */
-int G__raster_misc_write_line(const char *elem, const char *name,
- const char *str)
-{
- FILE *fd;
-
- fd = G_fopen_new_misc("cell_misc", elem, name);
- if (fd == NULL) {
- G_warning(_("Can't create %s metadata file for [%s in %s]"),
- elem, name, G_mapset());
- return -1;
- }
-
- fprintf(fd, "%s", str);
-
- return fclose(fd);
-}
Deleted: grass/trunk/lib/gis/rd_cellhd.c
===================================================================
--- grass/trunk/lib/gis/rd_cellhd.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/rd_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,433 +0,0 @@
-/* read cell header, or window.
- returns NULL if ok, error message otherwise
- note: the error message can be freed using G_free ().
- */
-
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include <string.h>
-
-#define ERROR(x,line) return error(x,line)
-static int scan_item(const char *, char *, char *);
-static int scan_int(const char *, int *);
-static double scan_double(const char *, double *);
-static char *error(const char *, int);
-
-#define F_PROJ 1
-#define F_ZONE 2
-#define F_NORTH 3
-#define F_SOUTH 4
-#define F_EAST 5
-#define F_WEST 6
-#define F_EWRES 7
-#define F_NSRES 8
-#define F_FORMAT 9
-#define F_COMP 10
-#define F_COLS 11
-#define F_ROWS 12
-
-#define F_EWRES3 13
-#define F_NSRES3 14
-#define F_COLS3 15
-#define F_ROWS3 16
-#define F_TOP 17
-#define F_BOTTOM 18
-#define F_TBRES 19
-#define F_DEPTHS 20
-
-#define SET(x) flags|=(1<<x)
-#define TEST(x) (flags&(1<<x))
-
-char *G__read_Cell_head_array(char **array,
- struct Cell_head *cellhd, int is_cellhd);
-
-char *G__read_Cell_head(FILE * fd, struct Cell_head *cellhd, int is_cellhd)
-{
- int count;
- char *result, **array;
- char buf[1024];
-
- G_debug(2, "G__read_Cell_head");
-
- /* Count lines */
- count = 0;
- fseek(fd, 0L, 0);
- while (G_getl(buf, sizeof(buf), fd))
- count++;
-
- array = (char **)G_calloc(count + 1, sizeof(char **));
-
- count = 0;
- fseek(fd, 0L, 0);
- while (G_getl(buf, sizeof(buf), fd)) {
- array[count] = G_store(buf);
- count++;
- }
-
- result = G__read_Cell_head_array(array, cellhd, is_cellhd);
-
- count = 0;
- while (array[count]) {
- G_free(array[count]);
- count++;
- }
- G_free(array);
-
- return result;
-}
-
-/* Read window from NULL terminated array of strings */
-char *G__read_Cell_head_array(char **array,
- struct Cell_head *cellhd, int is_cellhd)
-{
- char *buf;
- char label[200];
- char value[200];
- int i, line;
- int flags;
- const char *err;
-
- G_debug(2, "G__read_Cell_head_array");
-
- flags = 0;
-
- /* initialize the cell header */
- cellhd->format = 0;
- cellhd->rows = 0;
- cellhd->rows3 = 0;
- cellhd->cols = 0;
- cellhd->cols3 = 0;
- cellhd->depths = 1;
- cellhd->proj = -1;
- cellhd->zone = -1;
- cellhd->compressed = -1;
- cellhd->ew_res = 0.0;
- cellhd->ew_res3 = 1.0;
- cellhd->ns_res = 0.0;
- cellhd->ns_res3 = 1.0;
- cellhd->tb_res = 1.0;
- cellhd->north = 0.0;
- cellhd->south = 0.0;
- cellhd->east = 0.0;
- cellhd->west = 0.0;
- cellhd->top = 1.0;
- cellhd->bottom = 0.0;
-
- /* determine projection, zone first */
-
- i = 0;
- for (line = 1; (buf = array[i++]); line++) {
- if (TEST(F_PROJ) && TEST(F_ZONE))
- break;
-
- switch (scan_item(buf, label, value)) {
- case -1:
- ERROR(buf, line);
- case 0:
- continue;
- case 1:
- break;
- }
- if (strncmp(label, "proj", 4) == 0) {
- if (TEST(F_PROJ))
- ERROR(_("duplicate projection field"), line);
-
- if (!scan_int(value, &cellhd->proj))
- ERROR(buf, line);
-
- SET(F_PROJ);
- continue;
- }
- if (strncmp(label, "zone", 4) == 0) {
- if (TEST(F_ZONE))
- ERROR(_("duplicate zone field"), line);
-
- if (!scan_int(value, &cellhd->zone))
- ERROR(buf, line);
-
- SET(F_ZONE);
- continue;
- }
- }
- if (!TEST(F_PROJ))
- ERROR(_("projection field missing"), 0);
- if (!TEST(F_ZONE))
- ERROR(_("zone field missing"), 0);
-
- /* read the other info */
- i = 0;
- for (line = 1; (buf = array[i++]); line++) {
- G_debug(3, "region item: %s", buf);
- switch (scan_item(buf, label, value)) {
- case -1:
- ERROR(buf, line);
- case 0:
- continue;
- case 1:
- break;
- }
-
- if (strncmp(label, "proj", 4) == 0)
- continue;
- if (strncmp(label, "zone", 4) == 0)
- continue;
-
- if (strncmp(label, "nort", 4) == 0) {
- if (TEST(F_NORTH))
- ERROR(_("duplicate north field"), line);
- if (!G_scan_northing(value, &cellhd->north, cellhd->proj))
- ERROR(buf, line);
- SET(F_NORTH);
- continue;
- }
- if (strncmp(label, "sout", 4) == 0) {
- if (TEST(F_SOUTH))
- ERROR(_("duplicate south field"), line);
- if (!G_scan_northing(value, &cellhd->south, cellhd->proj))
- ERROR(buf, line);
- SET(F_SOUTH);
- continue;
- }
- if (strncmp(label, "east", 4) == 0) {
- if (TEST(F_EAST))
- ERROR(_("duplicate east field"), line);
- if (!G_scan_easting(value, &cellhd->east, cellhd->proj))
- ERROR(buf, line);
- SET(F_EAST);
- continue;
- }
- if (strncmp(label, "west", 4) == 0) {
- if (TEST(F_WEST))
- ERROR(_("duplicate west field"), line);
- if (!G_scan_easting(value, &cellhd->west, cellhd->proj))
- ERROR(buf, line);
- SET(F_WEST);
- continue;
- }
- if (strncmp(label, "top", 3) == 0) {
- if (TEST(F_TOP))
- ERROR(_("duplicate top field"), line);
- if (!scan_double(value, &cellhd->top))
- ERROR(buf, line);
- SET(F_TOP);
- continue;
- }
- if (strncmp(label, "bottom", 6) == 0) {
- if (TEST(F_BOTTOM))
- ERROR(_("duplicate bottom field"), line);
- if (!scan_double(value, &cellhd->bottom))
- ERROR(buf, line);
- SET(F_BOTTOM);
- continue;
- }
- if (strncmp(label, "e-w ", 4) == 0 && strlen(label) == 9) {
- if (TEST(F_EWRES))
- ERROR(_("duplicate e-w resolution field"), line);
- if (!G_scan_resolution(value, &cellhd->ew_res, cellhd->proj))
- ERROR(buf, line);
- if (cellhd->ew_res <= 0.0)
- ERROR(buf, line);
- SET(F_EWRES);
- continue;
- }
- if (strncmp(label, "e-w resol3", 10) == 0) {
- if (TEST(F_EWRES3))
- ERROR(_("duplicate 3D e-w resolution field"), line);
- if (!G_scan_resolution(value, &cellhd->ew_res3, cellhd->proj))
- ERROR(buf, line);
- if (cellhd->ew_res3 <= 0.0)
- ERROR(buf, line);
- SET(F_EWRES3);
- continue;
- }
- if (strncmp(label, "n-s ", 4) == 0 && strlen(label) == 9) {
- if (TEST(F_NSRES))
- ERROR(_("duplicate n-s resolution field"), line);
- if (!G_scan_resolution(value, &cellhd->ns_res, cellhd->proj))
- ERROR(buf, line);
- if (cellhd->ns_res <= 0.0)
- ERROR(buf, line);
- SET(F_NSRES);
- continue;
- }
- if (strncmp(label, "n-s resol3", 10) == 0) {
- if (TEST(F_NSRES3))
- ERROR(_("duplicate 3D n-s resolution field"), line);
- if (!G_scan_resolution(value, &cellhd->ns_res3, cellhd->proj))
- ERROR(buf, line);
- if (cellhd->ns_res3 <= 0.0)
- ERROR(buf, line);
- SET(F_NSRES3);
- continue;
- }
- if (strncmp(label, "t-b ", 4) == 0) {
- if (TEST(F_TBRES))
- ERROR(_("duplicate t-b resolution field"), line);
- if (!scan_double(value, &cellhd->tb_res))
- ERROR(buf, line);
- if (cellhd->tb_res <= 0.0)
- ERROR(buf, line);
- SET(F_TBRES);
- continue;
- }
- if (strncmp(label, "rows", 4) == 0 && strlen(label) == 4) {
- if (TEST(F_ROWS))
- ERROR(_("duplicate rows field"), line);
- if (!scan_int(value, &cellhd->rows))
- ERROR(buf, line);
- if (cellhd->rows <= 0)
- ERROR(buf, line);
- SET(F_ROWS);
- continue;
- }
- if (strncmp(label, "rows3", 5) == 0) {
- if (TEST(F_ROWS3))
- ERROR(_("duplicate 3D rows field"), line);
- if (!scan_int(value, &cellhd->rows3))
- ERROR(buf, line);
- if (cellhd->rows3 <= 0)
- ERROR(buf, line);
- SET(F_ROWS3);
- continue;
- }
- if (strncmp(label, "cols", 4) == 0 && strlen(label) == 4) {
- if (TEST(F_COLS))
- ERROR(_("duplicate cols field"), line);
- if (!scan_int(value, &cellhd->cols))
- ERROR(buf, line);
- if (cellhd->cols <= 0)
- ERROR(buf, line);
- SET(F_COLS);
- continue;
- }
- if (strncmp(label, "cols3", 5) == 0) {
- if (TEST(F_COLS3))
- ERROR(_("duplicate 3D cols field"), line);
- if (!scan_int(value, &cellhd->cols3))
- ERROR(buf, line);
- if (cellhd->cols3 <= 0)
- ERROR(buf, line);
- SET(F_COLS3);
- continue;
- }
- if (strncmp(label, "depths", 6) == 0) {
- if (TEST(F_DEPTHS))
- ERROR(_("duplicate depths field"), line);
- if (!scan_int(value, &cellhd->depths))
- ERROR(buf, line);
- if (cellhd->depths <= 0)
- ERROR(buf, line);
- SET(F_DEPTHS);
- continue;
- }
- if (strncmp(label, "form", 4) == 0) {
- if (TEST(F_FORMAT))
- ERROR(_("duplicate format field"), line);
- if (!scan_int(value, &cellhd->format))
- ERROR(buf, line);
- SET(F_FORMAT);
- continue;
- }
- if (strncmp(label, "comp", 4) == 0) {
- if (TEST(F_COMP))
- ERROR(_("duplicate compressed field"), line);
- if (!scan_int(value, &cellhd->compressed))
- ERROR(buf, line);
- SET(F_COMP);
- continue;
- }
- ERROR(buf, line);
- }
-
- /* check some of the fields */
- if (!TEST(F_NORTH))
- ERROR(_("north field missing"), 0);
- if (!TEST(F_SOUTH))
- ERROR(_("south field missing"), 0);
- if (!TEST(F_WEST))
- ERROR(_("west field missing"), 0);
- if (!TEST(F_EAST))
- ERROR(_("east field missing"), 0);
- if (!TEST(F_EWRES) && !TEST(F_COLS))
- ERROR(_("cols field missing"), 0);
- if (!TEST(F_NSRES) && !TEST(F_ROWS))
- ERROR(_("rows field missing"), 0);
- /* This next stmt is commented out to allow wr_cellhd.c to write
- * headers that will be readable by GRASS 3.1
- if ((TEST(F_ROWS) && TEST(F_NSRES))
- || (TEST(F_COLS) && TEST(F_EWRES)))
- ERROR ("row/col and resolution information can not both appear ",0);
- */
-
- /* 3D defined? */
- if (TEST(F_EWRES3) || TEST(F_NSRES3) || TEST(F_COLS3) || TEST(F_ROWS3)) {
- if (!TEST(F_EWRES3))
- ERROR(_("ewres3 field missing"), 0);
- if (!TEST(F_NSRES3))
- ERROR(_("nsres3 field missing"), 0);
- if (!TEST(F_COLS3))
- ERROR(_("cols3 field missing"), 0);
- if (!TEST(F_ROWS3))
- ERROR(_("rows3 field missing"), 0);
- }
- else { /* use 2D */
- cellhd->ew_res3 = cellhd->ew_res;
- cellhd->ns_res3 = cellhd->ns_res;
- cellhd->cols3 = cellhd->cols;
- cellhd->rows3 = cellhd->rows;
- }
-
- /* Adjust and complete the cell header */
- if ((err = G_adjust_Cell_head(cellhd, TEST(F_ROWS), TEST(F_COLS))))
- ERROR(err, 0);
-
-
- return NULL;
-}
-
-static int scan_item(const char *buf, char *label, char *value)
-{
- /* skip blank lines */
- if (sscanf(buf, "%1s", label) != 1)
- return 0;
-
- /* skip comment lines */
- if (*label == '#')
- return 0;
-
- /* must be label: value */
- if (sscanf(buf, "%[^:]:%[^\n]", label, value) != 2)
- return -1;
-
- G_strip(label);
- G_strip(value);
- return 1;
-}
-
-static int scan_int(const char *buf, int *n)
-{
- char dummy[3];
-
- *dummy = 0;
- return (sscanf(buf, "%d%1s", n, dummy) == 1 && *dummy == 0);
-}
-
-static double scan_double(const char *buf, double *n)
-{
- char dummy[3];
-
- *dummy = 0;
- return (sscanf(buf, "%lf%1s", n, dummy) == 1 && *dummy == 0);
-}
-
-static char *error(const char *msg, int line)
-{
- char buf[1024];
-
- if (line)
- sprintf(buf, _("line %d: <%s>"), line, msg);
- else
- sprintf(buf, "<%s>", msg);
-
- return G_store(buf);
-}
Deleted: grass/trunk/lib/gis/reclass.c
===================================================================
--- grass/trunk/lib/gis/reclass.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/reclass.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,403 +0,0 @@
-/*!
- * \file gis/reclass.c
- *
- * \brief GIS Library - Check if raster map is reclassified
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-static const char NULL_STRING[] = "null";
-static int reclass_type(FILE *, char **, char **);
-static FILE *fopen_cellhd_old(const char *, const char *);
-static FILE *fopen_cellhd_new(const char *);
-static int get_reclass_table(FILE *, struct Reclass *);
-
-/*!
- * \brief Check if raster map is reclassified
- *
- * This function determines if the raster map <i>name</i> in
- * <i>mapset</i> is a reclass file. If it is, then the name and mapset
- * of the referenced raster map are copied into the <i>r_name</i> and
- * <i>r_mapset</i> buffers.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] r_name name of reference map
- * \param[out] r_mapset mapset where reference map lives
- *
- * \returns 1 if it is a reclass file
- * \return 0 if it is not
- * \return -1 if there was a problem reading the raster header
- */
-int G_is_reclass(const char *name, const char *mapset, char *rname,
- char *rmapset)
-{
- FILE *fd;
- int type;
-
- fd = fopen_cellhd_old(name, mapset);
- if (fd == NULL)
- return -1;
-
- type = reclass_type(fd, &rname, &rmapset);
- fclose(fd);
- if (type < 0)
- return -1;
- else
- return type != 0;
-}
-
-/*!
- * \brief Get child reclass maps list
- *
- * This function generates a child reclass maps list from the
- * cell_misc/reclassed_to file which stores this list. The
- * cell_misc/reclassed_to file is written by G_put_reclass().
- * G_is_reclassed_to() is used by <tt>g.rename</tt>, <tt>g.remove</tt>
- * and <tt>r.reclass</tt> to prevent accidentally deleting the parent
- * map of a reclassed raster map.
- *
- * \param name map name
- * \param mapset mapset name
- * \param[out] nrmaps number of reference maps
- * \param[out] rmaps array of names of reference maps
- *
- * \return number of reference maps
- * \return -1 on error
- */
-int G_is_reclassed_to(const char *name, const char *mapset, int *nrmaps,
- char ***rmaps)
-{
- FILE *fd;
- int i, j, k, l;
- char buf2[256], buf3[256];
-
- fd = G_fopen_old_misc("cell_misc", "reclassed_to", name, mapset);
-
- if (fd == NULL) {
- return -1;
- }
-
- if (rmaps)
- *rmaps = NULL;
- for (i = 0; !feof(fd) && fgets(buf2, 255, fd);) {
- l = strlen(buf2);
- for (j = 0, k = 0; j < l; j++) {
- if (buf2[j] == '#' ||
- ((buf2[j] == ' ' || buf2[j] == '\t' || buf2[j] == '\n') && k))
- break;
- else if (buf2[j] != ' ' && buf2[j] != '\t')
- buf3[k++] = buf2[j];
- }
-
- if (k) {
- buf3[k] = 0;
- i++;
- if (rmaps) {
- *rmaps = (char **)G_realloc(*rmaps, i * sizeof(char *));
- (*rmaps)[i - 1] = (char *)G_malloc(k + 1);
- strncpy((*rmaps)[i - 1], buf3, k);
- (*rmaps)[i - 1][k] = 0;
- }
- }
- }
-
- if (nrmaps)
- *nrmaps = i;
-
- if (i && rmaps) {
- i++;
- *rmaps = (char **)G_realloc(*rmaps, i * sizeof(char *));
- (*rmaps)[i - 1] = NULL;
- }
-
- return i;
-}
-
-/*!
- \brief Get reclass
-
- \param name map name
- \param mapset mapset name
- \param[out] reclass pointer to Reclass structure
-
- \return -1 on error
- \return type code
-*/
-int G_get_reclass(const char *name, const char *mapset,
- struct Reclass *reclass)
-{
- FILE *fd;
- int stat;
-
- fd = fopen_cellhd_old(name, mapset);
- if (fd == NULL)
- return -1;
- reclass->name = NULL;
- reclass->mapset = NULL;
- reclass->type = reclass_type(fd, &reclass->name, &reclass->mapset);
- if (reclass->type <= 0) {
- fclose(fd);
- return reclass->type;
- }
-
- switch (reclass->type) {
- case RECLASS_TABLE:
- stat = get_reclass_table(fd, reclass);
- break;
- default:
- stat = -1;
- }
-
- fclose(fd);
- if (stat < 0) {
- if (stat == -2)
- G_warning(_("Too many reclass categories for <%s@%s>"),
- name, mapset);
- else
- G_warning(_("Illegal reclass format in header file for <%s@%s>"),
- name, mapset);
- stat = -1;
- }
- return stat;
-}
-
-/*!
- \brief Free Reclass structure
-
- \param reclass pointer to Reclass structure
-*/
-void G_free_reclass(struct Reclass *reclass)
-{
- switch (reclass->type) {
- case RECLASS_TABLE:
- if (reclass->num > 0)
- G_free(reclass->table);
- reclass->num = 0;
- if (reclass->name)
- G_free(reclass->name);
- if (reclass->mapset)
- G_free(reclass->mapset);
- reclass->name = NULL;
- reclass->mapset = NULL;
- break;
- default:
- break;
- }
-}
-
-static int reclass_type(FILE * fd, char **rname, char **rmapset)
-{
- char buf[128];
- char label[128], arg[128];
- int i;
- int type;
-
- /* Check to see if this is a reclass file */
- if (fgets(buf, sizeof(buf), fd) == NULL)
- return 0;
- if (strncmp(buf, "reclas", 6))
- return 0;
- /* later may add other types of reclass */
- type = RECLASS_TABLE;
-
- /* Read the mapset and file name of the REAL cell file */
- if (*rname)
- **rname = '\0';
- if (*rmapset)
- **rmapset = '\0';
- for (i = 0; i < 2; i++) {
- if (fgets(buf, sizeof buf, fd) == NULL)
- return -1;
- if (sscanf(buf, "%[^:]:%s", label, arg) != 2)
- return -1;
- if (strncmp(label, "maps", 4) == 0) {
- if (*rmapset)
- strcpy(*rmapset, arg);
- else
- *rmapset = G_store(arg);
- }
- else if (strncmp(label, "name", 4) == 0) {
- if (*rname)
- strcpy(*rname, arg);
- else
- *rname = G_store(arg);
- }
- else
- return -1;
- }
- if (**rmapset && **rname)
- return type;
- else
- return -1;
-}
-
-static FILE *fopen_cellhd_old(const char *name, const char *mapset)
-{
- return G_fopen_old("cellhd", name, mapset);
-}
-
-/*!
- \brief Put reclass
-
- \param name map name
- \param reclass pointer to Reclass structure
-
- \return -1 on error
- \return 1 on success
-*/
-int G_put_reclass(const char *name, const struct Reclass *reclass)
-{
- FILE *fd;
- long min, max;
- int i;
- char buf1[GPATH_MAX], buf2[GNAME_MAX], buf3[GNAME_MAX], *p;
-
- switch (reclass->type) {
- case RECLASS_TABLE:
- if (reclass->min > reclass->max || reclass->num <= 0) {
- G_fatal_error(_("Illegal reclass request"));
- return -1;
- }
- break;
- default:
- G_fatal_error(_("Illegal reclass type"));
- return -1;
- }
-
- fd = fopen_cellhd_new(name);
- if (fd == NULL) {
- G_warning(_("Unable to create header file for <%s@%s>"),
- name, G_mapset());
- return -1;
- }
-
- fprintf(fd, "reclass\n");
- fprintf(fd, "name: %s\n", reclass->name);
- fprintf(fd, "mapset: %s\n", reclass->mapset);
-
- /* find first non-null entry */
- for (min = 0; min < reclass->num; min++)
- if (!G_is_c_null_value(&reclass->table[min]))
- break;
- /* find last non-zero entry */
- for (max = reclass->num - 1; max >= 0; max--)
- if (!G_is_c_null_value(&reclass->table[max]))
- break;
-
- /*
- * if the resultant table is empty, write out a dummy table
- * else write out the table
- * first entry is #min
- * rest are translations for cat min+i
- */
- if (min > max)
- fprintf(fd, "0\n");
- else {
- fprintf(fd, "#%ld\n", (long)reclass->min + min);
- while (min <= max) {
- if (G_is_c_null_value(&reclass->table[min]))
- fprintf(fd, "%s\n", NULL_STRING);
- else
- fprintf(fd, "%ld\n", (long)reclass->table[min]);
- min++;
- }
- }
- fclose(fd);
-
- strcpy(buf2, reclass->name);
- if ((p = strchr(buf2, '@')))
- *p = 0;
-
- G__file_name_misc(buf1, "cell_misc", "reclassed_to", reclass->name,
- reclass->mapset);
-
- fd = fopen(buf1, "a+");
- if (fd == NULL) {
-#if 0
- G_warning(_("Unable to create dependency file in <%s@%s>"),
- buf2, reclass->mapset);
-#endif
- return 1;
- }
-
- fseek(fd, 0L, SEEK_SET);
-
- sprintf(buf2, "%s@%s\n", name, G_mapset());
- for (i = 0; !feof(fd) && fgets(buf3, 255, fd);) {
- if (!(strcmp(buf2, buf3))) {
- i = 1;
- break;
- }
- }
-
- if (!i) {
- fprintf(fd, "%s@%s\n", name, G_mapset());
- }
-
- fclose(fd);
-
- return 1;
-}
-
-static FILE *fopen_cellhd_new(const char *name)
-{
- return G_fopen_new("cellhd", name);
-}
-
-static int get_reclass_table(FILE * fd, struct Reclass *reclass)
-{
- char buf[128];
- int n;
- int first, null_str_size;
- CELL cat;
- long len;
-
- /*
- * allocate the table, expanding as each entry is read
- * note that G_realloc() will become G_malloc() if ptr in
- * NULL
- */
- reclass->min = 0;
- reclass->table = NULL;
- null_str_size = strlen(NULL_STRING);
- n = 0;
- first = 1;
- while (fgets(buf, sizeof buf, fd)) {
- if (first) {
- first = 0;
- if (sscanf(buf, "#%d", &cat) == 1) {
- reclass->min = cat;
- continue;
- }
- }
- if (strncmp(buf, NULL_STRING, null_str_size) == 0)
- G_set_c_null_value(&cat, 1);
- else {
- if (sscanf(buf, "%d", &cat) != 1)
- return -1;
- }
- n++;
- len = (long)n *sizeof(CELL);
-
- if (len != (int)len) { /* check for int overflow */
- if (reclass->table != NULL)
- G_free(reclass->table);
- return -2;
- }
- reclass->table = (CELL *) G_realloc((char *)reclass->table, (int)len);
- reclass->table[n - 1] = cat;
- }
- reclass->max = reclass->min + n - 1;
- reclass->num = n;
- return 1;
-}
Deleted: grass/trunk/lib/gis/sample.c
===================================================================
--- grass/trunk/lib/gis/sample.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/sample.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,338 +0,0 @@
-/*!
- \file gis/sample.c
-
- \brief GIS library - Sampling methods (extract a cell value from
- raster map)
-
- 1/2006: moved to libgis from v.sample/v.drape for clone removal
-
- (C) 2001-2009 by the GRASS Development Team
-
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
-
- \author James Darrell McCauley <darrell mccauley-usa.com>, http://mccauley-usa.com/
-*/
-
-#include <string.h>
-#include <unistd.h>
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-/* prototypes */
-static double scancatlabel(const char *);
-static void raster_row_error(const struct Cell_head *window, double north,
- double east);
-
-/*!
- * \brief Extract a cell value from raster map.
- *
- * Extract a cell value from raster map at given northing and easting
- * with a sampled 3x3 window using a specified interpolation method.
- *
- * - NEAREST neighbor interpolation
- * - BILINEAR bilinear interpolation
- * - CUBIC cubic interpolation
- *
- * \param fd file descriptor
- * \param window region settings
- * \param cats categories
- * \param north northing position
- * \param east easting position
- * \param usedesc flag to scan category label
- * \param itype interpolation method
- *
- * \return cell value at given position
- */
-DCELL G_get_raster_sample(int fd,
- const struct Cell_head *window,
- struct Categories *cats,
- double north, double east,
- int usedesc, INTERP_TYPE itype)
-{
- double retval;
-
- switch (itype) {
- case NEAREST:
- retval = G_get_raster_sample_nearest(fd, window, cats, north, east, usedesc);
- break;
- case BILINEAR:
- retval = G_get_raster_sample_bilinear(fd, window, cats, north, east, usedesc);
- break;
- case CUBIC:
- retval = G_get_raster_sample_cubic(fd, window, cats, north, east, usedesc);
- break;
- default:
- G_fatal_error("G_get_raster_sample: %s",
- _("Unknown interpolation type"));
- }
-
- return retval;
-}
-
-/*!
- * \brief Extract a cell value from raster map (neighbor interpolation)
- *
- * Extract a cell value from raster map at given northing and easting
- * with a sampled 3x3 window using a neighbor interpolation.
- *
- * \param fd file descriptor
- * \param window region settings
- * \param cats categories
- * \param north northing position
- * \param east easting position
- * \param usedesc flag to scan category label
- *
- * \return cell value at given position
- */
-DCELL G_get_raster_sample_nearest(int fd,
- const struct Cell_head *window,
- struct Categories *cats,
- double north, double east, int usedesc)
-{
- int row, col;
- DCELL result;
- DCELL *maprow = G_allocate_d_raster_buf();
-
- /* convert northing and easting to row and col, resp */
- row = (int)floor(G_northing_to_row(north, window));
- col = (int)floor(G_easting_to_col(east, window));
-
- if (row < 0 || row >= G_window_rows() ||
- col < 0 || col >= G_window_cols()) {
- G_set_d_null_value(&result, 1);
- goto done;
- }
-
- if (G_get_d_raster_row(fd, maprow, row) < 0)
- raster_row_error(window, north, east);
-
- if (G_is_d_null_value(&maprow[col])) {
- G_set_d_null_value(&result, 1);
- goto done;
- }
-
- if (usedesc) {
- char *buf = G_get_cat(maprow[col], cats);
-
- G_squeeze(buf);
- result = scancatlabel(buf);
- }
- else
- result = maprow[col];
-
-done:
- G_free(maprow);
-
- return result;
-}
-
-
-/*!
- * \brief Extract a cell value from raster map (bilinear interpolation).
- *
- * Extract a cell value from raster map at given northing and easting
- * with a sampled 3x3 window using a bilinear interpolation.
- *
- * \param fd file descriptor
- * \param window region settings
- * \param cats categories
- * \param north northing position
- * \param east easting position
- * \param usedesc flag to scan category label
- *
- * \return cell value at given position
- */
-DCELL G_get_raster_sample_bilinear(int fd,
- const struct Cell_head *window,
- struct Categories *cats,
- double north, double east, int usedesc)
-{
- int row, col;
- double grid[2][2];
- DCELL *arow = G_allocate_d_raster_buf();
- DCELL *brow = G_allocate_d_raster_buf();
- double frow, fcol, trow, tcol;
- DCELL result;
-
- frow = G_northing_to_row(north, window);
- fcol = G_easting_to_col(east, window);
-
- /* convert northing and easting to row and col, resp */
- row = (int)floor(frow - 0.5);
- col = (int)floor(fcol - 0.5);
-
- trow = frow - row - 0.5;
- tcol = fcol - col - 0.5;
-
- if (row < 0 || row + 1 >= G_window_rows() ||
- col < 0 || col + 1 >= G_window_cols()) {
- G_set_d_null_value(&result, 1);
- goto done;
- }
-
- if (G_get_d_raster_row(fd, arow, row) < 0)
- raster_row_error(window, north, east);
- if (G_get_d_raster_row(fd, brow, row + 1) < 0)
- raster_row_error(window, north, east);
-
- if (G_is_d_null_value(&arow[col]) || G_is_d_null_value(&arow[col + 1]) ||
- G_is_d_null_value(&brow[col]) || G_is_d_null_value(&brow[col + 1])) {
- G_set_d_null_value(&result, 1);
- goto done;
- }
-
- /*-
- * now were ready to do bilinear interpolation over
- * arow[col], arow[col+1],
- * brow[col], brow[col+1]
- */
-
- if (usedesc) {
- char *buf;
-
- G_squeeze(buf = G_get_cat((int)arow[col], cats));
- grid[0][0] = scancatlabel(buf);
- G_squeeze(buf = G_get_cat((int)arow[col + 1], cats));
- grid[0][1] = scancatlabel(buf);
- G_squeeze(buf = G_get_cat((int)brow[col], cats));
- grid[1][0] = scancatlabel(buf);
- G_squeeze(buf = G_get_cat((int)brow[col + 1], cats));
- grid[1][1] = scancatlabel(buf);
- }
- else {
- grid[0][0] = arow[col];
- grid[0][1] = arow[col + 1];
- grid[1][0] = brow[col];
- grid[1][1] = brow[col + 1];
- }
-
- result = G_interp_bilinear(tcol, trow,
- grid[0][0], grid[0][1], grid[1][0], grid[1][1]);
-
-done:
- G_free(arow);
- G_free(brow);
-
- return result;
-}
-
-/*!
- * \brief Extract a cell value from raster map (cubic interpolation).
- *
- * Extract a cell value from raster map at given northing and easting
- * with a sampled 3x3 window using a cubic interpolation.
- *
- * \param fd file descriptor
- * \param window region settings
- * \param cats categories
- * \param north northing position
- * \param east easting position
- * \param usedesc flag to scan category label
- *
- * \return cell value at given position
- */
-DCELL G_get_raster_sample_cubic(int fd,
- const struct Cell_head *window,
- struct Categories *cats,
- double north, double east, int usedesc)
-{
- int i, j, row, col;
- double grid[4][4];
- DCELL *rows[4];
- double frow, fcol, trow, tcol;
- DCELL result;
-
- for (i = 0; i < 4; i++)
- rows[i] = G_allocate_d_raster_buf();
-
- frow = G_northing_to_row(north, window);
- fcol = G_easting_to_col(east, window);
-
- /* convert northing and easting to row and col, resp */
- row = (int)floor(frow - 1.5);
- col = (int)floor(fcol - 1.5);
-
- trow = frow - row - 1.5;
- tcol = fcol - col - 1.5;
-
- if (row < 0 || row + 3 >= G_window_rows() ||
- col < 0 || col + 3 >= G_window_cols()) {
- G_set_d_null_value(&result, 1);
- goto done;
- }
-
- for (i = 0; i < 4; i++)
- if (G_get_d_raster_row(fd, rows[i], row + i) < 0)
- raster_row_error(window, north, east);
-
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- if (G_is_d_null_value(&rows[i][col + j])) {
- G_set_d_null_value(&result, 1);
- goto done;
- }
-
- /*
- * now were ready to do cubic interpolation over
- * arow[col], arow[col+1], arow[col+2], arow[col+3],
- * brow[col], brow[col+1], brow[col+2], brow[col+3],
- * crow[col], crow[col+1], crow[col+2], crow[col+3],
- * drow[col], drow[col+1], drow[col+2], drow[col+3],
- */
-
- if (usedesc) {
- char *buf;
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- G_squeeze(buf = G_get_cat(rows[i][col + j], cats));
- grid[i][j] = scancatlabel(buf);
- }
- }
- }
- else {
- for (i = 0; i < 4; i++)
- for (j = 0; j < 4; j++)
- grid[i][j] = rows[i][col + j];
- }
-
- result = G_interp_bicubic(tcol, trow,
- grid[0][0], grid[0][1], grid[0][2], grid[0][3],
- grid[1][0], grid[1][1], grid[1][2], grid[1][3],
- grid[2][0], grid[2][1], grid[2][2], grid[2][3],
- grid[3][0], grid[3][1], grid[3][2], grid[3][3]);
-
-done:
- for (i = 0; i < 4; i++)
- G_free(rows[i]);
-
- return result;
-}
-
-
-static double scancatlabel(const char *str)
-{
- double val;
-
- if (strcmp(str, "no data") != 0)
- sscanf(str, "%lf", &val);
- else {
- G_warning(_("\"no data\" label found; setting to zero"));
- val = 0.0;
- }
-
- return val;
-}
-
-
-static void raster_row_error(const struct Cell_head *window, double north,
- double east)
-{
- G_debug(3, "DIAG: \tRegion is: n=%g s=%g e=%g w=%g",
- window->north, window->south, window->east, window->west);
- G_debug(3, " \tData point is north=%g east=%g", north, east);
-
- G_fatal_error(_("Problem reading raster map"));
-}
Modified: grass/trunk/lib/gis/set_window.c
===================================================================
--- grass/trunk/lib/gis/set_window.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/set_window.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,8 +12,9 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
-#include "G.h"
+#include "../raster/G.h"
/*!
* \brief Get the current working window (region)
@@ -52,7 +53,7 @@
window = &twindow;
*/
- if ((err = G_adjust_Cell_head(window, 0, 0))) {
+ if ((err = Rast_adjust_Cell_head(window, 0, 0))) {
G_warning("G_set_window(): %s", err);
return -1;
}
@@ -77,7 +78,7 @@
/* close the mask */
if (G__.auto_mask > 0) {
- G_close_cell(maskfd);
+ Rast_close_cell(maskfd);
/* G_free (G__.mask_buf); */
G__.mask_fd = -1;
G__.auto_mask = -1; /* turn off masking */
@@ -110,14 +111,14 @@
/* opened for writing */
G_free (fcb->data);
fcb->data = (unsigned char *) G_calloc (G__.window.cols,
- G_raster_size(fcb->map_type));
+ Rast_raster_size(fcb->map_type));
}
/* allocate null bitstream buffers for reading/writing null rows */
for (j=0;j< NULL_ROWS_INMEM; j++)
{
G_free (fcb->NULL_ROWS[j]);
- fcb->NULL_ROWS[j] = G__allocate_null_bits(G__.window.cols);
+ fcb->NULL_ROWS[j] = (G__.window.cols);
}
@@ -133,7 +134,7 @@
}
/* turn masking (back) on if necessary */
- G__check_for_auto_masking();
+ Rast__check_for_auto_masking();
/* we want the number of bytes per cell to be maximum
so that there is enough memory for reading and writing rows */
Modified: grass/trunk/lib/gis/window_map.c
===================================================================
--- grass/trunk/lib/gis/window_map.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/window_map.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,9 +13,10 @@
#include <stdlib.h>
#include <grass/gis.h>
-#include "G.h"
+#include "../raster/G.h"
+
#define alloc_index(n) (COLUMN_MAPPING *) G_malloc((n)*sizeof(COLUMN_MAPPING))
Deleted: grass/trunk/lib/gis/zero_cell.c
===================================================================
--- grass/trunk/lib/gis/zero_cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gis/zero_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,55 +0,0 @@
-/*!
- * \file gis/zero_cell.c
- *
- * \brief GIS Library - Zero cell buffer functions.
- *
- * (C) 2001-2009 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author Original author CERL
- */
-
-#include <grass/gis.h>
-
-/*!
- * \brief Zero a raster CELL buffer.
- *
- * This routines assigns each member of the raster buffer array
- * <i>buf</i> to zero. It assumes that <i>buf</i> has been allocated
- * using G_allocate_cell_buf().
- *
- * \param buf data buffer
- */
-
-void G_zero_cell_buf(CELL * buf)
-{
- int i = G_window_cols();
-
- while (i--)
- *buf++ = 0;
-}
-
-/*!
- * \brief Zero a raster buffer.
- *
- * This routines assigns each member of the raster buffer array
- * <i>rast</i> to zero. It assumes that <i>rast</i> has been allocated
- * using G_allocate_cell_buf().
- *
- * \param rast data buffer
- * \param data_type raster type (CELL, FCELL, DCELL)
- */
-void G_zero_raster_buf(void *rast, RASTER_MAP_TYPE data_type)
-{
- int i;
- unsigned char *ptr;
-
- /* assuming that the size of unsigned char is 1 byte */
- i = G_window_cols() * G_raster_size(data_type);
- ptr = (unsigned char *)rast;
-
- while (i--)
- *ptr++ = 0;
-}
Modified: grass/trunk/lib/gpde/N_arrays.c
===================================================================
--- grass/trunk/lib/gpde/N_arrays.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gpde/N_arrays.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,10 +16,13 @@
*
*****************************************************************************/
-#include "grass/N_pde.h"
-#include "grass/glocale.h"
#include <math.h>
+#include <grass/N_pde.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+
/* ******************** 2D ARRAY FUNCTIONS *********************** */
/*!
@@ -233,7 +236,7 @@
G_debug(6,
"N_is_array_2d_value_null: null value is of type CELL at pos [%i][%i]",
col, row);
- return G_is_null_value((void *)
+ return Rast_is_null_value((void *)
&(data->
cell_array[row * data->cols_intern +
col]), CELL_TYPE);
@@ -242,7 +245,7 @@
G_debug(6,
"N_is_array_2d_value_null: null value is of type FCELL at pos [%i][%i]",
col, row);
- return G_is_null_value((void *)
+ return Rast_is_null_value((void *)
&(data->
fcell_array[row * data->cols_intern +
col]), FCELL_TYPE);
@@ -251,7 +254,7 @@
G_debug(6,
"N_is_array_2d_value_null: null value is of type DCELL at pos [%i][%i]",
col, row);
- return G_is_null_value((void *)
+ return Rast_is_null_value((void *)
&(data->
dcell_array[row * data->cols_intern +
col]), DCELL_TYPE);
@@ -262,7 +265,7 @@
G_debug(6,
"N_is_array_2d_value_null: null value is of type CELL at pos [%i][%i]",
col, row);
- return G_is_null_value((void *)
+ return Rast_is_null_value((void *)
&(data->
cell_array[(row +
data->offset) *
@@ -273,7 +276,7 @@
G_debug(6,
"N_is_array_2d_value_null: null value is of type FCELL at pos [%i][%i]",
col, row);
- return G_is_null_value((void *)
+ return Rast_is_null_value((void *)
&(data->
fcell_array[(row +
data->offset) *
@@ -284,7 +287,7 @@
G_debug(6,
"N_is_array_2d_value_null: null value is of type DCELL at pos [%i][%i]",
col, row);
- return G_is_null_value((void *)
+ return Rast_is_null_value((void *)
&(data->
dcell_array[(row +
data->offset) *
@@ -461,19 +464,19 @@
if (data->offset == 0) {
if (data->type == CELL_TYPE && data->cell_array != NULL) {
- G_set_c_null_value((void *)
+ Rast_set_c_null_value((void *)
&(data->
cell_array[row * data->cols_intern + col]),
1);
}
else if (data->type == FCELL_TYPE && data->fcell_array != NULL) {
- G_set_f_null_value((void *)
+ Rast_set_f_null_value((void *)
&(data->
fcell_array[row * data->cols_intern + col]),
1);
}
else if (data->type == DCELL_TYPE && data->dcell_array != NULL) {
- G_set_d_null_value((void *)
+ Rast_set_d_null_value((void *)
&(data->
dcell_array[row * data->cols_intern + col]),
1);
@@ -481,7 +484,7 @@
}
else {
if (data->type == CELL_TYPE && data->cell_array != NULL) {
- G_set_c_null_value((void *)
+ Rast_set_c_null_value((void *)
&(data->
cell_array[(row +
data->offset) *
@@ -489,7 +492,7 @@
data->offset]), 1);
}
else if (data->type == FCELL_TYPE && data->fcell_array != NULL) {
- G_set_f_null_value((void *)
+ Rast_set_f_null_value((void *)
&(data->
fcell_array[(row +
data->offset) *
@@ -497,7 +500,7 @@
data->offset]), 1);
}
else if (data->type == DCELL_TYPE && data->dcell_array != NULL) {
- G_set_d_null_value((void *)
+ Rast_set_d_null_value((void *)
&(data->
dcell_array[(row +
data->offset) *
Modified: grass/trunk/lib/gpde/N_arrays_calc.c
===================================================================
--- grass/trunk/lib/gpde/N_arrays_calc.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gpde/N_arrays_calc.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,11 +15,13 @@
* for details.
*
*****************************************************************************/
-
-#include "grass/N_pde.h"
-#include "grass/glocale.h"
#include <math.h>
+#include <grass/N_pde.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+
/* ******************** 2D ARRAY FUNCTIONS *********************** */
/*!
@@ -64,7 +66,7 @@
for (i = 0; i < source->cols_intern * source->rows_intern; i++) {
null = 0;
if (source->type == CELL_TYPE) {
- if (G_is_c_null_value((void *)&source->cell_array[i]))
+ if (Rast_is_c_null_value((void *)&source->cell_array[i]))
null = 1;
if (target->type == CELL_TYPE) {
@@ -72,25 +74,25 @@
}
if (target->type == FCELL_TYPE) {
if (null)
- G_set_f_null_value((void *)&(target->fcell_array[i]), 1);
+ Rast_set_f_null_value((void *)&(target->fcell_array[i]), 1);
else
target->fcell_array[i] = (FCELL) source->cell_array[i];
}
if (target->type == DCELL_TYPE) {
if (null)
- G_set_d_null_value((void *)&(target->dcell_array[i]), 1);
+ Rast_set_d_null_value((void *)&(target->dcell_array[i]), 1);
else
target->dcell_array[i] = (DCELL) source->cell_array[i];
}
}
if (source->type == FCELL_TYPE) {
- if (G_is_f_null_value((void *)&source->fcell_array[i]))
+ if (Rast_is_f_null_value((void *)&source->fcell_array[i]))
null = 1;
if (target->type == CELL_TYPE) {
if (null)
- G_set_c_null_value((void *)&(target->cell_array[i]), 1);
+ Rast_set_c_null_value((void *)&(target->cell_array[i]), 1);
else
target->cell_array[i] = (CELL) source->fcell_array[i];
}
@@ -99,24 +101,24 @@
}
if (target->type == DCELL_TYPE) {
if (null)
- G_set_d_null_value((void *)&(target->dcell_array[i]), 1);
+ Rast_set_d_null_value((void *)&(target->dcell_array[i]), 1);
else
target->dcell_array[i] = (DCELL) source->fcell_array[i];
}
}
if (source->type == DCELL_TYPE) {
- if (G_is_d_null_value((void *)&source->dcell_array[i]))
+ if (Rast_is_d_null_value((void *)&source->dcell_array[i]))
null = 1;
if (target->type == CELL_TYPE) {
if (null)
- G_set_c_null_value((void *)&(target->cell_array[i]), 1);
+ Rast_set_c_null_value((void *)&(target->cell_array[i]), 1);
else
target->cell_array[i] = (CELL) source->dcell_array[i];
}
if (target->type == FCELL_TYPE) {
if (null)
- G_set_f_null_value((void *)&(target->fcell_array[i]), 1);
+ Rast_set_f_null_value((void *)&(target->fcell_array[i]), 1);
else
target->fcell_array[i] = (FCELL) source->dcell_array[i];
}
@@ -163,27 +165,27 @@
v2 = 0.0;
if (a->type == CELL_TYPE) {
- if (!G_is_f_null_value((void *)&(a->cell_array[i])))
+ if (!Rast_is_f_null_value((void *)&(a->cell_array[i])))
v1 = (double)a->cell_array[i];
}
if (a->type == FCELL_TYPE) {
- if (!G_is_f_null_value((void *)&(a->fcell_array[i])))
+ if (!Rast_is_f_null_value((void *)&(a->fcell_array[i])))
v1 = (double)a->fcell_array[i];
}
if (a->type == DCELL_TYPE) {
- if (!G_is_f_null_value((void *)&(a->dcell_array[i])))
+ if (!Rast_is_f_null_value((void *)&(a->dcell_array[i])))
v1 = (double)a->dcell_array[i];
}
if (b->type == CELL_TYPE) {
- if (!G_is_f_null_value((void *)&(b->cell_array[i])))
+ if (!Rast_is_f_null_value((void *)&(b->cell_array[i])))
v2 = (double)b->cell_array[i];
}
if (b->type == FCELL_TYPE) {
- if (!G_is_f_null_value((void *)&(b->fcell_array[i])))
+ if (!Rast_is_f_null_value((void *)&(b->fcell_array[i])))
v2 = (double)b->fcell_array[i];
}
if (b->type == DCELL_TYPE) {
- if (!G_is_f_null_value((void *)&(b->dcell_array[i])))
+ if (!Rast_is_f_null_value((void *)&(b->dcell_array[i])))
v2 = (double)b->dcell_array[i];
}
@@ -438,7 +440,7 @@
if (a->type == CELL_TYPE)
for (i = 0; i < a->cols_intern * a->rows_intern; i++) {
- if (G_is_c_null_value((void *)&(a->cell_array[i]))) {
+ if (Rast_is_c_null_value((void *)&(a->cell_array[i]))) {
a->cell_array[i] = 0;
count++;
}
@@ -446,7 +448,7 @@
if (a->type == FCELL_TYPE)
for (i = 0; i < a->cols_intern * a->rows_intern; i++) {
- if (G_is_f_null_value((void *)&(a->fcell_array[i]))) {
+ if (Rast_is_f_null_value((void *)&(a->fcell_array[i]))) {
a->fcell_array[i] = 0.0;
count++;
}
@@ -455,7 +457,7 @@
if (a->type == DCELL_TYPE)
for (i = 0; i < a->cols_intern * a->rows_intern; i++) {
- if (G_is_d_null_value((void *)&(a->dcell_array[i]))) {
+ if (Rast_is_d_null_value((void *)&(a->dcell_array[i]))) {
a->dcell_array[i] = 0.0;
count++;
}
Modified: grass/trunk/lib/gpde/N_arrays_io.c
===================================================================
--- grass/trunk/lib/gpde/N_arrays_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/gpde/N_arrays_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,11 +15,13 @@
* for details.
*
*****************************************************************************/
-
-#include "grass/N_pde.h"
-#include "grass/glocale.h"
#include <math.h>
+#include <grass/N_pde.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+
/* ******************** 2D ARRAY FUNCTIONS *********************** */
/*!
@@ -62,11 +64,11 @@
cols = region.cols;
/*open the raster map */
- map = G_open_cell_old(name, G_find_cell2(name, ""));
+ map = Rast_open_cell_old(name, G_find_cell2(name, ""));
if (map < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- type = G_get_raster_map_type(map);
+ type = Rast_get_raster_map_type(map);
/*if the array is NULL create a new one with the data type of the raster map */
/*the offset is 0 by default */
@@ -91,22 +93,22 @@
("N_read_rast_to_array_2d: the data array size is different from the current region settings");
}
- rast = G_allocate_raster_buf(type);
+ rast = Rast_allocate_raster_buf(type);
G_message(_("Reading raster map <%s> into memory"), name);
for (y = 0; y < rows; y++) {
G_percent(y, rows - 1, 10);
- if (!G_get_raster_row(map, rast, y, type)) {
- G_close_cell(map);
+ if (!Rast_get_raster_row(map, rast, y, type)) {
+ Rast_close_cell(map);
G_fatal_error(_("Could not get raster row"));
}
for (x = 0, ptr = rast; x < cols;
- x++, ptr = G_incr_void_ptr(ptr, G_raster_size(type))) {
+ x++, ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(type))) {
if (type == CELL_TYPE) {
- if (G_is_c_null_value(ptr)) {
+ if (Rast_is_c_null_value(ptr)) {
N_put_array_2d_value_null(data, x, y);
}
else {
@@ -122,7 +124,7 @@
}
}
if (type == FCELL_TYPE) {
- if (G_is_f_null_value(ptr)) {
+ if (Rast_is_f_null_value(ptr)) {
N_put_array_2d_value_null(data, x, y);
}
else {
@@ -138,7 +140,7 @@
}
}
if (type == DCELL_TYPE) {
- if (G_is_d_null_value(ptr)) {
+ if (Rast_is_d_null_value(ptr)) {
N_put_array_2d_value_null(data, x, y);
}
else {
@@ -157,7 +159,7 @@
}
/* Close file */
- if (G_close_cell(map) < 0)
+ if (Rast_close_cell(map) < 0)
G_fatal_error(_("Unable to close input map"));
return data;
@@ -197,16 +199,16 @@
type = array->type;
/*Open the new map */
- map = G_open_raster_new(name, type);
+ map = Rast_open_raster_new(name, type);
if (map < 0)
G_fatal_error(_("Unable to create raster map <%s>"), name);
if (type == CELL_TYPE)
- rast = G_allocate_raster_buf(type);
+ rast = Rast_allocate_raster_buf(type);
if (type == FCELL_TYPE)
- frast = G_allocate_raster_buf(type);
+ frast = Rast_allocate_raster_buf(type);
if (type == DCELL_TYPE)
- drast = G_allocate_raster_buf(type);
+ drast = Rast_allocate_raster_buf(type);
G_message(_("Write 2d array to raster map <%s>"), name);
@@ -222,24 +224,24 @@
drast[x] = N_get_array_2d_d_value(array, x, y);
}
if (type == CELL_TYPE)
- if (!G_put_c_raster_row(map, rast)) {
- G_unopen_cell(map); /*unopen the new raster map */
+ if (!Rast_put_c_raster_row(map, rast)) {
+ Rast_unopen_cell(map); /*unopen the new raster map */
G_fatal_error(_("Unable to write raster row %i"), y);
}
if (type == FCELL_TYPE)
- if (!G_put_f_raster_row(map, frast)) {
- G_unopen_cell(map); /*unopen the new raster map */
+ if (!Rast_put_f_raster_row(map, frast)) {
+ Rast_unopen_cell(map); /*unopen the new raster map */
G_fatal_error(_("Unable to write raster row %i"), y);
}
if (type == DCELL_TYPE)
- if (!G_put_d_raster_row(map, drast)) {
- G_unopen_cell(map); /*unopen the new raster map */
+ if (!Rast_put_d_raster_row(map, drast)) {
+ Rast_unopen_cell(map); /*unopen the new raster map */
G_fatal_error(_("Unable to write raster row %i"), y);
}
}
/* Close file */
- if (G_close_cell(map) < 0)
+ if (Rast_close_cell(map) < 0)
G_fatal_error(_("Unable to close input map"));
return;
@@ -347,7 +349,7 @@
for (x = 0; x < cols; x++) {
if (type == FCELL_TYPE) {
G3d_getValue(map, x, y, z, &f1, type);
- if (G_is_f_null_value((void *)&f1)) {
+ if (Rast_is_f_null_value((void *)&f1)) {
N_put_array_3d_value_null(data, x, y, z);
}
else {
@@ -359,7 +361,7 @@
}
else {
G3d_getValue(map, x, y, z, &d1, type);
- if (G_is_d_null_value((void *)&d1)) {
+ if (Rast_is_d_null_value((void *)&d1)) {
N_put_array_3d_value_null(data, x, y, z);
}
else {
Modified: grass/trunk/lib/nviz/nviz.c
===================================================================
--- grass/trunk/lib/nviz/nviz.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/nviz/nviz.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
\date 2008
*/
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/nviz.h>
@@ -72,7 +73,7 @@
{
int red, grn, blu;
- if (G_str_to_color(color_str, &red, &grn, &blu) != 1) {
+ if (Rast_str_to_color(color_str, &red, &grn, &blu) != 1) {
G_warning(_("Invalid color (%s), using \"white\" as default"),
color_str);
red = grn = blu = 255;
Modified: grass/trunk/lib/ogsf/GS2.c
===================================================================
--- grass/trunk/lib/ogsf/GS2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/ogsf/GS2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -43,6 +43,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gstypes.h>
#include <grass/glocale.h>
@@ -1630,7 +1631,7 @@
}
/* Check to see if map is in Region */
- G_get_cellhd(filename, mapset, &rast_head);
+ Rast_get_cellhd(filename, mapset, &rast_head);
if (rast_head.north <= wind.south ||
rast_head.south >= wind.north ||
rast_head.east <= wind.west || rast_head.west >= wind.east) {
Modified: grass/trunk/lib/ogsf/Gp3.c
===================================================================
--- grass/trunk/lib/ogsf/Gp3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/ogsf/Gp3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/site.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -55,13 +56,13 @@
return 0;
}
- G_read_colors(grassname, col_map, &sc);
+ Rast_read_colors(grassname, col_map, &sc);
for (tp = gp; tp; tp = tp->next) {
cat = (int)tp->fattr;
color = NULL_COLOR;
- if (G_get_color(cat, &r, &g, &b, &sc)) {
+ if (Rast_get_color(cat, &r, &g, &b, &sc)) {
color = (r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16);
}
Modified: grass/trunk/lib/ogsf/Gs3.c
===================================================================
--- grass/trunk/lib/ogsf/Gs3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/ogsf/Gs3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/bitmap.h>
@@ -128,12 +129,12 @@
}
*has_null = 0;
- nullflags = G_allocate_null_buf(); /* G_fatal_error */
+ nullflags = Rast_allocate_null_buf(); /* G_fatal_error */
if (!nullflags) {
G_fatal_error(_("Unable to allocate memory for a null buffer"));
}
- if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
+ if ((cellfile = Rast_open_cell_old(map_name, map_set)) == -1) {
G_fatal_error(_("Unable to open raster map <%s>"), map_name);
}
@@ -142,13 +143,13 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
- G_get_f_raster_row(cellfile, &(buff[offset]), row);
- G_get_null_value_row(cellfile, nullflags, row);
+ Rast_get_f_raster_row(cellfile, &(buff[offset]), row);
+ Rast_get_null_value_row(cellfile, nullflags, row);
G_percent(row, wind->rows, 2);
for (col = 0; col < wind->cols; col++) {
- if (nullflags[col] || G_is_f_null_value(buff + offset + col)) {
+ if (nullflags[col] || Rast_is_f_null_value(buff + offset + col)) {
*has_null = 1;
BM_set(nullmap, col, row, 1);
}
@@ -159,7 +160,7 @@
G_debug(4, " has_null=%d", *has_null);
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
G_free(nullflags);
@@ -203,12 +204,12 @@
}
*has_null = 0;
- nullflags = G_allocate_null_buf(); /* G_fatal_error */
+ nullflags = Rast_allocate_null_buf(); /* G_fatal_error */
if (!nullflags) {
G_fatal_error(_("Unable to allocate memory for a null buffer"));
}
- if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
+ if ((cellfile = Rast_open_cell_old(map_name, map_set)) == -1) {
G_fatal_error(_("Unable to open raster map <%s>"), map_name);
}
@@ -217,8 +218,8 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
- G_get_c_raster_row(cellfile, &(buff[offset]), row);
- G_get_null_value_row(cellfile, nullflags, row);
+ Rast_get_c_raster_row(cellfile, &(buff[offset]), row);
+ Rast_get_null_value_row(cellfile, nullflags, row);
G_percent(row, wind->rows, 2);
@@ -233,7 +234,7 @@
}
G_percent(1, 1, 1);
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
G_free(nullflags);
@@ -246,7 +247,7 @@
\param filename raster map name
\param negflag
- \return -1 if map is integer and G_read_range() fails
+ \return -1 if map is integer and Rast_read_range() fails
\return data type (ARRY_*)
*/
int Gs_numtype(const char *filename, int *negflag)
@@ -287,17 +288,17 @@
return -1;
}
- if (G_raster_map_is_fp(filename, mapset)) {
+ if (Rast_raster_map_is_fp(filename, mapset)) {
G_debug(3, "Gs_numtype(): fp map detected");
return (ATTY_FLOAT);
}
- if (-1 == G_read_range(filename, mapset, &range)) {
+ if (-1 == Rast_read_range(filename, mapset, &range)) {
return (-1);
}
- G_get_range_min_max(&range, &min, &max);
+ Rast_get_range_min_max(&range, &min, &max);
*negflag = (min < 0);
if (max < max_char && min > 0) {
@@ -361,12 +362,12 @@
}
*has_null = 0;
- nullflags = G_allocate_null_buf();
+ nullflags = Rast_allocate_null_buf();
if (!nullflags) {
G_fatal_error(_("Unable to allocate memory for a null buffer"));
}
- if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
+ if ((cellfile = Rast_open_cell_old(map_name, map_set)) == -1) {
G_fatal_error(_("Unable to open raster map <%s>"), map_name);
}
@@ -380,8 +381,8 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
- G_get_c_raster_row(cellfile, tmp_buf, row);
- G_get_null_value_row(cellfile, nullflags, row);
+ Rast_get_c_raster_row(cellfile, tmp_buf, row);
+ Rast_get_null_value_row(cellfile, nullflags, row);
G_percent(row, wind->rows, 2);
@@ -412,7 +413,7 @@
}
G_percent(1, 1, 1);
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
G_free(tmp_buf);
G_free(nullflags);
@@ -477,12 +478,12 @@
}
*has_null = 0;
- nullflags = G_allocate_null_buf(); /* G_fatal_error */
+ nullflags = Rast_allocate_null_buf(); /* G_fatal_error */
if (!nullflags) {
G_fatal_error(_("Unable to allocate memory for a null buffer"));
}
- if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
+ if ((cellfile = Rast_open_cell_old(map_name, map_set)) == -1) {
G_fatal_error(_("Unable to open raster map <%s>"), map_name);
}
@@ -496,8 +497,8 @@
for (row = 0; row < wind->rows; row++) {
offset = row * wind->cols;
- G_get_c_raster_row(cellfile, tmp_buf, row);
- G_get_null_value_row(cellfile, nullflags, row);
+ Rast_get_c_raster_row(cellfile, tmp_buf, row);
+ Rast_get_null_value_row(cellfile, nullflags, row);
tc = (unsigned char *)&(buff[offset]);
ti = tmp_buf;
@@ -529,7 +530,7 @@
}
G_percent(1, 1, 1);
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
G_free(tmp_buf);
G_free(nullflags);
@@ -573,7 +574,7 @@
return -1;
}
- if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
+ if ((cellfile = Rast_open_cell_old(map_name, map_set)) == -1) {
G_fatal_error(_("Unable to open raster map <%s>"), map_name);
}
@@ -582,7 +583,7 @@
return -1;
}
- nullflags = G_allocate_null_buf();
+ nullflags = Rast_allocate_null_buf();
if (!nullflags) {
G_fatal_error(_("Unable to allocate memory for a null buffer"));
}
@@ -591,7 +592,7 @@
G_fully_qualified_name(map_name, map_set));
for (row = 0; row < wind->rows; row++) {
- G_get_null_value_row(cellfile, nullflags, row);
+ Rast_get_null_value_row(cellfile, nullflags, row);
for (col = 0; col < wind->cols; col++) {
if (nullflags[col]) {
@@ -604,7 +605,7 @@
}
}
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
G_free(tmp_buf);
G_free(nullflags);
@@ -640,8 +641,8 @@
return 0;
}
- G_read_colors(filename, mapset, &colrules);
- G_get_color_range(&min, &max, &colrules);
+ Rast_read_colors(filename, mapset, &colrules);
+ Rast_get_color_range(&min, &max, &colrules);
if (min < 0 || max > 255) {
G_warning(_("Color table range doesn't match data (mincol=%d, maxcol=%d"),
@@ -657,7 +658,7 @@
cats[i] = i;
}
- G_lookup_colors(cats, r, g, b, set, 256, &colrules);
+ Rast_lookup_colors(cats, r, g, b, set, 256, &colrules);
for (i = 0; i < 256; i++) {
@@ -702,14 +703,14 @@
b = (unsigned char *)G_malloc(cols);
set = (unsigned char *)G_malloc(cols);
- G_read_colors(filename, mapset, &colrules);
+ Rast_read_colors(filename, mapset, &colrules);
cur = buff;
G_message(_("Translating colors from raster map <%s>..."), filename);
for (i = 0; i < rows; i++) {
- G_lookup_colors(cur, r, g, b, set, cols, &colrules);
+ Rast_lookup_colors(cur, r, g, b, set, cols, &colrules);
G_percent(i, rows, 2);
for (j = 0; j < cols; j++) {
@@ -727,7 +728,7 @@
}
G_percent(1, 1, 1);
- G_free_colors(&colrules);
+ Rast_free_colors(&colrules);
G_free(r);
G_free(g);
@@ -772,7 +773,7 @@
b = (unsigned char *)G_malloc(cols);
set = (unsigned char *)G_malloc(cols);
- G_read_colors(filename, mapset, &colrules);
+ Rast_read_colors(filename, mapset, &colrules);
fcur = fbuf;
icur = ibuf;
@@ -780,7 +781,7 @@
G_message(_("Translating colors from raster map <%s>..."), filename);
for (i = 0; i < rows; i++) {
- G_lookup_f_raster_colors(fcur, r, g, b, set, cols, &colrules);
+ Rast_lookup_f_raster_colors(fcur, r, g, b, set, cols, &colrules);
G_percent(i, rows, 2);
for (j = 0; j < cols; j++) {
@@ -799,7 +800,7 @@
}
G_percent(1, 1, 1);
- G_free_colors(&colrules);
+ Rast_free_colors(&colrules);
G_free(r);
G_free(g);
@@ -836,23 +837,23 @@
return 0;
}
- if (-1 != G_read_cats(filename, mapset, &cats)) {
- fd = G_open_cell_old(filename, mapset);
- map_type = G_get_raster_map_type(fd);
+ if (-1 != Rast_read_cats(filename, mapset, &cats)) {
+ fd = Rast_open_cell_old(filename, mapset);
+ map_type = Rast_get_raster_map_type(fd);
if (map_type == CELL_TYPE) {
- buf = G_allocate_c_raster_buf();
+ buf = Rast_allocate_c_raster_buf();
- if (G_get_c_raster_row(fd, buf, drow) < 0) {
+ if (Rast_get_c_raster_row(fd, buf, drow) < 0) {
sprintf(catstr, "error");
}
- else if (G_is_c_null_value(&buf[dcol])) {
+ else if (Rast_is_c_null_value(&buf[dcol])) {
sprintf(catstr, "(NULL) %s",
- G_get_c_raster_cat(&buf[dcol], &cats));
+ Rast_get_c_raster_cat(&buf[dcol], &cats));
}
else {
sprintf(catstr, "(%d) %s", buf[dcol],
- G_get_c_raster_cat(&buf[dcol], &cats));
+ Rast_get_c_raster_cat(&buf[dcol], &cats));
}
G_free(buf);
@@ -860,18 +861,18 @@
else {
/* fp map */
- dbuf = G_allocate_d_raster_buf();
+ dbuf = Rast_allocate_d_raster_buf();
- if (G_get_d_raster_row(fd, dbuf, drow) < 0) {
+ if (Rast_get_d_raster_row(fd, dbuf, drow) < 0) {
sprintf(catstr, "error");
}
- else if (G_is_d_null_value(&dbuf[dcol])) {
+ else if (Rast_is_d_null_value(&dbuf[dcol])) {
sprintf(catstr, "(NULL) %s",
- G_get_d_raster_cat(&dbuf[dcol], &cats));
+ Rast_get_d_raster_cat(&dbuf[dcol], &cats));
}
else {
sprintf(catstr, "(%g) %s", dbuf[dcol],
- G_get_d_raster_cat(&dbuf[dcol], &cats));
+ Rast_get_d_raster_cat(&dbuf[dcol], &cats));
}
G_free(dbuf);
@@ -882,9 +883,9 @@
}
/* TODO: may want to keep these around for multiple queries */
- G_free_cats(&cats);
+ Rast_free_cats(&cats);
- G_close_cell(fd);
+ Rast_close_cell(fd);
return (1);
}
Modified: grass/trunk/lib/ogsf/Gvl3.c
===================================================================
--- grass/trunk/lib/ogsf/Gvl3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/ogsf/Gvl3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/gstypes.h>
#include <grass/glocale.h>
@@ -63,7 +64,7 @@
*/
int Gvl_unload_colors_data(void *color_data)
{
- G_free_colors(color_data);
+ Rast_free_colors(color_data);
G_free(color_data);
@@ -82,6 +83,6 @@
{
int r, g, b;
- G_get_f_raster_color((FCELL *) value, &r, &g, &b, color_data);
+ Rast_get_f_raster_color((FCELL *) value, &r, &g, &b, color_data);
return ((r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16));
}
Modified: grass/trunk/lib/ogsf/gsd_legend.c
===================================================================
--- grass/trunk/lib/ogsf/gsd_legend.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/ogsf/gsd_legend.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -32,6 +32,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/gstypes.h>
@@ -239,15 +240,15 @@
return (-1);
}
- is_fp = G_raster_map_is_fp(name, mapset);
+ is_fp = Rast_raster_map_is_fp(name, mapset);
- if (G_read_colors(name, mapset, &colors) == -1) {
+ if (Rast_read_colors(name, mapset, &colors) == -1) {
G_warning(_("Unable to read color file of raster map <%s>"), name);
return (-1);
}
if (cat_labs)
- if (G_read_cats(name, mapset, &cats) == -1) {
+ if (Rast_read_cats(name, mapset, &cats) == -1) {
G_warning(_("Unable to read category file of raster map <%s>"),
name);
cat_labs = 0;
@@ -264,23 +265,23 @@
}
else {
if (is_fp) {
- if (G_read_fp_range(name, mapset, &fp_range) != 1) {
+ if (Rast_read_fp_range(name, mapset, &fp_range) != 1) {
G_warning(_("Unable to read fp range of raster map <%s>"),
name);
return (-1);
}
- G_get_fp_range_min_max(&fp_range, &fmin, &fmax);
+ Rast_get_fp_range_min_max(&fp_range, &fmin, &fmax);
if (flags[4] && rangef[0] != -9999.)
fmin = rangef[0];
if (flags[4] && rangef[1] != -9999.)
fmax = rangef[1];
}
else {
- if (G_read_range(name, mapset, &range) == -1) {
+ if (Rast_read_range(name, mapset, &range) == -1) {
G_warning(_("Unable to read range of raster map <%s>"), name);
return (-1);
}
- G_get_range_min_max(&range, &min, &max);
+ Rast_get_range_min_max(&range, &min, &max);
if (flags[4] && rangef[0] != -9999.)
min = rangef[0];
if (flags[4] && rangef[1] != -9999.)
@@ -402,7 +403,7 @@
if (is_fp) {
tdcell = discrete ? Listcats[k] : labvals[k];
if (cat_labs) {
- cstr = G_get_d_raster_cat(&tdcell, &cats);
+ cstr = Rast_get_d_raster_cat(&tdcell, &cats);
}
if (cat_labs && !cat_vals) {
sprintf(buff, "%s", cstr);
@@ -423,10 +424,10 @@
tcell = discrete ? Listnum ?
Listcats[k] : min + k : labvals[k];
if (cat_labs && !cat_vals)
- sprintf(buff, "%s", G_get_cat(tcell, &cats));
+ sprintf(buff, "%s", Rast_get_cat(tcell, &cats));
else {
if (cat_labs && cat_vals) {
- cstr = G_get_cat(tcell, &cats);
+ cstr = Rast_get_cat(tcell, &cats);
if (cstr[0])
sprintf(buff, "%*d) %s", iprec, tcell, cstr);
else
@@ -514,10 +515,10 @@
}
if (k == 0 || tdcell != pdcell) {
if (is_fp)
- G_get_d_raster_color(&tdcell,
+ Rast_get_d_raster_color(&tdcell,
&red, &green, &blue, &colors);
else
- G_get_color((CELL) tdcell, &red, &green, &blue, &colors);
+ Rast_get_color((CELL) tdcell, &red, &green, &blue, &colors);
RGB_TO_INT(red, green, blue, colr);
if (discrete) { /* draw black-white-black separator */
@@ -634,9 +635,9 @@
labpos = 1. - labpos;
if (cat_labs) {
if (!is_fp)
- cstr = G_get_cat(tcell, &cats);
+ cstr = Rast_get_cat(tcell, &cats);
else
- cstr = G_get_d_raster_cat(&tdcell, &cats);
+ cstr = Rast_get_d_raster_cat(&tdcell, &cats);
}
if (cat_labs && !cat_vals)
sprintf(buff, "%s", cstr);
@@ -688,9 +689,9 @@
}
if (cat_labs)
- G_free_cats(&cats);
+ Rast_free_cats(&cats);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
gsd_end_legend_viewport();
Copied: grass/trunk/lib/raster/G.h (from rev 37989, grass/trunk/lib/gis/G.h)
===================================================================
--- grass/trunk/lib/raster/G.h (rev 0)
+++ grass/trunk/lib/raster/G.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,94 @@
+#include <grass/config.h>
+#include <grass/gis.h>
+#include <rpc/types.h>
+#include <rpc/xdr.h>
+#ifdef HAVE_GDAL
+#include <gdal.h>
+#endif
+
+#define XDR_FLOAT_NBYTES 4
+#define XDR_DOUBLE_NBYTES 8
+#define NULL_ROWS_INMEM 8
+
+/* if short is 16 bits, then
+ * short will allow 32767 cols
+ * unsigned short will allow 65536 cols
+ * use int if you need more columns (but this will take more memory).
+ *
+ */
+typedef int COLUMN_MAPPING;
+
+struct GDAL_link
+{
+ char *filename;
+ int band_num;
+ DCELL null_val;
+ int hflip;
+ int vflip;
+#ifdef HAVE_GDAL
+ GDALDatasetH data;
+ GDALRasterBandH band;
+ GDALDataType type;
+#endif
+};
+
+#ifdef HAVE_GDAL
+extern CPLErr G_gdal_raster_IO(
+ GDALRasterBandH, GDALRWFlag,
+ int, int, int, int,
+ void *, int, int, GDALDataType,
+ int, int);
+#endif
+
+struct fileinfo /* Information for opened cell files */
+{
+ int open_mode; /* see defines below */
+ struct Cell_head cellhd; /* Cell header */
+ struct Reclass reclass; /* Table reclass */
+ struct Cell_stats statf; /* Cell stats */
+ struct Range range; /* Range structure */
+ struct FPRange fp_range; /* float Range structure */
+ int want_histogram;
+ int reclass_flag; /* Automatic reclass flag */
+ off_t *row_ptr; /* File row addresses */
+ COLUMN_MAPPING *col_map; /* Data to window col mapping */
+ double C1, C2; /* Data to window row constants */
+ int cur_row; /* Current data row in memory */
+ int null_cur_row; /* Current null row in memory */
+ int cur_nbytes; /* nbytes per cell for current row */
+ unsigned char *data; /* Decompressed data buffer */
+ int nbytes; /* bytes per cell */
+ RASTER_MAP_TYPE map_type; /* type: int, float or double map */
+ char *temp_name; /* Temporary name for NEW files */
+ char *null_temp_name; /* Temporary name for NEW NULL files */
+ int null_file_exists; /* for existing raster maps */
+ char *name; /* Name of open file */
+ char *mapset; /* Mapset of open file */
+ int io_error; /* io error warning given */
+ XDR xdrstream; /* xdr stream for reading fp */
+ unsigned char *NULL_ROWS[NULL_ROWS_INMEM];
+ int min_null_row; /* Minimum row null row number in memory */
+ struct Quant quant;
+ struct GDAL_link *gdal;
+};
+
+struct G__ /* Structure of library globals */
+{
+ RASTER_MAP_TYPE fp_type; /* type for writing floating maps */
+ struct Cell_head window; /* Contains the current window */
+ int window_set; /* Flag: window set? */
+ int mask_fd; /* File descriptor for automatic mask */
+ int auto_mask; /* Flag denoting automatic masking */
+ int want_histogram;
+ int nbytes;
+ int compression_type;
+
+ int fileinfo_count;
+ struct fileinfo *fileinfo;
+};
+
+extern struct G__ G__; /* allocated in gisinit */
+
+#define OPEN_OLD 1
+#define OPEN_NEW_COMPRESSED 2
+#define OPEN_NEW_UNCOMPRESSED 3
Copied: grass/trunk/lib/raster/adj_cellhd.c (from rev 37989, grass/trunk/lib/gis/adj_cellhd.c)
===================================================================
--- grass/trunk/lib/raster/adj_cellhd.c (rev 0)
+++ grass/trunk/lib/raster/adj_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,356 @@
+/*!
+ * \file gis/adj_cellhd.c
+ *
+ * \brief GIS Library - CELL header adjustment.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+/*!
+ * \brief Adjust cell header.
+ *
+ * This function fills in missing parts of the input cell header (or
+ * region). It also makes projection-specific adjustments. The
+ * <i>cellhd</i> structure must have its <i>north, south, east,
+ * west</i>, and <i>proj</i> fields set.
+ *
+ * If <i>row_flag</i> is true, then the north-south resolution is
+ * computed from the number of <i>rows</i> in the <i>cellhd</i>
+ * structure. Otherwise the number of <i>rows</i> is computed from the
+ * north-south resolution in the structure, similarly for
+ * <i>col_flag</i> and the number of columns and the east-west
+ * resolution.
+ *
+ * <b>Note:</b> 3D values are not adjusted.
+ *
+ * \param[in,out] cellhd pointer to Cell_head structure
+ * \param row_flag compute n-s resolution
+ * \param col_flag compute e-w resolution
+
+ * \return NULL on success
+ * \return localized text string on error
+ */
+const char *Rast_adjust_Cell_head(struct Cell_head *cellhd, int row_flag, int col_flag)
+{
+ if (!row_flag) {
+ if (cellhd->ns_res <= 0)
+ return (_("Illegal n-s resolution value"));
+ }
+ else {
+ if (cellhd->rows <= 0)
+ return (_("Illegal row value"));
+ }
+ if (!col_flag) {
+ if (cellhd->ew_res <= 0)
+ return (_("Illegal e-w resolution value"));
+ }
+ else {
+ if (cellhd->cols <= 0)
+ return (_("Illegal col value"));
+ }
+
+ /* for lat/lon, check north,south. force east larger than west */
+ if (cellhd->proj == PROJECTION_LL) {
+ double epsilon_ns, epsilon_ew;
+
+ /* TODO: find good thresholds */
+ epsilon_ns = 1. / cellhd->rows * 0.001;
+ epsilon_ew = .000001; /* epsilon_ew calculation doesn't work due to cellhd->cols update/global wraparound below */
+
+ G_debug(3, "Rast_adjust_Cell_head: epsilon_ns: %g, epsilon_ew: %g",
+ epsilon_ns, epsilon_ew);
+
+ /* TODO: once working, change below G_warning to G_debug */
+
+ /* fix rounding problems if input map slightly exceeds the world definition -180 90 180 -90 */
+ if (cellhd->north > 90.0) {
+ if (((cellhd->north - 90.0) < epsilon_ns) &&
+ ((cellhd->north - 90.0) > GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of north boundary (%g>%g)"),
+ cellhd->north - 90.0, epsilon_ns);
+ cellhd->north = 90.0;
+ }
+ else
+ return (_("Illegal latitude for North"));
+ }
+
+ if (cellhd->south < -90.0) {
+ if (((cellhd->south + 90.0) < epsilon_ns) &&
+ ((cellhd->south + 90.0) < GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of south boundary (%g>%g)"),
+ cellhd->south + 90.0, epsilon_ns);
+ cellhd->south = -90.0;
+ }
+ else
+ return (_("Illegal latitude for South"));
+ }
+
+#if 0
+ /* DISABLED: this breaks global wrap-around */
+
+ G_debug(3,
+ "Rast_adjust_Cell_head() cellhd->west: %f, devi: %g, eps: %g",
+ cellhd->west, cellhd->west + 180.0, epsilon_ew);
+
+ if ((cellhd->west < -180.0) && ((cellhd->west + 180.0) < epsilon_ew)
+ && ((cellhd->west + 180.0) < GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of west boundary (%g>%g)"),
+ cellhd->west + 180.0, epsilon_ew);
+ cellhd->west = -180.0;
+ }
+
+ G_debug(3,
+ "Rast_adjust_Cell_head() cellhd->east: %f, devi: %g, eps: %g",
+ cellhd->east, cellhd->east - 180.0, epsilon_ew);
+
+ if ((cellhd->east > 180.0) && ((cellhd->east - 180.0) > epsilon_ew)
+ && ((cellhd->east - 180.0) > GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of east boundary (%g>%g)"),
+ cellhd->east - 180.0, epsilon_ew);
+ cellhd->east = 180.0;
+ }
+#endif
+
+ while (cellhd->east <= cellhd->west)
+ cellhd->east += 360.0;
+ }
+
+ /* check the edge values */
+ if (cellhd->north <= cellhd->south) {
+ if (cellhd->proj == PROJECTION_LL)
+ return (_("North must be north of South"));
+ else
+ return (_("North must be larger than South"));
+ }
+ if (cellhd->east <= cellhd->west)
+ return (_("East must be larger than West"));
+
+ /* compute rows and columns, if not set */
+ if (!row_flag) {
+ cellhd->rows =
+ (cellhd->north - cellhd->south +
+ cellhd->ns_res / 2.0) / cellhd->ns_res;
+ if (cellhd->rows == 0)
+ cellhd->rows = 1;
+ }
+ if (!col_flag) {
+ cellhd->cols =
+ (cellhd->east - cellhd->west +
+ cellhd->ew_res / 2.0) / cellhd->ew_res;
+ if (cellhd->cols == 0)
+ cellhd->cols = 1;
+ }
+
+ if (cellhd->cols < 0 || cellhd->rows < 0) {
+ return (_("Invalid coordinates"));
+ }
+
+
+ /* (re)compute the resolutions */
+ cellhd->ns_res = (cellhd->north - cellhd->south) / cellhd->rows;
+ cellhd->ew_res = (cellhd->east - cellhd->west) / cellhd->cols;
+
+ return NULL;
+}
+
+/*!
+ * \brief Adjust cell header for 3D values.
+ *
+ * This function fills in missing parts of the input cell header (or
+ * region). It also makes projection-specific adjustments. The
+ * <i>cellhd</i> structure must have its <i>north, south, east,
+ * west</i>, and <i>proj</i> fields set.
+ *
+ * If <i>row_flag</i> is true, then the north-south resolution is computed
+ * from the number of <i>rows</i> in the <i>cellhd</i> structure.
+ * Otherwise the number of <i>rows</i> is computed from the north-south
+ * resolution in the structure, similarly for <i>col_flag</i> and the
+ * number of columns and the east-west resolution.
+ *
+ * If <i>depth_flag</i> is true, top-bottom resolution is calculated
+ * from depths.
+ * If <i>depth_flag</i> are false, number of depths is calculated from
+ * top-bottom resolution.
+ *
+ * \param[in,out] cellhd pointer to Cell_head structure
+ * \param row_flag compute n-s resolution
+ * \param col_flag compute e-w resolution
+ * \param depth_flag compute t-b resolution
+ *
+ * \return NULL on success
+ * \return localized text string on error
+ */
+const char *Rast_adjust_Cell_head3(struct Cell_head *cellhd, int row_flag,
+ int col_flag, int depth_flag)
+{
+ if (!row_flag) {
+ if (cellhd->ns_res <= 0)
+ return (_("Illegal n-s resolution value"));
+ if (cellhd->ns_res3 <= 0)
+ return (_("Illegal n-s3 resolution value"));
+ }
+ else {
+ if (cellhd->rows <= 0)
+ return (_("Illegal row value"));
+ if (cellhd->rows3 <= 0)
+ return (_("Illegal row3 value"));
+ }
+ if (!col_flag) {
+ if (cellhd->ew_res <= 0)
+ return (_("Illegal e-w resolution value"));
+ if (cellhd->ew_res3 <= 0)
+ return (_("Illegal e-w3 resolution value"));
+ }
+ else {
+ if (cellhd->cols <= 0)
+ return (_("Illegal col value"));
+ if (cellhd->cols3 <= 0)
+ return (_("Illegal col3 value"));
+ }
+ if (!depth_flag) {
+ if (cellhd->tb_res <= 0)
+ return (_("Illegal t-b3 resolution value"));
+ }
+ else {
+ if (cellhd->depths <= 0)
+ return (_("Illegal depths value"));
+ }
+
+ /* for lat/lon, check north,south. force east larger than west */
+ if (cellhd->proj == PROJECTION_LL) {
+ double epsilon_ns, epsilon_ew;
+
+ /* TODO: find good thresholds */
+ epsilon_ns = 1. / cellhd->rows * 0.001;
+ epsilon_ew = .000001; /* epsilon_ew calculation doesn't work due to cellhd->cols update/global wraparound below */
+
+ G_debug(3, "Rast_adjust_Cell_head: epsilon_ns: %g, epsilon_ew: %g",
+ epsilon_ns, epsilon_ew);
+
+ /* TODO: once working, change below G_warning to G_debug */
+
+ /* fix rounding problems if input map slightly exceeds the world definition -180 90 180 -90 */
+ if (cellhd->north > 90.0) {
+ if (((cellhd->north - 90.0) < epsilon_ns) &&
+ ((cellhd->north - 90.0) > GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of north boundary (%g>%g)"),
+ cellhd->north - 90.0, epsilon_ns);
+ cellhd->north = 90.0;
+ }
+ else
+ return (_("Illegal latitude for North"));
+ }
+
+ if (cellhd->south < -90.0) {
+ if (((cellhd->south + 90.0) < epsilon_ns) &&
+ ((cellhd->south + 90.0) < GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of south boundary (%g>%g)"),
+ cellhd->south + 90.0, epsilon_ns);
+ cellhd->south = -90.0;
+ }
+ else
+ return (_("Illegal latitude for South"));
+ }
+
+#if 0
+ /* DISABLED: this breaks global wrap-around */
+
+ G_debug(3,
+ "Rast_adjust_Cell_head3() cellhd->west: %f, devi: %g, eps: %g",
+ cellhd->west, cellhd->west + 180.0, epsilon_ew);
+
+ if ((cellhd->west < -180.0) && ((cellhd->west + 180.0) < epsilon_ew)
+ && ((cellhd->west + 180.0) < GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of west boundary (%g>%g)"),
+ cellhd->west + 180.0, epsilon_ew);
+ cellhd->west = -180.0;
+ }
+
+ G_debug(3,
+ "Rast_adjust_Cell_head3() cellhd->east: %f, devi: %g, eps: %g",
+ cellhd->east, cellhd->east - 180.0, epsilon_ew);
+
+ if ((cellhd->east > 180.0) && ((cellhd->east - 180.0) > epsilon_ew)
+ && ((cellhd->east - 180.0) > GRASS_EPSILON)) {
+ G_warning(_("Fixing subtle input data rounding error of east boundary (%g>%g)"),
+ cellhd->east - 180.0, epsilon_ew);
+ cellhd->east = 180.0;
+ }
+#endif
+
+ while (cellhd->east <= cellhd->west)
+ cellhd->east += 360.0;
+ }
+
+ /* check the edge values */
+ if (cellhd->north <= cellhd->south) {
+ if (cellhd->proj == PROJECTION_LL)
+ return (_("North must be north of South"));
+ else
+ return (_("North must be larger than South"));
+ }
+ if (cellhd->east <= cellhd->west)
+ return (_("East must be larger than West"));
+ if (cellhd->top <= cellhd->bottom)
+ return (_("Top must be larger than Bottom"));
+
+
+ /* compute rows and columns, if not set */
+ if (!row_flag) {
+ cellhd->rows =
+ (cellhd->north - cellhd->south +
+ cellhd->ns_res / 2.0) / cellhd->ns_res;
+ if (cellhd->rows == 0)
+ cellhd->rows = 1;
+
+ cellhd->rows3 =
+ (cellhd->north - cellhd->south +
+ cellhd->ns_res3 / 2.0) / cellhd->ns_res3;
+ if (cellhd->rows3 == 0)
+ cellhd->rows3 = 1;
+ }
+ if (!col_flag) {
+ cellhd->cols =
+ (cellhd->east - cellhd->west +
+ cellhd->ew_res / 2.0) / cellhd->ew_res;
+ if (cellhd->cols == 0)
+ cellhd->cols = 1;
+
+ cellhd->cols3 =
+ (cellhd->east - cellhd->west +
+ cellhd->ew_res3 / 2.0) / cellhd->ew_res3;
+ if (cellhd->cols3 == 0)
+ cellhd->cols3 = 1;
+ }
+
+ if (!depth_flag) {
+ cellhd->depths =
+ (cellhd->top - cellhd->bottom +
+ cellhd->tb_res / 2.0) / cellhd->tb_res;
+ if (cellhd->depths == 0)
+ cellhd->depths = 1;
+
+ }
+
+ if (cellhd->cols < 0 || cellhd->rows < 0 || cellhd->cols3 < 0 ||
+ cellhd->rows3 < 0 || cellhd->depths < 0) {
+ return (_("Invalid coordinates"));
+ }
+
+ /* (re)compute the resolutions */
+ cellhd->ns_res = (cellhd->north - cellhd->south) / cellhd->rows;
+ cellhd->ns_res3 = (cellhd->north - cellhd->south) / cellhd->rows3;
+ cellhd->ew_res = (cellhd->east - cellhd->west) / cellhd->cols;
+ cellhd->ew_res3 = (cellhd->east - cellhd->west) / cellhd->cols3;
+ cellhd->tb_res = (cellhd->top - cellhd->bottom) / cellhd->depths;
+
+ return NULL;
+}
Copied: grass/trunk/lib/raster/alloc_cell.c (from rev 37989, grass/trunk/lib/gis/alloc_cell.c)
===================================================================
--- grass/trunk/lib/raster/alloc_cell.c (rev 0)
+++ grass/trunk/lib/raster/alloc_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,166 @@
+/*!
+ * \file gis/alloc_cell.c
+ *
+ * \brief GIS Library - Raster allocation routines.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <math.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/* convert type "RASTER_MAP_TYPE" into index */
+#define F2I(map_type) \
+ (map_type == CELL_TYPE ? 0 : (map_type == FCELL_TYPE ? 1 : 2))
+
+static const int type_size[3] = { sizeof(CELL), sizeof(FCELL), sizeof(DCELL) };
+
+/*!
+ * \brief Returns size of a raster CELL in bytes.
+ *
+ * - If <i>data_type</i> is CELL_TYPE, returns sizeof(CELL)
+ * - If <i>data_type</i> is FCELL_TYPE, returns sizeof(FCELL)
+ * - If <i>data_type</i> is DCELL_TYPE, returns sizeof(DCELL)
+ *
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ *
+ * \return raster type size
+ */
+
+size_t Rast_raster_size(RASTER_MAP_TYPE data_type)
+{
+ return (type_size[F2I(data_type)]);
+}
+
+/*!
+ * \brief Allocate memory for a CELL type raster map.
+ *
+ * This routine allocates a buffer of type CELL just large enough to
+ * hold one row of raster data based on the number of columns in the
+ * active region.
+ *
+ \code
+ CELL *cell;
+ cell = Rast_allocate_cell_buf();
+ \endcode
+ *
+ * If larger buffers are required, the routine G_malloc() can be used.
+ * The routine is generally used with each open cell file.
+ *
+ * <b>Note:</b> Rast_allocate_raster_buf() or G_alloc_c_raster_buf() is
+ * preferred over Rast_allocate_cell_buf().
+ *
+ * Prints error message and calls exit() on error.
+ *
+ * \return CELL * pointer to allocated buffer
+ */
+CELL *Rast_allocate_cell_buf(void)
+{
+ return (CELL *) G_calloc(G_window_cols() + 1, sizeof(CELL));
+}
+
+/*!
+ * \brief Allocate memory for a raster map of given type
+ *
+ * Allocate an array of CELL, FCELL, or DCELL (depending on
+ * <i>data_type</i>) based on the number of columns in the current
+ * region.
+ *
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ *
+ * \return pointer to allocated buffer
+ */
+void *Rast_allocate_raster_buf(RASTER_MAP_TYPE data_type)
+{
+ return (void *)G_calloc(G_window_cols() + 1, Rast_raster_size(data_type));
+}
+
+/*!
+ * \brief Allocates memory for a raster map of type CELL.
+ *
+ * Allocate an array of CELL based on the number of columns in the
+ * current region.
+ *
+ * \return pointer to allocated buffer
+ */
+CELL *Rast_allocate_c_raster_buf(void)
+{
+ return (CELL *) G_calloc(G_window_cols() + 1, sizeof(CELL));
+}
+
+/*!
+ * \brief Allocates memory for a raster map of type FCELL.
+ *
+ * Allocate an array of FCELL based on the number of columns in the
+ * current region.
+ *
+ * \return pointer to allocated buffer
+ */
+FCELL *Rast_allocate_f_raster_buf(void)
+{
+ return (FCELL *) G_calloc(G_window_cols() + 1, sizeof(FCELL));
+}
+
+/*!
+ * \brief Allocates memory for a raster map of type DCELL.
+ *
+ * Allocate an array of DCELL based on the number of columns in the
+ * current region.
+ *
+ * \return pointer to allocated buffer
+ */
+DCELL *Rast_allocate_d_raster_buf(void)
+{
+ return (DCELL *) G_calloc(G_window_cols() + 1, sizeof(DCELL));
+}
+
+/*!
+ * \brief Allocates memory for a null buffer.
+ *
+ * Allocate an array of char based on the number of columns in the
+ * current region.
+ *
+ * \return pointer to allocated buffer
+ */
+char *Rast_allocate_null_buf(void)
+{
+ return (char *)G_calloc(G_window_cols() + 1, sizeof(char));
+}
+
+/*!
+ * \brief Allocates memory for null bits.
+ *
+ * Allocates an array of unsigned char based on <i>cols</i>.
+ *
+ * \param cols number of columns in region
+ *
+ * \return pointer to allocated buffer
+ */
+unsigned char *Rast__allocate_null_bits(int cols)
+{
+ return (unsigned char *)G_calloc(Rast__null_bitstream_size(cols) + 1,
+ sizeof(unsigned char));
+}
+
+/*!
+ * \brief Determines null bitstream size.
+ *
+ * \param cols number of columns
+ *
+ * \return -1 if <i>cols</i> is invalid (<= 0)
+ * \return size of null bistream
+ */
+int Rast__null_bitstream_size(int cols)
+{
+ if (cols <= 0)
+ return -1;
+
+ return (cols / 8 + (cols % 8 != 0));
+}
Copied: grass/trunk/lib/raster/auto_mask.c (from rev 37989, grass/trunk/lib/gis/auto_mask.c)
===================================================================
--- grass/trunk/lib/raster/auto_mask.c (rev 0)
+++ grass/trunk/lib/raster/auto_mask.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,108 @@
+
+/**
+ * \file auto_mask.c
+ *
+ * \brief GIS Library - Auto masking routines.
+ *
+ * (C) 2001-2008 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author GRASS GIS Development Team
+ *
+ * \date 1999-2008
+ */
+
+#include <stdlib.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+
+
+/**
+ * \brief Checks for auto masking.
+ *
+ * On first call, opens the mask file if declared and available and
+ * allocates buffer for reading mask rows.
+ * On second call, returns 0 or 1.
+ *
+ * \return 0 if mask unset or unavailable
+ * \return 1 if mask set and available and ready to use
+ */
+
+int Rast__check_for_auto_masking(void)
+{
+ struct Cell_head cellhd;
+
+ /* if mask is switched off (-2) return -2
+ if G__.auto_mask is not set (-1) or set (>=0) recheck the MASK */
+
+ if (G__.auto_mask < -1)
+ return G__.auto_mask;
+
+ /* if(G__.mask_fd > 0) G_free (G__.mask_buf); */
+
+ /* look for the existence of the MASK file */
+ G__.auto_mask = (G_find_cell("MASK", G_mapset()) != 0);
+
+ if (G__.auto_mask <= 0)
+ return 0;
+
+ /* check MASK projection/zone against current region */
+ if (Rast_get_cellhd("MASK", G_mapset(), &cellhd) >= 0) {
+ if (cellhd.zone != G_zone() || cellhd.proj != G_projection()) {
+ G__.auto_mask = 0;
+ return 0;
+ }
+ }
+
+ Rast_unopen_cell(G__.mask_fd);
+ G__.mask_fd = Rast__open_cell_old("MASK", G_mapset());
+ if (G__.mask_fd < 0) {
+ G__.auto_mask = 0;
+ G_warning(_("Unable to open automatic MASK file"));
+ return 0;
+ }
+
+ /* G__.mask_buf = Rast_allocate_cell_buf(); */
+
+ G__.auto_mask = 1;
+
+ return 1;
+}
+
+
+/**
+ * \brief Suppresses masking.
+ *
+ * \return
+ */
+
+void Rast_suppress_masking(void)
+{
+ if (G__.auto_mask > 0) {
+ Rast_close_cell(G__.mask_fd);
+ /* G_free (G__.mask_buf); */
+ G__.mask_fd = -1;
+ }
+ G__.auto_mask = -2;
+}
+
+
+/**
+ * \brief Unsuppresses masking.
+ *
+ * \return
+ */
+
+void Rast_unsuppress_masking(void)
+{
+ if (G__.auto_mask < -1) {
+ G__.mask_fd = -1;
+ Rast__check_for_auto_masking();
+ }
+}
Copied: grass/trunk/lib/raster/cats.c (from rev 37989, grass/trunk/lib/gis/cats.c)
===================================================================
--- grass/trunk/lib/raster/cats.c (rev 0)
+++ grass/trunk/lib/raster/cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,1490 @@
+/*!
+ * \file gis/cats.c
+ *
+ * \brief GIS Library - Raster categories management
+ *
+ * Code in this file works with category files. There are two formats:
+ * Pre 3.0 direct category encoding form:
+ *
+ * 2 categories
+ * Map Title
+ * Elevation: 1000.00 to 1005.00 feet
+ * Elevation: 1005.00 to 1010.00 feet
+ * Elevation: 1010.00 to 1015.00 feet
+ *
+ * 3.0 format
+ *
+ * # 2 categories
+ * Map Title
+ * Elevation: $1.2 to $2.2 feet ## Format Statement
+ * 5.0 1000 5.0 1005 ## Coefficients
+ *
+ * The coefficient line can be followed by explicit category labels
+ * which override the format label generation.
+ * 0:no data
+ * 2: .
+ * 5: . ## explicit category labels
+ * 7: .
+ * explicit labels can be also of the form:
+ * 5.5:5:9 label description
+ * or
+ * 15:30 label description
+ *
+ * In the format line
+ * $1 refers to the value num*5.0+1000 (ie, using the first 2 coefficients)
+ * $2 refers to the value num*5.0+1005 (ie, using the last 2 coefficients)
+ *
+ * $1.2 will print $1 with 2 decimal places.
+ *
+ * Also, the form $?xxx$yyy$ translates into yyy if the category is 1, xxx
+ * otherwise. The $yyy$ is optional. Thus
+ *
+ * $1 meter$?s
+ *
+ * will become: 1 meter (for category 1)
+ * 2 meters (for category 2), etc.
+ *
+ * The format and coefficients above would be used to generate the
+ * following statement in creation of the format appropriate category
+ * string for category "num":
+ *
+ * sprintf(buff,"Elevation: %.2f to %.2f feet", num*5.0+1000, num*5.0*1005)
+ *
+ * Note: while both the format and coefficent lins must be present
+ * a blank line for the fmt will effectively suppress automatic
+ * label generation
+ *
+ * Note: quant rules of Categories structures are heavily dependent
+ * on the fact that rules are stored in the same order they are entered.
+ * since i-th rule and i-th label are entered at the same time, we
+ * know that i-th rule maps fp range to i, thus we know for sure
+ * that cats.labels[i] corresponds to i-th quant rule
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+static void get_cond(char **, char *, DCELL);
+static int get_fmt(char **, char *, int *);
+static int cmp(const void *, const void *);
+
+static int write_cats(const char *element, const char *name, struct Categories *cats);
+static CELL read_cats(const char *element,
+ const char *name,
+ const char *mapset, struct Categories * pcats, int full);
+
+static struct Categories save_cats;
+
+/*!
+ * \brief Read raster category file
+ *
+ * \todo Remove, the function Rast_read_raster_cats()
+ *
+ * The category file for raster map <i>name</i> in <i>mapset</i> is
+ * read into the <i>cats</i> structure. If there is an error reading
+ * the category file, a diagnostic message is printed and -1 is
+ * returned. Otherwise, 0 is returned.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param[out] cats pointer to Cats structure
+ *
+ * \return -1 on error
+ * \return 0 on success
+ */
+int Rast_read_cats(const char *name,
+ const char *mapset, struct Categories *pcats)
+{
+ return Rast_read_raster_cats(name, mapset, pcats);
+}
+
+/*!
+ * \brief Read raster category file
+ *
+ * The category file for raster map <i>name</i> in <i>mapset</i> is
+ * read into the <i>cats</i> structure. If there is an error reading
+ * the category file, a diagnostic message is printed and -1 is
+ * returned. Otherwise, 0 is returned.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param[out] cats pointer to Cats structure
+ *
+ * \return -1 on error
+ * \return 0 on success
+ */
+int Rast_read_raster_cats(const char *name,
+ const char *mapset, struct Categories *pcats)
+{
+ char *type;
+
+ switch (read_cats("cats", name, mapset, pcats, 1)) {
+ case -2:
+ type = "missing";
+ break;
+ case -1:
+ type = "invalid";
+ break;
+ default:
+ return 0;
+ }
+
+ G_warning(_("Category support for <%s@%s> %s"),
+ name, mapset, type);
+ return -1;
+}
+
+/*!
+ * \brief Read vector category file
+ *
+ * <b>Note:</b> This function works with <b>old</b> vector format.
+
+ * The category file for vector map <i>name</i> in <i>mapset</i> is
+ * read into the <i>cats</i> structure. If there is an error reading
+ * the category file, a diagnostic message is printed and -1 is
+ * returned. Otherwise, 0 is returned.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param[out] cats pointer to Cats structure
+ *
+ * \return -1 on error
+ * \return 0 on success
+ */
+int Rast_read_vector_cats(const char *name,
+ const char *mapset, struct Categories *pcats)
+{
+ char *type;
+
+ switch (read_cats("dig_cats", name, mapset, pcats, 1)) {
+ case -2:
+ type = "missing";
+ break;
+ case -1:
+ type = "invalid";
+ break;
+ default:
+ return 0;
+ }
+
+ G_warning(_("Category support for vector map <%s@%s> %s"),
+ name, mapset, type);
+ return -1;
+}
+
+/*!
+ \brief Get number of categories
+
+ \param name map name
+ \param mapset mapset name
+
+ \return -1 on error
+ \return number of cats
+*/
+CELL Rast_number_of_cats(const char *name, const char *mapset)
+{
+ struct Range range;
+ CELL min, max;
+
+ /* return the max category number */
+ if (Rast_read_range(name, mapset, &range) < 0)
+ return -1;
+ Rast_get_range_min_max(&range, &min, &max);
+ if (Rast_is_c_null_value(&max))
+ max = 0;
+ return max;
+}
+
+static CELL read_cats(const char *element,
+ const char *name,
+ const char *mapset, struct Categories * pcats, int full)
+{
+ FILE *fd;
+ char buff[1024];
+ CELL cat;
+ DCELL val1, val2;
+ int old = 0, fp_map;
+ long num = -1;
+
+
+ if (strncmp(element, "dig", 3) == 0)
+ fp_map = 0;
+ else
+ fp_map = Rast_raster_map_is_fp(name, mapset);
+
+ if (!(fd = G_fopen_old(element, name, mapset)))
+ return -2;
+
+ /* Read the number of categories */
+ if (G_getl(buff, sizeof buff, fd) == 0)
+ goto error;
+
+ if (sscanf(buff, "# %ld", &num) == 1)
+ old = 0;
+ else if (sscanf(buff, "%ld", &num) == 1)
+ old = 1;
+
+ if (!full) {
+ fclose(fd);
+ if (num < 0)
+ return 0; /* coorect */
+ return (CELL) num;
+ }
+
+ /* Read the title for the file */
+ if (G_getl(buff, sizeof buff, fd) == 0)
+ goto error;
+ G_strip(buff);
+ /* G_ascii_check(buff) ; */
+
+ Rast_init_raster_cats(buff, pcats);
+ if (num >= 0)
+ pcats->num = num;
+
+ if (!old) {
+ char fmt[256];
+ float m1, a1, m2, a2;
+
+ if (G_getl(fmt, sizeof fmt, fd) == 0)
+ goto error;
+ /* next line contains equation coefficients */
+ if (G_getl(buff, sizeof buff, fd) == 0)
+ goto error;
+ if (sscanf(buff, "%f %f %f %f", &m1, &a1, &m2, &a2) != 4)
+ goto error;
+ Rast_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
+ }
+
+ /* Read all category names */
+ for (cat = 0;; cat++) {
+ char label[1024];
+
+ if (G_getl(buff, sizeof buff, fd) == 0)
+ break;
+ if (old)
+ Rast_set_cat(cat, buff, pcats);
+ else {
+ *label = 0;
+ if (sscanf(buff, "%1s", label) != 1)
+ continue;
+ if (*label == '#')
+ continue;
+ *label = 0;
+ /* for fp maps try to read a range of data */
+ if (fp_map
+ && sscanf(buff, "%lf:%lf:%[^\n]", &val1, &val2, label) == 3)
+ Rast_set_raster_cat(&val1, &val2, label, pcats, DCELL_TYPE);
+ else if (sscanf(buff, "%d:%[^\n]", &cat, label) >= 1)
+ Rast_set_raster_cat(&cat, &cat, label, pcats, CELL_TYPE);
+ else if (sscanf(buff, "%lf:%[^\n]", &val1, label) >= 1)
+ Rast_set_raster_cat(&val1, &val1, label, pcats, DCELL_TYPE);
+ else
+ goto error;
+ }
+ }
+
+ fclose(fd);
+ return 0;
+ error:
+ fclose(fd);
+ return -1;
+}
+
+/*!
+ * \brief Get title from category structure struct
+ *
+ * \todo Remove from GIS Library, replace by Rast_get_raster_cats_title().
+ *
+ * Map layers store a one-line title in the category structure as
+ * well. This routine returns a pointer to the title contained in the
+ * <i>cats</i> structure. A legal pointer is always returned. If the
+ * map layer does not have a title, then a pointer to the empty string
+ * "" is returned.
+ *
+ * \param cats pointer to Categories structure
+ *
+ * \return title
+ * \return "" if missing
+ */
+
+char *Rast_get_cats_title(const struct Categories *pcats)
+{
+ return Rast_get_raster_cats_title(pcats);
+}
+
+/*!
+ * \brief Get raster cats title
+ *
+ * Returns pointer to a string with title.
+ *
+ * \param pcats pointer to Categories structure
+ *
+ * \return title
+ * \return "" if missing
+ */
+
+char *Rast_get_raster_cats_title(const struct Categories *pcats)
+{
+ return pcats->title ? pcats->title : "";
+}
+
+/*!
+ * \brief Get a raster category label
+ *
+ * \todo Remove from GIS Library, replaced by Rast_get_c_raster_cat().
+ *
+ * This routine looks up category <i>num</i> in the <i>pcats</i>
+ * structure and returns a pointer to a string which is the label for
+ * the category. A legal pointer is always returned. If the category
+ * does not exist in <i>pcats</i>, then a pointer to the empty string
+ * "" is returned.
+ *
+ * <b>Warning:</b> The pointer that is returned points to a hidden
+ * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * buffer.
+ *
+ * \param num cell value
+ * \param pcats pointer to Categories structure
+ *
+ * \return pointer to category label
+ * \return "" if category is not found
+ */
+char *Rast_get_cat(CELL num, struct Categories *pcats)
+{
+ return Rast_get_c_raster_cat(&num, pcats);
+}
+
+/*!
+ * \brief Get a raster category label (CELL)
+ *
+ * This routine looks up category <i>rast</i> in the <i>pcats</i>
+ * structure and returns a pointer to a string which is the label for
+ * the category. A legal pointer is always returned. If the category
+ * does not exist in <i>pcats</i>, then a pointer to the empty string
+ * "" is returned.
+ *
+ * <b>Warning:</b> The pointer that is returned points to a hidden
+ * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * buffer.
+ *
+ * \param rast cell value
+ * \param pcats pointer to Categories structure
+ *
+ * \return pointer to category label
+ * \return "" if category is not found
+ */
+char *Rast_get_c_raster_cat(CELL * rast, struct Categories *pcats)
+{
+ return Rast_get_raster_cat(rast, pcats, CELL_TYPE);
+}
+
+/*!
+ * \brief Get a raster category label (FCELL)
+ *
+ * This routine looks up category <i>rast</i> in the <i>pcats</i>
+ * structure and returns a pointer to a string which is the label for
+ * the category. A legal pointer is always returned. If the category
+ * does not exist in <i>pcats</i>, then a pointer to the empty string
+ * "" is returned.
+ *
+ * <b>Warning:</b> The pointer that is returned points to a hidden
+ * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * buffer.
+ *
+ * \param rast cell value
+ * \param pcats pointer to Categories structure
+ *
+ * \return pointer to category label
+ * \return "" if category is not found
+ */
+char *Rast_get_f_raster_cat(FCELL * rast, struct Categories *pcats)
+{
+ return Rast_get_raster_cat(rast, pcats, FCELL_TYPE);
+}
+
+/*!
+ * \brief Get a raster category label (DCELL)
+ *
+ * This routine looks up category <i>rast</i> in the <i>pcats</i>
+ * structure and returns a pointer to a string which is the label for
+ * the category. A legal pointer is always returned. If the category
+ * does not exist in <i>pcats</i>, then a pointer to the empty string
+ * "" is returned.
+ *
+ * <b>Warning:</b> The pointer that is returned points to a hidden
+ * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * buffer.
+ *
+ * \param rast cell value
+ * \param pcats pointer to Categories structure
+ *
+ * \return pointer to category label
+ * \return "" if category is not found
+ */
+char *Rast_get_d_raster_cat(DCELL * rast, struct Categories *pcats)
+{
+ return Rast_get_raster_cat(rast, pcats, DCELL_TYPE);
+}
+
+/*!
+ * \brief Get a raster category label
+ *
+ * This routine looks up category <i>rast</i> in the <i>pcats</i>
+ * structure and returns a pointer to a string which is the label for
+ * the category. A legal pointer is always returned. If the category
+ * does not exist in <i>pcats</i>, then a pointer to the empty string
+ * "" is returned.
+ *
+ * <b>Warning:</b> The pointer that is returned points to a hidden
+ * static buffer. Successive calls to Rast_get_cat() overwrite this
+ * buffer.
+ *
+ * \param rast cell value
+ * \param pcats pointer to Categories structure
+ * \param data_type map type (CELL, FCELL, DCELL)
+ *
+ * \return pointer to category label
+ * \return "" if category is not found
+ */
+char *Rast_get_raster_cat(void *rast,
+ struct Categories *pcats, RASTER_MAP_TYPE data_type)
+{
+ static char label[1024];
+ char *f, *l, *v;
+ CELL i;
+ DCELL val;
+ float a[2];
+ char fmt[30], value_str[30];
+
+ if (Rast_is_null_value(rast, data_type)) {
+ sprintf(label, "no data");
+ return label;
+ }
+
+ /* first search the list of labels */
+ *label = 0;
+ val = Rast_get_raster_value_d(rast, data_type);
+ i = Rast_quant_get_cell_value(&pcats->q, val);
+
+ G_debug(5, "Rast_get_raster_cat(): val %lf found i %d", val, i);
+
+ if (!Rast_is_c_null_value(&i) && i < pcats->ncats) {
+ if (pcats->labels[i] != NULL)
+ return pcats->labels[i];
+ return label;
+ }
+
+ /* generate the label */
+ if ((f = pcats->fmt) == NULL)
+ return label;
+
+ a[0] = (float)val *pcats->m1 + pcats->a1;
+ a[1] = (float)val *pcats->m2 + pcats->a2;
+
+ l = label;
+ while (*f) {
+ if (*f == '$') {
+ f++;
+ if (*f == '$')
+ *l++ = *f++;
+ else if (*f == '?') {
+ f++;
+ get_cond(&f, v = value_str, val);
+ while (*v)
+ *l++ = *v++;
+ }
+ else if (get_fmt(&f, fmt, &i)) {
+ sprintf(v = value_str, fmt, a[i]);
+ while (*v)
+ *l++ = *v++;
+ }
+ else
+ *l++ = '$';
+ }
+ else {
+ *l++ = *f++;
+ }
+ }
+ *l = 0;
+ return label;
+}
+
+/*!
+ * \brief Sets marks for all categories to 0.
+ *
+ * This initializes Categories structure for subsequest calls to
+ * Rast_mark_raster_cats() for each row of data, where non-zero mark for
+ * i-th label means that some of the cells in rast_row are labeled
+ * with i-th label and fall into i-th data range. These marks help
+ * determine from the Categories structure which labels were used and
+ * which weren't.
+ *
+ * \param pcats pointer to Categories structure
+ */
+void Rast_unmark_raster_cats(struct Categories *pcats)
+{
+ int i;
+
+ for (i = 0; i < pcats->ncats; i++)
+ pcats->marks[i] = 0;
+}
+
+/*!
+ * \brief Looks up the category label for each raster value (CELL).
+ *
+ * Looks up the category label for each raster value in the
+ * <i>rast_row</i> and updates the marks for labels found.
+ *
+ * <b>Note:</b> Non-zero mark for i-th label stores the number of of
+ * raster cells read so far which are labeled with i-th label and fall
+ * into i-th data range.
+ *
+ * \param rast_row raster row to update stats
+ * \param ncols number of columns
+ * \param pcats pointer to Categories structure
+ *
+ */
+void Rast_mark_c_raster_cats(const CELL * rast_row,
+ int ncols, struct Categories *pcats)
+{
+ Rast_mark_raster_cats(rast_row, ncols, pcats, CELL_TYPE);
+}
+
+/*!
+ * \brief Looks up the category label for each raster value (FCELL).
+ *
+ * Looks up the category label for each raster value in the
+ * <i>rast_row</i> and updates the marks for labels found.
+ *
+ * <b>Note:</b> Non-zero mark for i-th label stores the number of of
+ * raster cells read so far which are labeled with i-th label and fall
+ * into i-th data range.
+ *
+ * \param rast_row raster row to update stats
+ * \param ncols number of columns
+ * \param pcats pointer to Categories structure
+ *
+ */
+void Rast_mark_f_raster_cats(const FCELL * rast_row,
+ int ncols, struct Categories *pcats)
+{
+ Rast_mark_raster_cats(rast_row, ncols, pcats, FCELL_TYPE);
+}
+
+/*!
+ * \brief Looks up the category label for each raster value (DCELL).
+ *
+ * Looks up the category label for each raster value in the
+ * <i>rast_row</i> and updates the marks for labels found.
+ *
+ * <b>Note:</b> Non-zero mark for i-th label stores the number of of
+ * raster cells read so far which are labeled with i-th label and fall
+ * into i-th data range.
+ *
+ * \param rast_row raster row to update stats
+ * \param ncols number of columns
+ * \param pcats pointer to Categories structure
+ *
+ */
+void Rast_mark_d_raster_cats(const DCELL * rast_row,
+ int ncols, struct Categories *pcats)
+{
+ Rast_mark_raster_cats(rast_row, ncols, pcats, DCELL_TYPE);
+}
+
+/*!
+ * \brief Looks up the category label for each raster value (DCELL).
+ *
+ * Looks up the category label for each raster value in the
+ * <i>rast_row</i> and updates the marks for labels found.
+ *
+ * <b>Note:</b> Non-zero mark for i-th label stores the number of of
+ * raster cells read so far which are labeled with i-th label and fall
+ * into i-th data range.
+ *
+ * \param rast_row raster row to update stats
+ * \param ncols number of columns
+ * \param pcats pointer to Categories structure
+ *
+ * \return -1 on error
+ * \return 1 on success
+ */
+int Rast_mark_raster_cats(const void *rast_row,
+ int ncols, struct Categories *pcats,
+ RASTER_MAP_TYPE data_type)
+{
+ CELL i;
+
+ while (ncols-- > 0) {
+ i = Rast_quant_get_cell_value(&pcats->q,
+ Rast_get_raster_value_d(rast_row, data_type));
+ if (Rast_is_c_null_value(&i))
+ continue;
+ if (i > pcats->ncats)
+ return -1;
+ pcats->marks[i]++;
+ rast_row = Rast_incr_void_ptr(rast_row, Rast_raster_size(data_type));
+ }
+ return 1;
+}
+
+/*!
+ * \brief Rewind raster categories
+ *
+ * After call to this function Rast_get_next_marked_raster_cat() returns
+ * the first marked cat label.
+ *
+ * \param pcats pointer to Categories structure
+ */
+void Rast_rewind_raster_cats(struct Categories *pcats)
+{
+ pcats->last_marked_rule = -1;
+}
+
+/*!
+ \brief Get next marked raster categories (DCELL)
+
+ \param pcats pointer to Categories structure
+ \param rast1, rast2 cell values (raster range)
+ \param[out] count count
+
+ \return NULL if not found
+ \return description if found
+*/
+char *Rast_get_next_marked_d_raster_cat(struct Categories *pcats,
+ DCELL * rast1, DCELL * rast2,
+ long *count)
+{
+ char *descr = NULL;
+ int found, i;
+
+ found = 0;
+ /* pcats->ncats should be == Rast_quant_nof_rules(&pcats->q) */
+
+ G_debug(3, "last marked %d nrules %d\n", pcats->last_marked_rule, Rast_quant_nof_rules(&pcats->q));
+
+ for (i = pcats->last_marked_rule + 1; i < Rast_quant_nof_rules(&pcats->q); i++) {
+ descr = Rast_get_ith_d_raster_cat(pcats, i, rast1, rast2);
+ G_debug(5, "%d %d", i, pcats->marks[i]);
+ if (pcats->marks[i]) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ return NULL;
+
+ *count = pcats->marks[i];
+ pcats->last_marked_rule = i;
+ return descr;
+}
+
+/*!
+ \brief Get next marked raster categories (CELL)
+
+ \param pcats pointer to Categories structure
+ \param rast1, rast2 cell values (raster range)
+ \param[out] count count
+
+ \return NULL if not found
+ \return description if found
+*/
+char *Rast_get_next_marked_c_raster_cat(struct Categories *pcats,
+ CELL * rast1, CELL * rast2,
+ long *count)
+{
+ return Rast_get_next_marked_raster_cat(pcats, rast1, rast2, count,
+ CELL_TYPE);
+}
+
+/*!
+ \brief Get next marked raster categories (FCELL)
+
+ \param pcats pointer to Categories structure
+ \param rast1, rast2 cell values (raster range)
+ \param[out] count count
+
+ \return NULL if not found
+ \return description if found
+*/
+char *Rast_get_next_marked_f_raster_cat(struct Categories *pcats,
+ FCELL * rast1, FCELL * rast2,
+ long *count)
+{
+ return Rast_get_next_marked_raster_cat(pcats, rast1, rast2, count,
+ FCELL_TYPE);
+}
+
+/*!
+ \brief Get next marked raster categories
+
+ \param pcats pointer to Categories structure
+ \param rast1, rast2 cell values (raster range)
+ \param[out] count count
+ \param data_type map type
+
+ \return NULL if not found
+ \return description if found
+*/
+char *Rast_get_next_marked_raster_cat(struct Categories *pcats,
+ void *rast1, void *rast2,
+ long *count, RASTER_MAP_TYPE data_type)
+{
+ DCELL val1, val2;
+ char *lab;
+
+ lab = Rast_get_next_marked_d_raster_cat(pcats, &val1, &val2, count);
+ Rast_set_raster_value_d(rast1, val1, data_type);
+ Rast_set_raster_value_d(rast2, val2, data_type);
+ return lab;
+}
+
+static int get_fmt(char **f, char *fmt, int *i)
+{
+ char *ff;
+
+ ff = *f;
+ if (*ff == 0)
+ return 0;
+ if (*ff == '$') {
+ *f = ff + 1;
+ return 0;
+ }
+ switch (*ff++) {
+ case '1':
+ *i = 0;
+ break;
+ case '2':
+ *i = 1;
+ break;
+ default:
+ return 0;
+ }
+ *fmt++ = '%';
+ *fmt++ = '.';
+ if (*ff++ != '.') {
+ *f = ff - 1;
+ *fmt++ = '0';
+ *fmt++ = 'f';
+ *fmt = 0;
+ return 1;
+ }
+ *fmt = '0';
+ while (*ff >= '0' && *ff <= '9')
+ *fmt++ = *ff++;
+ *fmt++ = 'f';
+ *fmt = 0;
+ *f = ff;
+ return 1;
+}
+
+static void get_cond(char **f, char *value, DCELL val)
+{
+ char *ff;
+
+ ff = *f;
+ if (val == 1.) {
+ while (*ff)
+ if (*ff++ == '$')
+ break;
+ }
+
+ while (*ff)
+ if (*ff == '$') {
+ ff++;
+ break;
+ }
+ else
+ *value++ = *ff++;
+
+ if (val != 1.) {
+ while (*ff)
+ if (*ff++ == '$')
+ break;
+ }
+ *value = 0;
+ *f = ff;
+}
+
+
+/*!
+ * \brief Set a raster category label
+ *
+ * \todo To be removed, replaced by Rast_set_c_raster_cat().
+ *
+ * The <i>label</i> is copied into the <i>pcats</i> structure for
+ * category <i>num</i>.
+ *
+ * \param num raster cell
+ * \param label category label
+ * \param pcats pointer to Categories structure
+ *
+ * \return -1 on error
+ * \return 0 if null value detected
+ * \return 1 on success
+ */
+int Rast_set_cat(CELL num, const char *label, struct Categories *pcats)
+{
+ return Rast_set_c_raster_cat(&num, &num, label, pcats);
+}
+
+
+/*!
+ * \brief Set a raster category label (CELL)
+ *
+ * Adds the label for range <i>rast1</i> through <i>rast2</i> in
+ * category structure <i>pcats</i>.
+ *
+ * \param rast1, rast2 raster values (range)
+ * \param label category label
+ * \param pcats pointer to Categories structure
+ *
+ * \return -1 on error
+ * \return 0 if null value detected
+ * \return 1 on success
+ */
+int Rast_set_c_raster_cat(const CELL * rast1, const CELL * rast2,
+ const char *label, struct Categories *pcats)
+{
+ return Rast_set_raster_cat(rast1, rast2, label, pcats, CELL_TYPE);
+}
+
+/*!
+ * \brief Set a raster category label (FCELL)
+ *
+ * Adds the label for range <i>rast1</i> through <i>rast2</i> in
+ * category structure <i>pcats</i>.
+ *
+ * \param rast1, rast2 raster values (range)
+ * \param label category label
+ * \param pcats pointer to Categories structure
+ *
+ * \return
+ */
+int Rast_set_f_raster_cat(const FCELL * rast1, const FCELL * rast2,
+ const char *label, struct Categories *pcats)
+{
+ return Rast_set_raster_cat(rast1, rast2, label, pcats, FCELL_TYPE);
+}
+
+/*!
+ * \brief Set a raster category label (DCELL)
+ *
+ * Adds the label for range <i>rast1</i> through <i>rast2</i> in
+ * category structure <i>pcats</i>.
+ *
+ * \param rast1, rast2 raster values (range)
+ * \param label category label
+ * \param pcats pointer to Categories structure
+ *
+ * \return -1 on error
+ * \return 0 if null value detected
+ * \return 1 on success
+ */
+int Rast_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
+ const char *label, struct Categories *pcats)
+{
+ long len;
+ DCELL dtmp1, dtmp2;
+ int i;
+ char *descr;
+
+ /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(rast1 = %p,rast2 = %p,label = '%s',pcats = %p)\n",
+ rast1,rast2,label,pcats); */
+ if (Rast_is_d_null_value(rast1))
+ return 0;
+ if (Rast_is_d_null_value(rast2))
+ return 0;
+ /* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): adding quant rule: %f %f %d %d\n", *rast1, *rast2, pcats->ncats, pcats->ncats); */
+ /* the set_cat() functions are used in many places to reset the labels
+ for the range (or cat) with existing label. In this case we don't
+ want to store both rules with identical range even though the result
+ of get_cat() will be correct, since it will use rule added later.
+ we don't want to overuse memory and we don't want rules which are
+ not used to be writen out in cats file. So we first look if
+ the label for this range has been sen, and if it has, overwrite it */
+
+ for (i = 0; i < pcats->ncats; i++) {
+ descr = Rast_get_ith_d_raster_cat(pcats, i, &dtmp1, &dtmp2);
+ if ((dtmp1 == *rast1 && dtmp2 == *rast2)
+ || (dtmp1 == *rast2 && dtmp2 == *rast1)) {
+ if (pcats->labels[i] != NULL)
+ G_free(pcats->labels[i]);
+ pcats->labels[i] = G_store(label);
+ G_newlines_to_spaces(pcats->labels[i]);
+ G_strip(pcats->labels[i]);
+ return 1;
+ }
+ }
+ /* when rule for this range does not exist */
+ /* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): New rule: adding %d %p\n", i, pcats->labels); */
+ Rast_quant_add_rule(&pcats->q, *rast1, *rast2, pcats->ncats, pcats->ncats);
+ pcats->ncats++;
+ if (pcats->nalloc < pcats->ncats) {
+ /* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): need more space nalloc = %d ncats = %d\n", pcats->nalloc,pcats->ncats); */
+ len = (pcats->nalloc + 256) * sizeof(char *);
+ /* DEBUG fprintf (stderr, "Rast_set_d_raster_cat(): allocating %d labels(%d)\n", pcats->nalloc + 256,(int)len); */
+ if (len != (int)len) { /* make sure len doesn't overflow int */
+ pcats->ncats--;
+ return -1;
+ }
+ /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): pcats->nalloc = %d, pcats->labels = (%p), len = %d\n",pcats->nalloc,pcats->labels,(int)len); */
+ if (pcats->nalloc) {
+ /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): Realloc-ing pcats->labels (%p)\n",pcats->labels); */
+ pcats->labels =
+ (char **)G_realloc((char *)pcats->labels, (int)len);
+ }
+ else {
+ /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): alloc-ing new labels pointer array\n"); */
+ pcats->labels = (char **)G_malloc((int)len);
+ }
+ /* fflush(stderr); */
+ /* DEBUG fprintf (stderr, "Rast_set_d_raster_cats(): allocating %d marks(%d)\n", pcats->nalloc + 256,(int)len); */
+ len = (pcats->nalloc + 256) * sizeof(int);
+ if (len != (int)len) { /* make sure len doesn't overflow int */
+ pcats->ncats--;
+ return -1;
+ }
+ if (pcats->nalloc)
+ pcats->marks = (int *)G_realloc((char *)pcats->marks, (int)len);
+ else
+ pcats->marks = (int *)G_malloc((int)len);
+ pcats->nalloc += 256;
+ }
+ /* DEBUG fprintf(stderr,"Rast_set_d_raster_cats(): store new label\n"); */
+ pcats->labels[pcats->ncats - 1] = G_store(label);
+ G_newlines_to_spaces(pcats->labels[pcats->ncats - 1]);
+ G_strip(pcats->labels[pcats->ncats - 1]);
+ /* DEBUG
+ fprintf (stderr, "%d %s\n", pcats->ncats - 1, pcats->labels[pcats->ncats - 1]);
+ */
+ /* updates cats.num = max cat values. This is really just used in old
+ raster programs, and I am doing it for backwards cmpatibility (Olga) */
+ if ((CELL) * rast1 > pcats->num)
+ pcats->num = (CELL) * rast1;
+ if ((CELL) * rast2 > pcats->num)
+ pcats->num = (CELL) * rast2;
+ /* DEBUG fprintf(stderr,"Rast_set_d_raster_cat(): done\n"); */
+ /* DEBUG fflush(stderr); */
+ return 1;
+}
+
+
+/*!
+ * \brief Set a raster category label (DCELL)
+ *
+ * Adds the label for range <i>rast1</i> through <i>rast2</i> in
+ * category structure <i>pcats</i>.
+ *
+ * \param rast1, rast2 raster values (range)
+ * \param label category label
+ * \param pcats pointer to Categories structure
+ * \param data_type map type
+ *
+ * \return -1 on error
+ * \return 0 if null value detected
+ * \return 1 on success
+ */
+
+int Rast_set_raster_cat(const void *rast1, const void *rast2,
+ const char *label,
+ struct Categories *pcats, RASTER_MAP_TYPE data_type)
+{
+ DCELL val1, val2;
+
+ val1 = Rast_get_raster_value_d(rast1, data_type);
+ val2 = Rast_get_raster_value_d(rast2, data_type);
+ return Rast_set_d_raster_cat(&val1, &val2, label, pcats);
+}
+
+/*!
+ * \brief Write raster category file
+ *
+ * \todo To be removed, replaced by Rast_write_raster_cats().
+ *
+ * Writes the category file for the raster map <i>name</i> in the
+ * current mapset from the <i>cats</i> structure.
+ *
+ * \param name map name
+ * \param cats pointer to Categories structure
+ *
+ * \return 1 on success
+ * \return -1 is returned (no diagnostic is printed)
+ */
+int Rast_write_cats(const char *name, struct Categories *cats)
+{
+ return write_cats("cats", name, cats);
+}
+
+/*!
+ * \brief Write raster category file
+ *
+ * \todo To be removed, replaced by Rast_write_raster_cats().
+ *
+ * Writes the category file for the raster map <i>name</i> in the
+ * current mapset from the <i>cats</i> structure.
+ *
+ * \param name map name
+ * \param cats pointer to Categories structure
+ *
+ * \return 1 on success
+ * \return -1 is returned (no diagnostic is printed)
+ */
+int Rast_write_raster_cats(const char *name, struct Categories *cats)
+{
+ return write_cats("cats", name, cats);
+}
+
+/*!
+ * \brief Write vector category file
+ *
+ * <b>Note:</b> Used for only old vector format!
+ *
+ * \param name map name
+ * \param cats pointer to Categories structure
+ *
+ * \return 1 on success
+ * \return -1 is returned (no diagnostic is printed)
+ */
+int Rast_write_vector_cats(const char *name, struct Categories *cats)
+{
+ return write_cats("dig_cats", name, cats);
+}
+
+static int write_cats(const char *element, const char *name, struct Categories *cats)
+{
+ FILE *fd;
+ int i, fp_map;
+ char *descr;
+ DCELL val1, val2;
+ char str1[100], str2[100];
+
+ if (!(fd = G_fopen_new(element, name)))
+ return -1;
+
+ /* write # cats - note # indicate 3.0 or later */
+ fprintf(fd, "# %ld categories\n", (long)cats->num);
+
+ /* title */
+ fprintf(fd, "%s\n", cats->title != NULL ? cats->title : "");
+
+ /* write format and coefficients */
+ fprintf(fd, "%s\n", cats->fmt != NULL ? cats->fmt : "");
+ fprintf(fd, "%.2f %.2f %.2f %.2f\n",
+ cats->m1, cats->a1, cats->m2, cats->a2);
+
+ /* if the map is integer or if this is a vector map, sort labels */
+ if (strncmp(element, "dig", 3) == 0)
+ fp_map = 0;
+ else
+ fp_map = Rast_raster_map_is_fp(name, G_mapset());
+ if (!fp_map)
+ Rast_sort_cats(cats);
+
+ /* write the cat numbers:label */
+ for (i = 0; i < Rast_quant_nof_rules(&cats->q); i++) {
+ descr = Rast_get_ith_d_raster_cat(cats, i, &val1, &val2);
+ if ((cats->fmt && cats->fmt[0])
+ || (descr && descr[0])) {
+ if (val1 == val2) {
+ sprintf(str1, "%.10f", val1);
+ G_trim_decimal(str1);
+ fprintf(fd, "%s:%s\n", str1, descr != NULL ? descr : "");
+ }
+ else {
+ sprintf(str1, "%.10f", val1);
+ G_trim_decimal(str1);
+ sprintf(str2, "%.10f", val2);
+ G_trim_decimal(str2);
+ fprintf(fd, "%s:%s:%s\n", str1, str2,
+ descr != NULL ? descr : "");
+ }
+ }
+ }
+ fclose(fd);
+ return (1);
+}
+
+/*!
+ * \brief Get category description (DCELL)
+ *
+ * Returns i-th description and i-th data range from the list of
+ * category descriptions with corresponding data ranges. end points of
+ * data interval in <i>rast1</i> and <i>rast2</i>.
+ *
+ * \param pcats pointer to Categories structure
+ * \param i index
+ * \param rast1, rast2 raster values (range)
+ *
+ * \return "" on error
+ * \return pointer to category description
+ */
+char *Rast_get_ith_d_raster_cat(const struct Categories *pcats,
+ int i, DCELL * rast1, DCELL * rast2)
+{
+ int index;
+
+ if (i > pcats->ncats) {
+ Rast_set_d_null_value(rast1, 1);
+ Rast_set_d_null_value(rast2, 1);
+ return "";
+ }
+ Rast_quant_get_ith_rule(&pcats->q, i, rast1, rast2, &index, &index);
+ return pcats->labels[index];
+}
+
+/*!
+ * \brief Get category description (FCELL)
+ *
+ * Returns i-th description and i-th data range from the list of
+ * category descriptions with corresponding data ranges. end points of
+ * data interval in <i>rast1</i> and <i>rast2</i>.
+ *
+ * \param pcats pointer to Categories structure
+ * \param i index
+ * \param rast1, rast2 raster values (range)
+ *
+ * \return "" on error
+ * \return pointer to category description
+ */
+char *Rast_get_ith_f_raster_cat(const struct Categories *pcats,
+ int i, void *rast1, void *rast2)
+{
+ RASTER_MAP_TYPE data_type = FCELL_TYPE;
+ char *tmp;
+ DCELL val1, val2;
+
+ tmp = Rast_get_ith_d_raster_cat(pcats, i, &val1, &val2);
+ Rast_set_raster_value_d(rast1, val1, data_type);
+ Rast_set_raster_value_d(rast2, val2, data_type);
+ return tmp;
+}
+
+/*!
+ * \brief Get category description (CELL)
+ *
+ * Returns i-th description and i-th data range from the list of
+ * category descriptions with corresponding data ranges. end points of
+ * data interval in <i>rast1</i> and <i>rast2</i>.
+ *
+ * \param pcats pointer to Categories structure
+ * \param i index
+ * \param rast1, rast2 raster values (range)
+ *
+ * \return "" on error
+ * \return pointer to category description
+ */
+char *Rast_get_ith_c_raster_cat(const struct Categories *pcats,
+ int i, void *rast1, void *rast2)
+{
+ RASTER_MAP_TYPE data_type = CELL_TYPE;
+ char *tmp;
+ DCELL val1, val2;
+
+ tmp = Rast_get_ith_d_raster_cat(pcats, i, &val1, &val2);
+ Rast_set_raster_value_d(rast1, val1, data_type);
+ Rast_set_raster_value_d(rast2, val2, data_type);
+ return tmp;
+}
+
+/*!
+ * \brief Get category description
+ *
+ * Returns i-th description and i-th data range from the list of
+ * category descriptions with corresponding data ranges. end points of
+ * data interval in <i>rast1</i> and <i>rast2</i>.
+ *
+ * \param pcats pointer to Categories structure
+ * \param i index
+ * \param rast1, rast2 raster values (range)
+ * \param data_type map type
+ *
+ * \return "" on error
+ * \return pointer to category description
+ */
+char *Rast_get_ith_raster_cat(const struct Categories *pcats, int i, void *rast1,
+ void *rast2, RASTER_MAP_TYPE data_type)
+{
+ char *tmp;
+ DCELL val1, val2;
+
+ tmp = Rast_get_ith_d_raster_cat(pcats, i, &val1, &val2);
+ Rast_set_raster_value_d(rast1, val1, data_type);
+ Rast_set_raster_value_d(rast2, val2, data_type);
+ return tmp;
+}
+
+/*!
+ * \brief Initialize category structure
+ *
+ * To construct a new category file, the structure must first be
+ * initialized. This routine initializes the <i>cats</i> structure,
+ * and copies the <i>title</i> into the structure. The number of
+ * categories is set initially to <i>n</i>.
+ *
+ * For example:
+ \code
+ struct Categories cats;
+ Rast_init_cats ((CELL)0, * "", &cats);
+ \endcode
+ *
+ * \param num raster value
+ * \param title title
+ * \param pcats pointer to Categories structure
+ */
+void Rast_init_cats(CELL num, const char *title, struct Categories *pcats)
+{
+ Rast_init_raster_cats(title, pcats);
+ pcats->num = num;
+}
+
+/*!
+ * \brief Initialize category structure
+ *
+ * Same as existing Rast_init_raster_cats() only ncats argument is
+ * missign. ncats has no meaning in new Categories structure and only
+ * stores (int) largets data value for backwards compatibility.
+ *
+ * \param title title
+ * \param pcats pointer to Categories structure
+ */
+void Rast_init_raster_cats(const char *title, struct Categories *pcats)
+{
+ Rast_set_raster_cats_title(title, pcats);
+ pcats->labels = NULL;
+ pcats->nalloc = 0;
+ pcats->ncats = 0;
+ pcats->num = 0;
+ pcats->fmt = NULL;
+ pcats->m1 = 0.0;
+ pcats->a1 = 0.0;
+ pcats->m2 = 0.0;
+ pcats->a2 = 0.0;
+ pcats->last_marked_rule = -1;
+ Rast_quant_init(&pcats->q);
+}
+
+/*!
+ * \brief Set title in category structure
+ *
+ * \todo To be removed, replaced by Rast_set_raster_cats_title().
+ *
+ * The <i>title</i> is copied into the <i>pcats</i> structure.
+ *
+ * \param title title
+ * \param pcats pointer to Categories structure
+ */
+void Rast_set_cats_title(const char *title, struct Categories *pcats)
+{
+ Rast_set_raster_cats_title(title, pcats);
+}
+
+/*!
+ * \brief Set title in category structure
+ *
+ * The <i>title</i> is copied into the <i>pcats</i> structure.
+ *
+ * \param title title
+ * \param pcats pointer to Categories structure
+ */
+void Rast_set_raster_cats_title(const char *title, struct Categories *pcats)
+{
+ if (title == NULL)
+ title = "";
+ pcats->title = G_store(title);
+ G_newlines_to_spaces(pcats->title);
+ G_strip(pcats->title);
+}
+
+/*!
+ \brief Set category fmt (?)
+
+ \todo To be removed, replaced by Rast_set_raster_cats_fmt().
+
+ \param fmt
+ \param m1,
+ \param a1,m2,a2
+ \param pcats pointer to Categories structure
+*/
+void Rast_set_cats_fmt(const char *fmt, double m1, double a1, double m2,
+ double a2, struct Categories *pcats)
+{
+ Rast_set_raster_cats_fmt(fmt, m1, a1, m2, a2, pcats);
+}
+
+/*!
+ \brief Set category fmt (?)
+
+ \todo To be removed, replaced by Rast_set_raster_cats_fmt().
+
+ \param fmt
+ \param m1,
+ \param a1,m2,a2
+ \param pcats pointer to Categories structure
+*/
+void Rast_set_raster_cats_fmt(const char *fmt, double m1, double a1, double m2,
+ double a2, struct Categories *pcats)
+{
+ pcats->m1 = m1;
+ pcats->a1 = a1;
+ pcats->m2 = m2;
+ pcats->a2 = a2;
+
+ pcats->fmt = G_store(fmt);
+ G_newlines_to_spaces(pcats->fmt);
+ G_strip(pcats->fmt);
+}
+
+/*!
+ * \brief Free category structure memory
+ *
+ * \todo To be removed, replaced by Rast_free_raster_cats().
+ *
+ * Frees memory allocated by Rast_read_cats(), Rast_init_cats() and
+ * Rast_set_cat().
+ *
+ * \param pcats pointer to Categories structure
+ */
+void Rast_free_cats(struct Categories *pcats)
+{
+ Rast_free_raster_cats(pcats);
+}
+
+/*!
+ * \brief Free category structure memory
+ *
+ * \todo To be removed, replaced by Rast_free_raster_cats().
+ *
+ * Frees memory allocated by Rast_read_cats(), Rast_init_cats() and
+ * Rast_set_cat().
+ *
+ * \param pcats pointer to Categories structure
+ */
+void Rast_free_raster_cats(struct Categories *pcats)
+{
+ int i;
+
+ if (pcats->title != NULL) {
+ G_free(pcats->title);
+ pcats->title = NULL;
+ }
+ if (pcats->fmt != NULL) {
+ G_free(pcats->fmt);
+ pcats->fmt = NULL;
+ }
+ if (pcats->ncats > 0) {
+ for (i = 0; i < pcats->ncats; i++)
+ if (pcats->labels[i] != NULL)
+ G_free(pcats->labels[i]);
+ G_free(pcats->labels);
+ G_free(pcats->marks);
+ pcats->labels = NULL;
+ }
+ Rast_quant_free(&pcats->q);
+ pcats->ncats = 0;
+ pcats->nalloc = 0;
+}
+
+/*!
+ * \brief Copy raster categories
+ *
+ * Allocates NEW space for quant rules and labels n <i>pcats_to</i>
+ * and copies all info from <i>pcats_from</i> cats to
+ * <i>pcats_to</i> cats.
+ *
+ * \param pcats_to pointer to destination Categories structure
+ * \param pcats_from pointer to source Categories structure
+ */
+void Rast_copy_raster_cats(struct Categories *pcats_to,
+ const struct Categories *pcats_from)
+{
+ int i;
+ char *descr;
+ DCELL d1, d2;
+
+ Rast_init_raster_cats(pcats_from->title, pcats_to);
+ for (i = 0; i < pcats_from->ncats; i++) {
+ descr = Rast_get_ith_d_raster_cat(pcats_from, i, &d1, &d2);
+ Rast_set_d_raster_cat(&d1, &d2, descr, pcats_to);
+ }
+}
+
+/*!
+ \brief Get number of raster categories
+
+ \param pcats pointer to Categories structure
+
+ \return number of categories
+*/
+int Rast_number_of_raster_cats(struct Categories *pcats)
+{
+ return pcats->ncats;
+}
+
+/*!
+ \brief Sort categories
+
+ \param pcats pointer to Categories structure
+
+ \return -1 on error (nothing to sort)
+ \return 0 on success
+*/
+int Rast_sort_cats(struct Categories *pcats)
+{
+ int *indexes, i, ncats;
+ char *descr;
+ DCELL d1, d2;
+
+ if (pcats->ncats <= 1)
+ return -1;
+
+ ncats = pcats->ncats;
+ G_debug(3, "Rast_sort_cats(): Copying to save cats buffer");
+ Rast_copy_raster_cats(&save_cats, pcats);
+ Rast_free_raster_cats(pcats);
+
+ indexes = (int *)G_malloc(sizeof(int) * ncats);
+ for (i = 0; i < ncats; i++)
+ indexes[i] = i;
+
+ qsort(indexes, ncats, sizeof(int), cmp);
+ Rast_init_raster_cats(save_cats.title, pcats);
+ for (i = 0; i < ncats; i++) {
+ descr = Rast_get_ith_d_raster_cat(&save_cats, indexes[i], &d1, &d2);
+ G_debug(4, " Write sorted cats, pcats = %p pcats->labels = %p",
+ pcats, pcats->labels);
+ Rast_set_d_raster_cat(&d1, &d2, descr, pcats);
+ }
+ Rast_free_raster_cats(&save_cats);
+
+ return 0;
+}
+
+static int cmp(const void *aa, const void *bb)
+{
+ const int *a = aa, *b = bb;
+ DCELL min_rast1, min_rast2, max_rast1, max_rast2;
+ CELL index;
+
+ Rast_quant_get_ith_rule(&(save_cats.q), *a,
+ &min_rast1, &max_rast1, &index, &index);
+ Rast_quant_get_ith_rule(&(save_cats.q), *b,
+ &min_rast2, &max_rast2, &index, &index);
+ if (min_rast1 < min_rast2)
+ return -1;
+ if (min_rast1 > min_rast2)
+ return 1;
+ return 0;
+}
Copied: grass/trunk/lib/raster/cell_stats.c (from rev 37989, grass/trunk/lib/gis/cell_stats.c)
===================================================================
--- grass/trunk/lib/raster/cell_stats.c (rev 0)
+++ grass/trunk/lib/raster/cell_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,392 @@
+/*!
+ * \file gis/cell_stats.c
+ *
+ * \brief GIS Library - Raster cell statistics
+ *
+ * (C) 2001-2009 GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <stdlib.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+#define INCR 10
+#define SHIFT 6
+
+static const int NCATS = 1 << SHIFT;
+
+#define NODE struct Cell_stats_node
+
+static int next_node(struct Cell_stats *);
+static void init_node(NODE *, int, int);
+
+/*!
+ * \brief Initialize cell stats
+ *
+ * This routine, which must be called first, initializes the
+ * Cell_stats structure.
+ *
+ * Set the count for NULL-values to zero.
+ *
+ * \param s pointer to Cell_stats structure
+ */
+void Rast_init_cell_stats(struct Cell_stats *s)
+{
+ s->N = 0;
+ s->tlen = INCR;
+ s->node = (NODE *) G_malloc(s->tlen * sizeof(NODE));
+ s->null_data_count = 0;
+}
+
+/*!
+ * \brief Sdd data to cell stats
+ *
+ * The <i>n</i> CELL values in the <i>data</i> array are inserted (and
+ * counted) in the Cell_stats structure.
+ *
+ * Look for NULLs and update the NULL-value count.
+ *
+ * \param cell raster values
+ * \param n number of values
+ * \param s pointer to Cell_stats structure which holds cell stats info
+ *
+ * \return 1 on failure
+ * \return 0 on success
+ */
+int Rast_update_cell_stats(const CELL * cell, int n, struct Cell_stats *s)
+{
+ CELL cat;
+ int p, q;
+ int idx, offset;
+ int N;
+ NODE *node, *pnode;
+ NODE *new_node;
+
+ if (n <= 0)
+ return 1;
+
+ node = s->node;
+
+ /* first non-null node is special case */
+ if ((N = s->N) == 0) {
+ cat = *cell++;
+ while (Rast_is_c_null_value(&cat)) {
+ s->null_data_count++;
+ cat = *cell++;
+ n--;
+ }
+ if (n > 0) { /* if there are some non-null cells */
+ N = 1;
+ if (cat < 0) {
+ idx = -((-cat) >> SHIFT) - 1;
+ offset = cat + ((-idx) << SHIFT) - 1;
+ }
+ else {
+ idx = cat >> SHIFT;
+ offset = cat - (idx << SHIFT);
+ }
+ fflush(stderr);
+ init_node(&node[1], idx, offset);
+ node[1].right = 0;
+ n--;
+ }
+ }
+ while (n-- > 0) {
+ cat = *cell++;
+ if (Rast_is_c_null_value(&cat)) {
+ s->null_data_count++;
+ continue;
+ }
+ if (cat < 0) {
+ idx = -((-cat) >> SHIFT) - 1;
+ offset = cat + ((-idx) << SHIFT) - 1;
+ }
+ else {
+ idx = cat >> SHIFT;
+ offset = cat - (idx << SHIFT);
+ }
+
+ q = 1;
+ while (q > 0) {
+ pnode = &node[p = q];
+ if (pnode->idx == idx) {
+ pnode->count[offset]++;
+ break;
+ }
+ if (pnode->idx > idx)
+ q = pnode->left; /* go left */
+ else
+ q = pnode->right; /* go right */
+ }
+ if (q > 0)
+ continue; /* found */
+
+ /* new node */
+ N++;
+
+ /* grow the tree? */
+ if (N >= s->tlen) {
+ node =
+ (NODE *) G_realloc((char *)node,
+ sizeof(NODE) * (s->tlen += INCR));
+ pnode = &node[p]; /* realloc moves node, must reassign pnode */
+ }
+
+ /* add node to tree */
+ init_node(new_node = &node[N], idx, offset);
+
+ if (pnode->idx > idx) {
+ new_node->right = -p; /* create thread */
+ pnode->left = N; /* insert left */
+ }
+ else {
+ new_node->right = pnode->right; /* copy right link/thread */
+ pnode->right = N; /* add right */
+ }
+ } /* while n-- > 0 */
+ s->N = N;
+ s->node = node;
+
+ return 0;
+}
+
+static void init_node(NODE * node, int idx, int offset)
+{
+ long *count;
+ int i;
+
+ count = node->count = (long *)G_calloc(i = NCATS, sizeof(long));
+ while (i--)
+ *count++ = 0;
+ node->idx = idx;
+ node->count[offset] = 1;
+ node->left = 0;
+}
+
+
+/*!
+ * \brief Random query of cell stats
+ *
+ * This routine allows a random query of the Cell_stats structure. The
+ * <i>count</i> associated with the raster value <i>cat</i> is
+ * set. The routine returns 1 if <i>cat<i> was found in the
+ * structure, 0 otherwise.
+ *
+ * Allow finding the count for the NULL-value.
+ *
+ * \param cat raster value
+ * \param[out] count count
+ * \param s pointer to Cell_stats structure which holds cell stats info
+ *
+ * \return 1 if found
+ * \return 0 if not found
+ */
+int Rast_find_cell_stat(CELL cat, long *count, const struct Cell_stats *s)
+{
+ int q;
+ int idx;
+ int offset;
+
+ *count = 0;
+ if (Rast_is_c_null_value(&cat)) {
+ *count = s->null_data_count;
+ return (*count != 0);
+ }
+
+ if (s->N <= 0)
+ return 0;
+
+ /*
+ if (cat < 0)
+ {
+ idx = -(-cat/NCATS) - 1;
+ offset = cat - idx*NCATS - 1;
+ }
+ else
+ {
+ idx = cat/NCATS;
+ offset = cat - idx*NCATS;
+ }
+ */
+ if (cat < 0) {
+ idx = -((-cat) >> SHIFT) - 1;
+ offset = cat + ((-idx) << SHIFT) - 1;
+ }
+ else {
+ idx = cat >> SHIFT;
+ offset = cat - (idx << SHIFT);
+ }
+
+ q = 1;
+ while (q > 0) {
+ if (s->node[q].idx == idx) {
+ *count = s->node[q].count[offset];
+ return (*count != 0);
+ }
+ if (s->node[q].idx > idx)
+ q = s->node[q].left; /* go left */
+ else
+ q = s->node[q].right; /* go right */
+ }
+ return 0;
+}
+
+/*!
+ * \brief Reset/rewind cell stats
+ *
+ * The structure <i>s</i> is rewound (i.e., positioned at the first
+ * raster category) so that sorted sequential retrieval can begin.
+ *
+ * \param s pointer to Cell_stats structure which holds cell stats info
+ *
+ * \return 0
+ */
+int Rast_rewind_cell_stats(struct Cell_stats *s)
+{
+ int q;
+
+ if (s->N <= 0)
+ return 1;
+ /* start at root and go all the way to the left */
+ s->curp = 1;
+ while ((q = s->node[s->curp].left))
+ s->curp = q;
+ s->curoffset = -1;
+
+ return 0;
+}
+
+static int next_node(struct Cell_stats *s)
+{
+ int q;
+
+ /* go to the right */
+ s->curp = s->node[s->curp].right;
+
+ if (s->curp == 0) /* no more */
+ return 0;
+
+ if (s->curp < 0) { /* thread. stop here */
+ s->curp = -(s->curp);
+ return 1;
+ }
+
+ while ((q = s->node[s->curp].left)) /* now go all the way left */
+ s->curp = q;
+
+ return 1;
+}
+
+/*!
+ * \brief Retrieve sorted cell stats
+ *
+ * Retrieves the next <i>cat, count</i> combination from the
+ * structure. Returns 0 if there are no more items, non-zero if there
+ * are more. For example:
+ *
+ \code
+ struct Cell_stats s;
+ CELL cat;
+ long count;
+
+ // updating <b>s</b> occurs here
+
+ Rast_rewind_cell_stats(&s);
+ while (Rast_next_cell_stat(&cat,&count,&s)
+ fprintf(stdout, "%ld %ld\n", (long) cat, count);
+ \endcode
+ *
+ * Do not return a record for the NULL-value
+ *
+ * \param cat raster value
+ * \param[out] count
+ * \param s pointer to Cell_stats structure which holds cell stats info
+ *
+ * \return 0 if there are no more items
+ * \return non-zero if there are more
+ */
+int Rast_next_cell_stat(CELL * cat, long *count, struct Cell_stats *s)
+{
+ int idx;
+
+ /* first time report stats for null */
+ /* decided not to return stats for null in this function
+ static int null_reported = 0;
+ if(!null_reported && s->null_data_count > 0)
+ {
+ *count = s->null_data_count;
+ Rast_set_c_null_value(&cat,1);
+ null_reported = 1;
+ return 1;
+ }
+ */
+ if (s->N <= 0)
+ return 0;
+ for (;;) {
+ s->curoffset++;
+ if (s->curoffset >= NCATS) {
+ if (!next_node(s))
+ return 0;
+ s->curoffset = -1;
+ continue;
+ }
+ if ((*count = s->node[s->curp].count[s->curoffset])) {
+ idx = s->node[s->curp].idx;
+
+ /*
+ if (idx < 0)
+ *cat = idx*NCATS + s->curoffset+1;
+ else
+ *cat = idx*NCATS + s->curoffset;
+ */
+ if (idx < 0)
+ *cat = -((-idx) << SHIFT) + s->curoffset + 1;
+ else
+ *cat = (idx << SHIFT) + s->curoffset;
+
+ return 1;
+ }
+ }
+}
+
+
+/*!
+ * \brief Get number of null values.
+ *
+ * Get a number of null values from stats structure.
+ *
+ * Note: when reporting values which appear in a map using
+ * Rast_next_cell_stats(), to get stats for null, call
+ * Rast_get_stats_for_null_value() first, since Rast_next_cell_stats() does
+ * not report stats for null.
+ *
+ * \param count count
+ * \param s pointer to Cell_stats structure which holds cell stats info
+ */
+void Rast_get_stats_for_null_value(long *count, const struct Cell_stats *s)
+{
+ *count = s->null_data_count;
+}
+
+/*!
+ * \brief Free cell stats structure
+ *
+ * The memory associated with structure <i>s</i> is freed. This
+ * routine may be called any time after calling Rast_init_cell_stats().
+ *
+ * \param s pointer to Cell_stats structure
+ */
+void Rast_free_cell_stats(struct Cell_stats *s)
+{
+ int i;
+
+ for (i = 1; i <= s->N; i++)
+ G_free(s->node[i].count);
+ G_free(s->node);
+}
Copied: grass/trunk/lib/raster/cell_title.c (from rev 37989, grass/trunk/lib/gis/cell_title.c)
===================================================================
--- grass/trunk/lib/raster/cell_title.c (rev 0)
+++ grass/trunk/lib/raster/cell_title.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,50 @@
+
+/**************************************************************
+ * char *Rast_get_cell_title (name, mapset)
+ * char *name name of map file
+ * char *mapset mapset containing name
+ *
+ * returns pointer to string containing cell title. (from cats file)
+ *************************************************************/
+
+#include <grass/gis.h>
+
+
+/*!
+ * \brief get raster map title
+ *
+ * If only the map layer title is needed, it is not necessary to read the
+ * entire category file into memory. This routine gets the title for raster map
+ * <b>name</b> in <b>mapset</b> directly from the category file, and returns
+ * a pointer to the title. A legal pointer is always returned. If the map layer
+ * does not have a title, then a pointer to the empty string "" is returned.
+ *
+ * \param name
+ * \param mapset
+ * \return char *
+ */
+
+char *Rast_get_cell_title(const char *name, const char *mapset)
+{
+ FILE *fd;
+ int stat;
+ char title[1024];
+
+ stat = -1;
+ fd = G_fopen_old("cats", name, mapset);
+ if (fd) {
+ stat = 1;
+ if (!fgets(title, sizeof title, fd)) /* skip number of cats */
+ stat = -1;
+ else if (!G_getl(title, sizeof title, fd)) /* read title */
+ stat = -1;
+
+ fclose(fd);
+ }
+
+ if (stat < 0)
+ *title = 0;
+ else
+ G_strip(title);
+ return G_store(title);
+}
Copied: grass/trunk/lib/raster/cellstats_eq.c (from rev 37989, grass/trunk/lib/gis/cellstats_eq.c)
===================================================================
--- grass/trunk/lib/raster/cellstats_eq.c (rev 0)
+++ grass/trunk/lib/raster/cellstats_eq.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,76 @@
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+int Rast_cell_stats_histo_eq(struct Cell_stats *statf, CELL min1, CELL max1, /* input range to be rescaled */
+ CELL min2, CELL max2, /* output range */
+ int zero, /* include zero if min1 <= 0 <= min2 ? */
+ void (*func) (CELL, CELL, CELL))
+{
+ long count, total;
+ CELL prev = 0;
+ CELL cat;
+ CELL x;
+ CELL newcat = 0;
+ int first;
+ double span, sum;
+ double range2;
+
+
+ if (min1 > max1 || min2 > max2)
+ return 0;
+
+ total = 0;
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
+ if (cat < min1)
+ continue;
+ if (cat > max1)
+ break;
+ if (cat == 0 && !zero)
+ continue;
+
+ total += count;
+ }
+ if (total <= 0)
+ return 0;
+
+ range2 = max2 - min2 + 1;
+ span = total / range2;
+
+ first = 1;
+ sum = 0;
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
+ if (cat < min1)
+ continue;
+ if (cat > max1)
+ break;
+ if (cat == 0 && !zero)
+ continue;
+
+ x = (sum + (count / 2.0)) / span;
+ if (x < 0)
+ x = 0;
+ x += min2;
+ sum += count;
+
+ if (first) {
+ prev = cat;
+ newcat = x;
+ first = 0;
+ }
+ else if (newcat != x) {
+ func(prev, cat - 1, newcat);
+ newcat = x;
+ prev = cat;
+ }
+ }
+ if (!first) {
+ func(prev, cat, newcat);
+ if (!zero && min1 <= 0 && max1 >= 0)
+ func((CELL) 0, (CELL) 0, (CELL) 0);
+ }
+
+ return first == 0;
+}
Copied: grass/trunk/lib/raster/closecell.c (from rev 37989, grass/trunk/lib/gis/closecell.c)
===================================================================
--- grass/trunk/lib/raster/closecell.c (rev 0)
+++ grass/trunk/lib/raster/closecell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,505 @@
+/*!
+ * \file gis/closecell.c
+ *
+ * \brief GIS Library - Close raster file
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#ifdef __MINGW32__
+# include <windows.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+
+#define FORMAT_FILE "f_format"
+#define QUANT_FILE "f_quant"
+#define NULL_FILE "null"
+
+static int close_old(int);
+static int close_new(int, int);
+
+static int write_fp_format(int fd);
+
+/*!
+ * \brief Close a raster map
+ *
+ * The raster map opened on file descriptor <i>fd</i> is
+ * closed. Memory allocated for raster processing is freed. If open
+ * for writing, skeletal support files for the new raster map are
+ * created as well.
+ *
+ * <b>Note:</b> If a module wants to explicitly write support files
+ * (e.g., a specific color table) for a raster map it creates, it must
+ * do so after the raster map is closed. Otherwise the close will
+ * overwrite the support files. See \ref
+ * Raster_Map_Layer_Support_Routines for routines which write raster
+ * support files.
+ *
+ * If the map is a new floating point, move the <tt>.tmp</tt> file
+ * into the <tt>fcell</tt> element, create an empty file in the
+ * <tt>cell</tt> directory; write the floating-point range file; write
+ * a default quantization file quantization file is set here to round
+ * fp numbers (this is a default for now). create an empty category
+ * file, with max cat = max value (for backwards compatibility). Move
+ * the <tt>.tmp</tt> NULL-value bitmap file to the <tt>cell_misc</tt>
+ * directory.
+ *
+ * \param fd file descriptor
+ *
+ * \return -1 on error
+ * \return 1 on success
+ */
+int Rast_close_cell(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ if (fd < 0 || fd >= G__.fileinfo_count || fcb->open_mode <= 0)
+ return -1;
+ if (fcb->open_mode == OPEN_OLD)
+ return close_old(fd);
+
+ return close_new(fd, 1);
+}
+
+/*!
+ * \brief Unopen a raster map
+ *
+ * The raster map opened on file descriptor <i>fd</i> is
+ * closed. Memory allocated for raster processing is freed. If open
+ * for writing, the raster map is not created and the temporary file
+ * created when the raster map was opened is removed (see \ref
+ * Creating_and_Opening_New_Raster_Files). This routine is useful when
+ * errors are detected and it is desired to not create the new raster
+ * map. While it is true that the raster map will not be created if
+ * the module exits without closing the file, the temporary file will
+ * not be removed at module exit. GRASS database management will
+ * eventually remove the temporary file, but the file can be quite
+ * large and will take up disk space until GRASS does remove it. Use
+ * this routine as a courtesy to the user.
+ *
+ * \param fd file descriptor
+ *
+ * \return -1 on error
+ * \return 1 on success
+ */
+int Rast_unopen_cell(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ if (fd < 0 || fd >= G__.fileinfo_count || fcb->open_mode <= 0)
+ return -1;
+ if (fcb->open_mode == OPEN_OLD)
+ return close_old(fd);
+ else
+ return close_new(fd, 0);
+}
+
+static int close_old(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int i;
+
+ /* if G__.auto_mask was only allocated for reading map rows to create
+ non-existant null rows, and not for actuall mask, free G__.mask_row
+ if(G__.auto_mask <=0)
+ G_free (G__.mask_buf);
+ This is obsolete since now the mask_bus is always allocated
+ */
+
+ if (fcb->gdal)
+ Rast_close_gdal_link(fcb->gdal);
+
+ for (i = 0; i < NULL_ROWS_INMEM; i++)
+ G_free(fcb->NULL_ROWS[i]);
+
+ if (fcb->cellhd.compressed)
+ G_free(fcb->row_ptr);
+ G_free(fcb->col_map);
+ G_free(fcb->mapset);
+ G_free(fcb->data);
+ G_free(fcb->name);
+ if (fcb->reclass_flag)
+ Rast_free_reclass(&fcb->reclass);
+ fcb->open_mode = -1;
+
+ if (fcb->map_type != CELL_TYPE) {
+ Rast_quant_free(&fcb->quant);
+ xdr_destroy(&fcb->xdrstream);
+ }
+ close(fd);
+
+ return 1;
+}
+
+static void write_support_files(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ struct Categories cats;
+ struct History hist;
+ CELL cell_min, cell_max;
+ char path[GPATH_MAX];
+
+ /* remove color table */
+ Rast_remove_colors(fcb->name, "");
+
+ /* create a history file */
+ Rast_short_history(fcb->name, "raster", &hist);
+ Rast_write_history(fcb->name, &hist);
+
+ /* write the range */
+ if (fcb->map_type == CELL_TYPE) {
+ Rast_write_range(fcb->name, &fcb->range);
+ Rast__remove_fp_range(fcb->name);
+ }
+ /*NOTE: int range for floating point maps is not written out */
+ else { /* if(fcb->map_type != CELL_TYPE) */
+
+ Rast_write_fp_range(fcb->name, &fcb->fp_range);
+ Rast_construct_default_range(&fcb->range);
+ /* this range will be used to add default rule to quant structure */
+ }
+
+ if (fcb->map_type != CELL_TYPE)
+ fcb->cellhd.format = -1;
+ else /* CELL map */
+ fcb->cellhd.format = fcb->nbytes - 1;
+
+ /* write header file */
+ Rast_put_cellhd(fcb->name, &fcb->cellhd);
+
+ /* if map is floating point write the quant rules, otherwise remove f_quant */
+ if (fcb->map_type != CELL_TYPE) {
+ /* DEFAULT RANGE QUANT
+ Rast_get_fp_range_min_max(&fcb->fp_range, &dcell_min, &dcell_max);
+ if(!Rast_is_d_null_value(&dcell_min) && !Rast_is_d_null_value(&dcell_max))
+ {
+ Rast_get_range_min_max(&fcb->range, &cell_min, &cell_max);
+ Rast_quant_add_rule(&fcb->quant, dcell_min, dcell_max,
+ cell_min, cell_max);
+ }
+ */
+ Rast_quant_round(&fcb->quant);
+ if (Rast_write_quant(fcb->name, fcb->mapset, &fcb->quant) < 0)
+ G_warning(_("unable to write quant file!"));
+ }
+ else {
+ /* remove cell_misc/name/f_quant */
+ G__file_name_misc(path, "cell_misc", QUANT_FILE, fcb->name,
+ fcb->mapset);
+ remove(path);
+ }
+
+ /* create empty cats file */
+ Rast_get_range_min_max(&fcb->range, &cell_min, &cell_max);
+ if (Rast_is_c_null_value(&cell_max))
+ cell_max = 0;
+ Rast_init_cats(cell_max, (char *)NULL, &cats);
+ Rast_write_cats(fcb->name, &cats);
+ Rast_free_cats(&cats);
+
+ /* write the histogram */
+ /* only works for integer maps */
+ if ((fcb->map_type == CELL_TYPE)
+ && (fcb->want_histogram)) {
+ Rast_write_histogram_cs(fcb->name, &fcb->statf);
+ Rast_free_cell_stats(&fcb->statf);
+ }
+ else {
+ Rast_remove_histogram(fcb->name);
+ }
+}
+
+static int close_new_gdal(int fd, int ok)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ char path[GPATH_MAX];
+ int stat = 1;
+
+ if (ok) {
+ int cell_fd;
+
+ G_debug(1, "close %s GDAL", fcb->name);
+
+ if (fcb->cur_row < fcb->cellhd.rows) {
+ int row;
+
+ Rast_zero_raster_buf(fcb->data, fcb->map_type);
+ for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
+ Rast_put_raster_row(fd, fcb->data, fcb->map_type);
+ G_free(fcb->data);
+ fcb->data = NULL;
+ }
+
+ /* create path : full null file name */
+ G__make_mapset_element_misc("cell_misc", fcb->name);
+ G__file_name_misc(path, "cell_misc", NULL_FILE, fcb->name,
+ G_mapset());
+ remove(path);
+
+ /* write 0-length cell file */
+ G__make_mapset_element("cell");
+ G__file_name(path, "cell", fcb->name, fcb->mapset);
+ cell_fd = creat(path, 0666);
+ close(cell_fd);
+
+ if (fcb->map_type != CELL_TYPE) { /* floating point map */
+ if (write_fp_format(fd) != 0) {
+ G_warning(_("Error writing floating point format file for map %s"),
+ fcb->name);
+ stat = -1;
+ }
+
+ /* write 0-length fcell file */
+ G__make_mapset_element("fcell");
+ G__file_name(path, "fcell", fcb->name, fcb->mapset);
+ cell_fd = creat(path, 0666);
+ close(cell_fd);
+ }
+ else {
+ /* remove fcell/name file */
+ G__file_name(path, "fcell", fcb->name, fcb->mapset);
+ remove(path);
+ /* remove cell_misc/name/f_format */
+ G__file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
+ fcb->mapset);
+ remove(path);
+ }
+
+ if (Rast_close_gdal_write_link(fcb->gdal) < 0)
+ stat = -1;
+ }
+ else {
+ remove(fcb->gdal->filename);
+ Rast_close_gdal_link(fcb->gdal);
+ }
+
+ /* NOW CLOSE THE FILE DESCRIPTOR */
+ close(fd);
+ fcb->open_mode = -1;
+
+ if (fcb->data != NULL)
+ G_free(fcb->data);
+
+ if (ok)
+ write_support_files(fd);
+
+ G_free(fcb->name);
+ G_free(fcb->mapset);
+
+ if (fcb->map_type != CELL_TYPE)
+ Rast_quant_free(&fcb->quant);
+
+ return stat;
+}
+
+static int close_new(int fd, int ok)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int stat;
+ char path[GPATH_MAX];
+ int row, i;
+ const char *CELL_DIR;
+
+ if (fcb->gdal)
+ return close_new_gdal(fd, ok);
+
+ if (ok) {
+ switch (fcb->open_mode) {
+ case OPEN_NEW_COMPRESSED:
+ G_debug(1, "close %s compressed", fcb->name);
+ break;
+ case OPEN_NEW_UNCOMPRESSED:
+ G_debug(1, "close %s uncompressed", fcb->name);
+ break;
+ }
+
+ if (fcb->cur_row < fcb->cellhd.rows) {
+ Rast_zero_raster_buf(fcb->data, fcb->map_type);
+ for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
+ Rast_put_raster_row(fd, fcb->data, fcb->map_type);
+ G_free(fcb->data);
+ fcb->data = NULL;
+ }
+
+ /* create path : full null file name */
+ G__make_mapset_element_misc("cell_misc", fcb->name);
+ G__file_name_misc(path, "cell_misc", NULL_FILE, fcb->name,
+ G_mapset());
+ remove(path);
+
+ if (fcb->null_cur_row > 0) {
+ /* if temporary NULL file exists, write it into cell_misc/name/null */
+ int null_fd;
+
+ null_fd = Rast__open_null_write(fd);
+ if (null_fd <= 0)
+ return -1;
+ if (null_fd < 1)
+ return -1;
+
+ /* first finish writing null file */
+ /* write out the rows stored in memory */
+ for (row = fcb->min_null_row; row < fcb->null_cur_row; row++)
+ Rast__write_null_bits(null_fd,
+ fcb->NULL_ROWS[row - fcb->min_null_row],
+ row, fcb->cellhd.cols, fd);
+
+ /* write missing rows */
+ if (fcb->null_cur_row < fcb->cellhd.rows) {
+ unsigned char *null_work_buf = Rast__allocate_null_bits(fcb->cellhd.cols);
+ Rast__init_null_bits(null_work_buf, fcb->cellhd.cols);
+ for (row = fcb->null_cur_row; row < fcb->cellhd.rows; row++)
+ Rast__write_null_bits(null_fd, null_work_buf, row,
+ fcb->cellhd.cols, fd);
+ G_free(null_work_buf);
+ }
+ close(null_fd);
+
+ if (rename(fcb->null_temp_name, path)) {
+ G_warning(_("Unable to renae null file '%s'"),
+ fcb->null_temp_name, path);
+ stat = -1;
+ }
+ else {
+ remove(fcb->null_temp_name);
+ }
+ }
+ else {
+ remove(fcb->null_temp_name);
+ remove(path);
+ } /* null_cur_row > 0 */
+
+ if (fcb->open_mode == OPEN_NEW_COMPRESSED) { /* auto compression */
+ fcb->row_ptr[fcb->cellhd.rows] = lseek(fd, 0L, SEEK_CUR);
+ Rast__write_row_ptrs(fd);
+ }
+
+ if (fcb->map_type != CELL_TYPE) { /* floating point map */
+ int cell_fd;
+
+ if (write_fp_format(fd) != 0) {
+ G_warning(_("Error writing floating point format file for map <%s>"),
+ fcb->name);
+ stat = -1;
+ }
+
+ /* now write 0-length cell file */
+ G__make_mapset_element("cell");
+ cell_fd =
+ creat(G__file_name(path, "cell", fcb->name, fcb->mapset),
+ 0666);
+ close(cell_fd);
+ CELL_DIR = "fcell";
+ }
+ else {
+ /* remove fcell/name file */
+ G__file_name(path, "fcell", fcb->name, fcb->mapset);
+ remove(path);
+ /* remove cell_misc/name/f_format */
+ G__file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name,
+ fcb->mapset);
+ remove(path);
+ CELL_DIR = "cell";
+ close(fd);
+ }
+ } /* ok */
+ /* NOW CLOSE THE FILE DESCRIPTOR */
+
+ close(fd);
+ fcb->open_mode = -1;
+
+ if (fcb->data != NULL)
+ G_free(fcb->data);
+
+ if (fcb->null_temp_name != NULL) {
+ G_free(fcb->null_temp_name);
+ fcb->null_temp_name = NULL;
+ }
+
+ /* if the cell file was written to a temporary file
+ * move this temporary file into the cell file
+ * if the move fails, tell the user, but go ahead and create
+ * the support files
+ */
+ stat = 1;
+ if (ok && (fcb->temp_name != NULL)) {
+ G__file_name(path, CELL_DIR, fcb->name, fcb->mapset);
+ remove(path);
+ if (rename(fcb->temp_name, path)) {
+ G_warning(_("Unable to rename cell file '%s'"),
+ fcb->temp_name, path);
+ stat = -1;
+ }
+ else {
+ remove(fcb->temp_name);
+ }
+ }
+
+ if (fcb->temp_name != NULL) {
+ G_free(fcb->temp_name);
+ }
+
+ if (ok)
+ write_support_files(fd);
+
+ G_free(fcb->name);
+ G_free(fcb->mapset);
+
+ for (i = 0; i < NULL_ROWS_INMEM; i++)
+ G_free(fcb->NULL_ROWS[i]);
+
+ if (fcb->map_type != CELL_TYPE)
+ Rast_quant_free(&fcb->quant);
+
+ return stat;
+}
+
+/* returns 0 on success, 1 on failure */
+static int write_fp_format(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ struct Key_Value *format_kv;
+ char path[GPATH_MAX];
+ int stat;
+
+ if (fcb->map_type == CELL_TYPE) {
+ G_warning(_("unable to write f_format file for CELL maps"));
+ return 0;
+ }
+ format_kv = G_create_key_value();
+ if (fcb->map_type == FCELL_TYPE)
+ G_set_key_value("type", "float", format_kv);
+ else
+ G_set_key_value("type", "double", format_kv);
+
+ G_set_key_value("byte_order", "xdr", format_kv);
+
+ if (fcb->open_mode == OPEN_NEW_COMPRESSED)
+ G_set_key_value("lzw_compression_bits", "-1", format_kv);
+
+ G__make_mapset_element_misc("cell_misc", fcb->name);
+ G__file_name_misc(path, "cell_misc", FORMAT_FILE, fcb->name, fcb->mapset);
+ G_write_key_value_file(path, format_kv, &stat);
+
+ G_free_key_value(format_kv);
+
+ return stat;
+}
Copied: grass/trunk/lib/raster/color_compat.c (from rev 37989, grass/trunk/lib/gis/color_compat.c)
===================================================================
--- grass/trunk/lib/raster/color_compat.c (rev 0)
+++ grass/trunk/lib/raster/color_compat.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,315 @@
+/*!
+ * \file gis/color_compat.c
+ *
+ * \brief GIS Library - Predefined color tables
+ *
+ * (C) 2007-2009 Glynn Clements and the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Glynn Clements <glynn at gclements.plus.com>
+ */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Make color wave (integer)
+ *
+ * Generates a color table with 3 sections: red only, green only, and
+ * blue only, each increasing from none to full intensity and back
+ * down to none. This table is good for continuous data like
+ * elevation.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_wave_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "wave", min, max);
+}
+
+/*!
+ * \brief Make color wave (floating-point)
+ *
+ * Generates a color table with 3 sections: red only, green only, and
+ * blue only, each increasing from none to full intensity and back
+ * down to none. This table is good for continuous data like
+ * elevation.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_wave_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "wave", min, max);
+}
+
+/*!
+ * \brief Create RYG color table (integer)
+ *
+ * Generates a color table red-yellow-green.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_ryg_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "ryg", min, max);
+}
+
+/*!
+ * \brief Create RYG color table (floating-point)
+ *
+ * Generates a color table red-yellow-green.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_ryg_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "ryg", min, max);
+}
+
+/*!
+ * \brief Make color ramp (integer)
+ *
+ * Generates a color table with 3 sections: red only, green only, and
+ * blue only, each increasing from none to full intensity. This table
+ * is good for continuous data, such as elevation.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_ramp_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "ramp", min, max);
+}
+
+/*!
+ * \brief Make color ramp (floating-point)
+ *
+ * Generates a color table with 3 sections: red only, green only, and
+ * blue only, each increasing from none to full intensity. This table
+ * is good for continuous data, such as elevation.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_ramp_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "ramp", min, max);
+}
+
+/*!
+ * \brief Make rainbow colors (integer)
+ *
+ * Generates a "shifted" rainbow color table - yellow to green to cyan
+ * to blue to magenta to red. The color table is based on rainbow
+ * colors. (Normal rainbow colors are red, orange, yellow, green,
+ * blue, indigo, and violet.) This table is good for continuous data,
+ * such as elevation.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_rainbow_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "rainbow", min, max);
+}
+
+/*!
+ * \brief Make rainbow colors (floating-point)
+ *
+ * Generates a "shifted" rainbow color table - yellow to green to cyan
+ * to blue to magenta to red. The color table is based on rainbow
+ * colors. (Normal rainbow colors are red, orange, yellow, green,
+ * blue, indigo, and violet.) This table is good for continuous data,
+ * such as elevation.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_rainbow_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "rainbow", min, max);
+}
+
+/*!
+ * \brief Create GYR color table (integer)
+ *
+ * Generates a color table green-yellow-red.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_gyr_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "gyr", min, max);
+}
+
+/*!
+ * \brief Create GYR color table (floating-point)
+ *
+ * Generates a color table green-yellow-red.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_gyr_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "gyr", min, max);
+}
+
+/*!
+ * \brief Make linear grey scale (integer)
+ *
+ * Generates a grey scale color table. Each color is a level of grey,
+ * increasing from black to white.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_grey_scale_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "grey", min, max);
+}
+
+/*!
+ * \brief Make linear grey scale (floating-point)
+ *
+ * Generates a grey scale color table. Each color is a level of grey,
+ * increasing from black to white.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_grey_scale_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "grey", min, max);
+}
+
+/*!
+ * \brief Create BYR color table (integer)
+ *
+ * Generates a color table blue-yellow-red.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_byr_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "byr", min, max);
+}
+
+/*!
+ * \brief Create BYR color table (floating-point)
+ *
+ * Generates a color table blue-yellow-red.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_byr_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "byr", min, max);
+}
+
+/*!
+ * \brief Create BGYR color table (integer)
+ *
+ * Generates a color table blue-green-yellow-red.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_bgyr_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "bgyr", min, max);
+}
+
+/*!
+ * \brief Create BGYR color table (floating-point)
+ *
+ * Generates a color table blue-green-yellow-red.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_bgyr_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "bgyr", min, max);
+}
+
+/*!
+ * \brief Create BYG color table (integer)
+ *
+ * Generates a color table blue-yellow-green.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_byg_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "byg", min, max);
+}
+
+/*!
+ * \brief Create BYG color table (floating-point)
+ *
+ * Generates a color table blue-yellow-green.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_byg_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "byg", min, max);
+}
+
+/*!
+ * \brief Make aspect colors (integer)
+ *
+ * Generates a color table for aspect data.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_aspect_colors(struct Colors *colors, CELL min, CELL max)
+{
+ Rast_make_colors(colors, "aspect", min, max);
+}
+
+/*!
+ * \brief Make aspect colors (floating-point)
+ *
+ * Generates a color table for aspect data.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param min minimum value
+ * \param max maximum value
+ */
+void Rast_make_aspect_fp_colors(struct Colors *colors, DCELL min, DCELL max)
+{
+ Rast_make_fp_colors(colors, "aspect", min, max);
+}
Copied: grass/trunk/lib/raster/color_free.c (from rev 37989, grass/trunk/lib/gis/color_free.c)
===================================================================
--- grass/trunk/lib/raster/color_free.c (rev 0)
+++ grass/trunk/lib/raster/color_free.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,105 @@
+/*!
+ * \file gis/color_free.c
+ *
+ * \brief GIS Library - Free Colors structure
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <stdlib.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Free color structure memory
+ *
+ * The dynamically allocated memory associated with the <i>colors</i>
+ * structure is freed.
+ *
+ * <b>Note:</b> This routine may be used after Rast_read_colors() as well
+ * as after Rast_init_colors().
+ *
+ * \param colors pointer to Colors structure
+ */
+void Rast_free_colors(struct Colors *colors)
+{
+ Rast__color_reset(colors);
+ Rast_init_colors(colors);
+}
+
+/*!
+ \brief Free color rules structure
+
+ Note: Only for internal use.
+
+ \param cp pointer to _Color_Info structure
+*/
+void Rast__color_free_rules(struct _Color_Info_ *cp)
+{
+ struct _Color_Rule_ *rule, *next;
+
+ for (rule = cp->rules; rule; rule = next) {
+ next = rule->next;
+ G_free(rule);
+ }
+ cp->rules = NULL;
+}
+
+/*!
+ \brief Free color rules structure
+
+ Note: Only for internal use.
+
+ \param cp pointer to _Color_Info structure
+*/
+void Rast__color_free_lookup(struct _Color_Info_ *cp)
+{
+ if (cp->lookup.active) {
+ G_free(cp->lookup.red);
+ G_free(cp->lookup.blu);
+ G_free(cp->lookup.grn);
+ G_free(cp->lookup.set);
+ cp->lookup.active = 0;
+ }
+}
+
+/*!
+ \brief Free color rules structure
+
+ Note: Only for internal use.
+
+ \param cp pointer to _Color_Info structure
+*/
+void Rast__color_free_fp_lookup(struct _Color_Info_ *cp)
+{
+ if (cp->fp_lookup.active) {
+ G_free(cp->fp_lookup.vals);
+ G_free(cp->fp_lookup.rules);
+ cp->fp_lookup.active = 0;
+ cp->fp_lookup.nalloc = 0;
+ }
+}
+
+/*!
+ \brief Reset colors structure
+
+ Note: Only for internal use.
+
+ This routine should NOT init the colors.
+
+ \param colors pointer to Colors structure
+*/
+void Rast__color_reset(struct Colors *colors)
+{
+ Rast__color_free_lookup(&colors->fixed);
+ Rast__color_free_lookup(&colors->modular);
+ Rast__color_free_rules(&colors->fixed);
+ Rast__color_free_rules(&colors->modular);
+ colors->version = 0;
+}
Copied: grass/trunk/lib/raster/color_get.c (from rev 37989, grass/trunk/lib/gis/color_get.c)
===================================================================
--- grass/trunk/lib/raster/color_get.c (rev 0)
+++ grass/trunk/lib/raster/color_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,194 @@
+/*!
+ * \file gis/color_get.c
+ *
+ * \brief GIS Library - Get colors from a raster map.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Get a category color.
+ *
+ * \todo To be removed, replaced by Rast_get_raster_color().
+ *
+ * The <i>red, green</i>, and <i>blue</i> intensities for the color
+ * associated with category <i>n</i> are extracted from the
+ * <i>colors</i> structure. The intensities will be in the range 0 -
+ * 255. Also works for null cells.
+ *
+ * \param n cell to get color from
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ *
+ * \return 1 if color is set
+ * \return 0 if color is not set
+ */
+int Rast_get_color(CELL n, int *red, int *grn, int *blu, struct Colors *colors)
+{
+ CELL cat;
+ unsigned char r, g, b, set;
+
+ cat = n;
+ Rast_lookup_colors(&cat, &r, &g, &b, &set, 1, colors);
+
+ *red = (int)r;
+ *grn = (int)g;
+ *blu = (int)b;
+
+ return (int)set;
+}
+
+/*!
+ * \brief Gets color from raster map
+ *
+ * Looks up the rgb colors for <i>rast</i> in the color table
+ * <i>colors</i>.
+ *
+ * \param rast raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ * \param map_type map type (CELL, FCELL, DCELL)
+ *
+ * \return 1 if color is set
+ * \return 0 if color is not set
+ */
+int Rast_get_raster_color(const void *rast,
+ int *red, int *grn, int *blu,
+ struct Colors *colors, RASTER_MAP_TYPE map_type)
+{
+ unsigned char r, g, b, set;
+
+ Rast_lookup_raster_colors(rast, &r, &g, &b, &set, 1, colors, map_type);
+
+ *red = (int)r;
+ *grn = (int)g;
+ *blu = (int)b;
+
+ return (int)set;
+}
+
+/*!
+ * \brief Gets color from raster map (CELL)
+ *
+ * Looks up the rgb colors for <i>rast</i> in the color table
+ * <i>colors</i>.
+ *
+ * \param rast raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ *
+ * \return 1 if color is set
+ * \return 0 if color is not set
+ */
+int Rast_get_c_raster_color(const CELL * rast,
+ int *red, int *grn, int *blu, struct Colors *colors)
+{
+ return Rast_get_raster_color(rast, red, grn, blu, colors, CELL_TYPE);
+}
+
+/*!
+ * \brief Gets color from raster map (FCELL)
+ *
+ * Looks up the rgb colors for <i>rast</i> in the color table
+ * <i>colors</i>.
+ *
+ * \param rast raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ *
+ * \return 1 if color is set
+ * \return 0 if color is not set
+ */
+int Rast_get_f_raster_color(const FCELL * rast,
+ int *red, int *grn, int *blu, struct Colors *colors)
+{
+ return Rast_get_raster_color(rast, red, grn, blu, colors, FCELL_TYPE);
+}
+
+/*!
+ * \brief Gets color from raster map (DCELL)
+ *
+ * Looks up the rgb colors for <i>rast</i> in the color table
+ * <i>colors</i>.
+ *
+ * \param rast raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ *
+ * \return 1 if color is set
+ * \return 0 if color is not set
+ */
+int Rast_get_d_raster_color(const DCELL * rast,
+ int *red, int *grn, int *blu, struct Colors *colors)
+{
+ return Rast_get_raster_color(rast, red, grn, blu, colors, DCELL_TYPE);
+}
+
+/*!
+ * \brief Gets color for null value.
+ *
+ * Puts the red, green, and blue components of <i>colors</i> for the
+ * NULL-value into <i>red, grn, and blu</i>.
+ *
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_get_null_value_color(int *red, int *grn, int *blu,
+ const struct Colors *colors)
+{
+ if (colors->null_set) {
+ *red = (int)colors->null_red;
+ *grn = (int)colors->null_grn;
+ *blu = (int)colors->null_blu;
+ }
+ else if (colors->undef_set) {
+ *red = (int)colors->undef_red;
+ *grn = (int)colors->undef_grn;
+ *blu = (int)colors->undef_blu;
+ }
+ else
+ *red = *blu = *grn = 255; /* white */
+}
+
+/*!
+ * \brief Gets default color.
+ *
+ * Puts the red, green, and blue components of the <tt>"default"</tt>
+ * color into <i>red, grn, and blu</i>.
+ *
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_get_default_color(int *red, int *grn, int *blu,
+ const struct Colors *colors)
+{
+ if (colors->undef_set) {
+ *red = (int)colors->undef_red;
+ *grn = (int)colors->undef_grn;
+ *blu = (int)colors->undef_blu;
+ }
+ else
+ *red = *blu = *grn = 255; /* white */
+}
Copied: grass/trunk/lib/raster/color_hist.c (from rev 37989, grass/trunk/lib/gis/color_hist.c)
===================================================================
--- grass/trunk/lib/raster/color_hist.c (rev 0)
+++ grass/trunk/lib/raster/color_hist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,157 @@
+/*!
+ * \file gis/color_hist.c
+ *
+ * \brief GIS Library - histogram grey scale colors
+ *
+ * (C) 2007-2009 Glynn Clements and the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Glynn Clements <glynn at gclements.plus.com>
+ */
+
+#include <math.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Make histogram-stretched grey colors
+ *
+ * Generates a histogram contrast-stretched grey scale color table
+ * that goes from the, histogram information in the Cell_stats
+ * structure (see \ref Raster_Histograms).
+ *
+ * Color range is 0-255.
+ *
+ * \param colors pointer to Colors structure which holds color info
+ * \param stalf pointer to Cell_stats structure which holds cell stats info
+ */
+void Rast_make_histogram_eq_colors(struct Colors *colors,
+ struct Cell_stats *statf)
+{
+ long count, total;
+ CELL prev = 0, cat;
+ double span, sum;
+ int first;
+ int x, grey;
+ int R, G, B;
+
+ Rast_init_colors(colors);
+
+ Rast_str_to_color(DEFAULT_BG_COLOR, &R, &G, &B);
+ Rast_set_null_value_color(R, G, B, colors);
+
+ total = 0;
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf))
+ if (count > 0)
+ total += count;
+ if (total <= 0)
+ return;
+
+ span = total / 256.0;
+ first = 1;
+ grey = 0;
+ sum = 0.0;
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
+ if (count <= 0)
+ continue;
+ x = (sum + (count / 2.0)) / span;
+ if (x < 0)
+ x = 0;
+ else if (x > 255)
+ x = 255;
+ sum += count;
+ if (first) {
+ prev = cat;
+ grey = x;
+ first = 0;
+ }
+ else if (grey != x) {
+ Rast_add_color_rule(prev, grey, grey, grey, cat - 1, grey, grey,
+ grey, colors);
+ grey = x;
+ prev = cat;
+ }
+ }
+ if (!first) {
+ Rast_add_color_rule(prev, grey, grey, grey, cat, grey, grey, grey,
+ colors);
+ }
+}
+
+/*!
+ \brief Generates histogram with normalized log transformed grey scale.
+
+ Generates histogram with normalized log transformed grey scale from
+ cell stats structure info. Color range is 0-255.
+
+ \param colors pointer to Colors structure which holds color info
+ \param stalf pointer to Cell_stats structure which holds cell stats info
+ \param min minimum value
+ \param max maximum value
+*/
+void Rast_make_histogram_log_colors(struct Colors *colors,
+ struct Cell_stats *statf, int min, int max)
+{
+ long count, total;
+ double lmin, lmax;
+ CELL prev = 0, cat;
+ int first;
+ int x, grey;
+ int R, G, B;
+
+ Rast_init_colors(colors);
+
+ Rast_str_to_color(DEFAULT_BG_COLOR, &R, &G, &B);
+ Rast_set_null_value_color(R, G, B, colors);
+
+ total = 0;
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf))
+ if (count > 0)
+ total += count;
+ if (total <= 0)
+ return;
+
+ first = 1;
+ grey = 0;
+
+ lmin = log(min);
+ lmax = log(max);
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
+ if (count <= 0)
+ continue;
+
+ /* log transform normalized */
+ x = (int)(255 * (log(cat) - lmin) / (lmax - lmin));
+
+ if (x < 0)
+ x = 0;
+ else if (x > 255)
+ x = 255;
+ if (first) {
+ prev = cat;
+ grey = x;
+ first = 0;
+ }
+ else if (grey != x) {
+ Rast_add_color_rule(prev, grey, grey, grey, cat - 1, grey, grey,
+ grey, colors);
+ grey = x;
+ prev = cat;
+ }
+ }
+ if (!first) {
+ Rast_add_color_rule(prev, grey, grey, grey, cat, grey, grey, grey,
+ colors);
+ }
+}
Copied: grass/trunk/lib/raster/color_init.c (from rev 37989, grass/trunk/lib/gis/color_init.c)
===================================================================
--- grass/trunk/lib/raster/color_init.c (rev 0)
+++ grass/trunk/lib/raster/color_init.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,49 @@
+/*!
+ * \file gis/color_init.c
+ *
+ * \brief GIS Library - Initialize Colors structure
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+
+/*!
+ * \brief Initialize color structure
+ *
+ * The <i>colors</i> structure is initialized for subsequent calls
+ * to Rast_add_color_rule() and Rast_set_color().
+ *
+ * \param colors pointer to Colors structure
+ */
+void Rast_init_colors(struct Colors *colors)
+{
+ colors->version = 0;
+ colors->null_set = 0;
+ colors->undef_set = 0;
+ colors->shift = 0.0;
+ colors->invert = 0;
+ colors->cmin = 0;
+ colors->is_float = 0;
+ colors->cmax = -1;
+ colors->fixed.min = 0;
+ colors->fixed.max = -1;
+ colors->fixed.rules = NULL;
+ colors->fixed.n_rules = 0;
+ colors->fixed.lookup.active = 0;
+ colors->fixed.fp_lookup.active = 0;
+ colors->fixed.fp_lookup.nalloc = 0;
+ colors->modular.min = 0;
+ colors->modular.max = -1;
+ colors->modular.rules = NULL;
+ colors->modular.n_rules = 0;
+ colors->modular.lookup.active = 0;
+ colors->modular.fp_lookup.active = 0;
+ colors->modular.fp_lookup.nalloc = 0;
+ colors->organizing = 0;
+}
Copied: grass/trunk/lib/raster/color_insrt.c (from rev 37989, grass/trunk/lib/gis/color_insrt.c)
===================================================================
--- grass/trunk/lib/raster/color_insrt.c (rev 0)
+++ grass/trunk/lib/raster/color_insrt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,108 @@
+/* This routine is public only because source is in different files.
+ * It should NEVER be called directly.
+ * It is used by Rast_add_color_rule() and G__read_old_colors().
+ * These routines know when it is approriate to call this routine.
+ */
+#include <grass/gis.h>
+#define umalloc(n) (unsigned char *) G_malloc((size_t)n)
+#define urealloc(s,n) (unsigned char *) G_realloc(s,(size_t)n)
+
+#define LIMIT(x) if (x < 0) x = 0; else if (x > 255) x = 255;
+
+int Rast__insert_color_into_lookup(CELL cat,
+ int red, int grn, int blu,
+ struct _Color_Info_ *cp)
+{
+ long nalloc;
+ long i;
+ long newlen, curlen, gap;
+
+ LIMIT(red);
+ LIMIT(grn);
+ LIMIT(blu);
+
+ /* first color? */
+ if (!cp->lookup.active) {
+ cp->lookup.active = 1;
+ cp->lookup.nalloc = 256;
+ cp->lookup.red = umalloc(cp->lookup.nalloc);
+ cp->lookup.grn = umalloc(cp->lookup.nalloc);
+ cp->lookup.blu = umalloc(cp->lookup.nalloc);
+ cp->lookup.set = umalloc(cp->lookup.nalloc);
+ cp->max = cp->min = cat;
+ }
+
+ /* extend the color table? */
+ else if (cat > cp->max) {
+ curlen = cp->max - cp->min + 1;
+ newlen = cat - cp->min + 1;
+ nalloc = newlen;
+ if (nalloc != (int)nalloc) /* check for int overflow */
+ return -1;
+
+ if (nalloc > cp->lookup.nalloc) {
+ while (cp->lookup.nalloc < nalloc)
+ cp->lookup.nalloc += 256;
+ nalloc = cp->lookup.nalloc;
+
+ cp->lookup.red = urealloc((char *)cp->lookup.red, nalloc);
+ cp->lookup.grn = urealloc((char *)cp->lookup.grn, nalloc);
+ cp->lookup.blu = urealloc((char *)cp->lookup.blu, nalloc);
+ cp->lookup.set = urealloc((char *)cp->lookup.set, nalloc);
+ }
+
+ /* fill in gap with white */
+ for (i = curlen; i < newlen; i++) {
+ cp->lookup.red[i] = 255;
+ cp->lookup.grn[i] = 255;
+ cp->lookup.blu[i] = 255;
+ cp->lookup.set[i] = 0;
+ }
+ cp->max = cat;
+ }
+ else if (cat < cp->min) {
+ curlen = cp->max - cp->min + 1;
+ newlen = cp->max - cat + 1;
+ gap = newlen - curlen;
+ nalloc = newlen;
+ if (nalloc != (int)nalloc) /* check for int overflow */
+ return -1;
+
+ if (nalloc > cp->lookup.nalloc) {
+ while (cp->lookup.nalloc < nalloc)
+ cp->lookup.nalloc += 256;
+ nalloc = cp->lookup.nalloc;
+
+ cp->lookup.red = urealloc((char *)cp->lookup.red, nalloc);
+ cp->lookup.grn = urealloc((char *)cp->lookup.grn, nalloc);
+ cp->lookup.blu = urealloc((char *)cp->lookup.blu, nalloc);
+ cp->lookup.set = urealloc((char *)cp->lookup.set, nalloc);
+ }
+
+ /* shift the table to make room in front */
+ for (i = 1; i <= curlen; i++) {
+ cp->lookup.red[newlen - i] = cp->lookup.red[curlen - i];
+ cp->lookup.grn[newlen - i] = cp->lookup.grn[curlen - i];
+ cp->lookup.blu[newlen - i] = cp->lookup.blu[curlen - i];
+ cp->lookup.set[newlen - i] = cp->lookup.set[curlen - i];
+ }
+
+ /* fill in gap with white */
+ for (i = 1; i < gap; i++) {
+ cp->lookup.red[i] = 255;
+ cp->lookup.grn[i] = 255;
+ cp->lookup.blu[i] = 255;
+ cp->lookup.set[i] = 0;
+ }
+ cp->min = cat;
+ }
+
+ /* set the color! */
+ i = cat - cp->min;
+ cp->lookup.red[i] = red;
+ cp->lookup.grn[i] = grn;
+ cp->lookup.blu[i] = blu;
+ cp->lookup.set[i] = 1;
+
+ return 1;
+}
Copied: grass/trunk/lib/raster/color_invrt.c (from rev 37989, grass/trunk/lib/gis/color_invrt.c)
===================================================================
--- grass/trunk/lib/raster/color_invrt.c (rev 0)
+++ grass/trunk/lib/raster/color_invrt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,6 @@
+#include <grass/gis.h>
+
+void Rast_invert_colors(struct Colors *colors)
+{
+ colors->invert = !colors->invert;
+}
Copied: grass/trunk/lib/raster/color_look.c (from rev 37989, grass/trunk/lib/gis/color_look.c)
===================================================================
--- grass/trunk/lib/raster/color_look.c (rev 0)
+++ grass/trunk/lib/raster/color_look.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,477 @@
+/*!
+ * \file gis/color_lookup.c
+ *
+ * \brief GIS Library - Lookup array of colors
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#include <math.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Lookup an array of colors
+ *
+ * \todo To be removed, replaced by Rast_lookup_c_raster_colors().
+ *
+ * Extracts colors for an array of <i>cell</i> values. The colors
+ * for the <i>n</i> values in the <i>cell</i> array are stored in
+ * the <i>red, green</i>, and <i>blue</i> arrays. The values in the
+ * <i>set</i> array will indicate if the corresponding <i>cell</i>
+ * value has a color or not (1 means it does, 0 means it does not).
+ *
+ * The programmer must allocate the <i>red, green, blue</i>, and
+ * <b>set</b> arrays to be at least dimension <i>n</i>.
+ *
+ * <b>Note:</b> The <i>red, green</i>, and <i>blue</i> intensities
+ * will be in the range 0 - 255.
+ *
+ * Modified to return a color for NULL-values.
+ *
+ * \param cell raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param set array which indicates if color is set or not
+ * \param n number of values
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_lookup_colors(const CELL * cell,
+ unsigned char *red, unsigned char *grn,
+ unsigned char *blu, unsigned char *set, int n,
+ struct Colors *colors)
+{
+ Rast_lookup_c_raster_colors(cell, red, grn, blu, set, n, colors);
+}
+
+/*!
+ * \brief Lookup an array of colors
+ *
+ * Extracts colors for an array of <i>cell</i> values. The colors
+ * for the <i>n</i> values in the <i>cell</i> array are stored in
+ * the <i>red, green</i>, and <i>blue</i> arrays. The values in the
+ * <i>set</i> array will indicate if the corresponding <i>cell</i>
+ * value has a color or not (1 means it does, 0 means it does not).
+ *
+ * The programmer must allocate the <i>red, green, blue</i>, and
+ * <b>set</b> arrays to be at least dimension <i>n</i>.
+ *
+ * <b>Note:</b> The <i>red, green</i>, and <i>blue</i> intensities
+ * will be in the range 0 - 255.
+ *
+ * Modified to return a color for NULL-values.
+ *
+ * \param cell raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param set array which indicates if color is set or not
+ * \param n number of values
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_lookup_c_raster_colors(const CELL * cell,
+ unsigned char *red, unsigned char *grn,
+ unsigned char *blu, unsigned char *set, int n,
+ struct Colors *colors)
+{
+ Rast__organize_colors(colors); /* make sure the lookup tables are in place */
+
+ G_zero((char *)set, n * sizeof(unsigned char));
+
+ /* first lookup the fixed colors */
+ Rast__lookup_colors((void *)cell, red, grn, blu, set, n, colors, 0, 0,
+ CELL_TYPE);
+
+ /* now lookup unset colors using the modular rules */
+ Rast__lookup_colors((void *)cell, red, grn, blu, set, n, colors, 1, 0,
+ CELL_TYPE);
+}
+
+/*!
+ * \brief Lookup an array of colors
+ *
+ * - If the <em>map_type</em> is CELL_TYPE, calls Rast_lookup_colors()
+ * - If the <em>map_type</em> is FCELL_TYPE, calls Rast_lookup_f_raster_colors()
+ * - If the <em>map_type</em> is DCELL_TYPE, calls Rast_lookup_d_raster_colors()
+ *
+ * \param raster raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param set array which indicates if color is set or not
+ * \param n number of values
+ * \param colors pointer to Colors structure which holds color info
+ * \param map_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast_lookup_raster_colors(const void *raster,
+ unsigned char *red, unsigned char *grn,
+ unsigned char *blu, unsigned char *set, int n,
+ struct Colors *colors, RASTER_MAP_TYPE map_type)
+{
+ Rast__organize_colors(colors); /* make sure the lookup tables are in place */
+ /* in case of float color rules, fp_lookup table is created */
+
+ G_zero((char *)set, n * sizeof(unsigned char));
+
+ /* first lookup the fixed colors */
+ Rast__lookup_colors(raster, red, grn, blu, set, n, colors, 0, 0, map_type);
+
+ /* now lookup unset colors using the modular rules */
+ Rast__lookup_colors(raster, red, grn, blu, set, n, colors, 1, 0, map_type);
+}
+
+/*!
+ * \brief Lookup an array of colors (FCELL)
+ *
+ * Converts the <em>n</em> floating-point values in the <em>fcell</em>
+ * array to their <em>r,g,b</em> color components. Embedded
+ * NULL-values are handled properly as well.
+ *
+ * \param fcell raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param set array which indicates if color is set or not
+ * \param n number of values
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_lookup_f_raster_colors(const FCELL * fcell, unsigned char *red,
+ unsigned char *grn, unsigned char *blu,
+ unsigned char *set, int n, struct Colors *colors)
+{
+ Rast__organize_colors(colors); /* make sure the lookup tables are in place */
+ /* in case of float color rules, fp_lookup table is created */
+
+ G_zero((char *)set, n * sizeof(unsigned char));
+
+ /* first lookup the fixed colors */
+ Rast__lookup_colors((void *)fcell, red, grn, blu, set, n, colors, 0, 0,
+ FCELL_TYPE);
+
+ /* now lookup unset colors using the modular rules */
+ Rast__lookup_colors((void *)fcell, red, grn, blu, set, n, colors, 1, 0,
+ FCELL_TYPE);
+}
+
+/*!
+ * \brief Lookup an array of colors (DCELL)
+ *
+ * Converts the <em>n</em> double-precision values in the
+ * <em>dcell</em> array to their <em>r,g,b</em> color
+ * components. Embedded NULL-values are handled properly as well.
+ *
+ * \param dcell raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param set array which indicates if color is set or not
+ * \param n number of values
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_lookup_d_raster_colors(const DCELL * dcell, unsigned char *red,
+ unsigned char *grn, unsigned char *blu,
+ unsigned char *set, int n, struct Colors *colors)
+{
+ Rast__organize_colors(colors); /* make sure the lookup tables are in place */
+ /* in case of float color rules, fp_lookup table is created */
+
+ G_zero((char *)set, n * sizeof(unsigned char));
+
+ /* first lookup the fixed colors */
+ Rast__lookup_colors((void *)dcell, red, grn, blu, set, n, colors, 0, 0,
+ DCELL_TYPE);
+
+ /* now lookup unset colors using the modular rules */
+ Rast__lookup_colors((void *)dcell, red, grn, blu, set, n, colors, 1, 0,
+ DCELL_TYPE);
+}
+
+
+static int less_or_equal(double x, double y)
+{
+ if (x <= y)
+ return 1;
+ else
+ return 0;
+}
+
+static int less(double x, double y)
+{
+ if (x < y)
+ return 1;
+ else
+ return 0;
+}
+
+/*!
+ * \brief Lookup an array of colors
+ *
+ * \param raster raster cell value
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param set array which indicates if color is set or not
+ * \param n number of values
+ * \param colors pointer to Colors structure which holds color info
+ * \param mod
+ * \param rules_only
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast__lookup_colors(const void *raster, unsigned char *red,
+ unsigned char *grn, unsigned char *blu,
+ unsigned char *set, int n, struct Colors *colors,
+ int mod, int rules_only, RASTER_MAP_TYPE data_type)
+{
+ struct _Color_Info_ *cp;
+ struct _Color_Rule_ *rule;
+ DCELL dmin, dmax, val, dmod = 0L, shift;
+ CELL cat, min, max;
+ const void *ptr, *last_ptr = NULL;
+ int invert;
+ int found, r, g, b;
+ int cell_type;
+ int lookup, max_ind, min_ind, try;
+ int (*lower) ();
+
+ if (mod)
+ cp = &colors->modular;
+ else
+ cp = &colors->fixed;
+
+ /* rules_only will be true only when called by Rast__organize_colors()
+ * when building the integer lookup talbes from the rules,
+ * so do not shift, invert, use lookup table or modulate cats.
+ * these operations will happen when lookup is called by user code
+ */
+ /* we want min, max for cp, not min, max overall */
+ dmin = cp->min;
+ dmax = cp->max;
+ min = (CELL) dmin;
+ max = (CELL) dmax + 1;
+
+ cell_type = (data_type == CELL_TYPE);
+
+ if (rules_only) {
+ shift = invert = lookup = mod = 0;
+ }
+ else {
+ if (mod) {
+ dmod = dmax - dmin;
+ /* for integers color table we make a gap of 1 in order
+ to make the same colors as before */
+ if (cell_type)
+ dmod += 1;
+ }
+
+ shift = colors->shift;
+ invert = colors->invert;
+ lookup = cp->lookup.active;
+ }
+
+ ptr = raster;
+
+ for (; n-- > 0;
+ ptr =
+ Rast_incr_void_ptr(ptr, Rast_raster_size(data_type)), red++, grn++, blu++,
+ *set++ = found) {
+ /* if the cell is the same as last one, use the prev color values */
+ if (ptr != raster && Rast_raster_cmp(ptr, last_ptr, data_type) == 0) {
+ *red = *(red - 1);
+ *blu = *(blu - 1);
+ *grn = *(grn - 1);
+ found = *(set - 1);
+ last_ptr = ptr;
+ continue;
+ }
+ val = Rast_get_raster_value_d(ptr, data_type);
+ /* DEBUG fprintf (stderr, "val: %.4lf\n", val); */
+ last_ptr = ptr;
+
+ if (*set) {
+ found = 1;
+ continue;
+ }
+
+ if (Rast_is_null_value(ptr, data_type)) {
+ /* returns integers, not unsigned chars */
+ Rast_get_null_value_color(&r, &g, &b, colors);
+ *red = r;
+ *grn = g;
+ *blu = b;
+ found = 1;
+ continue;
+ }
+
+ if (shift && val >= dmin && val <= dmax) {
+ val += shift;
+ while (val < dmin)
+ val += dmax - dmin + 1;
+ while (val > dmax)
+ val -= dmax - dmin + 1;
+ }
+
+ /* invert non-null data around midpoint of range [min:max] */
+ if (invert)
+ val = dmin + dmax - val;
+
+ if (mod) {
+ if (dmod > 0) {
+ val -= dmin;
+ while (val < 0)
+ val += dmod;
+ val = val - dmod * floor(val / dmod);
+ val += dmin;
+ }
+ else
+ val = dmin;
+ }
+
+ cat = (CELL) val;
+
+ found = 0;
+
+ /* for non-null integers try to look them up in lookup table */
+ /* note: lookup table exists only for integer maps, and we also must
+ check if val is really integer */
+
+ if (lookup && ((double)cat - val == 0.)) {
+ if (cat >= min && cat <= max) {
+ cat -= min;
+ if (cp->lookup.set[cat]) {
+ *red = cp->lookup.red[cat];
+ *grn = cp->lookup.grn[cat];
+ *blu = cp->lookup.blu[cat];
+ found = 1;
+ /*DEBUG
+ fprintf (stderr, "lookup %d %.2lf %d %d %d\n\n", cat, val, *red, *grn, *blu);
+ */
+ }
+ }
+ }
+
+ if (found)
+ continue;
+
+ /* if floating point lookup table is active, look up in there */
+ if (cp->fp_lookup.active) {
+ try = (cp->fp_lookup.nalloc - 1) / 2;
+ min_ind = 0;
+ max_ind = cp->fp_lookup.nalloc - 2;
+ while (1) {
+ /* when the rule for the interval is NULL, we exclude the end points.
+ when it exists, we include the end-points */
+ if (cp->fp_lookup.rules[try])
+ lower = less;
+ else
+ lower = less_or_equal;
+ /* DEBUG
+ fprintf (stderr, "%d %d %d %lf %lf %lf\n", min_ind, try, max_ind,
+ cp->fp_lookup.vals[try-1],
+ val,
+ cp->fp_lookup.vals[try]);
+ */
+
+ if (lower(cp->fp_lookup.vals[try + 1], val)) { /* recurse to the second half */
+ min_ind = try + 1;
+ /* must be still < nalloc-1, since number is within the range */
+ try = (max_ind + min_ind) / 2;
+ if (min_ind > max_ind) {
+ rule = NULL;
+ break;
+ }
+ continue;
+ }
+ if (lower(val, cp->fp_lookup.vals[try])) { /* recurse to the second half */
+ max_ind = try - 1;
+ /* must be still >= 0, since number is within the range */
+ try = (max_ind + min_ind) / 2;
+ if (max_ind < min_ind) {
+ rule = NULL;
+ break;
+ }
+ continue;
+ }
+ rule = cp->fp_lookup.rules[try];
+ break;
+ }
+ }
+ else {
+ /* find the [low:high] rule that applies */
+ for (rule = cp->rules; rule; rule = rule->next) {
+ /* DEBUG
+ fprintf (stderr, "%.2lf %.2lf %.2lf\n",
+ val, rule->low.value, rule->high.value);
+ */
+ if (rule->low.value <= val && val <= rule->high.value)
+ break;
+ }
+ }
+
+ /* if found, perform linear interpolation from low to high.
+ * else set colors to colors->undef or white if undef not set
+ */
+
+ if (rule) {
+ Rast__interpolate_color_rule(val, red, grn, blu, rule);
+ found = 1;
+ }
+ if (!found) {
+ /* otherwise use default color */
+ Rast_get_default_color(&r, &g, &b, colors);
+ *red = r;
+ *grn = g;
+ *blu = b;
+ }
+ /* DEBUG
+ if (rule)
+ fprintf (stderr, "%.2lf %d %d %d %.2lf %d %d %d \n", rule->low.value , (int)rule->low.red, (int)rule->low.grn, (int)rule->low.blu, rule->high.value, (int)rule->high.red, (int)rule->high.grn, (int)rule->high.blu);
+ fprintf (stderr, "rule found %d %.2lf %d %d %d\n\n", cat, val, *red, *grn, *blu);
+ */
+ }
+}
+
+/*!
+ \brief Interpolate color rules
+
+ \param val raster cell value
+ \param[out] red red value
+ \param[out] grn green value
+ \param[out] blu blue value
+ \param rule pointer to _Color_Rule which holds color rules info
+*/
+void Rast__interpolate_color_rule(DCELL val, unsigned char *red,
+ unsigned char *grn, unsigned char *blu,
+ const struct _Color_Rule_ *rule)
+{
+ DCELL delta;
+
+ if ((delta = rule->high.value - rule->low.value)) {
+ val -= rule->low.value;
+
+ *red =
+ (int)(val * (double)((int)rule->high.red - (int)rule->low.red) /
+ delta)
+ + (int)rule->low.red;
+ *grn =
+ (int)(val * (double)((int)rule->high.grn - (int)rule->low.grn) /
+ delta)
+ + (int)rule->low.grn;
+ *blu =
+ (int)(val * (double)((int)rule->high.blu - (int)rule->low.blu) /
+ delta)
+ + (int)rule->low.blu;
+ }
+ else {
+ *red = rule->low.red;
+ *grn = rule->low.grn;
+ *blu = rule->low.blu;
+ }
+}
Copied: grass/trunk/lib/raster/color_org.c (from rev 37989, grass/trunk/lib/gis/color_org.c)
===================================================================
--- grass/trunk/lib/raster/color_org.c (rev 0)
+++ grass/trunk/lib/raster/color_org.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,147 @@
+#include <stdlib.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+#define LOOKUP_COLORS 2048
+
+static void organize_lookup(struct Colors *, int);
+static int organize_fp_lookup(struct Colors *, int);
+static int double_comp(const void *, const void *);
+
+void Rast__organize_colors(struct Colors *colors)
+{
+ /* don't do anything if called recursively */
+ if (!colors->organizing) {
+ colors->organizing = 1;
+
+ organize_lookup(colors, 0);
+ organize_lookup(colors, 1);
+
+ organize_fp_lookup(colors, 0);
+ organize_fp_lookup(colors, 1);
+
+ colors->organizing = 0;
+ }
+}
+
+static int organize_fp_lookup(struct Colors *colors, int mod)
+{
+ int i;
+ DCELL val;
+ struct _Color_Info_ *cp;
+ struct _Color_Rule_ *rule;
+
+ if (mod)
+ cp = &colors->modular;
+ else
+ cp = &colors->fixed;
+
+ /* if one of the lookup tables exist, don't do anything */
+ if (cp->lookup.active || cp->fp_lookup.active)
+ return 1;
+ if (cp->n_rules == 0)
+ return 1;
+
+ cp->fp_lookup.vals = (DCELL *)
+ G_calloc(cp->n_rules * 2, sizeof(DCELL));
+ /* 2 endpoints for each rule */
+ cp->fp_lookup.rules = (struct _Color_Rule_ **)
+ G_calloc(cp->n_rules * 2, sizeof(struct _Color_Rule_ *));
+
+ /* get the list of DCELL values from set of all lows and highs
+ of all rules */
+ /* NOTE: if low==high in a rule, the value appears twice in a list
+ but if low==high of the previous, rule the value appears only once */
+
+ i = 0;
+ /* go through the list of rules from end to beginning,
+ because rules are sored in reverse order of reading,
+ and we want to read the in correct order, to ignore
+ the same values in the end of rule and beginning of next rule */
+
+ /* first go to the last rules */
+ for (rule = cp->rules; rule->next; rule = rule->next) ;
+ /* now traverse from the last to the first rule */
+ for (; rule; rule = rule->prev) {
+ /* check if the min is the same as previous maximum */
+ if (i == 0 || rule->low.value != cp->fp_lookup.vals[i - 1])
+ cp->fp_lookup.vals[i++] = rule->low.value;
+ cp->fp_lookup.vals[i++] = rule->high.value;
+ }
+ cp->fp_lookup.nalloc = i;
+
+ /* now sort the values */
+ qsort((char *)cp->fp_lookup.vals, cp->fp_lookup.nalloc,
+ sizeof(DCELL), &double_comp);
+
+ /* now find the rule to apply inbetween each 2 values in a list */
+ for (i = 0; i < cp->fp_lookup.nalloc - 1; i++) {
+ val = (cp->fp_lookup.vals[i] + cp->fp_lookup.vals[i + 1]) / 2.;
+ /* fprintf (stderr, "%lf %lf ", cp->fp_lookup.vals[i], cp->fp_lookup.vals[i+1]); */
+
+ for (rule = cp->rules; rule; rule = rule->next)
+ if (rule->low.value <= val && val <= rule->high.value)
+ break;
+ /* if(rule) fprintf (stderr, "%d %lf %lf %d\n", i, rule->low.value, rule->high.value, rule);
+ else fprintf (stderr, "null\n");
+ */
+ cp->fp_lookup.rules[i] = rule;
+ }
+ cp->fp_lookup.active = 1;
+
+ return 0;
+}
+
+static void organize_lookup(struct Colors *colors, int mod)
+{
+ int i, n;
+ CELL x;
+ CELL cat[LOOKUP_COLORS];
+ struct _Color_Info_ *cp;
+
+ /* don't do anything if the color structure is float */
+ if (colors->is_float)
+ return;
+
+ if (mod)
+ cp = &colors->modular;
+ else
+ cp = &colors->fixed;
+
+ if (cp->lookup.active)
+ return;
+
+ n = (CELL) cp->max - (CELL) cp->min + 1;
+ if (n >= LOOKUP_COLORS || n <= 0)
+ return;
+
+ x = (CELL) cp->min;
+ for (i = 0; i < n; i++)
+ cat[i] = x++;;
+
+ cp->lookup.nalloc = n;
+ cp->lookup.red = (unsigned char *)G_malloc(n);
+ cp->lookup.grn = (unsigned char *)G_malloc(n);
+ cp->lookup.blu = (unsigned char *)G_malloc(n);
+ cp->lookup.set = (unsigned char *)G_malloc(n);
+
+ G_zero(cp->lookup.set, n * sizeof(unsigned char));
+ Rast__lookup_colors((void *)cat,
+ cp->lookup.red, cp->lookup.grn, cp->lookup.blu,
+ cp->lookup.set, n, colors, mod, 1, CELL_TYPE);
+
+ cp->lookup.active = 1;
+}
+
+static int double_comp(const void *xx, const void *yy)
+{
+ const DCELL *x = xx, *y = yy;
+
+ if (*x < *y)
+ return -1;
+ else if (*x == *y)
+ return 0;
+ else
+ return 1;
+}
Copied: grass/trunk/lib/raster/color_rand.c (from rev 37989, grass/trunk/lib/gis/color_rand.c)
===================================================================
--- grass/trunk/lib/raster/color_rand.c (rev 0)
+++ grass/trunk/lib/raster/color_rand.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,49 @@
+#include <time.h> /* For time() */
+#include <stdio.h> /* For NULL */
+#include <stdlib.h> /* For rand() and srand() */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#define MAX_COLORS 1024
+#define DEVIATION 128
+
+
+/*!
+ * \brief make random colors
+ *
+ * Generates random colors. Good as a first pass at a
+ * color table for nominal data.
+ *
+ * \param colors
+ * \param min
+ * \param max
+ * \return
+ */
+
+void Rast_make_random_colors(struct Colors *colors, CELL min, CELL max)
+{
+ unsigned char red, grn, blu;
+ int count;
+ CELL n;
+
+ Rast_init_colors(colors);
+ if (min > max)
+ G_fatal_error(_("Rast_make_random_colors: min (%d) > max (%d)"),
+ min, max);
+
+ srand(time(NULL));
+
+ count = MAX_COLORS - DEVIATION + rand() % DEVIATION;
+ if (count > max - min + 1)
+ count = max - min + 1;
+
+ for (n = 1; n <= count; n++) {
+ red = rand() & 0377;
+ grn = rand() & 0377;
+ blu = rand() & 0377;
+ Rast_add_modular_color_rule(n, red, grn, blu, n, red, grn, blu, colors);
+ }
+ Rast_set_color_range(min, max, colors);
+}
Copied: grass/trunk/lib/raster/color_range.c (from rev 37989, grass/trunk/lib/gis/color_range.c)
===================================================================
--- grass/trunk/lib/raster/color_range.c (rev 0)
+++ grass/trunk/lib/raster/color_range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,93 @@
+/*!
+ * \file gis/color_range.c
+ *
+ * \brief GIS Library - Color range functions.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <math.h>
+#include <grass/gis.h>
+
+/*!
+ \brief Set color range (CELL version)
+
+ \todo Rename to G_set_c_color_range() ?
+
+ \param min,max minimum and maximum value
+ \param colors pointer to Colors structure which holds color info
+*/
+void Rast_set_color_range(CELL min, CELL max, struct Colors *colors)
+{
+ if (min < max) {
+ colors->cmin = (DCELL) min;
+ colors->cmax = (DCELL) max;
+ }
+ else {
+ colors->cmin = (DCELL) max;
+ colors->cmax = (DCELL) min;
+ }
+}
+
+/*!
+ \brief Set color range (DCELL version)
+
+ \param min,max minimum and maximum value
+ \param colors pointer to Colors structure which holds color info
+*/
+void Rast_set_d_color_range(DCELL min, DCELL max, struct Colors *colors)
+{
+ if (min < max) {
+ colors->cmin = min;
+ colors->cmax = max;
+ }
+ else {
+ colors->cmin = max;
+ colors->cmax = min;
+ }
+}
+
+/*!
+ \brief Get color range values (CELL)
+
+ \todo Rename to G_get_c_color_range() ?
+
+ Returns min and max category in the range or huge numbers if the
+ color table is defined on floating cell values and not on
+ categories.
+
+ \param[out] min,max minimum and maximum value
+ \param colors pointer to Colors structure which holds color info
+ */
+void Rast_get_color_range(CELL * min, CELL * max, const struct Colors *colors)
+{
+ if (!colors->is_float) {
+ *min = (CELL) floor(colors->cmin);
+ *max = (CELL) ceil(colors->cmax);
+ }
+ else {
+ *min = -255 * 255 * 255;
+ *max = 255 * 255 * 255;
+ }
+}
+
+/*!
+ \brief Get color range values (DELL)
+
+ Returns min and max category in the range or huge numbers if the
+ color table is defined on floating cell values and not on
+ categories.
+
+ \param[out] min,max minimum and maximum value
+ \param colors pointer to Colors structure which holds color info
+ */
+void Rast_get_d_color_range(DCELL * min, DCELL * max, const struct Colors *colors)
+{
+ *min = colors->cmin;
+ *max = colors->cmax;
+}
Copied: grass/trunk/lib/raster/color_read.c (from rev 37989, grass/trunk/lib/gis/color_read.c)
===================================================================
--- grass/trunk/lib/raster/color_read.c (rev 0)
+++ grass/trunk/lib/raster/color_read.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,391 @@
+/*!
+ * \file gis/color_read.c
+ *
+ * \brief GIS Library - Read color table of raster map
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+static int read_colors(const char *, const char *, const char *,
+ struct Colors *);
+static int read_new_colors(FILE *, struct Colors *);
+static int read_old_colors(FILE *, struct Colors *);
+
+
+/*!
+ * \brief Read raster map layer color table
+ *
+ * The color table for the raster map <i>name</i> in the specified
+ * <i>mapset</i> is read into the <i>colors</i> structure. If the data
+ * layer has no color table, a default color table is generated and 0
+ * is returned. If there is an error reading the color table, a
+ * diagnostic message is printed and -1 is returned. If the color
+ * table is read ok, 1 is returned.
+ *
+ * This routine reads the rules from the color file. If the input
+ * raster map is is a floating-point map it calls
+ * Rast_mark_colors_as_fp().
+ *
+ * Note: If a secondary color file for map name <i>name</i> exists in
+ * the current project, that color file is read. This allows the
+ * user to define their own color lookup tables for cell maps found
+ * in other mapsets.
+ *
+ * Warning message is printed if the color file is
+ * missing or invalid.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param[out] colors pointer to Colors structure
+ *
+ * \return -1 on error
+ * \return 0 if missing, but default colors generated
+ * \return 1 on success
+ */
+int Rast_read_colors(const char *name, const char *mapset, struct Colors *colors)
+{
+ int fp;
+ char buf[GNAME_MAX];
+ char *err;
+ char xname[GNAME_MAX];
+ struct Range range;
+ struct FPRange drange;
+ CELL min, max;
+ DCELL dmin, dmax;
+
+ fp = Rast_raster_map_is_fp(name, mapset);
+ Rast_init_colors(colors);
+
+ strcpy(xname, name);
+ mapset = G_find_cell(xname, mapset);
+ name = xname;
+
+ if (fp)
+ Rast_mark_colors_as_fp(colors);
+
+ /* first look for secondary color table in current mapset */
+ sprintf(buf, "colr2/%s", mapset);
+ if (read_colors(buf, name, G_mapset(), colors) >= 0)
+ return 1;
+
+ /* now look for the regular color table */
+ switch (read_colors("colr", name, mapset, colors)) {
+ case -2:
+ if (!fp) {
+ if (Rast_read_range(name, mapset, &range) >= 0) {
+ Rast_get_range_min_max(&range, &min, &max);
+ if (!Rast_is_c_null_value(&min) && !Rast_is_c_null_value(&max))
+ Rast_make_rainbow_colors(colors, min, max);
+ return 0;
+ }
+ }
+ else {
+ if (Rast_read_fp_range(name, mapset, &drange) >= 0) {
+ Rast_get_fp_range_min_max(&drange, &dmin, &dmax);
+ if (!Rast_is_d_null_value(&dmin) && !Rast_is_d_null_value(&dmax))
+ Rast_make_rainbow_fp_colors(colors, dmin, dmax);
+ return 0;
+ }
+ }
+ err = _("missing");
+ break;
+ case -1:
+ err = _("invalid");
+ break;
+ default:
+ return 1;
+ }
+
+ G_warning(_("Color support for <%s@%s> %s"), name, mapset,
+ err);
+ return -1;
+}
+
+static int read_colors(const char *element, const char *name,
+ const char *mapset, struct Colors *colors)
+{
+ FILE *fd;
+ int stat;
+ char buf[1024];
+
+ if (!(fd = G_fopen_old(element, name, mapset)))
+ return -2;
+
+ /*
+ * first line in 4.0 color files is %
+ * otherwise it is pre 4.0
+ */
+ if (fgets(buf, sizeof buf, fd) == NULL) {
+ fclose(fd);
+ return -1;
+ }
+ fseek(fd, 0L, 0);
+
+ G_strip(buf);
+ if (*buf == '%') { /* 4.0 format */
+ stat = read_new_colors(fd, colors);
+ colors->version = 0; /* 4.0 format */
+ }
+ else {
+ stat = read_old_colors(fd, colors);
+ colors->version = -1; /* pre 4.0 format */
+ }
+ fclose(fd);
+ return stat;
+}
+
+/* parse input lines with the following formats
+ * val1:r:g:b val2:r:g:b
+ * val:r:g:b (implies cat1==cat2)
+ *
+ * r:g:b can be just a single grey level
+ * cat1:x cat2:y
+ * cat:x
+ *
+ * optional lines are
+ * invert invert color table
+ * shift:n where n is the amount to shift the color table
+ * nv:r:g:b color to use for NULL values
+ * *:r:g:b color to use for undefined (beyond color rules)
+ */
+static int read_new_colors(FILE * fd, struct Colors *colors)
+{
+ double val1, val2;
+ long cat1, cat2;
+ int r1, g1, b1;
+ int r2, g2, b2;
+ char buf[1024];
+ char word1[256], word2[256];
+ int n, fp_rule;
+ int null, undef;
+ int modular;
+ DCELL shift;
+
+ if (fgets(buf, sizeof buf, fd) == NULL)
+ return -1;
+ G_strip(buf);
+
+ if (sscanf(buf + 1, "%lf %lf", &val1, &val2) == 2)
+ Rast_set_d_color_range((DCELL) val1, (DCELL) val2, colors);
+
+ modular = 0;
+ while (fgets(buf, sizeof buf, fd)) {
+ null = undef = fp_rule = 0;
+ *word1 = *word2 = 0;
+ n = sscanf(buf, "%s %s", word1, word2);
+ if (n < 1)
+ continue;
+
+ if (sscanf(word1, "shift:%lf", &shift) == 1
+ || (strcmp(word1, "shift:") == 0 &&
+ sscanf(word2, "%lf", &shift) == 1)) {
+ Rast_shift_d_colors(shift, colors);
+ continue;
+ }
+ if (strcmp(word1, "invert") == 0) {
+ Rast_invert_colors(colors);
+ continue;
+ }
+ if (strcmp(word1, "%%") == 0) {
+ modular = !modular;
+ continue;
+ }
+
+ switch (sscanf(word1, "nv:%d:%d:%d", &r1, &g1, &b1)) {
+ case 1:
+ null = 1;
+ b1 = g1 = r1;
+ break;
+ case 3:
+ null = 1;
+ break;
+ }
+ if (!null)
+ switch (sscanf(word1, "*:%d:%d:%d", &r1, &g1, &b1)) {
+ case 1:
+ undef = 1;
+ b1 = g1 = r1;
+ break;
+ case 3:
+ undef = 1;
+ break;
+ }
+ if (!null && !undef)
+ switch (sscanf(word1, "%ld:%d:%d:%d", &cat1, &r1, &g1, &b1)) {
+ case 2:
+ b1 = g1 = r1;
+ break;
+ case 4:
+ break;
+ default:
+ if (sscanf(word1, "%lf:%d:%d:%d", &val1, &r1, &g1, &b1) == 4)
+ fp_rule = 1;
+ else if (sscanf(word1, "%lf:%d", &val1, &r1) == 2) {
+ fp_rule = 1;
+ b1 = g1 = r1;
+ }
+ else
+ continue; /* other lines are ignored */
+ }
+ if (n == 2) {
+ switch (sscanf(word2, "%ld:%d:%d:%d", &cat2, &r2, &g2, &b2)) {
+ case 2:
+ b2 = g2 = r2;
+ if (fp_rule)
+ val2 = (DCELL) cat2;
+ break;
+ case 4:
+ if (fp_rule)
+ val2 = (DCELL) cat2;
+ break;
+ default:
+ if (sscanf(word2, "%lf:%d:%d:%d", &val2, &r2, &g2, &b2) == 4) {
+ if (!fp_rule)
+ val1 = (DCELL) cat1;
+ fp_rule = 1;
+ }
+ else if (sscanf(word2, "%lf:%d", &val2, &r2) == 2) {
+ if (!fp_rule)
+ val1 = (DCELL) cat1;
+ fp_rule = 1;
+ b2 = g2 = r2;
+ }
+ else
+ continue; /* other lines are ignored */
+ }
+ }
+ else {
+ if (!fp_rule)
+ cat2 = cat1;
+ else
+ val2 = val1;
+ r2 = r1;
+ g2 = g1;
+ b2 = b1;
+ }
+ if (null)
+ Rast_set_null_value_color(r1, g1, b1, colors);
+ else if (undef)
+ Rast_set_default_color(r1, g1, b1, colors);
+
+ else if (modular) {
+ if (fp_rule)
+ Rast_add_modular_d_raster_color_rule((DCELL *) & val1, r1, g1,
+ b1, (DCELL *) & val2, r2,
+ g2, b2, colors);
+ else
+ Rast_add_modular_color_rule((CELL) cat1, r1, g1, b1,
+ (CELL) cat2, r2, g2, b2, colors);
+ }
+ else {
+ if (fp_rule)
+ Rast_add_d_raster_color_rule((DCELL *) & val1, r1, g1, b1,
+ (DCELL *) & val2, r2, g2, b2,
+ colors);
+ else
+ Rast_add_color_rule((CELL) cat1, r1, g1, b1,
+ (CELL) cat2, r2, g2, b2, colors);
+ }
+ G_debug(3, "adding rule %d=%.2lf %d %d %d %d=%.2lf %d %d %d",
+ cat1, val1, r1, g1, b1, cat2, val2, r2, g2, b2);
+ }
+ return 1;
+}
+
+static int read_old_colors(FILE * fd, struct Colors *colors)
+{
+ char buf[256];
+ long n;
+ long min;
+ float red_f, grn_f, blu_f;
+ int red, grn, blu;
+ int old;
+ int zero;
+
+ Rast_init_colors(colors);
+ /*
+ * first line in pre 3.0 color files is number of colors - ignore
+ * otherwise it is #min first color, and the next line is for color 0
+ */
+ if (fgets(buf, sizeof buf, fd) == NULL)
+ return -1;
+
+ G_strip(buf);
+ if (*buf == '#') { /* 3.0 format */
+ old = 0;
+ if (sscanf(buf + 1, "%ld", &min) != 1) /* first color */
+ return -1;
+ zero = 1;
+ }
+ else {
+ old = 1;
+ min = 0;
+ zero = 0;
+ }
+
+ colors->cmin = min;
+ n = min;
+ while (fgets(buf, sizeof buf, fd)) {
+ if (old) {
+ if (sscanf(buf, "%f %f %f", &red_f, &grn_f, &blu_f) != 3)
+ return -1;
+
+ red = 256 * red_f;
+ grn = 256 * grn_f;
+ blu = 256 * blu_f;
+ }
+ else {
+ switch (sscanf(buf, "%d %d %d", &red, &grn, &blu)) {
+ case 1:
+ blu = grn = red;
+ break;
+ case 2:
+ blu = grn;
+ break;
+ case 3:
+ break;
+ default:
+ return -1;
+ }
+ }
+ if (zero) {
+ Rast__insert_color_into_lookup((CELL) 0, red, grn, blu,
+ &colors->fixed);
+ zero = 0;
+ }
+ else
+ Rast__insert_color_into_lookup((CELL) n++, red, grn, blu,
+ &colors->fixed);
+ }
+ colors->cmax = n - 1;
+
+ return 0;
+}
+
+/*!
+ * \brief Mark colors as floating-point.
+ *
+ * Sets a flag in the <i>colors</i> structure that indicates that
+ * these colors should only be looked up using floating-point raster
+ * data (not integer data). In particular if this flag is set, the
+ * routine Rast_get_colors_min_max() should return min=-255$^3$ and
+ * max=255$^3$.
+ *
+ * \param colors pointer to Colors structure
+ */
+void Rast_mark_colors_as_fp(struct Colors *colors)
+{
+ colors->is_float = 1;
+}
Copied: grass/trunk/lib/raster/color_remove.c (from rev 37989, grass/trunk/lib/gis/color_remove.c)
===================================================================
--- grass/trunk/lib/raster/color_remove.c (rev 0)
+++ grass/trunk/lib/raster/color_remove.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,44 @@
+
+/****************************************************************************
+ *
+ * MODULE: gis library
+ * AUTHOR(S): Glynn Clements <glynn at gclements.plus.com>
+ * COPYRIGHT: (C) 2007 Glynn Clements
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *****************************************************************************/
+
+#include <string.h>
+#include <stdio.h>
+#include <grass/gis.h>
+
+int Rast_remove_colors(const char *name, const char *mapset)
+{
+ char element[GMAPSET_MAX + 6];
+ char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
+ int stat;
+
+ if (G__name_is_fully_qualified(name, xname, xmapset)) {
+ if (strcmp(xmapset, mapset) != 0)
+ return -1;
+ name = xname;
+ }
+
+ /* get rid of existing colr2, if any */
+ sprintf(element, "colr2/%s", mapset);
+ stat = G_remove(element, name);
+
+ if (strcmp(mapset, G_mapset()) == 0)
+ stat = G_remove("colr", name);
+
+ return stat;
+}
Copied: grass/trunk/lib/raster/color_rule.c (from rev 37989, grass/trunk/lib/gis/color_rule.c)
===================================================================
--- grass/trunk/lib/raster/color_rule.c (rev 0)
+++ grass/trunk/lib/raster/color_rule.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,441 @@
+/*!
+ * \file gis/color_rule.c
+ *
+ * \brief GIS Library - Color rules.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+#define LIMIT(x) if (x < 0) x = 0; else if (x > 255) x = 255;
+
+static void add_color_rule(const void *, int, int, int,
+ const void *, int, int, int,
+ struct _Color_Info_ *, int,
+ DCELL *, DCELL *, RASTER_MAP_TYPE);
+
+
+/*!
+ * \brief Adds the floating-point rule (DCELL version)
+ *
+ * See Rast_add_raster_color_rule() for details.
+ *
+ * \param v1 cell value
+ * \param r1,g1,b1 color value
+ * \param v2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ * \return
+ */
+void Rast_add_d_raster_color_rule(const DCELL * val1, int r1, int g1, int b1,
+ const DCELL * val2, int r2, int g2, int b2,
+ struct Colors *colors)
+{
+ add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->fixed,
+ colors->version, &colors->cmin, &colors->cmax, DCELL_TYPE);
+}
+
+
+/*!
+ * \brief Adds the floating-point rule (FCELL version)
+ *
+ * See Rast_add_raster_color_rule() for details.
+ *
+ * \param v1 cell value
+ * \param r1,g1,b1 color value
+ * \param v2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ * \return
+ */
+void Rast_add_f_raster_color_rule(const FCELL * cat1, int r1, int g1, int b1,
+ const FCELL * cat2, int r2, int g2, int b2,
+ struct Colors *colors)
+{
+ add_color_rule(cat1, r1, g1, b1, cat2, r2, g2, b2, &colors->fixed,
+ colors->version, &colors->cmin, &colors->cmax, FCELL_TYPE);
+}
+
+
+/*!
+ * \brief Adds the floating-point rule (CCELL version)
+ *
+ * See Rast_add_raster_color_rule() for details.
+ *
+ * \param v1 cell value
+ * \param r1,g1,b1 color value
+ * \param v2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ * \return
+ */
+void Rast_add_c_raster_color_rule(const CELL * cat1, int r1, int g1, int b1,
+ const CELL * cat2, int r2, int g2, int b2,
+ struct Colors *colors)
+{
+ add_color_rule(cat1, r1, g1, b1, cat2, r2, g2, b2, &colors->fixed,
+ colors->version, &colors->cmin, &colors->cmax, CELL_TYPE);
+}
+
+
+/*!
+ * \brief Adds the floating-point rule
+ *
+ * Adds the floating-point rule that the range [<em>v1,v2</em>] gets a
+ * linear ramp of colors from [<em>r1,g1,b1</em>] to
+ * [<em>r2,g2,b2</em>].
+ * If either <em>v1</em> or <em>v2</em> is the NULL-value, this call is converted into
+ * <tt>Rast_set_null_value_color (r1, g1, b1, colors)</tt>
+ *
+ * - If <em>map_type</em> is CELL_TYPE, calls Rast_add_c_raster_color_rule()
+ * - If <em>map_type</em> is FCELL_TYPE, calls Rast_add_f_raster_color_rule()
+ * - If <em>map_type</em> is DCELL_TYPE, calls Rast_add_d_raster_color_rule()
+ *
+ * \param v1 cell value
+ * \param r1,g1,b1 color value
+ * \param v2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ * \param data_type raster data type (CELL, FCELL, DCELL)
+ * \return
+ */
+
+void Rast_add_raster_color_rule(const void *val1, int r1, int g1, int b1,
+ const void *val2, int r2, int g2, int b2,
+ struct Colors *colors, RASTER_MAP_TYPE data_type)
+{
+ add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->fixed,
+ colors->version, &colors->cmin, &colors->cmax, data_type);
+}
+
+
+/*!
+ * \brief Set colors rules
+ *
+ * This is the heart
+ * and soul of the new color logic. It adds a color rule to the <b>colors</b>
+ * structure. The colors defined by the red, green, and blue values
+ * <b>r1,g1,b1</b> and <b>r2,g2,b2</b> are assigned to <b>cat1</b> and
+ * <b>cat2</b> respectively. Colors for data values between <b>cat1</b> and
+ * <b>cat2</b> are not stored in the structure but are interpolated when
+ * queried by <i>Rast_lookup_colors</i> and<i>Rast_get_color.</i> The color
+ * components <b>r1,g1,b1</b> and <b>r2,g2,b2</b> must be in the range
+ * 0 -- 255.
+ * For example, to create a linear grey scale for the range 200 -- 1000:
+ *
+ \code
+ struct Colors colr;
+ Rast_init_colors (&colr);
+ Rast_add_color_rule ((CELL)200, 0,0,0, (CELL) 1000, 255,255,255);
+ \endcode
+ *
+ * The programmer is encouraged to review \ref
+ * Raster_Color_Table_Format how this routine fits into the 5.x raster
+ * color logic.
+ *
+ * <b>Note:</b> The <i>colors</i> structure must have been initialized
+ * by Rast_init_colors(). See \ref Predefined_Color_Tables for routines
+ * to build some predefined color tables.
+ *
+ * \param cat1 cell value
+ * \param r1,g1,b1 color value
+ * \param cat2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ * \return
+ */
+void Rast_add_color_rule(CELL cat1, int r1, int g1, int b1,
+ CELL cat2, int r2, int g2,
+ int b2, struct Colors *colors)
+{
+ add_color_rule((void *)&cat1, r1, g1, b1, (void *)&cat2, r2, g2, b2,
+ &colors->fixed, colors->version, &colors->cmin,
+ &colors->cmax, CELL_TYPE);
+}
+
+/*!
+ * \brief Add modular color rule (DCELL version)
+ *
+ * \param val1 cell value
+ * \param r1,g1,b1 color value
+ * \param val2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ *
+ * \return -1 on failure
+ * \return 1 on success
+ */
+int Rast_add_modular_d_raster_color_rule(const DCELL * val1, int r1, int g1, int b1,
+ const DCELL * val2, int r2, int g2, int b2,
+ struct Colors *colors)
+{
+ DCELL min, max;
+
+ if (colors->version < 0)
+ return -1; /* can't use this on 3.0 colors */
+ min = colors->cmin;
+ max = colors->cmax;
+ add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->modular, 0,
+ &colors->cmin, &colors->cmax, DCELL_TYPE);
+ colors->cmin = min; /* don't reset these */
+ colors->cmax = max;
+
+ return 1;
+}
+
+/*!
+ * \brief Add modular color rule (FCELL version)
+ *
+ * \param val1 cell value
+ * \param r1,g1,b1 color value
+ * \param val2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ *
+ * \return -1 on failure
+ * \return 1 on success
+ */
+int Rast_add_modular_f_raster_color_rule(const FCELL * val1, int r1, int g1, int b1,
+ const FCELL * val2, int r2, int g2, int b2,
+ struct Colors *colors)
+{
+ DCELL min, max;
+
+ if (colors->version < 0)
+ return -1; /* can;t use this on 3.0 colors */
+ min = colors->cmin;
+ max = colors->cmax;
+ add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->modular, 0,
+ &colors->cmin, &colors->cmax, FCELL_TYPE);
+ colors->cmin = min; /* don't reset these */
+ colors->cmax = max;
+
+ return 1;
+}
+
+/*!
+ * \brief Add modular color rule (CCELL version)
+ *
+ * \param val1 cell value
+ * \param r1,g1,b1 color value
+ * \param val2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ *
+ * \return -1 on failure
+ * \return 1 on success
+ */
+int Rast_add_modular_c_raster_color_rule(const CELL * val1, int r1, int g1, int b1,
+ const CELL * val2, int r2, int g2, int b2,
+ struct Colors *colors)
+{
+ return Rast_add_modular_color_rule(*val1, r1, g1, b1, *val2, r2, g2, b2,
+ colors);
+}
+
+/*!
+ * \brief Add modular color rule
+ *
+ * \todo Question: shouldn't this function call
+ * G_add_modular_<data_type>_raster_color_rule() instead?
+ *
+ * \param val1 cell value
+ * \param r1,g1,b1 color value
+ * \param val2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ * \param data_type raster data type
+ *
+ * \return -1 on failure
+ * \return 1 on success
+ */
+int Rast_add_modular_raster_color_rule(
+ const void *val1, int r1, int g1, int b1,
+ const void *val2, int r2, int g2, int b2,
+ struct Colors *colors, RASTER_MAP_TYPE data_type)
+{
+ CELL min, max;
+
+ if (colors->version < 0)
+ return -1; /* can't use this on 3.0 colors */
+ min = colors->cmin;
+ max = colors->cmax;
+ add_color_rule(val1, r1, g1, b1, val2, r2, g2, b2, &colors->modular, 0,
+ &colors->cmin, &colors->cmax, data_type);
+ colors->cmin = min; /* don't reset these */
+ colors->cmax = max;
+
+ return 1;
+}
+
+/*!
+ * \brief Add modular color rule
+ *
+ * \todo This function seems to be same as
+ * Rast_add_modular_raster_color_rule(). Can be removed?
+ *
+ * \param val1 cell value
+ * \param r1,g1,b1 color value
+ * \param val2 cell value
+ * \param r2,g2,b2 color value
+ * \param[in,out] colors pointer to color table structure
+ * \param data_type raster data type
+ *
+ * \return -1 on failure
+ * \return 1 on success
+ */
+int Rast_add_modular_color_rule(CELL cat1, int r1, int g1,
+ int b1, CELL cat2, int r2,
+ int g2, int b2, struct Colors *colors)
+{
+ CELL min, max;
+
+ if (colors->version < 0)
+ return -1; /* can;t use this on 3.0 colors */
+ min = colors->cmin;
+ max = colors->cmax;
+ add_color_rule((void *)&cat1, r1, g1, b1, (void *)&cat2, r2, g2, b2,
+ &colors->modular, 0, &colors->cmin, &colors->cmax,
+ CELL_TYPE);
+ colors->cmin = min; /* don't reset these */
+ colors->cmax = max;
+
+ return 1;
+}
+
+static void add_color_rule(const void *pt1, int r1, int g1, int b1,
+ const void *pt2, int r2, int g2, int b2,
+ struct _Color_Info_ *cp, int version, DCELL * cmin,
+ DCELL * cmax, RASTER_MAP_TYPE data_type)
+{
+ struct _Color_Rule_ *rule, *next;
+ unsigned char red, grn, blu;
+ DCELL min, max, val1, val2;
+ CELL cat;
+
+ val1 = Rast_get_raster_value_d(pt1, data_type);
+ val2 = Rast_get_raster_value_d(pt2, data_type);
+ /* allocate a low:high rule */
+ rule = (struct _Color_Rule_ *)G_malloc(sizeof(*rule));
+ rule->next = rule->prev = NULL;
+
+ /* make sure colors are in the range [0,255] */
+ LIMIT(r1);
+ LIMIT(g1);
+ LIMIT(b1);
+ LIMIT(r2);
+ LIMIT(g2);
+ LIMIT(b2);
+
+ /* val1==val2, use average color */
+ /* otherwise make sure low < high */
+ if (val1 == val2) {
+ rule->low.value = rule->high.value = val1;
+ rule->low.red = rule->high.red = (r1 + r2) / 2;
+ rule->low.grn = rule->high.grn = (g1 + g2) / 2;
+ rule->low.blu = rule->high.blu = (b1 + b2) / 2;
+ }
+ else if (val1 < val2) {
+ rule->low.value = val1;
+ rule->low.red = r1;
+ rule->low.grn = g1;
+ rule->low.blu = b1;
+
+ rule->high.value = val2;
+ rule->high.red = r2;
+ rule->high.grn = g2;
+ rule->high.blu = b2;
+ }
+ else {
+ rule->low.value = val2;
+ rule->low.red = r2;
+ rule->low.grn = g2;
+ rule->low.blu = b2;
+
+ rule->high.value = val1;
+ rule->high.red = r1;
+ rule->high.grn = g1;
+ rule->high.blu = b1;
+ }
+
+ /* keep track of the overall min and max, excluding null */
+ if (Rast_is_d_null_value(&(rule->low.value)))
+ return;
+ if (Rast_is_d_null_value(&(rule->high.value)))
+ return;
+ min = rule->low.value;
+ max = rule->high.value;
+ if (min <= max) {
+ if (cp->min > cp->max) {
+ cp->min = min;
+ cp->max = max;
+ }
+ else {
+ if (cp->min > min)
+ cp->min = min;
+ if (cp->max < max)
+ cp->max = max;
+ }
+ }
+ if (*cmin > *cmax) {
+ *cmin = cp->min;
+ *cmax = cp->max;
+ }
+ else {
+ if (*cmin > cp->min)
+ *cmin = cp->min;
+ if (*cmax < cp->max)
+ *cmax = cp->max;
+ }
+
+ /* If version is old style (i.e., pre 4.0),
+ * interpolate this rule from min to max
+ * and insert each cat into the lookup table.
+ * Then free the rule.
+ * Otherwise, free the lookup table, if active.
+ * G_organize_colors() will regenerate it
+ * Link this rule into the list of rules
+ */
+
+ if (version < 0) {
+ for (cat = (CELL) min; cat <= (CELL) max; cat++) {
+ Rast__interpolate_color_rule((DCELL) cat, &red, &grn, &blu, rule);
+ Rast__insert_color_into_lookup(cat, (int)red, (int)grn, (int)blu,
+ cp);
+ }
+ G_free(rule);
+ }
+ else {
+ if (cp->rules)
+ cp->rules->prev = rule;
+ rule->next = cp->rules;
+ cp->rules = rule;
+
+ /* prune the rules:
+ * remove all rules that are contained by this rule
+ */
+ min = rule->low.value; /* mod 4.1 */
+ max = rule->high.value; /* mod 4.1 */
+ cp->n_rules++;
+ for (rule = rule->next; rule; rule = next) {
+ next = rule->next; /* has to be done here, not in for stmt */
+ if (min <= rule->low.value && max >= rule->high.value) {
+ if ((rule->prev->next = next)) /* remove from the list */
+ next->prev = rule->prev;
+ G_free(rule);
+ cp->n_rules--;
+ }
+ }
+
+ /* free lookup array, if allocated */
+ Rast__color_free_lookup(cp);
+ Rast__color_free_fp_lookup(cp);
+ }
+}
Copied: grass/trunk/lib/raster/color_rule_get.c (from rev 37989, grass/trunk/lib/gis/color_rule_get.c)
===================================================================
--- grass/trunk/lib/raster/color_rule_get.c (rev 0)
+++ grass/trunk/lib/raster/color_rule_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,123 @@
+
+/**
+ * \file color_rule_get.c
+ *
+ * \brief GIS Library - Get color rules.
+ *
+ * (C) 2001-2008 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author GRASS GIS Development Team
+ *
+ * \date 1999-2008
+ */
+
+#include <grass/gis.h>
+
+/*!
+ \brief Get both modular and fixed rules count
+
+ \param colors pointer to color table structure
+
+ \return number of rules in color table
+ */
+int Rast_colors_count(const struct Colors *colors)
+{
+ int count = 0;
+ struct _Color_Rule_ *rule;
+
+ if (colors->fixed.rules) {
+ count++;
+ rule = colors->fixed.rules;
+
+ while (rule->next) {
+ count++;
+ rule = rule->next;
+ }
+ }
+ if (colors->modular.rules) {
+ count++;
+ rule = colors->modular.rules;
+
+ while (rule->next) {
+ count++;
+ rule = rule->next;
+ }
+ }
+ return count;
+}
+
+/*!
+ \brief Get color rule from both modular and fixed rules
+
+ Rules are returned in the order as stored in the table (i.e. unexpected, high values first)
+
+ \param val1 color value
+ \param[out] r1,g1,b1 color value
+ \param val2 color value
+ \param[out] r2,g2,b2 color value
+ \param colors pointer to color table structure
+ \param rule rule index from 0 to G_color_count()-1
+
+ \return 0 success
+ \return 1 index out of range
+ */
+int Rast_get_f_color_rule(DCELL * val1, unsigned char *r1, unsigned char *g1,
+ unsigned char *b1, DCELL * val2, unsigned char *r2,
+ unsigned char *g2, unsigned char *b2,
+ const struct Colors *colors, int rule)
+{
+ int index = -1;
+ int found = 0;
+ const struct _Color_Rule_ *rl;
+
+ *val1 = *val2 = 0.0;
+ *r1 = *g1 = *b1 = *r2 = *g2 = *b2 = 0;
+
+ /* Find the rule */
+ if (colors->fixed.rules) {
+ rl = colors->fixed.rules;
+ index++;
+ if (index == rule)
+ found = 1;
+
+ while (!found && rl->next) {
+ rl = rl->next;
+ index++;
+ if (index == rule)
+ found = 1;
+ }
+ }
+ if (!found && colors->modular.rules) {
+ rl = colors->modular.rules;
+ index++;
+ if (index == rule)
+ found = 1;
+
+ while (!found && rl->next) {
+ rl = rl->next;
+ index++;
+ if (index == rule)
+ found = 1;
+ }
+ }
+
+ if (!found)
+ return 1;
+
+ /* Set values */
+ *val1 = rl->low.value;
+ *val2 = rl->high.value;
+
+ *r1 = rl->low.red;
+ *g1 = rl->low.grn;
+ *b1 = rl->low.blu;
+
+ *r2 = rl->high.red;
+ *g2 = rl->high.grn;
+ *b2 = rl->high.blu;
+
+ return 0;
+}
Copied: grass/trunk/lib/raster/color_rules.c (from rev 37989, grass/trunk/lib/gis/color_rules.c)
===================================================================
--- grass/trunk/lib/raster/color_rules.c (rev 0)
+++ grass/trunk/lib/raster/color_rules.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,272 @@
+
+/****************************************************************************
+ *
+ * MODULE: gis library
+ * AUTHOR(S): Glynn Clements <glynn at gclements.plus.com>
+ * COPYRIGHT: (C) 2007 Glynn Clements and the GRASS Development Team
+ *
+ * NOTE: Based upon r.colors/rules.c
+ * The colors are stored in ./colors/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+struct rule
+{
+ int set;
+ int r, g, b;
+ DCELL val;
+};
+
+enum rule_error
+{
+ CR_OK = 0,
+ CR_ERROR_SYNTAX,
+ CR_ERROR_RGB,
+ CR_ERROR_COLOR,
+ CR_ERROR_PERCENT,
+ CR_ERROR_VALUE,
+};
+
+int Rast_parse_color_rule(DCELL min, DCELL max, const char *buf,
+ DCELL * val, int *r, int *g, int *b,
+ int *norm, int *nval, int *dflt)
+{
+ char value[80], color[80];
+ double x;
+ char c;
+
+ *norm = *nval = *dflt = 0;
+
+ if (sscanf(buf, "%s %[^\n]", value, color) != 2)
+ return CR_ERROR_SYNTAX;
+
+ G_chop(color);
+
+ if (sscanf(color, "%d:%d:%d", r, g, b) == 3 ||
+ sscanf(color, "%d %d %d", r, g, b) == 3) {
+ if (*r < 0 || *r > 255 || *g < 0 || *g > 255 || *b < 0 || *b > 255)
+ return CR_ERROR_RGB;
+ }
+ else {
+ float fr, fg, fb;
+
+ if (G_color_values(color, &fr, &fg, &fb) < 0)
+ return CR_ERROR_COLOR;
+
+ *r = (int)(fr * 255.99);
+ *g = (int)(fg * 255.99);
+ *b = (int)(fb * 255.99);
+ }
+
+ G_chop(value);
+
+ if (G_strcasecmp(value, "default") == 0) {
+ *dflt = 1;
+ return CR_OK;
+ }
+
+ if (G_strcasecmp(value, "nv") == 0) {
+ *nval = 1;
+ return CR_OK;
+ }
+
+ if (sscanf(value, "%lf%c", &x, &c) == 2 && c == '%') {
+ if (x < 0 || x > 100)
+ return CR_ERROR_PERCENT;
+
+ *val = min + (max - min) * (x / 100);
+ *norm = 1;
+ return CR_OK;
+ }
+
+ if (sscanf(value, "%lf", val) == 1) {
+ *norm = 1;
+ return CR_OK;
+ }
+
+ return CR_ERROR_VALUE;
+}
+
+const char *Rast_parse_color_rule_error(int code)
+{
+ switch (code) {
+ case CR_OK:
+ return "";
+ case CR_ERROR_SYNTAX:
+ return _("syntax error");
+ case CR_ERROR_RGB:
+ return _("R/G/B not in range 0-255");
+ case CR_ERROR_COLOR:
+ return _("invalid color name");
+ case CR_ERROR_PERCENT:
+ return _("percentage not in range 0-100");
+ case CR_ERROR_VALUE:
+ return _("invalid value");
+ default:
+ return _("unknown error");
+ }
+}
+
+int Rast_read_color_rule(void *closure, DCELL min, DCELL max,
+ DCELL * val, int *r, int *g, int *b,
+ int *norm, int *nval, int *dflt)
+{
+ char buf[1024];
+ FILE *fp = closure;
+ int ret;
+
+ *norm = *nval = *dflt = 0;
+
+ for (;;) {
+ if (!G_getl2(buf, sizeof(buf), fp))
+ return 0;
+
+ G_strip(buf);
+ G_debug(5, "color buf = [%s]", buf);
+
+ if (*buf == '\0')
+ continue;
+ if (*buf == '#')
+ continue;
+
+ ret =
+ Rast_parse_color_rule(min, max, buf, val, r, g, b, norm, nval, dflt);
+ if (ret == 0)
+ return 1;
+
+ G_fatal_error(_("bad rule (%s): [%s]"),
+ Rast_parse_color_rule_error(ret), buf);
+ }
+
+ return 0;
+}
+
+int Rast_read_color_rules(struct Colors *colors, DCELL min, DCELL max,
+ read_rule_fn * read_rule, void *closure)
+{
+ struct rule *rule = NULL;
+ int nrules = 0;
+ struct rule dflt, null;
+ int set, is_null, is_dflt, r, g, b;
+ DCELL val;
+ int n;
+
+ if (!read_rule)
+ read_rule = Rast_read_color_rule;
+
+ Rast_init_colors(colors);
+
+ /* initialization */
+ dflt.r = dflt.g = dflt.b = dflt.set = 0;
+ null.r = null.g = null.b = null.set = 0;
+
+ while ((*read_rule)
+ (closure, min, max, &val, &r, &g, &b, &set, &is_null, &is_dflt)) {
+ struct rule *p;
+
+ if (set) {
+ n = nrules++;
+ rule = G_realloc(rule, nrules * sizeof(struct rule));
+ p = &rule[n];
+ }
+ else if (is_dflt)
+ p = &dflt;
+ else if (is_null)
+ p = &null;
+
+ p->r = r;
+ p->g = g;
+ p->b = b;
+ p->set = 1;
+ p->val = val;
+ }
+
+ if (nrules == 0)
+ return 0;
+
+ if (nrules == 1) {
+ const struct rule *p = &rule[0];
+
+ Rast_set_d_color(p->val, p->r, p->g, p->b, colors);
+ }
+
+ for (n = 1; n < nrules; n++) {
+ struct rule *lo = &rule[n - 1];
+ struct rule *hi = &rule[n];
+
+ Rast_add_d_raster_color_rule(&lo->val, lo->r, lo->g, lo->b,
+ &hi->val, hi->r, hi->g, hi->b, colors);
+ }
+
+ /* null value and default color set up, if rules are set up by user */
+ if (null.set)
+ Rast_set_null_value_color(null.r, null.g, null.b, colors);
+
+ if (dflt.set)
+ Rast_set_default_color(dflt.r, dflt.g, dflt.b, colors);
+
+ return 1;
+}
+
+static int load_rules_file(struct Colors *colors, const char *path, DCELL min, DCELL max)
+{
+ FILE *fp;
+ int ret;
+
+ fp = fopen(path, "r");
+
+ if (!fp)
+ return 0;
+
+ ret = Rast_read_color_rules(colors, min, max, Rast_read_color_rule, (void *)fp);
+
+ fclose(fp);
+
+ return ret;
+}
+
+int Rast_load_colors(struct Colors *colors, const char *path, CELL min, CELL max)
+{
+ return load_rules_file(colors, path, (DCELL) min, (DCELL) max);
+}
+
+int Rast_load_fp_colors(struct Colors *colors, const char *path, DCELL min, DCELL max)
+{
+ return load_rules_file(colors, path, min, max);
+}
+
+static void load_rules_name(struct Colors *colors, const char *name, DCELL min, DCELL max)
+{
+ char path[GPATH_MAX];
+
+ sprintf(path, "%s/etc/colors/%s", G_gisbase(), name);
+
+ if (!load_rules_file(colors, path, min, max))
+ G_fatal_error(_("Unable to load color rules <%s>"), name);
+}
+
+void Rast_make_colors(struct Colors *colors, const char *name, CELL min, CELL max)
+{
+ return load_rules_name(colors, name, (DCELL) min, (DCELL) max);
+}
+
+void Rast_make_fp_colors(struct Colors *colors, const char *name, DCELL min, DCELL max)
+{
+ return load_rules_name(colors, name, min, max);
+}
Copied: grass/trunk/lib/raster/color_set.c (from rev 37989, grass/trunk/lib/gis/color_set.c)
===================================================================
--- grass/trunk/lib/raster/color_set.c (rev 0)
+++ grass/trunk/lib/raster/color_set.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,105 @@
+/*!
+ * \file gis/color_set.c
+ *
+ * \brief GIS Library - Set colors for raster maps.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Set a category color (CELL)
+ *
+ * The <i>red, green</i>, and <i>blue</i> intensities for the color
+ * associated with category <i>cat</i> are set in the <i>colors</i>
+ * structure. The intensities must be in the range 0 - 255. Values
+ * below zero are set as zero, values above 255 are set as 255.
+ *
+ * <b>Warning: Use of this routine is discouraged because it defeats the new
+ * color logic.</b>
+ *
+ * It is provided only for backward compatibility. Overuse can create
+ * large color tables. Rast_add_color_rule() should be used whenever
+ * possible.
+ *
+ * <b>Note:</b> The <i>colors</i> structure must have been
+ * initialized by G_init_color().
+ *
+ * \param cat raster cell value
+ * \param r red value
+ * \param g green value
+ * \param b blue value
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_set_color(CELL cat, int r, int g, int b, struct Colors *colors)
+{
+ if (Rast_is_c_null_value(&cat))
+ Rast_set_null_value_color(r, g, b, colors);
+ else
+ Rast_add_color_rule(cat, r, g, b, cat, r, g, b, colors);
+}
+
+/*!
+ * \brief Set a category color (DCELL)
+ *
+ * See Rast_set_color() for detailed information.
+ *
+ * \param cat raster cell value
+ * \param r red value
+ * \param g green value
+ * \param b blue value
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_set_d_color(DCELL val, int r, int g, int b, struct Colors *colors)
+{
+ if (Rast_is_d_null_value(&val))
+ Rast_set_null_value_color(r, g, b, colors);
+ else
+ Rast_add_d_raster_color_rule(&val, r, g, b, &val, r, g, b, colors);
+}
+
+/*!
+ * \brief Set color for NULL-value
+ *
+ * Sets the color (in <i>colors</i>) for the NULL-value to
+ * <i>red, green, blue</i>.
+ *
+ * \param red red value
+ * \param grn green value
+ * \param blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_set_null_value_color(int red, int grn, int blu, struct Colors *colors)
+{
+ colors->null_red = red;
+ colors->null_grn = grn;
+ colors->null_blu = blu;
+ colors->null_set = 1;
+}
+
+/*!
+ * \brief Set default color value
+ *
+ * Sets the default color (in <i>colors</i>) to <i>red, green,
+ * blue</i>. This is the color for values which do not have an
+ * explicit rule.
+ *
+ * \param red red value
+ * \param grn green value
+ * \param blu blue value
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast_set_default_color(int red, int grn, int blu, struct Colors *colors)
+{
+ colors->undef_red = red;
+ colors->undef_grn = grn;
+ colors->undef_blu = blu;
+ colors->undef_set = 1;
+}
Copied: grass/trunk/lib/raster/color_shift.c (from rev 37989, grass/trunk/lib/gis/color_shift.c)
===================================================================
--- grass/trunk/lib/raster/color_shift.c (rev 0)
+++ grass/trunk/lib/raster/color_shift.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,10 @@
+#include <grass/gis.h>
+void Rast_shift_colors(int shift, struct Colors *colors)
+{
+ colors->shift += (DCELL) shift;
+}
+
+void Rast_shift_d_colors(DCELL shift, struct Colors *colors)
+{
+ colors->shift += shift;
+}
Copied: grass/trunk/lib/raster/color_str.c (from rev 37989, grass/trunk/lib/gis/color_str.c)
===================================================================
--- grass/trunk/lib/raster/color_str.c (rev 0)
+++ grass/trunk/lib/raster/color_str.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,150 @@
+/*!
+ \file color_str.c
+
+ \brief GIS library - color management, named color to RGB triplet
+
+ (C) 2001-2008 by the GRASS Development Team
+
+ This program is free software under the
+ GNU General Public License (>=v2).
+ Read the file COPYING that comes with GRASS
+ for details.
+
+ \author Original author CERL
+ */
+
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/colors.h>
+
+/* The order in this table is important! It will be indexed by color number */
+static const struct color_rgb standard_colors_rgb[] = {
+ {0, 0, 0}, /* This is a dummy value to make lookup easier */
+ {0, 0, 0}, /* BLACK */
+ {255, 0, 0}, /* RED */
+ {0, 255, 0}, /* GREEN */
+ {0, 0, 255}, /* BLUE */
+ {255, 255, 0}, /* YELLOW */
+ {0, 255, 255}, /* CYAN */
+ {255, 0, 255}, /* MAGENTA */
+ {255, 255, 255}, /* WHITE */
+ {128, 128, 128}, /* GRAY */
+ {255, 128, 0}, /* ORANGE */
+ {100, 128, 255}, /* AQUA */
+ {0, 128, 255}, /* INDIGO */
+ {128, 0, 255}, /* VIOLET */
+ {180, 77, 25} /* BROWN */
+};
+
+/* The order in this table has no meaning. */
+static const struct color_name standard_color_names[] = {
+ {"black", BLACK},
+ {"red", RED},
+ {"green", GREEN},
+ {"blue", BLUE},
+ {"yellow", YELLOW},
+ {"cyan", CYAN},
+ {"magenta", MAGENTA},
+ {"white", WHITE},
+ {"grey", GREY},
+ {"gray", GRAY},
+ {"orange", ORANGE},
+ {"aqua", AQUA},
+ {"indigo", INDIGO},
+ {"violet", VIOLET},
+ {"purple", PURPLE},
+ {"brown", BROWN}
+};
+
+/*!
+ \brief Get number of named colors (RGB triplets)
+
+ \return number of colors
+ */
+int G_num_standard_colors(void)
+{
+ return sizeof(standard_colors_rgb) / sizeof(standard_colors_rgb[0]);
+}
+
+/*!
+ \brief Get RGB triplet of given color
+
+ \param n color index
+ */
+struct color_rgb G_standard_color_rgb(int n)
+{
+ return standard_colors_rgb[n];
+}
+
+/*!
+ \brief Get number of named colors (color names)
+
+ \return number of colors
+ */
+int G_num_standard_color_names(void)
+{
+ return sizeof(standard_color_names) / sizeof(standard_color_names[0]);
+}
+
+/*!
+ \brief Get color name
+
+ \param n color index
+ */
+const struct color_name *G_standard_color_name(int n)
+{
+ return &standard_color_names[n];
+}
+
+/*!
+ \brief Parse color string and set red,green,blue
+
+ \param str color string
+ \param[out] red red value
+ \param[out] grn green value
+ \param[out] blu blue value
+
+ \return 1 OK
+ \return 2 NONE
+ \return 0 on error
+ */
+int Rast_str_to_color(const char *str, int *red, int *grn, int *blu)
+{
+ char buf[100];
+ int num_names = G_num_standard_color_names();
+ int i;
+
+ strcpy(buf, str);
+ G_chop(buf);
+
+ G_debug(3, "Rast_str_to_color(): str = '%s'", buf);
+
+ if (G_strcasecmp(buf, "NONE") == 0)
+ return 2;
+
+ if (sscanf(buf, "%d%*[,:; ]%d%*[,:; ]%d", red, grn, blu) == 3) {
+ if (*red < 0 || *red > 255 ||
+ *grn < 0 || *grn > 255 || *blu < 0 || *blu > 255)
+ return 0;
+
+ return 1;
+ }
+
+ /* Look for this color in the standard (preallocated) colors */
+ for (i = 0; i < num_names; i++) {
+ const struct color_name *name = &standard_color_names[i];
+
+ if (G_strcasecmp(buf, name->name) == 0) {
+ struct color_rgb rgb = standard_colors_rgb[name->number];
+
+ *red = (int)rgb.r;
+ *grn = (int)rgb.g;
+ *blu = (int)rgb.b;
+
+ return 1;
+ }
+ }
+
+ return 0;
+}
Copied: grass/trunk/lib/raster/color_write.c (from rev 37989, grass/trunk/lib/gis/color_write.c)
===================================================================
--- grass/trunk/lib/raster/color_write.c (rev 0)
+++ grass/trunk/lib/raster/color_write.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,268 @@
+/*!
+ * \file gis/color_write.c
+ *
+ * \brief GIS Library - Write color table of raster map
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+#define PRECISION 30
+#define THRESHOLD .0000000000000000000000000000005 /* .5 * 10 ^(-30) */
+
+static void write_rules(FILE *, struct _Color_Rule_ *, DCELL, DCELL);
+static void write_new_colors(FILE *, struct Colors *);
+static void write_old_colors(FILE *, struct Colors *);
+static void forced_write_old_colors(FILE *, struct Colors *);
+static void format_min(char *, double);
+static void format_max(char *, double);
+
+/*!
+ * \brief Write map layer color table
+ *
+ * The color table is written for the raster map <i>name</i> in the
+ * specified <i>mapset</i> from the <i>colors</i> structure.
+ *
+ * If there is an error, -1 is returned. No diagnostic is
+ * printed. Otherwise, 1 is returned.
+ *
+ * The <i>colors</i> structure must be created properly, i.e.,
+ * Rast_init_colors() to initialize the structure and Rast_add_color_rule()
+ * to set the category colors. These routines are called by
+ * higher level routines which read or create entire color tables,
+ * such as Rast_read_colors() or Rast_make_ramp_colors().
+ *
+ * <b>Note:</b> The calling sequence for this function deserves
+ * special attention. The <i>mapset</i> parameter seems to imply that
+ * it is possible to overwrite the color table for a raster map which
+ * is in another mapset. However, this is not what actually
+ * happens. It is very useful for users to create their own color
+ * tables for raster maps in other mapsets, but without overwriting
+ * other users' color tables for the same raster map. If <i>mapset</i>
+ * is the current mapset, then the color file for <i>name</i> will be
+ * overwritten by the new color table. But if <i>mapset</i> is not the
+ * current mapset, then the color table is actually written in the
+ * current mapset under the <tt>colr2</tt> element as:
+ * <tt>colr2/mapset/name</tt>.
+ *
+ * The rules are written out using floating-point format, removing
+ * trailing zeros (possibly producing integers). The flag marking the
+ * colors as floating-point is <b>not</b> written.
+ *
+ * If the environment variable FORCE_GRASS3_COLORS is set (to anything at all)
+ * then the output format is 3.0, even if the structure contains 4.0 rules.
+ * This allows users to create 3.0 color files for export to sites which
+ * don't yet have 4.0
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param colors pointer to structure Colors which holds color info
+ *
+ * \return 1 on success
+ * \return -1 on failure
+ */
+int Rast_write_colors(const char *name, const char *mapset,
+ struct Colors *colors)
+{
+ char element[512];
+ char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
+ FILE *fd;
+
+ if (G__name_is_fully_qualified(name, xname, xmapset)) {
+ if (strcmp(xmapset, mapset) != 0)
+ return -1;
+ name = xname;
+ }
+ /*
+ * if mapset is current mapset, remove colr2 file (created by pre 3.0 grass)
+ * and then write original color table
+ * else write secondary color table
+ */
+ sprintf(element, "colr2/%s", mapset);
+ if (strcmp(mapset, G_mapset()) == 0) {
+ G_remove(element, name); /* get rid of existing colr2, if any */
+ strcpy(element, "colr");
+ }
+ if (!(fd = G_fopen_new(element, name)))
+ return -1;
+
+ Rast__write_colors(fd, colors);
+ fclose(fd);
+ return 1;
+}
+
+/*!
+ * \brief Write map layer color table
+ *
+ * \param fd file descriptor
+ * \param colors pointer to Colors structure which holds color info
+ */
+void Rast__write_colors(FILE * fd, struct Colors *colors)
+{
+ if (getenv("FORCE_GRASS3_COLORS"))
+ forced_write_old_colors(fd, colors);
+ else if (colors->version < 0)
+ write_old_colors(fd, colors);
+ else
+ write_new_colors(fd, colors);
+}
+
+static void write_new_colors(FILE * fd, struct Colors *colors)
+{
+ char str1[100], str2[100];
+
+ format_min(str1, (double)colors->cmin);
+ format_max(str2, (double)colors->cmax);
+ fprintf(fd, "%% %s %s\n", str1, str2);
+
+ if (colors->shift) {
+ sprintf(str2, "%.10f", (double)colors->shift);
+ G_trim_decimal(str2);
+ fprintf(fd, "shift:%s\n", str2);
+ }
+ if (colors->invert)
+ fprintf(fd, "invert\n");
+
+ if (colors->null_set) {
+ fprintf(fd, "nv:%d", colors->null_red);
+ if (colors->null_red != colors->null_grn || colors->null_red
+ != colors->null_blu)
+ fprintf(fd, ":%d:%d", colors->null_grn, colors->null_blu);
+ fprintf(fd, "\n");
+ }
+ if (colors->undef_set) {
+ fprintf(fd, "*:%d", colors->undef_red);
+ if (colors->undef_red != colors->undef_grn || colors->undef_red
+ != colors->undef_blu)
+ fprintf(fd, ":%d:%d", colors->undef_grn, colors->undef_blu);
+ fprintf(fd, "\n");
+ }
+ if (colors->modular.rules) {
+ fprintf(fd, "%s\n", "%%");
+ write_rules(fd, colors->modular.rules, colors->cmin, colors->cmax);
+ fprintf(fd, "%s\n", "%%");
+ }
+ if (colors->fixed.rules)
+ write_rules(fd, colors->fixed.rules, colors->cmin, colors->cmax);
+}
+
+/* overall min and max data values in color table */
+static void write_rules(FILE * fd, struct _Color_Rule_ *crules, DCELL dmin, DCELL dmax)
+{
+ struct _Color_Rule_ *rule;
+ char str[100];
+
+ /* find the end of the rules list */
+ rule = crules;
+ while (rule->next)
+ rule = rule->next;
+
+ /* write out the rules in reverse order */
+ for (; rule; rule = rule->prev) {
+ if (rule->low.value == dmin)
+ format_min(str, (double)rule->low.value);
+ else {
+ sprintf(str, "%.10f", (double)rule->low.value);
+ G_trim_decimal(str);
+ }
+ fprintf(fd, "%s:%d", str, (int)rule->low.red);
+ if (rule->low.red != rule->low.grn || rule->low.red != rule->low.blu)
+ fprintf(fd, ":%d:%d", rule->low.grn, rule->low.blu);
+ /* even if low==high, write second end when the high is dmax */
+ if (rule->high.value == dmax || rule->low.value != rule->high.value) {
+ if (rule->high.value == dmax)
+ format_max(str, (double)rule->high.value);
+ else {
+ sprintf(str, "%.10f", (double)rule->high.value);
+ G_trim_decimal(str);
+ }
+ fprintf(fd, " %s:%d", str, (int)rule->high.red);
+ if (rule->high.red != rule->high.grn ||
+ rule->high.red != rule->high.blu)
+ fprintf(fd, ":%d:%d", rule->high.grn, rule->high.blu);
+ }
+ fprintf(fd, "\n");
+ }
+}
+
+static void write_old_colors(FILE * fd, struct Colors *colors)
+{
+ int i, n;
+
+ fprintf(fd, "#%ld first color\n", (long)colors->fixed.min);
+ if (colors->null_set) {
+ fprintf(fd, "%d %d %d\n",
+ (int)colors->null_red,
+ (int)colors->null_grn, (int)colors->null_blu);
+ }
+ else
+ fprintf(fd, "255 255 255\n"); /* white */
+
+ n = colors->fixed.max - colors->fixed.min + 1;
+
+ for (i = 0; i < n; i++) {
+ fprintf(fd, "%d", (int)colors->fixed.lookup.red[i]);
+ if (colors->fixed.lookup.red[i] != colors->fixed.lookup.grn[i]
+ || colors->fixed.lookup.red[i] != colors->fixed.lookup.blu[i])
+ fprintf(fd, " %d %d",
+ (int)colors->fixed.lookup.grn[i],
+ (int)colors->fixed.lookup.blu[i]);
+ fprintf(fd, "\n");
+ }
+}
+
+static void forced_write_old_colors(FILE * fd, struct Colors *colors)
+{
+ int red, grn, blu;
+ CELL cat;
+
+ fprintf(fd, "#%ld first color\n", (long)colors->cmin);
+ Rast_get_color((CELL) 0, &red, &grn, &blu, colors);
+ fprintf(fd, "%d %d %d\n", red, grn, blu);
+
+ for (cat = colors->cmin; cat <= colors->cmax; cat++) {
+ Rast_get_color(cat, &red, &grn, &blu, colors);
+ fprintf(fd, "%d", red);
+ if (red != grn || red != blu)
+ fprintf(fd, " %d %d", grn, blu);
+ fprintf(fd, "\n");
+ }
+}
+
+static void format_min(char *str, double dval)
+{
+ double dtmp;
+
+ sprintf(str, "%.*f", PRECISION, dval);
+ G_trim_decimal(str);
+ sscanf(str, "%lf", &dtmp);
+ if (dtmp != dval) { /* if no zeros after decimal point were trimmed */
+ sprintf(str, "%.*f", PRECISION, dval - THRESHOLD);
+ /* because precision is probably higher than PRECISION */
+ }
+}
+
+static void format_max(char *str, double dval)
+{
+ double dtmp;
+
+ sprintf(str, "%.*f", PRECISION, dval);
+ G_trim_decimal(str);
+ sscanf(str, "%lf", &dtmp);
+ if (dtmp != dval) { /* if no zeros after decimal point were trimmed */
+ sprintf(str, "%.*f", PRECISION, dval + THRESHOLD);
+ /* because precision is probably higher than PRECISION */
+ }
+}
Copied: grass/trunk/lib/raster/color_xform.c (from rev 37989, grass/trunk/lib/gis/color_xform.c)
===================================================================
--- grass/trunk/lib/raster/color_xform.c (rev 0)
+++ grass/trunk/lib/raster/color_xform.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,319 @@
+
+/****************************************************************************
+ *
+ * MODULE: gis library
+ * AUTHOR(S): Glynn Clements <glynn at gclements.plus.com>
+ * COPYRIGHT: (C) 2007 Glynn Clements
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *****************************************************************************/
+
+/**********************************************************************
+ *
+ * Rast_histogram_eq_colors (dst, src, statf)
+ *
+ * struct Colors *dst struct to hold new colors
+ * struct Colors *src struct containing original colors
+ * struct Cell_stats *statf cell stats info
+ *
+ * Generates histogram equalized version of an existing color table from
+ * cell stats structure info.
+ *
+ **********************************************************************
+ *
+ * Rast_log_colors (dst, src, samples)
+ *
+ * struct Colors *dst struct to hold new colors
+ * struct Colors *src struct containing original colors
+ * int samples number of samples
+ *
+ * Generates logarithmically-scaled version of an existing color table.
+ *
+ **********************************************************************/
+
+#include <math.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief make histogram-stretched version of existing color table
+ *
+ * Generates a histogram
+ * contrast-stretched color table that goes from the histogram
+ * information in the Cell_stats structure <b>statf.</b> (See
+ * Raster_Histograms).
+ *
+ * \param dst
+ * \param src
+ * \param statf
+ * \return
+ */
+
+void Rast_histogram_eq_colors(struct Colors *dst,
+ struct Colors *src, struct Cell_stats *statf)
+{
+ DCELL min, max;
+ int red, grn, blu;
+ long count, total, sum;
+ CELL cat, prev;
+ int first;
+
+ Rast_init_colors(dst);
+
+ Rast_get_d_color_range(&min, &max, src);
+
+ Rast_get_default_color(&red, &grn, &blu, src);
+ Rast_set_default_color(red, grn, blu, dst);
+
+ Rast_get_null_value_color(&red, &grn, &blu, src);
+ Rast_set_null_value_color(red, grn, blu, dst);
+
+ total = 0;
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf))
+ if (count > 0)
+ total += count;
+
+ if (total <= 0)
+ return;
+
+ sum = 0;
+ prev = 0;
+ first = 1;
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
+ int red2, grn2, blu2;
+ DCELL x;
+
+ if (count <= 0)
+ continue;
+
+ x = min + (max - min) * (sum + count / 2.0) / total;
+ Rast_get_d_raster_color(&x, &red2, &grn2, &blu2, src);
+
+ if (!first)
+ Rast_add_color_rule(prev, red, grn, blu, cat, red2, grn2, blu2, dst);
+
+ sum += count;
+ first = 0;
+
+ prev = cat;
+ red = red2;
+ grn = grn2;
+ blu = blu2;
+ }
+}
+
+/*!
+ * \brief make histogram-stretched version of existing color table (FP version)
+ *
+ * Generates a histogram
+ * contrast-stretched color table that goes from the histogram
+ * information in the FP_stats structure <b>statf.</b> (See
+ * Raster_Histograms).
+ *
+ * \param dst
+ * \param src
+ * \param statf
+ * \return void
+ */
+
+void Rast_histogram_eq_colors_fp(struct Colors *dst,
+ struct Colors *src, struct FP_stats *statf)
+{
+ DCELL min, max;
+ int red, grn, blu;
+ unsigned long sum;
+ DCELL val;
+ int first;
+ int i;
+
+ Rast_init_colors(dst);
+
+ Rast_get_d_color_range(&min, &max, src);
+
+ Rast_get_default_color(&red, &grn, &blu, src);
+ Rast_set_default_color(red, grn, blu, dst);
+
+ Rast_get_null_value_color(&red, &grn, &blu, src);
+ Rast_set_null_value_color(red, grn, blu, dst);
+
+ if (!statf->total)
+ return;
+
+ sum = 0;
+ first = 1;
+
+ for (i = 0; i <= statf->count; i++) {
+ int red2, grn2, blu2;
+ DCELL val2, x;
+
+ val2 = statf->min + (statf->max - statf->min) * i / statf->count;
+ if (statf->geometric)
+ val2 = exp(val2);
+ if (statf->geom_abs)
+ val2 = exp(val2) - 1;
+ if (statf->flip)
+ val2 = -val2;
+ x = min + (max - min) * sum / statf->total;
+ Rast_get_d_raster_color(&x, &red2, &grn2, &blu2, src);
+
+ if (!first)
+ Rast_add_d_raster_color_rule(&val, red, grn, blu, &val2, red2, grn2, blu2, dst);
+ first = 0;
+
+ if (i == statf->count)
+ break;
+
+ sum += statf->stats[i];
+
+ val = val2;
+ red = red2;
+ grn = grn2;
+ blu = blu2;
+ }
+}
+
+/*!
+ * \brief make logarithmically-scaled version of an existing color table
+ *
+ * \param dst
+ * \param src
+ * \param samples
+ * \return
+ */
+
+void Rast_log_colors(struct Colors *dst, struct Colors *src, int samples)
+{
+ DCELL min, max;
+ double lmin, lmax;
+ int red, grn, blu;
+ DCELL prev;
+ int i;
+
+ Rast_init_colors(dst);
+
+ Rast_get_d_color_range(&min, &max, src);
+
+ lmin = log(min);
+ lmax = log(max);
+
+ Rast_get_default_color(&red, &grn, &blu, src);
+ Rast_set_default_color(red, grn, blu, dst);
+
+ Rast_get_null_value_color(&red, &grn, &blu, src);
+ Rast_set_null_value_color(red, grn, blu, dst);
+
+ for (i = 0; i <= samples; i++) {
+ int red2, grn2, blu2;
+ double lx;
+ DCELL x, y;
+
+ y = min + (max - min) * i / samples;
+ Rast_get_d_raster_color(&y, &red2, &grn2, &blu2, src);
+
+ if (i == 0)
+ x = min;
+ else if (i == samples)
+ x = max;
+ else {
+ lx = lmin + (lmax - lmin) * i / samples;
+ x = exp(lx);
+ }
+
+ if (i > 0)
+ Rast_add_d_raster_color_rule(&prev, red, grn, blu,
+ &x, red2, grn2, blu2,
+ dst);
+
+ prev = x;
+
+ red = red2;
+ grn = grn2;
+ blu = blu2;
+ }
+}
+
+/*!
+ * \brief make logarithmically-scaled version of an existing color table, allowing for signed values
+ *
+ * \param dst
+ * \param src
+ * \param samples
+ * \return
+ */
+
+void Rast_abs_log_colors(struct Colors *dst, struct Colors *src, int samples)
+{
+ DCELL min, max;
+ double lmin, lmax;
+ DCELL amax, lamax;
+ int red, grn, blu;
+ DCELL prev;
+ int i;
+
+ Rast_init_colors(dst);
+
+ Rast_get_d_color_range(&min, &max, src);
+
+ lmin = log(fabs(min) + 1.0);
+ lmax = log(fabs(max) + 1.0);
+
+ amax = fabs(min) > fabs(max) ? fabs(min) : fabs(max);
+ lamax = lmin > lmax ? lmin : lmax;
+
+ Rast_get_default_color(&red, &grn, &blu, src);
+ Rast_set_default_color(red, grn, blu, dst);
+
+ Rast_get_null_value_color(&red, &grn, &blu, src);
+ Rast_set_null_value_color(red, grn, blu, dst);
+
+ for (i = 0; i <= samples; i++) {
+ int red2, grn2, blu2;
+ double lx;
+ DCELL x, y;
+
+ y = min + (max - min) * i / samples;
+ Rast_get_d_raster_color(&y, &red2, &grn2, &blu2, src);
+
+ if (i == 0)
+ x = 1;
+ else if (i == samples)
+ x = amax;
+ else {
+ lx = 0 + lamax * i / samples;
+ x = exp(lx);
+ }
+
+ if (i > 0) {
+ DCELL x0 = prev, x1 = x;
+ Rast_add_d_raster_color_rule(&x0, red, grn, blu,
+ &x1, red2, grn2, blu2,
+ dst);
+ x0 = -x0;
+ x1 = -x1;
+ Rast_add_d_raster_color_rule(&x0, red, grn, blu,
+ &x1, red2, grn2, blu2,
+ dst);
+ }
+
+ prev = x;
+
+ red = red2;
+ grn = grn2;
+ blu = blu2;
+ }
+}
+
Copied: grass/trunk/lib/raster/format.c (from rev 37989, grass/trunk/lib/gis/format.c)
===================================================================
--- grass/trunk/lib/raster/format.c (rev 0)
+++ grass/trunk/lib/raster/format.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,189 @@
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <grass/config.h>
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+
+/*!
+
+ <h3>GRASS Raster Format</h3>
+
+ Small example to illustrate the raster format:
+
+ A file may contain the following 3x3 floating point matrix:
+ \verbatim
+ 10.000 20.000 30.000
+ 20.000 40.000 50.000
+ 30.000 50.000 60.000
+ \endverbatim
+
+ The header is a single byte, equal to sizeof(off_t) (typically 4 on a
+ 32-bit platform, 8 on a 64-bit platform). Then, NROWS+1 offsets are
+ written as off_t's (i.e. 4 or 8 bytes, depending upon platform) in
+ big-endian (Motorola) byte order.
+ <P>
+ Thus, above example is actually interpreted as:
+ \verbatim
+ 4 sizeof(off_t)
+ 0 0 0 17 offset of row 0
+ 0 0 0 36 offset of row 1
+ 0 0 0 55 offset of row 2
+ 0 0 0 74 offset of end of data
+ \endverbatim
+
+ See Rast__write_row_ptrs() below for the code which writes this data.
+ However, note that the row offsets are initially zero;
+ they get overwritten later (if you are writing compressed data,
+ you don't know how much space it will require until you've compressed
+ it).
+
+ As for the format of the actual row data, see put_fp_data() in
+ src/libes/gis/put_row.c and RFC 1014 (the XDR specification):
+ http://www.faqs.org/rfcs/rfc1014.html
+
+ */
+
+/**********************************************************************
+ *
+ * Rast__check_format(int fd)
+ *
+ * Check to see if map with file descriptor "fd" is in compressed
+ * format. If it is, the offset table at the beginning of the
+ * file (which gives seek addresses into the file where code for
+ * each row is found) is read into the File Control Buffer (FCB).
+ * The compressed flag in the FCB is appropriately set.
+ *
+ * returns: 1 if row pointers were read successfully, -1 otherwise
+ **********************************************************************/
+
+int Rast__check_format(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ unsigned char compress[4];
+
+ /*
+ * Check to see if the file is in compress mode
+ * 4 possibilites
+ * compressed flag in cellhd is negative (meaning pre 3.0 cell file)
+ * compression flag is first 3 bytes of cell file
+ * compression flag is 0 - not compressed
+ * compression flag is 1 - compressed using RLE (int) or zlib (FP)
+ * compression flag is 2 - compressed using zlib
+ */
+
+ if (fcb->cellhd.compressed < 0) {
+ if (read(fd, compress, 3) != 3
+ || compress[0] != 251 || compress[1] != 255 || compress[2] != 251)
+ fcb->cellhd.compressed = 0;
+ }
+
+ if (!fcb->cellhd.compressed)
+ return fd;
+
+ /* allocate space to hold the row address array */
+ fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
+
+ /* read the row address array */
+ return Rast__read_row_ptrs(fd);
+}
+
+int Rast__read_row_ptrs(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int nrows = fcb->cellhd.rows;
+ unsigned char nbytes;
+ unsigned char *buf, *b;
+ int n;
+ int row;
+
+ /*
+ * pre3.0 row addresses were written directly from the array of off_t's
+ * (this makes them machine dependent)
+ */
+
+ if (fcb->cellhd.compressed < 0) {
+ n = (nrows + 1) * sizeof(off_t);
+ if (read(fd, fcb->row_ptr, n) != n)
+ goto badread;
+ return 1;
+ }
+
+ /*
+ * 3.0 row address array is in a machine independent format
+ * (warning - the format will work even if the sizeof(off_t) is
+ * not the same from machine to machine, as long as the
+ * actual values do not exceed the capability of the off_t)
+ */
+
+ if (read(fd, &nbytes, 1) != 1)
+ goto badread;
+ if (nbytes == 0)
+ goto badread;
+
+ n = (nrows + 1) * nbytes;
+ buf = G_malloc(n);
+ if (read(fd, buf, n) != n)
+ goto badread;
+
+ for (row = 0, b = buf; row <= nrows; row++) {
+ off_t v = 0;
+
+ for (n = 0; n < (int)nbytes; n++) {
+ unsigned char c = *b++;
+
+ if (nbytes > sizeof(off_t) && n < nbytes - sizeof(off_t) &&
+ c != 0)
+ goto badread;
+
+ v <<= 8;
+ v += c;
+ }
+
+ fcb->row_ptr[row] = v;
+ }
+
+ G_free(buf);
+
+ return 1;
+
+ badread:
+ G_warning(_("Fail of initial read of compressed file [%s in %s]"),
+ fcb->name, fcb->mapset);
+ return -1;
+}
+
+int Rast__write_row_ptrs(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int nrows = fcb->cellhd.rows;
+ int nbytes = sizeof(off_t);
+ unsigned char *buf, *b;
+ int len, row, result;
+
+ lseek(fd, 0L, SEEK_SET);
+
+ len = (nrows + 1) * nbytes + 1;
+ b = buf = G_malloc(len);
+ *b++ = nbytes;
+
+ for (row = 0; row <= nrows; row++) {
+ off_t v = fcb->row_ptr[row];
+ int i;
+
+ for (i = nbytes - 1; i >= 0; i--) {
+ b[i] = v & 0xff;
+ v >>= 8;
+ }
+
+ b += nbytes;
+ }
+
+ result = (write(fd, buf, len) == len);
+ G_free(buf);
+
+ return result;
+}
Copied: grass/trunk/lib/raster/fpreclass.c (from rev 37989, grass/trunk/lib/gis/fpreclass.c)
===================================================================
--- grass/trunk/lib/raster/fpreclass.c (rev 0)
+++ grass/trunk/lib/raster/fpreclass.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,720 @@
+
+/**********************************************************************
+ *
+ * Rast_fpreclass_init (r)
+ *
+ * struct FPReclass *r;
+ *
+ * initializes new reclassification structure. calls
+ * Rast_fpreclass_clear() before it returns.
+ *
+ **********************************************************************
+ *
+ * void
+ * Rast_fpreclass_reset (r)
+ *
+ * struct FPReclass *r;
+ *
+ * resets the number of defined rules to 0 and free's space allocated
+ * for rules. calls Rast_fpreclass_clear ().
+ *
+ **********************************************************************
+ *
+ * void
+ * Rast_fpreclass_clear (r)
+ *
+ * struct FPReclass *r;
+ *
+ * resets the number of defined rules to 0. Resets default Min and Max
+ * to be unknown. (see Rast_fpreclass_set_domain (), Rast_fpreclass_set_range ()).
+ * deactivates default mapping.
+ *
+ **********************************************************************
+ *
+ * void
+ * Rast_fpreclass_set_domain (r, dLow, dHigh)
+ *
+ * struct FPReclass *r;
+ * DCELL dLow, dHigh;
+ *
+ * defines the domain for the default mapping and
+ * activates default mapping. (see G_fpreclass_perform_d ()).
+ *
+ * note: dHigh < dLow is valid.
+ *
+ **********************************************************************
+ *
+ * void
+ * Rast_fpreclass_set_range (r, low, high)
+ *
+ * struct FPReclass *r;
+ * DCELL low, high;
+ *
+ * defines the range for the default mapping. does NOT
+ * activate default mapping. (see G_fpreclass_perform_d ()).
+ *
+ **********************************************************************
+ *
+ * int
+ * Rast_fpreclass_get_limits (r, dMin, dMax, rMin, rmax)
+ *
+ * const struct FPReclass *r;
+ * DCELL *dMin, *dMax;
+ * DCELL *rMin, *rmax;
+ *
+ * returns the minimum and maximum values of all the rules defined.
+ *
+ * returns: -1 if after Rast_fpreclass_init (), or any call to
+ * Rast_fpreclass_clear () or Rast_fpreclass_reset () neither
+ * Rast_fpreclass_add_rule () nor Rast_fpreclass_set_domain () is
+ * used. in this case the returned minimum and maximum
+ * range and domain values are undefined.
+ * 0 if the default rule values are returned.domain values
+ * are identical to those set with Rast_fpreclass_set_domain ().
+ * range values are either reclassification internal default,
+ * or the values set with Rast_fpreclass_set_range ().
+ * 1 otherwise. in this case the values returned correspond
+ * to the extreme values of the defined rules (they need
+ * not be identical to the values set with
+ * Rast_fpreclass_set_domain ()).
+ *
+ **********************************************************************
+ *
+ * int
+ * Rast_fpreclass_nof_rules (r)
+ *
+ * const struct FPReclass *r;
+ *
+ * returns the number of reclassification rules defined. This number does
+ * not include the 2 infinite intervals.
+ *
+ **********************************************************************
+ *
+ * void
+ * Rast_fpreclass_get_ith_rule (r, i, dLow, dHigh, rLow, rHigh)
+ *
+ * const struct FPReclass *r;
+ * int i;
+ * DCELL *dLow, *dHigh;
+ * DCELL *rLow, *rHigh;
+ *
+ * returns the i'th reclassification rule, for
+ * 0 <= i < Rast_fpreclass_nof_rules().
+ * a larger value for i means that the rule has been added later.
+ *
+ **********************************************************************
+ * void
+ * Rast_fpreclass_set_neg_infinite_rule (r, dLeft, c)
+ *
+ * struct FPReclass *r;
+ * DCELL dLeft;
+ * DCELL c;
+ *
+ * defines a rule for values "dLeft" and smaller. values in this range
+ * are mapped to "c" if none of the "finite" reclassification rules applies.
+ *
+ * **********************************************************************
+ *
+ * int
+ * Rast_fpreclass_get_neg_infinite_rule (r, dLeft, c)
+ *
+ * const struct FPReclass *r;
+ * DCELL *dLeft;
+ * DCELL *c;
+ *
+ * returns in "dLeft" and "c" the rule values for the negative infinite
+ * interval (see Rast_fpreclass_set_neg_infinite_rule ()).
+ *
+ * returns: 0 if this rule is not defined
+ * 1 otherwise.
+ *
+ **********************************************************************
+ * void
+ * Rast_fpreclass_set_pos_infinite_rule (r, dRight, c)
+ *
+ * struct FPReclass *r;
+ * DCELL dRight;
+ * DCELL c;
+ *
+ * defines a rule for values "dRight" and larger. values in this range
+ * are mapped to "c" if neither any of the "finite" reclassification
+ * rules nor the negative infinite rule applies.
+ *
+ * **********************************************************************
+ *
+ * int
+ * Rast_fpreclass_get_pos_infinite_rule (r, dRight, c)
+ *
+ * const struct FPReclass *r;
+ * DCELL *dRight;
+ * DCELL *c;
+ *
+ * returns in "dRight" and "c" the rule values for the positive infinite
+ * interval (see Rast_fpreclass_set_pos_infinite_rule ()).
+ *
+ * returns: 0 if this rule is not defined
+ * 1 otherwise.
+ *
+ **********************************************************************
+ *
+ * void
+ * Rast_fpreclass_reverse_rule_order (r)
+ *
+ * struct FPReclass *r;
+ *
+ * reverses the order in which the reclassification rules are stored. (see
+ * also Rast_fpreclass_get_ith_rule () and G_fpreclass_perform_XY ()).
+ *
+ **********************************************************************
+ *
+ * void
+ * Rast_fpreclass_add_rule (r, dLow, dHigh, rLow, rHigh)
+ *
+ * struct FPReclass *r;
+ * DCELL dLow, dHigh;
+ * DCELL rLow, rHigh;
+ *
+ * adds a new rule to the set of reclassification rules. if dLow > dHigh
+ * the rule will be stored with the low and high values interchanged.
+ *
+ * Note: currently no cleanup of rules is performed, i.e. redundant
+ * rules are not removed.
+ *
+ **********************************************************************
+ *
+ * DCELL
+ * Rast_fpreclass_get_cell_value (r, cellValue)
+ *
+ * const struct FPReclass *r;
+ * DCELL *cellValue;
+ *
+ * returns the reclassified value corresponding to "cellValue".
+ *
+ * if several reclassification rules apply for cellValue, the one which has
+ * been inserted latest (i.e. the one of them which is returned by
+ * Rast_fpreclass_get_ith_rule() for the largest i) is used. if no such rule
+ * applies the cellValue is first tested against the negative infinite
+ * rule, and finally against the positive infinite rule. if none of
+ * these rules apply, NO_DATA is returned. the actual value of NO_DATA
+ * is found by calling Rast_set_d_null_value()
+ *
+ * if after Rast_fpreclass_init (), or any call to Rast_fpreclass_clear () or
+ * Rast_fpreclass_reset () neither Rast_fpreclass_add_rule (),
+ * Rast_fpreclass_set_neg_infinite_rule (),
+ * Rast_fpreclass_set_pos_infinite_rule (), * nor Rast_fpreclass_set_domain ()
+ * is used NO_DATA is returned independently of the cellValue.
+ *
+ * if Rast_fpreclass_set_domain () is called but no explicit reclassification
+ * rule is set, the default mapping to the cell range set with
+ * Rast_fpreclass_set_range () or, if the cell range is not set,
+ * to the default CELL range [0,256 - 1] is applied.
+ *
+ **********************************************************************
+ *
+ * void
+ * G_fpreclass_perform_XY (r, xcell, ycell, n)
+ *
+ * const struct FPReclass *r;
+ * XCELL *xcell;
+ * YCELL *ycell;
+ * int n;
+ *
+ * "X" and "Y" in the function name can be any of "d", "f", or "i". These
+ * correspond to "DCELL", "FCELL", and "CELL", respectively, and denote
+ * the type of the domain and range values.
+ *
+ * returns in "ycell" the reclassified YCELL values corresponding to the
+ * XCELL values stored in "xcell". the number of elements reclassified
+ * is n. reclassification is performed by repeated application of
+ * Rast_fpreclass_get_cell_value ().
+ *
+ **********************************************************************/
+
+/*--------------------------------------------------------------------------*/
+
+/*
+ the reclassification table is stored as a linear array. rules are added
+ starting from index 0. redundant rules are not eliminated. rules are tested
+ from the highest index downto 0. there are two "infinite" rules. support is
+ provided to reverse the order of the rules.
+ */
+
+/*--------------------------------------------------------------------------*/
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*--------------------------------------------------------------------------*/
+
+#undef MIN
+#undef MAX
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+#define NO_DEFAULT_RULE (! r->defaultDRuleSet)
+#define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
+#define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)
+#define NO_FINITE_RULE (r->nofRules <= 0)
+#define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
+ NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
+
+#define DEFAULT_MIN ((DCELL) 1)
+#define DEFAULT_MAX ((DCELL) 255)
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_clear(struct FPReclass *r)
+{
+ r->nofRules = 0;
+ r->defaultDRuleSet = 0;
+ r->defaultRRuleSet = 0;
+ r->infiniteRightSet = r->infiniteLeftSet = 0;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_reset(struct FPReclass *r)
+{
+ Rast_fpreclass_clear(r);
+
+ if (r->maxNofRules > 0)
+ G_free(r->table);
+
+ r->maxNofRules = 0;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_init(struct FPReclass *r)
+{
+ r->maxNofRules = 0;
+ Rast_fpreclass_reset(r);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_set_domain(struct FPReclass *r, DCELL dLow, DCELL dHigh)
+{
+ r->defaultDMin = dLow;
+ r->defaultDMax = dHigh;
+ r->defaultDRuleSet = 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_set_range(struct FPReclass *r, DCELL low, DCELL high)
+{
+ r->defaultRMin = low;
+ r->defaultRMax = high;
+ r->defaultRRuleSet = 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static void fpreclass_set_limits(struct FPReclass *r,
+ DCELL dLow, DCELL dHigh,
+ DCELL rLow, DCELL rHigh)
+{
+ r->dMin = dLow;
+ r->dMax = dHigh;
+ r->rMin = rLow;
+ r->rMax = rHigh;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static void fpreclass_update_limits(struct FPReclass *r,
+ DCELL dLow, DCELL dHigh,
+ DCELL rLow, DCELL rHigh)
+{
+ if (NO_EXPLICIT_RULE) {
+ fpreclass_set_limits(r, dLow, dHigh, rLow, rHigh);
+ return;
+ }
+
+ r->dMin = MIN(r->dMin, MIN(dLow, dHigh));
+ r->dMax = MAX(r->dMax, MAX(dLow, dHigh));
+ r->rMin = MIN(r->rMin, MIN(rLow, rHigh));
+ r->rMax = MAX(r->rMax, MAX(rLow, rHigh));
+}
+
+/*--------------------------------------------------------------------------*/
+
+int Rast_fpreclass_get_limits(const struct FPReclass *r,
+ DCELL * dMin, DCELL * dMax,
+ DCELL * rMin, DCELL * rMax)
+{
+ if (NO_EXPLICIT_RULE) {
+ if (NO_DEFAULT_RULE)
+ return -1;
+
+ *dMin = r->defaultDMin;
+ *dMax = r->defaultDMax;
+
+ if (r->defaultRRuleSet) {
+ *rMin = r->defaultRMin;
+ *rMax = r->defaultRMax;
+ }
+ else {
+ *rMin = DEFAULT_MIN;
+ *rMax = DEFAULT_MAX;
+ }
+
+ return 0;
+ }
+
+ *dMin = r->dMin;
+ *dMax = r->dMax;
+ *rMin = r->rMin;
+ *rMax = r->rMax;
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+int Rast_fpreclass_nof_rules(const struct FPReclass *r)
+{
+ return r->nofRules;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_get_ith_rule(const struct FPReclass *r, int i,
+ DCELL *dLow, DCELL *dHigh,
+ DCELL *rLow, DCELL *rHigh)
+{
+ *dLow = r->table[i].dLow;
+ *dHigh = r->table[i].dHigh;
+ *rLow = r->table[i].rLow;
+ *rHigh = r->table[i].rHigh;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static void fpreclass_table_increase(struct FPReclass *r)
+{
+ if (r->nofRules < r->maxNofRules)
+ return;
+
+ if (r->maxNofRules == 0) {
+ r->maxNofRules = 50;
+ r->table = (struct FPReclass_table *)
+ G_malloc(r->maxNofRules * sizeof(struct FPReclass_table));
+ }
+ else {
+ r->maxNofRules += 50;
+ r->table = (struct FPReclass_table *)
+ G_realloc((char *)r->table,
+ r->maxNofRules * sizeof(struct FPReclass_table));
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+void
+Rast_fpreclass_set_neg_infinite_rule(struct FPReclass *r, DCELL dLeft, DCELL c)
+{
+ r->infiniteDLeft = dLeft;
+ r->infiniteRLeft = c;
+ fpreclass_update_limits(r, dLeft, dLeft, c, c);
+ r->infiniteLeftSet = 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+int Rast_fpreclass_get_neg_infinite_rule(const struct FPReclass *r,
+ DCELL *dLeft, DCELL *c)
+{
+ if (r->infiniteLeftSet == 0)
+ return 0;
+
+ *dLeft = r->infiniteDLeft;
+ *c = r->infiniteRLeft;
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_set_pos_infinite_rule(struct FPReclass *r, DCELL dRight, DCELL c)
+{
+ r->infiniteDRight = dRight;
+ r->infiniteRRight = c;
+ fpreclass_update_limits(r, dRight, dRight, c, c);
+ r->infiniteRightSet = 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+int Rast_fpreclass_get_pos_infinite_rule(const struct FPReclass *r,
+ DCELL *dRight, DCELL *c)
+{
+ if (r->infiniteRightSet == 0)
+ return 0;
+
+ *dRight = r->infiniteDRight;
+ *c = r->infiniteRRight;
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_add_rule(struct FPReclass *r,
+ DCELL dLow, DCELL dHigh,
+ DCELL rLow, DCELL rHigh)
+{
+ int i;
+ struct FPReclass_table *p;
+
+ fpreclass_table_increase(r);
+
+ i = r->nofRules;
+
+ p = &(r->table[i]);
+ if (dHigh >= dLow) {
+ p->dLow = dLow;
+ p->dHigh = dHigh;
+ p->rLow = rLow;
+ p->rHigh = rHigh;
+ }
+ else {
+ p->dLow = dHigh;
+ p->dHigh = dLow;
+ p->rLow = rHigh;
+ p->rHigh = rLow;
+ }
+
+ fpreclass_update_limits(r, dLow, dHigh, rLow, rHigh);
+
+ r->nofRules++;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_reverse_rule_order(struct FPReclass *r)
+{
+ struct FPReclass_table tmp;
+ struct FPReclass_table *pLeft, *pRight;
+
+ pLeft = r->table;
+ pRight = &(r->table[r->nofRules - 1]);
+
+ while (pLeft < pRight) {
+ tmp.dLow = pLeft->dLow;
+ tmp.dHigh = pLeft->dHigh;
+ tmp.rLow = pLeft->rLow;
+ tmp.rHigh = pLeft->rHigh;
+
+ pLeft->dLow = pRight->dLow;
+ pLeft->dHigh = pRight->dHigh;
+ pLeft->rLow = pRight->rLow;
+ pLeft->rHigh = pRight->rHigh;
+
+ pRight->dLow = tmp.dLow;
+ pRight->dHigh = tmp.dHigh;
+ pRight->rLow = tmp.rLow;
+ pRight->rHigh = tmp.rHigh;
+
+ pLeft++;
+ pRight--;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+static DCELL fpreclass_interpolate(
+ DCELL dLow, DCELL dHigh,
+ DCELL rLow, DCELL rHigh,
+ DCELL dValue)
+{
+ if (rLow == rHigh)
+ return rLow;
+ if (dLow == dHigh)
+ return rLow;
+
+ return ((dValue - dLow) / (dHigh - dLow) * (rHigh - rLow) + rLow);
+}
+
+/*--------------------------------------------------------------------------*/
+
+static DCELL fpreclass_get_default_cell_value(const struct FPReclass *r, DCELL cellVal)
+{
+ DCELL tmp;
+
+ Rast_set_d_null_value(&tmp, 1);
+
+ if ((cellVal < MIN(r->defaultDMin, r->defaultDMax)) ||
+ (cellVal > MAX(r->defaultDMin, r->defaultDMax)))
+ return tmp;
+
+ if (r->defaultRRuleSet)
+ return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
+ r->defaultRMin, r->defaultRMax, cellVal);
+ else
+ return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
+ DEFAULT_MIN, DEFAULT_MAX, cellVal);
+}
+
+/*--------------------------------------------------------------------------*/
+
+DCELL Rast_fpreclass_get_cell_value(const struct FPReclass * r, DCELL cellVal)
+{
+ DCELL tmp;
+ const struct FPReclass_table *p;
+
+ Rast_set_d_null_value(&tmp, 1);
+ if (NO_EXPLICIT_RULE) {
+
+ if (NO_DEFAULT_RULE)
+ return tmp;
+ return fpreclass_get_default_cell_value(r, cellVal);
+ }
+
+ if (!NO_FINITE_RULE)
+ for (p = &(r->table[r->nofRules - 1]); p >= r->table; p--)
+ if ((cellVal >= p->dLow) && (cellVal <= p->dHigh))
+ return fpreclass_interpolate(p->dLow, p->dHigh, p->rLow,
+ p->rHigh, cellVal);
+
+ if ((!NO_LEFT_INFINITE_RULE) && (cellVal <= r->infiniteDLeft))
+ return r->infiniteRLeft;
+
+ if ((NO_RIGHT_INFINITE_RULE) || (cellVal < r->infiniteDRight))
+ return tmp;
+
+ return r->infiniteRRight;
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_di(const struct FPReclass *r,
+ const DCELL *dcell, CELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, dcell++)
+ if (!Rast_is_d_null_value(dcell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
+ else
+ Rast_set_c_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_df(const struct FPReclass *r,
+ const DCELL *dcell, FCELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, dcell++)
+ if (!Rast_is_d_null_value(dcell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
+ else
+ Rast_set_f_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_dd(const struct FPReclass *r,
+ const DCELL *dcell, DCELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, dcell++)
+ if (!Rast_is_d_null_value(dcell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, *dcell);
+ else
+ Rast_set_d_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_fi(const struct FPReclass *r,
+ const FCELL *fcell, CELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, fcell++)
+ if (!Rast_is_f_null_value(fcell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * fcell);
+ else
+ Rast_set_c_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_ff(const struct FPReclass *r,
+ const FCELL *fcell, FCELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, fcell++)
+ if (!Rast_is_f_null_value(fcell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * fcell);
+ else
+ Rast_set_f_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_fd(const struct FPReclass *r,
+ const FCELL *fcell, DCELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, fcell++)
+ if (!Rast_is_f_null_value(fcell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * fcell);
+ else
+ Rast_set_d_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_ii(const struct FPReclass *r,
+ const CELL *icell, CELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, icell++)
+ if (!Rast_is_c_null_value(icell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * icell);
+ else
+ Rast_set_c_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_if(const struct FPReclass *r,
+ const CELL *icell, FCELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, icell++)
+ if (!Rast_is_c_null_value(icell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * icell);
+ else
+ Rast_set_f_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+void Rast_fpreclass_perform_id(const struct FPReclass *r,
+ const CELL *icell, DCELL *cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, icell++)
+ if (!Rast_is_c_null_value(icell))
+ *cell++ = Rast_fpreclass_get_cell_value(r, (DCELL) * icell);
+ else
+ Rast_set_d_null_value(cell++, 1);
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
Copied: grass/trunk/lib/raster/gdal.c (from rev 37989, grass/trunk/lib/gis/gdal.c)
===================================================================
--- grass/trunk/lib/raster/gdal.c (rev 0)
+++ grass/trunk/lib/raster/gdal.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,533 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <grass/config.h>
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+
+#ifndef HAVE_GDAL
+#undef GDAL_LINK
+#endif
+
+#ifdef GDAL_LINK
+
+#ifdef GDAL_DYNAMIC
+# if defined(__unix) || defined(__unix__)
+# include <dlfcn.h>
+# endif
+# ifdef _WIN32
+# include <windows.h>
+# endif
+#endif
+
+static void CPL_STDCALL (*pGDALAllRegister)(void);
+static void CPL_STDCALL (*pGDALClose)(GDALDatasetH);
+static GDALRasterBandH CPL_STDCALL (*pGDALGetRasterBand)(GDALDatasetH, int);
+static GDALDatasetH CPL_STDCALL (*pGDALOpen)(
+ const char *pszFilename, GDALAccess eAccess);
+static CPLErr CPL_STDCALL (*pGDALRasterIO)(
+ GDALRasterBandH hRBand, GDALRWFlag eRWFlag,
+ int nDSXOff, int nDSYOff, int nDSXSize, int nDSYSize,
+ void * pBuffer, int nBXSize, int nBYSize,GDALDataType eBDataType,
+ int nPixelSpace, int nLineSpace);
+static GDALDriverH CPL_STDCALL (*pGDALGetDriverByName)(const char *);
+static const char * CPL_STDCALL (*pGDALGetMetadataItem)(GDALMajorObjectH, const char *, const char *);
+static GDALDatasetH CPL_STDCALL (*pGDALCreate)(GDALDriverH hDriver, const char *, int, int, int, GDALDataType, char **);
+static GDALDatasetH CPL_STDCALL (*pGDALCreateCopy)(GDALDriverH, const char *, GDALDatasetH, int, char **, GDALProgressFunc, void *);
+static CPLErr CPL_STDCALL (*pGDALSetRasterNoDataValue)(GDALRasterBandH, double);
+static CPLErr CPL_STDCALL (*pGDALSetGeoTransform)(GDALDatasetH, double *);
+static CPLErr CPL_STDCALL (*pGDALSetProjection)(GDALDatasetH, const char *);
+static const char * CPL_STDCALL (*pGDALGetDriverShortName)(GDALDriverH);
+static GDALDriverH CPL_STDCALL (*pGDALGetDatasetDriver)(GDALDatasetH);
+
+#if GDAL_DYNAMIC
+# if defined(__unix) && !defined(__unix__)
+# define __unix__ __unix
+# endif
+
+static void *library_h;
+
+static void *get_symbol(const char *name)
+{
+ void *sym;
+
+# ifdef __unix__
+ sym = dlsym(library_h, name);
+# endif
+# ifdef _WIN32
+ sym = GetProcAddress((HINSTANCE) library_h, name);
+# endif
+
+ if (!sym)
+ G_fatal_error(_("Unable to locate symbol <%s>"), name);
+
+ return sym;
+}
+
+static void try_load_library(const char *name)
+{
+# ifdef __unix__
+ library_h = dlopen(name, RTLD_NOW);
+# endif
+# ifdef _WIN32
+ library_h = LoadLibrary(name);
+# endif
+}
+
+static void load_library(void)
+{
+ static const char * const candidates[] = {
+# ifdef __unix__
+ "libgdal.1.1.so",
+ "gdal.1.0.so",
+ "gdal.so.1.0",
+ "libgdal.so.1",
+ "libgdal.so",
+# endif
+# ifdef _WIN32
+ "gdal11.dll",
+ "gdal.1.0.dll",
+ "gdal.dll",
+# endif
+ NULL
+ };
+ int i;
+
+ for (i = 0; candidates[i]; i++) {
+ try_load_library(candidates[i]);
+ if (library_h)
+ return;
+ }
+
+ G_fatal_error(_("Unable to load GDAL library"));
+}
+
+static void init_gdal(void)
+{
+ load_library();
+
+ pGDALAllRegister = get_symbol("GDALAllRegister");
+ pGDALOpen = get_symbol("GDALOpen");
+ pGDALClose = get_symbol("GDALClose");
+ pGDALGetRasterBand = get_symbol("GDALGetRasterBand");
+ pGDALRasterIO = get_symbol("GDALRasterIO");
+ pGDALGetDriverByName = get_symbol("GDALGetDriverByName");
+ pGDALGetMetadataItem = get_symbol("GDALGetMetadataItem");
+ pGDALCreate = get_symbol("GDALCreate");
+ pGDALCreateCopy = get_symbol("GDALCreateCopy");
+ pGDALSetRasterNoDataValue = get_symbol("GDALSetRasterNoDataValue");
+ pGDALSetGeoTransform = get_symbol("GDALSetGeoTransform");
+ pGDALSetProjection = get_symbol("GDALSetProjection");
+ pGDALGetDriverShortName = get_symbol("GDALGetDriverShortName");
+ pGDALGetDatasetDriver = get_symbol("GDALGetDatasetDriver");
+}
+
+#else /* GDAL_DYNAMIC */
+
+static void init_gdal(void)
+{
+ pGDALAllRegister = &GDALAllRegister;
+ pGDALOpen = &GDALOpen;
+ pGDALClose = &GDALClose;
+ pGDALGetRasterBand = &GDALGetRasterBand;
+ pGDALRasterIO = &GDALRasterIO;
+ pGDALGetDriverByName = &GDALGetDriverByName;
+ pGDALGetMetadataItem = &GDALGetMetadataItem;
+ pGDALCreate = &GDALCreate;
+ pGDALCreateCopy = &GDALCreateCopy;
+ pGDALSetRasterNoDataValue = &GDALSetRasterNoDataValue;
+ pGDALSetGeoTransform = &GDALSetGeoTransform;
+ pGDALSetProjection = &GDALSetProjection;
+ pGDALGetDriverShortName = &GDALGetDriverShortName;
+ pGDALGetDatasetDriver = &GDALGetDatasetDriver;
+}
+
+#endif /* GDAL_DYNAMIC */
+
+#endif /* GDAL_LINK */
+
+void Rast_init_gdal(void)
+{
+#ifdef GDAL_LINK
+ static int initialized;
+
+ if (G_is_initialized(&initialized))
+ return;
+
+ init_gdal();
+ (*pGDALAllRegister)();
+ G_initialize_done(&initialized);
+#endif
+}
+
+struct GDAL_link *Rast_get_gdal_link(const char *name, const char *mapset)
+{
+#ifdef GDAL_LINK
+ GDALDatasetH data;
+ GDALRasterBandH band;
+ GDALDataType type;
+ RASTER_MAP_TYPE req_type;
+#endif
+ const char *filename;
+ int band_num;
+ struct GDAL_link *gdal;
+ RASTER_MAP_TYPE map_type;
+ FILE *fp;
+ struct Key_Value *key_val;
+ const char *p;
+ DCELL null_val;
+ int hflip, vflip;
+
+ if (!G_find_cell2(name, mapset))
+ return NULL;
+
+ map_type = Rast_raster_map_type(name, mapset);
+ if (map_type < 0)
+ return NULL;
+
+ fp = G_fopen_old_misc("cell_misc", "gdal", name, mapset);
+ if (!fp)
+ return NULL;
+ key_val = G_fread_key_value(fp);
+ fclose(fp);
+
+ if (!key_val)
+ return NULL;
+
+ filename = G_find_key_value("file", key_val);
+ if (!filename)
+ return NULL;
+
+ p = G_find_key_value("band", key_val);
+ if (!p)
+ return NULL;
+ band_num = atoi(p);
+ if (!band_num)
+ return NULL;
+
+ p = G_find_key_value("null", key_val);
+ if (!p)
+ return NULL;
+ if (strcmp(p, "none") == 0)
+ Rast_set_d_null_value(&null_val, 1);
+ else
+ null_val = atof(p);
+
+ hflip = G_find_key_value("hflip", key_val) ? 1 : 0;
+ vflip = G_find_key_value("vflip", key_val) ? 1 : 0;
+
+#ifdef GDAL_LINK
+ p = G_find_key_value("type", key_val);
+ if (!p)
+ return NULL;
+ type = atoi(p);
+
+ switch (type) {
+ case GDT_Byte:
+ case GDT_Int16:
+ case GDT_UInt16:
+ case GDT_Int32:
+ case GDT_UInt32:
+ req_type = CELL_TYPE;
+ break;
+ case GDT_Float32:
+ req_type = FCELL_TYPE;
+ break;
+ case GDT_Float64:
+ req_type = DCELL_TYPE;
+ break;
+ default:
+ return NULL;
+ }
+
+ if (req_type != map_type)
+ return NULL;
+
+ Rast_init_gdal();
+
+ data = (*pGDALOpen)(filename, GA_ReadOnly);
+ if (!data)
+ return NULL;
+
+ band = (*pGDALGetRasterBand)(data, band_num);
+ if (!band) {
+ (*pGDALClose)(data);
+ return NULL;
+ }
+#endif
+
+ gdal = G_calloc(1, sizeof(struct GDAL_link));
+
+ gdal->filename = G_store(filename);
+ gdal->band_num = band_num;
+ gdal->null_val = null_val;
+ gdal->hflip = hflip;
+ gdal->vflip = vflip;
+#ifdef GDAL_LINK
+ gdal->data = data;
+ gdal->band = band;
+ gdal->type = type;
+#endif
+
+ return gdal;
+}
+
+struct GDAL_Options {
+ const char *dir;
+ const char *ext;
+ const char *format;
+ char **options;
+};
+
+static struct state {
+ int initialized;
+ struct GDAL_Options opts;
+ struct Key_Value *projinfo, *projunits;
+ char *srswkt;
+} state;
+
+static struct state *st = &state;
+
+static void read_gdal_options(void)
+{
+ FILE *fp;
+ struct Key_Value *key_val;
+ const char *p;
+
+ fp = G_fopen_old("", "GDAL", G_mapset());
+ if (!fp)
+ G_fatal_error(_("Unable to open GDAL file"));
+ key_val = G_fread_key_value(fp);
+ fclose(fp);
+
+ p = G_find_key_value("directory", key_val);
+ if (!p)
+ p = "gdal";
+ if (*p == '/') {
+ st->opts.dir = G_store(p);
+ }
+ else {
+ char path[GPATH_MAX];
+ G__file_name(path, p, "", G_mapset());
+ st->opts.dir = G_store(path);
+ if (access(path, 0) != 0)
+ G__make_mapset_element(p);
+ }
+
+ p = G_find_key_value("extension", key_val);
+ st->opts.ext = G_store(p ? p : "");
+
+ p = G_find_key_value("format", key_val);
+ st->opts.format = G_store(p ? p : "GTiff");
+
+ p = G_find_key_value("options", key_val);
+ st->opts.options = p ? G_tokenize(p, ",") : NULL;
+
+ G_free_key_value(key_val);
+}
+
+struct GDAL_link *Rast_create_gdal_link(const char *name, RASTER_MAP_TYPE map_type)
+{
+#ifdef GDAL_LINK
+ char path[GPATH_MAX];
+ GDALDriverH driver;
+ double transform[6];
+ struct GDAL_link *gdal;
+ FILE *fp;
+ struct Key_Value *key_val;
+ char buf[32];
+
+
+ Rast_init_gdal();
+
+ if (!G_is_initialized(&st->initialized)) {
+ read_gdal_options();
+ st->projinfo = G_get_projinfo();
+ st->projunits = G_get_projunits();
+#if 0
+ /* We cannot use GPJ_grass_to_wkt() here because that would create a
+ circular dependency between libgis and libgproj */
+ if (st->projinfo && st->projunits)
+ st->srswkt = GPJ_grass_to_wkt(st->projinfo, st->projunits);
+#endif
+ G_initialize_done(&st->initialized);
+ }
+
+ gdal = G_calloc(1, sizeof(struct GDAL_link));
+
+ sprintf(path, "%s/%s%s", st->opts.dir, name, st->opts.ext);
+ gdal->filename = G_store(path);
+ gdal->band_num = 1;
+ gdal->hflip = 0;
+ gdal->vflip = 0;
+
+ switch (map_type) {
+ case CELL_TYPE:
+ switch (G__.nbytes) {
+ case 1:
+ gdal->type = GDT_Byte;
+ gdal->null_val = (DCELL) 0xFF;
+ break;
+ case 2:
+ gdal->type = GDT_UInt16;
+ gdal->null_val = (DCELL) 0xFFFF;
+ break;
+ case 3:
+ case 4:
+ gdal->type = GDT_Int32;
+ gdal->null_val = (DCELL) 0x80000000U;
+ break;
+ }
+ break;
+ case FCELL_TYPE:
+ gdal->type = GDT_Float32;
+ Rast_set_d_null_value(&gdal->null_val, 1);
+ break;
+ case DCELL_TYPE:
+ gdal->type = GDT_Float64;
+ Rast_set_d_null_value(&gdal->null_val, 1);
+ break;
+ default:
+ G_fatal_error(_("Invalid map type <%d>"), map_type);
+ break;
+ }
+
+ driver = (*pGDALGetDriverByName)(st->opts.format);
+ if (!driver)
+ G_fatal_error(_("Unable to get <%s> driver"), st->opts.format);
+
+ /* Does driver support GDALCreate ? */
+ if ((*pGDALGetMetadataItem)(driver, GDAL_DCAP_CREATE, NULL))
+ {
+ gdal->data = (*pGDALCreate)(driver, gdal->filename, G__.window.cols, G__.window.rows,
+ 1, gdal->type, st->opts.options);
+ if (!gdal->data)
+ G_fatal_error(_("Unable to create <%s> dataset using <%s> driver"),
+ name, st->opts.format);
+ }
+ /* If not - create MEM driver for intermediate dataset.
+ * Check if raster can be created at all (with GDALCreateCopy) */
+ else if ((*pGDALGetMetadataItem)(driver, GDAL_DCAP_CREATECOPY, NULL)) {
+ GDALDriverH mem_driver;
+
+ G_message(_("Driver <%s> does not support direct writing. "
+ "Using MEM driver for intermediate dataset."),
+ st->opts.format);
+
+ mem_driver = (*pGDALGetDriverByName)("MEM");
+ if (!mem_driver)
+ G_fatal_error(_("Unable to get in-memory raster driver"));
+
+ gdal->data = (*pGDALCreate)(mem_driver, "", G__.window.cols, G__.window.rows,
+ 1, gdal->type, st->opts.options);
+ if (!gdal->data)
+ G_fatal_error(_("Unable to create <%s> dataset using memory driver"),
+ name);
+ }
+ else
+ G_fatal_error(_("Driver <%s> does not support creating rasters"),
+ st->opts.format);
+
+ gdal->band = (*pGDALGetRasterBand)(gdal->data, gdal->band_num);
+
+ (*pGDALSetRasterNoDataValue)(gdal->band, gdal->null_val);
+
+ /* Set Geo Transform */
+ transform[0] = G__.window.west;
+ transform[1] = G__.window.ew_res;
+ transform[2] = 0.0;
+ transform[3] = G__.window.north;
+ transform[4] = 0.0;
+ transform[5] = -G__.window.ns_res;
+
+ if ((*pGDALSetGeoTransform)(gdal->data, transform) >= CE_Failure)
+ G_warning(_("Unable to set geo transform"));
+
+ if (st->srswkt)
+ if ((*pGDALSetProjection)(gdal->data, st->srswkt) == CE_Failure)
+ G_warning(_("Unable to set projection"));
+
+ fp = G_fopen_new_misc("cell_misc", "gdal", name);
+ if (!fp)
+ G_fatal_error(_("Unable to create cell_misc/%s/gdal file"), name);
+
+ key_val = G_create_key_value();
+
+ G_set_key_value("file", gdal->filename, key_val);
+
+ sprintf(buf, "%d", gdal->band_num);
+ G_set_key_value("band", buf, key_val);
+
+ sprintf(buf, "%.22g", gdal->null_val);
+ G_set_key_value("null", buf, key_val);
+
+ sprintf(buf, "%d", gdal->type);
+ G_set_key_value("type", buf, key_val);
+
+ if (G_fwrite_key_value(fp, key_val) < 0)
+ G_fatal_error(_("Error writing cell_misc/%s/gdal file"), name);
+
+ G_free_key_value(key_val);
+
+ fclose(fp);
+
+ return gdal;
+#else
+ return NULL;
+#endif
+}
+
+void Rast_close_gdal_link(struct GDAL_link *gdal)
+{
+#ifdef GDAL_LINK
+ (*pGDALClose)(gdal->data);
+#endif
+ G_free(gdal->filename);
+ G_free(gdal);
+}
+
+int Rast_close_gdal_write_link(struct GDAL_link *gdal)
+{
+ int stat = 1;
+#ifdef GDAL_LINK
+ GDALDriverH src_drv = (*pGDALGetDatasetDriver)(gdal->data);
+
+ if (G_strcasecmp((*pGDALGetDriverShortName)(src_drv), "MEM") == 0) {
+ GDALDriverH dst_drv = (*pGDALGetDriverByName)(st->opts.format);
+ GDALDatasetH dst = (*pGDALCreateCopy)(dst_drv, gdal->filename, gdal->data, FALSE,
+ st->opts.options, NULL, NULL);
+ if (!dst) {
+ G_warning(_("Unable to create output file <%s> using driver <%s>"),
+ gdal->filename, st->opts.format);
+ stat = -1;
+ }
+ (*pGDALClose)(dst);
+ }
+
+ (*pGDALClose)(gdal->data);
+
+#endif
+ G_free(gdal->filename);
+ G_free(gdal);
+
+ return stat;
+}
+
+#ifdef GDAL_LINK
+CPLErr G_gdal_raster_IO(
+ GDALRasterBandH band, GDALRWFlag rw_flag,
+ int x_off, int y_off, int x_size, int y_size,
+ void *buffer, int buf_x_size, int buf_y_size, GDALDataType buf_type,
+ int pixel_size, int line_size)
+{
+ return (*pGDALRasterIO)(
+ band, rw_flag, x_off, y_off, x_size, y_size,
+ buffer, buf_x_size, buf_y_size, buf_type,
+ pixel_size, line_size);
+}
+#endif
Copied: grass/trunk/lib/raster/get_cellhd.c (from rev 37989, grass/trunk/lib/gis/get_cellhd.c)
===================================================================
--- grass/trunk/lib/raster/get_cellhd.c (rev 0)
+++ grass/trunk/lib/raster/get_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,97 @@
+/*!
+ \file gis/get_cellhd.c
+
+ \brief GIS library - Read raster map header
+
+ (C) 2001-2009 by the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Original author CERL
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+/*!
+ \brief Read the raster header
+
+ The raster header for the raster map <i>name</i> in the specified
+ <i>mapset</i> is read into the <i>cellhd</i> structure. If there is
+ an error reading the raster header file, a diagnostic message is
+ printed and -1 is returned. Otherwise, 0 is returned.
+
+ <b>Note</b>:a warning message for errors encountered.
+
+ Cell header files may contain either grid cell header information or
+ reclass information. If it is a reclass file, it will specify the
+ map and mapset names of the actual grid cell file being
+ reclassed. Rast_get_cellhd(), upon reading reclass information will go
+ read the cell header information for the referenced file. Only one
+ reference is allowed.
+
+ \param name name of map
+ \param mapset mapset that map belongs to
+ \param[out] cellhd structure to hold cell header info
+
+ \return 0 on success
+ \return -1 on error
+ */
+int Rast_get_cellhd(const char *name, const char *mapset,
+ struct Cell_head *cellhd)
+{
+ FILE *fd;
+ int is_reclass;
+ char real_name[GNAME_MAX], real_mapset[GMAPSET_MAX];
+ char buf[1024];
+ char *tail;
+
+ /*
+ is_reclass = Rast_is_reclass (name, mapset, real_name, real_mapset);
+ if (is_reclass < 0)
+ {
+ sprintf (buf,"Can't read header file for [%s in %s]\n", name, mapset);
+ tail = buf + strlen(buf);
+ strcpy (tail, "It is a reclass file, but with an invalid format");
+ G_warning(buf);
+ return -1;
+ }
+ */
+ is_reclass = (Rast_is_reclass(name, mapset, real_name, real_mapset) > 0);
+ if (is_reclass) {
+ fd = G_fopen_old("cellhd", real_name, real_mapset);
+ if (fd == NULL) {
+ sprintf(buf,
+ _("Unable to read header file for raster map <%s@%s>."),
+ name, mapset);
+ tail = buf + strlen(buf);
+ sprintf(tail, _(" It is a reclass of raster map <%s@%s> "),
+ real_name, real_mapset);
+ tail = buf + strlen(buf);
+ if (!G_find_cell(real_name, real_mapset))
+ sprintf(tail, _("which is missing."));
+ else
+ sprintf(tail, _("whose header file can't be opened."));
+ G_warning ("%s", buf);
+ return -1;
+ }
+ }
+ else {
+ fd = G_fopen_old("cellhd", name, mapset);
+ if (fd == NULL) {
+ G_warning(_("Unable to open header file for raster map <%s@%s>"),
+ name, mapset);
+ return -1;
+ }
+ }
+
+ Rast__read_Cell_head(fd, cellhd, 1);
+ fclose(fd);
+
+ return 0;
+}
Copied: grass/trunk/lib/raster/get_row.c (from rev 37989, grass/trunk/lib/gis/get_row.c)
===================================================================
--- grass/trunk/lib/raster/get_row.c (rev 0)
+++ grass/trunk/lib/raster/get_row.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,1221 @@
+/*!
+ \file gis/get_row.c
+
+ \brief GIS library - Get raster row
+
+ (C) 2003-2009 by the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author Original author CERL
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <rpc/types.h> /* need this for sgi */
+#include <rpc/xdr.h>
+
+#include <grass/config.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+
+#define NULL_FILE "null"
+
+static int embed_nulls(int, void *, int, RASTER_MAP_TYPE, int, int);
+
+static int compute_window_row(int fd, int row, int *cellRow)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ double f;
+ int r;
+
+ /* check for row in window */
+ if (row < 0 || row >= G__.window.rows) {
+ G_warning(_("Reading raster map <%s@%s> request for row %d is outside region"),
+ fcb->name, fcb->mapset, row);
+
+ return -1;
+ }
+
+ /* convert window row to cell file row */
+ f = row * fcb->C1 + fcb->C2;
+ r = (int)f;
+ if (f < r) /* adjust for rounding up of negatives */
+ r--;
+
+ if (r < 0 || r >= fcb->cellhd.rows)
+ return 0;
+
+ *cellRow = r;
+
+ return 1;
+}
+
+static void do_reclass_int(int fd, void *cell, int null_is_zero)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ CELL *c = cell;
+ CELL *reclass_table = fcb->reclass.table;
+ CELL min = fcb->reclass.min;
+ CELL max = fcb->reclass.max;
+ int i;
+
+ for (i = 0; i < G__.window.cols; i++) {
+ if (Rast_is_c_null_value(&c[i])) {
+ if (null_is_zero)
+ c[i] = 0;
+ continue;
+ }
+
+ if (c[i] < min || c[i] > max) {
+ if (null_is_zero)
+ c[i] = 0;
+ else
+ Rast_set_c_null_value(&c[i], 1);
+ continue;
+ }
+
+ c[i] = reclass_table[c[i] - min];
+
+ if (null_is_zero && Rast_is_c_null_value(&c[i]))
+ c[i] = 0;
+ }
+}
+
+static int read_data_fp_compressed(int fd, int row, unsigned char *data_buf,
+ int *nbytes)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ off_t t1 = fcb->row_ptr[row];
+ off_t t2 = fcb->row_ptr[row + 1];
+ size_t readamount = t2 - t1;
+ size_t bufsize = fcb->cellhd.cols * fcb->nbytes;
+
+ if (lseek(fd, t1, SEEK_SET) < 0)
+ return -1;
+
+ *nbytes = fcb->nbytes;
+
+ if ((size_t) G_zlib_read(fd, readamount, data_buf, bufsize) != bufsize)
+ return -1;
+
+ return 0;
+}
+
+static void rle_decompress(unsigned char *dst, const unsigned char *src,
+ int nbytes, int size)
+{
+ int pairs = size / (nbytes + 1);
+ int i;
+
+ for (i = 0; i < pairs; i++) {
+ int repeat = *src++;
+ int j;
+
+ for (j = 0; j < repeat; j++) {
+ memcpy(dst, src, nbytes);
+ dst += nbytes;
+ }
+
+ src += nbytes;
+ }
+}
+
+static int read_data_compressed(int fd, int row, unsigned char *data_buf,
+ int *nbytes)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ off_t t1 = fcb->row_ptr[row];
+ off_t t2 = fcb->row_ptr[row + 1];
+ ssize_t readamount = t2 - t1;
+ unsigned char *cmp;
+ int n;
+
+ if (lseek(fd, t1, SEEK_SET) < 0)
+ return -1;
+
+ cmp = G__alloca(readamount);
+
+ if (read(fd, cmp, readamount) != readamount) {
+ G__freea(cmp);
+ return -1;
+ }
+
+ /* Now decompress the row */
+ if (fcb->cellhd.compressed > 0) {
+ /* one byte is nbyte count */
+ n = *nbytes = *cmp++;
+ readamount--;
+ }
+ else
+ /* pre 3.0 compression */
+ n = *nbytes = fcb->nbytes;
+
+ if (fcb->cellhd.compressed < 0 || readamount < n * fcb->cellhd.cols) {
+ if (fcb->cellhd.compressed == 2)
+ G_zlib_expand(cmp, readamount, data_buf, n * fcb->cellhd.cols);
+ else
+ rle_decompress(data_buf, cmp, n, readamount);
+ }
+ else
+ memcpy(data_buf, cmp, readamount);
+
+ G__freea(cmp);
+
+ return 0;
+}
+
+static int read_data_uncompressed(int fd, int row, unsigned char *data_buf,
+ int *nbytes)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ ssize_t bufsize = fcb->cellhd.cols * fcb->nbytes;
+
+ *nbytes = fcb->nbytes;
+
+ if (lseek(fd, (off_t) row * bufsize, SEEK_SET) == -1)
+ return -1;
+
+ if (read(fd, data_buf, bufsize) != bufsize)
+ return -1;
+
+ return 0;
+}
+
+#ifdef HAVE_GDAL
+static int read_data_gdal(int fd, int row, unsigned char *data_buf, int *nbytes)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ unsigned char *buf;
+ CPLErr err;
+
+ *nbytes = fcb->nbytes;
+
+ if (fcb->gdal->vflip)
+ row = fcb->cellhd.rows - 1 - row;
+
+ buf = fcb->gdal->hflip
+ ? G__alloca(fcb->cellhd.cols * fcb->cur_nbytes)
+ : data_buf;
+
+ err = G_gdal_raster_IO(
+ fcb->gdal->band, GF_Read, 0, row, fcb->cellhd.cols, 1, buf,
+ fcb->cellhd.cols, 1, fcb->gdal->type, 0, 0);
+
+ if (fcb->gdal->hflip) {
+ int i;
+
+ for (i = 0; i < fcb->cellhd.cols; i++)
+ memcpy(data_buf + i * fcb->cur_nbytes,
+ buf + (fcb->cellhd.cols - 1 - i) * fcb->cur_nbytes,
+ fcb->cur_nbytes);
+ G__freea(buf);
+ }
+
+ return err == CE_None ? 0 : -1;
+}
+#endif
+
+static int read_data(int fd, int row, unsigned char *data_buf, int *nbytes)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+#ifdef HAVE_GDAL
+ if (fcb->gdal)
+ return read_data_gdal(fd, row, data_buf, nbytes);
+#endif
+
+ if (!fcb->cellhd.compressed)
+ return read_data_uncompressed(fd, row, data_buf, nbytes);
+
+ /* map is in compressed form */
+
+ if (fcb->map_type == CELL_TYPE)
+ return read_data_compressed(fd, row, data_buf, nbytes);
+ else
+ return read_data_fp_compressed(fd, row, data_buf, nbytes);
+}
+
+/* copy cell file data to user buffer translated by window column mapping */
+static void cell_values_int(int fd, const unsigned char *data,
+ const COLUMN_MAPPING * cmap, int nbytes,
+ void *cell, int n)
+{
+ CELL *c = cell;
+ COLUMN_MAPPING cmapold = 0;
+ int big = (size_t) nbytes >= sizeof(CELL);
+ int i;
+
+ for (i = 0; i < n; i++) {
+ const unsigned char *d;
+ int neg;
+ CELL v;
+ int j;
+
+ if (!cmap[i]) {
+ c[i] = 0;
+ continue;
+ }
+
+ if (cmap[i] == cmapold) {
+ c[i] = c[i - 1];
+ continue;
+ }
+
+ d = data + (cmap[i] - 1) * nbytes;
+
+ if (big && (*d & 0x80)) {
+ neg = 1;
+ v = *d++ & 0x7f;
+ }
+ else {
+ neg = 0;
+ v = *d++;
+ }
+
+ for (j = 1; j < nbytes; j++)
+ v = (v << 8) + *d++;
+
+ c[i] = neg ? -v : v;
+
+ cmapold = cmap[i];
+ }
+}
+
+static void cell_values_float(int fd, const unsigned char *data,
+ const COLUMN_MAPPING * cmap, int nbytes,
+ void *cell, int n)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ FCELL *c = cell;
+ COLUMN_MAPPING cmapold = 0;
+ XDR *xdrs = &fcb->xdrstream;
+ int i;
+
+ /* xdr stream is initialized to read from */
+ /* fcb->data in 'opencell.c' */
+ xdr_setpos(xdrs, 0);
+
+ for (i = 0; i < n; i++) {
+ if (!cmap[i]) {
+ c[i] = 0;
+ continue;
+ }
+
+ if (cmap[i] == cmapold) {
+ c[i] = c[i - 1];
+ continue;
+ }
+
+ if (cmap[i] < cmapold) {
+ xdr_setpos(xdrs, 0);
+ cmapold = 0;
+ }
+
+ while (cmapold++ != cmap[i]) /* skip */
+ if (!xdr_float(xdrs, &c[i]))
+ G_fatal_error(_("cell_values_float: xdr_float failed for index %d"),
+ i);
+
+ cmapold--;
+ }
+}
+
+static void cell_values_double(int fd, const unsigned char *data,
+ const COLUMN_MAPPING * cmap, int nbytes,
+ void *cell, int n)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ DCELL *c = cell;
+ COLUMN_MAPPING cmapold = 0;
+ XDR *xdrs = &fcb->xdrstream;
+ int i;
+
+ /* xdr stream is initialized to read from */
+ /* fcb->data in 'opencell.c' */
+ xdr_setpos(xdrs, 0);
+
+ for (i = 0; i < n; i++) {
+ if (!cmap[i]) {
+ c[i] = 0;
+ continue;
+ }
+
+ if (cmap[i] == cmapold) {
+ c[i] = c[i - 1];
+ continue;
+ }
+
+ if (cmap[i] < cmapold) {
+ xdr_setpos(xdrs, 0);
+ cmapold = 0;
+ }
+
+ while (cmapold++ != cmap[i]) /* skip */
+ if (!xdr_double(xdrs, &c[i]))
+ G_fatal_error(_("cell_values_double: xdr_double failed for index %d"),
+ i);
+
+ cmapold--;
+ }
+}
+
+#ifdef HAVE_GDAL
+static void gdal_values_int(int fd, const unsigned char *data,
+ const COLUMN_MAPPING *cmap, int nbytes,
+ CELL *cell, int n)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ const unsigned char *d;
+ COLUMN_MAPPING cmapold = 0;
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (!cmap[i]) {
+ cell[i] = 0;
+ continue;
+ }
+
+ if (cmap[i] == cmapold) {
+ cell[i] = cell[i-1];
+ continue;
+ }
+
+ d = data + (cmap[i] - 1) * nbytes;
+
+ switch (fcb->gdal->type) {
+ case GDT_Byte: cell[i] = *(GByte *)d; break;
+ case GDT_Int16: cell[i] = *(GInt16 *)d; break;
+ case GDT_UInt16: cell[i] = *(GUInt16 *)d; break;
+ case GDT_Int32: cell[i] = *(GInt32 *)d; break;
+ case GDT_UInt32: cell[i] = *(GUInt32 *)d; break;
+ default:
+ /* shouldn't happen */
+ Rast_set_c_null_value(&cell[i], 1);
+ break;
+ }
+
+ cmapold = cmap[i];
+ }
+}
+
+static void gdal_values_float(int fd, const float *data,
+ const COLUMN_MAPPING *cmap, int nbytes,
+ FCELL *cell, int n)
+{
+ COLUMN_MAPPING cmapold = 0;
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (!cmap[i]) {
+ cell[i] = 0;
+ continue;
+ }
+
+ if (cmap[i] == cmapold) {
+ cell[i] = cell[i-1];
+ continue;
+ }
+
+ cell[i] = data[cmap[i] - 1];
+
+ cmapold = cmap[i];
+ }
+}
+
+static void gdal_values_double(int fd, const double *data,
+ const COLUMN_MAPPING *cmap, int nbytes,
+ DCELL *cell, int n)
+{
+ COLUMN_MAPPING cmapold = 0;
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (!cmap[i]) {
+ cell[i] = 0;
+ continue;
+ }
+
+ if (cmap[i] == cmapold) {
+ cell[i] = cell[i-1];
+ continue;
+ }
+
+ cell[i] = data[cmap[i] - 1];
+
+ cmapold = cmap[i];
+ }
+}
+#endif
+
+/* transfer_to_cell_XY takes bytes from fcb->data, converts these bytes with
+ the appropriate procedure (e.g. XDR or byte reordering) into type X
+ values which are put into array work_buf.
+ finally the values in work_buf are converted into
+ type Y and put into 'cell'.
+ if type X == type Y the intermediate step of storing the values in
+ work_buf might be ommited. check the appropriate function for XY to
+ determine the procedure of conversion.
+ */
+static void transfer_to_cell_XX(int fd, void *cell)
+{
+ static void (*cell_values_type[3]) () = {
+ cell_values_int, cell_values_float, cell_values_double};
+#ifdef HAVE_GDAL
+ static void (*gdal_values_type[3]) () = {
+ gdal_values_int, gdal_values_float, gdal_values_double};
+#endif
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+#ifdef HAVE_GDAL
+ if (fcb->gdal)
+ (gdal_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
+ fcb->cur_nbytes, cell,
+ G__.window.cols);
+ else
+#endif
+ (cell_values_type[fcb->map_type]) (fd, fcb->data, fcb->col_map,
+ fcb->cur_nbytes, cell,
+ G__.window.cols);
+}
+
+static void transfer_to_cell_fi(int fd, void *cell)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
+ int i;
+
+ transfer_to_cell_XX(fd, work_buf);
+
+ for (i = 0; i < G__.window.cols; i++)
+ ((CELL *) cell)[i] = (fcb->col_map[i] == 0)
+ ? 0
+ : Rast_quant_get_cell_value(&fcb->quant, work_buf[i]);
+
+ G__freea(work_buf);
+}
+
+static void transfer_to_cell_di(int fd, void *cell)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
+ int i;
+
+ transfer_to_cell_XX(fd, work_buf);
+
+ for (i = 0; i < G__.window.cols; i++)
+ ((CELL *) cell)[i] = (fcb->col_map[i] == 0)
+ ? 0
+ : Rast_quant_get_cell_value(&fcb->quant, work_buf[i]);
+
+ G__freea(work_buf);
+}
+
+static void transfer_to_cell_if(int fd, void *cell)
+{
+ CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
+ int i;
+
+ transfer_to_cell_XX(fd, work_buf);
+
+ for (i = 0; i < G__.window.cols; i++)
+ ((FCELL *) cell)[i] = work_buf[i];
+
+ G__freea(work_buf);
+}
+
+static void transfer_to_cell_df(int fd, void *cell)
+{
+ DCELL *work_buf = G__alloca(G__.window.cols * sizeof(DCELL));
+ int i;
+
+ transfer_to_cell_XX(fd, work_buf);
+
+ for (i = 0; i < G__.window.cols; i++)
+ ((FCELL *) cell)[i] = work_buf[i];
+
+ G__freea(work_buf);
+}
+
+static void transfer_to_cell_id(int fd, void *cell)
+{
+ CELL *work_buf = G__alloca(G__.window.cols * sizeof(CELL));
+ int i;
+
+ transfer_to_cell_XX(fd, work_buf);
+
+ for (i = 0; i < G__.window.cols; i++)
+ ((DCELL *) cell)[i] = work_buf[i];
+
+ G__freea(work_buf);
+}
+
+static void transfer_to_cell_fd(int fd, void *cell)
+{
+ FCELL *work_buf = G__alloca(G__.window.cols * sizeof(FCELL));
+ int i;
+
+ transfer_to_cell_XX(fd, work_buf);
+
+ for (i = 0; i < G__.window.cols; i++)
+ ((DCELL *) cell)[i] = work_buf[i];
+
+ G__freea(work_buf);
+}
+
+/*
+ * works for all map types and doesn't consider
+ * null row corresponding to the requested row
+ */
+static int get_map_row_nomask(int fd, void *rast, int row,
+ RASTER_MAP_TYPE data_type)
+{
+ static void (*transfer_to_cell_FtypeOtype[3][3])() = {
+ {transfer_to_cell_XX, transfer_to_cell_if, transfer_to_cell_id},
+ {transfer_to_cell_fi, transfer_to_cell_XX, transfer_to_cell_fd},
+ {transfer_to_cell_di, transfer_to_cell_df, transfer_to_cell_XX}
+ };
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int r;
+ int rowStatus;
+
+ rowStatus = compute_window_row(fd, row, &r);
+
+ if (rowStatus <= 0) {
+ fcb->cur_row = -1;
+ Rast_zero_raster_buf(rast, data_type);
+ return rowStatus;
+ }
+
+ /* read cell file row if not in memory */
+ if (r != fcb->cur_row) {
+ fcb->cur_row = r;
+
+ if (read_data(fd, fcb->cur_row, fcb->data, &fcb->cur_nbytes) < 0) {
+ Rast_zero_raster_buf(rast, data_type);
+
+ if (!fcb->io_error) {
+ if (fcb->cellhd.compressed)
+ G_warning(_("Error reading compressed map <%s@%s>, row %d"),
+ fcb->name, fcb->mapset, r);
+ else
+ G_warning(_("Error reading map <%s@%s>, row %d"),
+ fcb->name, fcb->mapset, r);
+
+ fcb->io_error = 1;
+ }
+ return -1;
+ }
+ }
+
+ (transfer_to_cell_FtypeOtype[fcb->map_type][data_type]) (fd, rast);
+
+ return 1;
+}
+
+static int get_map_row_no_reclass(int fd, void *rast, int row,
+ RASTER_MAP_TYPE data_type, int null_is_zero,
+ int with_mask)
+{
+ int stat;
+
+ stat = get_map_row_nomask(fd, rast, row, data_type);
+ if (stat < 0)
+ return stat;
+
+ stat = embed_nulls(fd, rast, row, data_type, null_is_zero, with_mask);
+ if (stat < 0)
+ return stat;
+
+ return 1;
+}
+
+static int get_map_row(int fd, void *rast, int row, RASTER_MAP_TYPE data_type,
+ int null_is_zero, int with_mask)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int size = Rast_raster_size(data_type);
+ CELL *temp_buf = NULL;
+ void *buf;
+ int type;
+ int stat;
+ int i;
+
+ if (fcb->reclass_flag && data_type != CELL_TYPE) {
+ temp_buf = G__alloca(G__.window.cols * sizeof(CELL));
+ buf = temp_buf;
+ type = CELL_TYPE;
+ }
+ else {
+ buf = rast;
+ type = data_type;
+ }
+
+ stat = get_map_row_no_reclass(fd, buf, row, type, null_is_zero, with_mask);
+ if (stat < 0) {
+ if (temp_buf)
+ G__freea(temp_buf);
+ return stat;
+ }
+
+ if (!fcb->reclass_flag)
+ return 1;
+
+ /* if the map is reclass table, get and
+ reclass CELL row and copy results to needed type */
+
+ do_reclass_int(fd, buf, null_is_zero);
+
+ if (data_type == CELL_TYPE)
+ return 1;
+
+ for (i = 0; i < G__.window.cols; i++) {
+ Rast_set_raster_value_c(rast, temp_buf[i], data_type);
+ rast = Rast_incr_void_ptr(rast, size);
+ }
+
+ G__freea(temp_buf);
+
+ return 1;
+}
+
+/*!
+ * \brief Read raster row without masking (this routine is deprecated)
+ *
+ * This routine reads the specified <em>row</em> from the raster map
+ * open on file descriptor <em>fd</em> into the <em>buf</em> buffer
+ * like Rast_get_map_row() does. The difference is that masking is
+ * suppressed. If the user has a mask set, Rast_get_map_row() will apply
+ * the mask but Rast_get_map_row_nomask() will ignore it. This routine
+ * prints a diagnostic message and returns -1 if there is an error
+ * reading the raster map. Otherwise a nonnegative value is returned.
+ *
+ * <b>Note.</b> Ignoring the mask is not generally acceptable. Users
+ * expect the mask to be applied. However, in some cases ignoring the
+ * mask is justified. For example, the GRASS modules
+ * <i>r.describe</i>, which reads the raster map directly to report
+ * all data values in a raster map, and <i>r.slope.aspect</i>, which
+ * produces slope and aspect from elevation, ignore both the mask and
+ * the region. However, the number of GRASS modules which do this
+ * should be minimal. See Mask for more information about the mask.
+ *
+ * <b>This routine is deprecated! Use Rast_get_raster_row_nomask()
+ * instead.</b>
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_map_row_nomask(int fd, CELL * buf, int row)
+{
+ return get_map_row(fd, buf, row, CELL_TYPE, 1, 0);
+}
+
+/*!
+ * \brief Read raster row without masking
+ *
+ * Same as Rast_get_raster_row() except no masking occurs.
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ * \param data_type data type
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_raster_row_nomask(int fd, void *buf, int row,
+ RASTER_MAP_TYPE data_type)
+{
+ return get_map_row(fd, buf, row, data_type, 0, 0);
+}
+
+/*!
+ * \brief Read raster row without masking (CELL type)
+ *
+ * Same as Rast_get_c_raster_row() except no masking occurs.
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ * \param data_type data type
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_c_raster_row_nomask(int fd, CELL * buf, int row)
+{
+ return Rast_get_raster_row_nomask(fd, buf, row, CELL_TYPE);
+}
+
+/*!
+ * \brief Read raster row without masking (FCELL type)
+ *
+ * Same as Rast_get_f_raster_row() except no masking occurs.
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ * \param data_type data type
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_f_raster_row_nomask(int fd, FCELL * buf, int row)
+{
+ return Rast_get_raster_row_nomask(fd, buf, row, FCELL_TYPE);
+}
+
+/*!
+ * \brief Read raster row without masking (DCELL type)
+ *
+ * Same as Rast_get_d_raster_row() except no masking occurs.
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ * \param data_type data type
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_d_raster_row_nomask(int fd, DCELL * buf, int row)
+{
+ return Rast_get_raster_row_nomask(fd, buf, row, DCELL_TYPE);
+}
+
+/*!
+ * \brief Get raster row (this routine is deprecated!)
+ *
+ * If the map is floating-point, quantize the floating-point values to
+ * integer using the quantization rules established for the map when
+ * the map was opened for reading (this quantization is read from
+ * cell_misc/name/f_quant file, but can be reset after opening raster
+ * map by Rast_set_quant_rules()). NULL values are converted to zeros.
+ *
+ * <b>This routine is deprecated! Use Rast_get_raster_row() instead.</b>
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_map_row(int fd, CELL * buf, int row)
+{
+ return get_map_row(fd, buf, row, CELL_TYPE, 1, 1);
+}
+
+/*!
+ * \brief Get raster row
+ *
+ * If <em>data_type</em> is
+ * - CELL_TYPE, calls Rast_get_c_raster_row()
+ * - FCELL_TYPE, calls Rast_get_f_raster_row()
+ * - DCELL_TYPE, calls Rast_get_d_raster_row()
+ *
+ * Reads appropriate information into the buffer <em>buf</em> associated
+ * with the requested row <em>row</em>. <em>buf</em> is associated with the
+ * current window.
+ *
+ * Note, that the type of the data in <em>buf</em> (say X) is independent of
+ * the type of the data in the file described by <em>fd</em> (say Y).
+ *
+ * - Step 1: Read appropriate raw map data into a intermediate buffer.
+ * - Step 2: Convert the data into a CPU readable format, and subsequently
+ * resample the data. the data is stored in a second intermediate
+ * buffer (the type of the data in this buffer is Y).
+ * - Step 3: Convert this type Y data into type X data and store it in
+ * buffer "buf". Conversion is performed in functions
+ * "transfer_to_cell_XY". (For details of the conversion between
+ * two particular types check the functions).
+ * - Step 4: read or simmulate null value row and zero out cells corresponding
+ * to null value cells. The masked out cells are set to null when the
+ * mask exists. (the MASK is taken care of by null values
+ * (if the null file doesn't exist for this map, then the null row
+ * is simulated by assuming that all zero are nulls *** in case
+ * of Rast_get_raster_row() and assuming that all data is valid
+ * in case of G_get_f/d_raster_row(). In case of deprecated function
+ * Rast_get_map_row() all nulls are converted to zeros (so there are
+ * no embedded nulls at all). Also all masked out cells become zeros.
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ * \param data_type data type
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_raster_row(int fd, void *buf, int row, RASTER_MAP_TYPE data_type)
+{
+ return get_map_row(fd, buf, row, data_type, 0, 1);
+}
+
+/*!
+ * \brief Get raster row (CELL type)
+ *
+ * Reads a row of raster data and leaves the NULL values intact. (As
+ * opposed to the deprecated function Rast_get_map_row() which
+ * converts NULL values to zero.)
+ *
+ * <b>NOTE.</b> When the raster map is old and null file doesn't
+ * exist, it is assumed that all 0-cells are no-data. When map is
+ * floating point, uses quant rules set explicitly by
+ * Rast_set_quant_rules() or stored in map's quant file to convert floats
+ * to integers.
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_c_raster_row(int fd, CELL * buf, int row)
+{
+ return Rast_get_raster_row(fd, buf, row, CELL_TYPE);
+}
+
+/*!
+ * \brief Get raster row (FCELL type)
+ *
+ * Read a row from the raster map open on <em>fd</em> into the
+ * <tt>float</tt> array <em>fcell</em> performing type conversions as
+ * necessary based on the actual storage type of the map. Masking,
+ * resampling into the current region. NULL-values are always
+ * embedded in <tt>fcell</tt> (<em>never converted to a value</em>).
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_f_raster_row(int fd, FCELL * buf, int row)
+{
+ return Rast_get_raster_row(fd, buf, row, FCELL_TYPE);
+}
+
+/*!
+ * \brief Get raster row (DCELL type)
+ *
+ * Same as Rast_get_f_raster_row() except that the array <em>dcell</em>
+ * is <tt>double</tt>.
+ *
+ * \param fd file descriptor for the opened raster map
+ * \param buf buffer for the row to be placed into
+ * \param row data row desired
+ *
+ * \return 1 on success
+ * \return 0 row requested not within window
+ * \return -1 on error
+ */
+int Rast_get_d_raster_row(int fd, DCELL * buf, int row)
+{
+ return Rast_get_raster_row(fd, buf, row, DCELL_TYPE);
+}
+
+static int open_null_read(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ const char *name, *mapset, *dummy;
+ int null_fd;
+
+ if (fcb->null_file_exists == 0)
+ return -1;
+
+ if (fcb->reclass_flag) {
+ name = fcb->reclass.name;
+ mapset = fcb->reclass.mapset;
+ }
+ else {
+ name = fcb->name;
+ mapset = fcb->mapset;
+ }
+
+ dummy = G_find_file2_misc("cell_misc", NULL_FILE, name, mapset);
+
+ if (!dummy) {
+ /* G_warning("unable to find [%s]",path); */
+ fcb->null_file_exists = 0;
+ return -1;
+ }
+
+ null_fd = G_open_old_misc("cell_misc", NULL_FILE, name, mapset);
+ if (null_fd < 0)
+ return -1;
+
+ fcb->null_file_exists = 1;
+
+ return null_fd;
+}
+
+static int read_null_bits(int null_fd, unsigned char *flags, int row,
+ int cols, int fd)
+{
+ off_t offset;
+ ssize_t size;
+ int R;
+
+ if (compute_window_row(fd, row, &R) <= 0) {
+ Rast__init_null_bits(flags, cols);
+ return 1;
+ }
+
+ if (null_fd < 0)
+ return -1;
+
+ size = Rast__null_bitstream_size(cols);
+ offset = (off_t) size *R;
+
+ if (lseek(null_fd, offset, SEEK_SET) < 0) {
+ G_warning(_("Error reading null row %d"), R);
+ return -1;
+ }
+
+ if (read(null_fd, flags, size) != size) {
+ G_warning(_("Error reading null row %d"), R);
+ return -1;
+ }
+
+ return 1;
+}
+
+static void get_null_value_row_nomask(int fd, char *flags, int row)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int i, j, null_fd;
+
+ if (row > G__.window.rows || row < 0) {
+ G_warning(_("Reading raster map <%s@%s> request for row %d is outside region"),
+ fcb->name, fcb->mapset, row);
+ }
+
+ if ((fcb->min_null_row > row) ||
+ (fcb->min_null_row + NULL_ROWS_INMEM - 1 < row))
+ /* the null row row is not in memory */
+ {
+ unsigned char *null_work_buf = G__alloca(
+ Rast__null_bitstream_size(fcb->cellhd.cols));
+
+ /* read in NULL_ROWS_INMEM rows from null file
+ so that the requested row is between fcb->min_null_row
+ and fcb->min_null_row + NULL_ROWS_INMEM */
+
+ fcb->min_null_row = (row / NULL_ROWS_INMEM) * NULL_ROWS_INMEM;
+
+ null_fd = open_null_read(fd);
+
+ for (i = 0; i < NULL_ROWS_INMEM; i++) {
+ /* G__.window.rows doesn't have to be a multiple of NULL_ROWS_INMEM */
+ if (i + fcb->min_null_row >= G__.window.rows)
+ break;
+
+ if (read_null_bits(null_fd, null_work_buf,
+ i + fcb->min_null_row, fcb->cellhd.cols,
+ fd) < 0) {
+ if (fcb->map_type == CELL_TYPE) {
+ /* If can't read null row, assume that all map 0's are nulls */
+ CELL *mask_buf = G__alloca(G__.window.cols * sizeof(CELL));
+
+ get_map_row_nomask(fd, mask_buf, i + fcb->min_null_row,
+ CELL_TYPE);
+ for (j = 0; j < G__.window.cols; j++)
+ flags[j] = (mask_buf[j] == 0);
+
+ G__freea(mask_buf);
+ }
+ else { /* fp map */
+
+ /* if can't read null row, assume that all data is valid */
+ G_zero(flags, sizeof(char) * G__.window.cols);
+ /* the flags row is ready now */
+ }
+ } /*if no null file */
+ else {
+ /* copy null row to flags row translated by window column mapping */
+ /* the fcb->NULL_ROWS[row-fcb->min_null_row] has G__.window.cols bits, */
+ /* the null_work_buf has size fcb->cellhd.cols */
+ for (j = 0; j < G__.window.cols; j++) {
+ if (!fcb->col_map[j])
+ flags[j] = 1;
+ else
+ flags[j] = Rast__check_null_bit(null_work_buf,
+ fcb->col_map[j] - 1,
+ fcb->cellhd.cols);
+ }
+ }
+ /* remember the null row for i for the future reference */
+
+ /*bf-We should take of the size - or we get
+ zeros running on their own after flags convertions -A.Sh. */
+ fcb->NULL_ROWS[i] = G_realloc(fcb->NULL_ROWS[i],
+ Rast__null_bitstream_size(G__.window.
+ cols) + 1);
+ if (fcb->NULL_ROWS[i] == NULL)
+ G_fatal_error("get_null_value_row_nomask: %s",
+ _("Unable to realloc buffer"));
+
+ Rast__convert_01_flags(flags, fcb->NULL_ROWS[i], G__.window.cols);
+
+ } /* for loop */
+
+ if (null_fd > 0)
+ close(null_fd);
+
+ G__freea(null_work_buf);
+ } /* row is not in memory */
+
+ /* copy null file data translated by column mapping to user null row */
+ /* the user requested flags row is of size G__.window.cols */
+ Rast__convert_flags_01(flags, fcb->NULL_ROWS[row - fcb->min_null_row],
+ G__.window.cols);
+}
+
+/*--------------------------------------------------------------------------*/
+
+#ifdef HAVE_GDAL
+
+static void get_null_value_row_gdal(int fd, char *flags, int row)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ DCELL *tmp_buf = Rast_allocate_d_raster_buf();
+ int i;
+
+ if (get_map_row_nomask(fd, tmp_buf, row, DCELL_TYPE) <= 0) {
+ memset(flags, 1, G__.window.cols);
+ G_free(tmp_buf);
+ return;
+ }
+
+ for (i = 0; i < G__.window.cols; i++)
+ /* note: using == won't work if the null value is NaN */
+ flags[i] = memcmp(&tmp_buf[i], &fcb->gdal->null_val, sizeof(DCELL)) == 0;
+
+ G_free(tmp_buf);
+}
+
+#endif
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static void embed_mask(char *flags, int row)
+{
+ CELL *mask_buf = G__alloca(G__.window.cols * sizeof(CELL));
+ int i;
+
+ if (G__.auto_mask <= 0)
+ return;
+
+ if (get_map_row_nomask(G__.mask_fd, mask_buf, row, CELL_TYPE) < 0) {
+ G__freea(mask_buf);
+ return;
+ }
+
+ if (G__.fileinfo[G__.mask_fd].reclass_flag)
+ do_reclass_int(G__.mask_fd, mask_buf, 1);
+
+ for (i = 0; i < G__.window.cols; i++)
+ if (mask_buf[i] == 0)
+ flags[i] = 1;
+
+ G__freea(mask_buf);
+}
+
+static void get_null_value_row(int fd, char *flags, int row, int with_mask)
+{
+#ifdef HAVE_GDAL
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ if (fcb->gdal)
+ get_null_value_row_gdal(fd, flags, row);
+ else
+#endif
+ get_null_value_row_nomask(fd, flags, row);
+
+ if (with_mask)
+ embed_mask(flags, row);
+}
+
+static int embed_nulls(int fd, void *buf, int row, RASTER_MAP_TYPE map_type,
+ int null_is_zero, int with_mask)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ char *null_buf;
+ int i;
+
+ /* this is because without null file the nulls can be only due to 0's
+ in data row or mask */
+ if (null_is_zero && !fcb->null_file_exists
+ && (G__.auto_mask <= 0 || !with_mask))
+ return 1;
+
+ null_buf = G__alloca(G__.window.cols);
+
+ get_null_value_row(fd, null_buf, row, with_mask);
+
+ for (i = 0; i < G__.window.cols; i++) {
+ /* also check for nulls which might be already embedded by quant
+ rules in case of fp map. */
+ if (null_buf[i] || Rast_is_null_value(buf, map_type)) {
+ /* G__set_[f/d]_null_value() sets it to 0 is the embedded mode
+ is not set and calls G_set_[f/d]_null_value() otherwise */
+ Rast__set_null_value(buf, 1, null_is_zero, map_type);
+ }
+ buf = Rast_incr_void_ptr(buf, Rast_raster_size(map_type));
+ }
+
+ G__freea(null_buf);
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*!
+ \brief Read or simmulate null value row
+
+ Read or simmulate null value row and set the cells corresponding
+ to null value to 1. The masked out cells are set to null when the
+ mask exists. (the MASK is taken care of by null values
+ (if the null file doesn't exist for this map, then the null row
+ is simulated by assuming that all zeros in raster map are nulls.
+ Also all masked out cells become nulls.
+
+ \param fd file descriptor for the opened map
+ \param buf buffer for the row to be placed into
+ \param row data row desired
+
+ \return 1
+ */
+int Rast_get_null_value_row(int fd, char *flags, int row)
+{
+ get_null_value_row(fd, flags, row, 1);
+
+ return 1;
+}
Copied: grass/trunk/lib/raster/get_row_colr.c (from rev 37989, grass/trunk/lib/gis/get_row_colr.c)
===================================================================
--- grass/trunk/lib/raster/get_row_colr.c (rev 0)
+++ grass/trunk/lib/raster/get_row_colr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,71 @@
+/*!
+ * \file gis/get_row_colr.c
+ *
+ * \brief GIS Library - Get raster row (colors)
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+#include "G.h"
+
+/*!
+ * \brief Reads a row of raster data and converts it to RGB.
+ *
+ * Reads a row of raster data and converts it to red, green and blue
+ * components according to the <em>colors</em> parameter. This
+ * provides a convenient way to treat a raster layer as a color image
+ * without having to explictly cater for each of <tt>CELL</tt>,
+ * <tt>FCELL</tt> and <tt>DCELL</tt> types.
+ *
+ * \param fd field descriptor
+ * \param row row number
+ * \param colors pointer to Colors structure which holds color info
+ * \param[out] red red value
+ * \param[out] grn green value
+ * \param[out] blu blue value
+ * \param[out] nul null value
+ *
+ * \return -1 on error
+ * \return 0 on success
+ */
+int Rast_get_raster_row_colors(int fd, int row, struct Colors *colors,
+ unsigned char *red, unsigned char *grn,
+ unsigned char *blu, unsigned char *nul)
+{
+ int cols = G_window_cols();
+ int type = Rast_get_raster_map_type(fd);
+ int size = Rast_raster_size(type);
+ void *array;
+ unsigned char *set;
+ void *p;
+ int i;
+
+ array = G__alloca(cols * size);
+
+ if (Rast_get_raster_row(fd, array, row, type) < 0) {
+ G__freea(array);
+ return -1;
+ }
+
+ if (nul)
+ for (i = 0, p = array; i < cols; i++, p = Rast_incr_void_ptr(p, size))
+ nul[i] = Rast_is_null_value(p, type);
+
+ set = G__alloca(cols);
+
+ Rast_lookup_raster_colors(array, red, grn, blu, set, cols, colors, type);
+
+ G__freea(array);
+ G__freea(set);
+
+ return 0;
+}
Copied: grass/trunk/lib/raster/histo_eq.c (from rev 37989, grass/trunk/lib/gis/histo_eq.c)
===================================================================
--- grass/trunk/lib/raster/histo_eq.c (rev 0)
+++ grass/trunk/lib/raster/histo_eq.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,78 @@
+
+/**************************************************************
+* Rast_histogram_eq (histo, map, min, max)
+*
+* struct Histogram *histo; histogram as returned by Rast_read_histogram()
+* unsigned char **map; equalized category mapping
+* CELL *min, *max; min,max category for map
+*
+* perform histogram equalization
+* inputs are histo, output is map,min,max
+****************************************************************/
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+void Rast_histogram_eq(const struct Histogram *histo,
+ unsigned char **map, CELL *min, CELL *max)
+{
+ int i;
+ int x;
+ CELL cat, prev;
+ double total;
+ double sum;
+ double span;
+ int ncats;
+ long count;
+ unsigned char *xmap;
+ int len;
+ int first, last;
+
+ ncats = Rast_get_histogram_num(histo);
+ if (ncats == 1) {
+ *min = *max = Rast_get_histogram_cat(0, histo);
+ *map = xmap = (unsigned char *)G_malloc(1);
+ *xmap = 0;
+ return;
+ }
+ if ((*min = Rast_get_histogram_cat(first = 0, histo)) == 0)
+ *min = Rast_get_histogram_cat(++first, histo);
+ if ((*max = Rast_get_histogram_cat(last = ncats - 1, histo)) == 0)
+ *max = Rast_get_histogram_cat(--last, histo);
+ len = *max - *min + 1;
+ *map = xmap = (unsigned char *)G_malloc(len);
+
+ total = 0;
+ for (i = first; i <= last; i++) {
+ if (Rast_get_histogram_cat(i, histo) == 0)
+ continue;
+ count = Rast_get_histogram_count(i, histo);
+ if (count > 0)
+ total += count;
+ }
+ if (total <= 0) {
+ for (i = 0; i < len; i++)
+ xmap[i] = 0;
+ return;
+ }
+
+ span = total / 256;
+
+ sum = 0.0;
+ cat = *min - 1;
+ for (i = first; i <= last; i++) {
+ prev = cat + 1;
+ cat = Rast_get_histogram_cat(i, histo);
+ count = Rast_get_histogram_count(i, histo);
+ if (count < 0 || cat == 0)
+ count = 0;
+ x = (sum + (count / 2.0)) / span;
+ if (x < 0)
+ x = 0;
+ else if (x > 255)
+ x = 255;
+ sum += count;
+
+ while (prev++ <= cat)
+ *xmap++ = x;
+ }
+}
Copied: grass/trunk/lib/raster/histogram.c (from rev 37989, grass/trunk/lib/gis/histogram.c)
===================================================================
--- grass/trunk/lib/raster/histogram.c (rev 0)
+++ grass/trunk/lib/raster/histogram.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,455 @@
+#include <stdlib.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#define LIST struct Histogram_list
+
+static FILE *fopen_histogram_new(const char *);
+static int cmp(const void *, const void *);
+static int cmp_count(const void *, const void *);
+
+
+/*!
+ * \brief initializes the histogram structure
+ *
+ * initializes the histogram structure for calls to Rast_set_histogram()
+ * and Rast_add_histogram()
+ * \param histogram
+ * \return
+ */
+
+void Rast_init_histogram(struct Histogram *histogram)
+{
+ histogram->num = 0;
+ histogram->list = NULL;
+}
+
+
+/*!
+ * \brief read the histogram information
+ *
+ * Reads the histogram information associated with map layer "map"
+ * in mapset "mapset" into the structure "histogram".
+ *
+ * note: a warning message is printed if the file is missing or incorrect
+ * \param name: name of map
+ * \param mapset: mapset that map belongs to
+ * \param histogram: struct for histogram
+ * \return 1 if successful,
+ * 0 if no histogram file,
+ * -1 on fail
+ */
+
+int Rast_read_histogram(const char *name, const char *mapset,
+ struct Histogram *histogram)
+{
+ FILE *fd = NULL;
+ long cat;
+ long count;
+ char buf[200];
+
+ Rast_init_histogram(histogram);
+
+ if (G_find_file2_misc("cell_misc", "histogram", name, mapset) == NULL) {
+ G_warning(_("Histogram for [%s in %s] missing (run r.support)"), name,
+ mapset);
+
+ return 0;
+ }
+
+ fd = G_fopen_old_misc("cell_misc", "histogram", name, mapset);
+ if (!fd) {
+ G_warning(_("Can't read histogram for [%s in %s]"), name, mapset);
+
+ return -1;
+ }
+
+ while (fgets(buf, sizeof buf, fd)) {
+ if (sscanf(buf, "%ld:%ld", &cat, &count) != 2) {
+ Rast_free_histogram(histogram);
+ fclose(fd);
+ G_warning(_("Invalid histogram file for [%s in %s]"), name,
+ mapset);
+
+ return -1;
+ }
+ Rast_extend_histogram((CELL) cat, count, histogram);
+ }
+ fclose(fd);
+
+ if (histogram->num == 0) {
+ G_warning(_("Invalid histogram file for [%s in %s]"), name, mapset);
+
+ return -1;
+ }
+
+ Rast_sort_histogram(histogram);
+
+ return 1;
+}
+
+
+/*!
+ * \brief Writes the histogram information
+ *
+ * Writes the histogram information associated with map layer "name"
+ * \param name: name of map
+ * \param histogram: struct for histogram
+ * \return 1 if successful,
+ * -1 on fail
+ */
+
+int Rast_write_histogram(const char *name, const struct Histogram *histogram)
+{
+ FILE *fd;
+ int n;
+ LIST *list;
+
+ fd = fopen_histogram_new(name);
+ if (fd == NULL)
+ return -1;
+
+ list = histogram->list;
+ for (n = 0; n < histogram->num; n++) {
+ if (list[n].count)
+ fprintf(fd, "%ld:%ld\n", (long)list[n].cat, list[n].count);
+ }
+ fclose(fd);
+
+ return 1;
+}
+
+
+/*!
+ * \brief Writes the histogram based on cell statistics to file
+ *
+ * \param name: name of map
+ * \param statf: cell statistics
+ * \return 1 on success
+ * -1 on failure
+ */
+
+int Rast_write_histogram_cs(const char *name, struct Cell_stats *statf)
+{
+ FILE *fd;
+ CELL cat;
+ long count;
+
+ fd = fopen_histogram_new(name);
+ if (fd == NULL)
+ return -1;
+
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
+ if (count > 0)
+ fprintf(fd, "%ld:%ld\n", (long)cat, count);
+ }
+ fclose(fd);
+
+ return 1;
+}
+
+
+/*!
+ * \brief Creates histogram based on cell statistics
+ *
+ * \param statf: cell statistics
+ * \param histogram: raster histogram
+ * \return
+ */
+void Rast_make_histogram_cs(struct Cell_stats *statf, struct Histogram *histogram)
+{
+ CELL cat;
+ long count;
+
+ Rast_init_histogram(histogram);
+ Rast_rewind_cell_stats(statf);
+ while (Rast_next_cell_stat(&cat, &count, statf))
+ Rast_add_histogram(cat, count, histogram);
+
+ Rast_sort_histogram(histogram);
+}
+
+
+/*!
+ * \brief Sorts the histogram in ascending order by counts then category
+ *
+ * Sorts the histogram in ascending order by counts then category.
+ * No combining is done.
+ * \param histogram: struct for histogram
+ * \return 1 if successful,
+ * -1 on fail
+ */
+int Rast_get_histogram_num(const struct Histogram *histogram)
+{
+ return histogram->num;
+}
+
+
+/*!
+ * \brief Returns cat for the nth element in the histogram
+ *
+ * Returns cat for the nth element in the histogram
+ * \param histogram: struct for histogram
+ * \return CELL
+ */
+CELL Rast_get_histogram_cat(int n, const struct Histogram * histogram)
+{
+ if (n < 0 || n >= histogram->num)
+ return 0;
+
+ return histogram->list[n].cat;
+}
+
+
+/*!
+ * \brief Returns count for the nth element in the histogram
+ *
+ * Returns count for the nth element in the histogram
+ * \param n: nth element
+ * \param histogram: struct for histogram
+ * \return count
+ */
+long Rast_get_histogram_count(int n, const struct Histogram *histogram)
+{
+ if (n < 0 || n >= histogram->num)
+ return 0;
+
+ return histogram->list[n].count;
+}
+
+
+/*!
+ * \brief Frees memory allocated for the histogram
+ *
+ * frees the memory allocated for the histogram
+ * \param histogram: struct for histogram
+ * \return
+ */
+void Rast_free_histogram(struct Histogram *histogram)
+{
+ if (histogram->num > 0)
+ G_free(histogram->list);
+ histogram->num = 0;
+ histogram->list = NULL;
+}
+
+/*!
+ * \brief Sorts the histogram
+ *
+ * Sorts the histogram in ascending order by category,
+ * combining (by adding) elements that have the same category.
+ * \param histogram: struct for histogram
+ * \return 0 if successful,
+ * 1 on fail
+ */
+int Rast_sort_histogram(struct Histogram *histogram)
+{
+ int a, b, n;
+ LIST *list;
+
+ /* if histogram only has 1 entry, nothing to do */
+ if ((n = histogram->num) <= 1)
+ return 1;
+
+ list = histogram->list;
+
+ /* quick check to see if sorting needed */
+ for (a = 1; a < n; a++)
+ if (list[a - 1].cat >= list[a].cat)
+ break;
+ if (a >= n)
+ return 1;
+
+ /* sort */
+ qsort(list, n, sizeof(LIST), &cmp);
+
+ /* sum duplicate entries */
+ for (a = 0, b = 1; b < n; b++) {
+ if (list[a].cat != list[b].cat) {
+ a++;
+ list[a].count = list[b].count;
+ list[a].cat = list[b].cat;
+ }
+ else {
+ list[a].count += list[b].count;
+ }
+ }
+ histogram->num = a + 1;
+
+ return 0;
+}
+
+
+static int cmp(const void *aa, const void *bb)
+{
+ const LIST *a = aa, *b = bb;
+
+ if (a->cat < b->cat)
+ return -1;
+
+ if (a->cat > b->cat)
+ return 1;
+
+ return 0;
+}
+
+/*!
+ * \brief Sorts the histogram by counts
+ *
+ * Sorts the histogram in ascending order by counts then category.
+ * No combining is done.
+ * \param histogram: struct for histogram
+ * \return 0 if successful,
+ * 1 on fail
+ */
+int Rast_sort_histogram_by_count(struct Histogram *histogram)
+{
+ int n;
+ LIST *list;
+
+ /* if histogram only has 1 entry, nothing to do */
+ if ((n = histogram->num) <= 1)
+ return 1;
+
+ list = histogram->list;
+
+ /* sort */
+ qsort(list, n, sizeof(LIST), &cmp_count);
+
+ return 0;
+}
+
+
+static int cmp_count(const void *aa, const void *bb)
+{
+ const LIST *a = aa, *b = bb;
+
+ if (a->count < b->count)
+ return -1;
+
+ if (a->count > b->count)
+ return 1;
+
+ if (a->cat < b->cat)
+ return -1;
+
+ if (a->cat > b->cat)
+ return 1;
+
+ return 0;
+}
+
+static FILE *fopen_histogram_new(const char *name)
+{
+ FILE *fd;
+
+ fd = G_fopen_new_misc("cell_misc", "histogram", name);
+ if (fd == NULL)
+ G_warning(_("can't create histogram for [%s in %s]"), name,
+ G_mapset());
+
+ return fd;
+}
+
+
+/*!
+ * \brief Removes the histogram
+ *
+ * Removes the histogram information associated with map layer "name"
+ * \param name: name of map
+ * \return
+ */
+
+void Rast_remove_histogram(const char *name)
+{
+ G_remove_misc("cell_misc", "histogram", name);
+}
+
+
+/*!
+ * \brief adds count to the histogram value for cat
+ *
+ * adds count to the histogram value for cat
+ * \param cat: category
+ * \param count
+ * \param histogram: struct for histogram
+ * \return 0 if successful,
+ * 1 on fail
+ */
+int Rast_add_histogram(CELL cat, long count, struct Histogram *histogram)
+{
+ int i;
+
+ for (i = 0; i < histogram->num; i++) {
+ if (histogram->list[i].cat == cat) {
+ histogram->list[i].count += count;
+ return 1;
+ }
+ }
+ Rast_extend_histogram(cat, count, histogram);
+
+ return 0;
+}
+
+
+/*!
+ * \brief sets the histogram value for cat to count
+ *
+ * sets the histogram value for cat to count
+ * \param cat: category
+ * \param count
+ * \param histogram: struct for histogram
+ * \return 0 if successful,
+ * 1 on fail
+ */
+int Rast_set_histogram(CELL cat, long count, struct Histogram *histogram)
+{
+ int i;
+
+ for (i = 0; i < histogram->num; i++) {
+ if (histogram->list[i].cat == cat) {
+ histogram->list[i].count = count;
+ return 1;
+ }
+ }
+ Rast_extend_histogram(cat, count, histogram);
+
+ return 0;
+}
+
+
+/*!
+ * \brief Extends histogram struct to accomodate a new value
+ *
+ * \param cat: category
+ * \param count
+ * \param histogram: struct for histogram
+ * \return
+ */
+void Rast_extend_histogram(CELL cat, long count, struct Histogram *histogram)
+{
+ histogram->num++;
+ histogram->list =
+ (LIST *) G_realloc(histogram->list,
+ histogram->num * sizeof(LIST));
+ histogram->list[histogram->num - 1].cat = cat;
+ histogram->list[histogram->num - 1].count = count;
+}
+
+
+/*!
+ * \brief Zero out histogram struct
+ *
+ * \param histogram: struct for histogram
+ * \return
+ */
+void Rast_zero_histogram(struct Histogram *histogram)
+{
+ int i;
+
+ for (i = 0; i < histogram->num; i++)
+ histogram->list[i].count = 0;
+}
Copied: grass/trunk/lib/raster/history.c (from rev 37989, grass/trunk/lib/gis/history.c)
===================================================================
--- grass/trunk/lib/raster/history.c (rev 0)
+++ grass/trunk/lib/raster/history.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,271 @@
+/*!
+ * \file gis/history.c
+ *
+ * \brief GIS Library - History management
+ *
+ * (C) 2001-2009 GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <string.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+static void print_history_error(const char *, const char *, FILE *);
+
+/*!
+ * \brief Read raster history file
+ *
+ * This routine reads the history file for the raster map <i>name</i>
+ * in <i>mapset</i> into the <i>hist</i> structure.
+ *
+ * A diagnostic message is printed and -1 is returned if there is an
+ * error reading the history file. Otherwise, 0 is returned.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param hist pointer to History structure which holds history info
+ *
+ * \return -1 on error
+ * \return 0 on success
+ */
+int Rast_read_history(const char *name, const char *mapset, struct History *hist)
+{
+ FILE *fd;
+
+ G_zero(hist, sizeof(struct History));
+ fd = G_fopen_old("hist", name, mapset);
+ if (!fd) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+
+ if (!G_getl(hist->mapid, sizeof(hist->mapid), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->mapid);
+
+ if (!G_getl(hist->title, sizeof(hist->title), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->title);
+
+ if (!G_getl(hist->mapset, sizeof(hist->mapset), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->mapset);
+
+ if (!G_getl(hist->creator, sizeof(hist->creator), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->creator);
+
+ if (!G_getl(hist->maptype, sizeof(hist->maptype), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->maptype);
+
+ if (!G_getl(hist->datsrc_1, sizeof(hist->datsrc_1), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->datsrc_1);
+
+ if (!G_getl(hist->datsrc_2, sizeof(hist->datsrc_2), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->datsrc_2);
+
+ if (!G_getl(hist->keywrd, sizeof(hist->keywrd), fd)) {
+ print_history_error(name, mapset, fd);
+ return -1;
+ }
+ G_ascii_check(hist->keywrd);
+
+ hist->edlinecnt = 0;
+ while ((hist->edlinecnt < MAXEDLINES) &&
+ (G_getl
+ (hist->edhist[hist->edlinecnt], sizeof(hist->edhist[0]), fd))) {
+ G_ascii_check(hist->edhist[hist->edlinecnt]);
+ hist->edlinecnt++;
+ }
+
+ fclose(fd);
+
+ return 0;
+}
+
+void print_history_error(const char *name, const char *mapset, FILE *fd)
+{
+ if (fd != NULL)
+ fclose(fd);
+
+ if (mapset) {
+ G_warning(_("Unable to get history information for <%s@%s>"),
+ name, mapset);
+ }
+ else { /* write */
+ G_warning(_("Unable to write history information for <%s>"), name);
+ }
+}
+
+/*!
+ * \brief Write raster history file
+ *
+ * This routine writes the history file for the raster map
+ * <i>name</i> in the current mapset from the <i>hist</i> structure.
+ *
+ * A diagnostic message is printed and -1 is returned if there is an
+ * error writing the history file. Otherwise, 0 is returned.
+ *
+ * <b>Note:</b> The <i>hist</i> structure should first be initialized
+ * using Rast_short_history().
+ *
+ * \param name map name
+ * \param[out] hist pointer to History structure which holds history info
+ *
+ * \return -1 on error
+ * \return 0 on success
+ */
+int Rast_write_history(const char *name, struct History *hist)
+{
+ FILE *fd;
+ int i;
+
+ fd = G_fopen_new("hist", name);
+ if (!fd) {
+ print_history_error(name, NULL, fd);
+ return -1;
+ }
+
+ fprintf(fd, "%s\n", hist->mapid);
+ fprintf(fd, "%s\n", hist->title);
+ fprintf(fd, "%s\n", hist->mapset);
+ fprintf(fd, "%s\n", hist->creator);
+ fprintf(fd, "%s\n", hist->maptype);
+ fprintf(fd, "%s\n", hist->datsrc_1);
+ fprintf(fd, "%s\n", hist->datsrc_2);
+ fprintf(fd, "%s\n", hist->keywrd);
+
+ for (i = 0; i < hist->edlinecnt; i++)
+ fprintf(fd, "%s\n", hist->edhist[i]);
+
+ fclose(fd);
+
+ return 0;
+}
+
+/*!
+ * \brief Initialize history structure
+ *
+ * This routine initializes the <i>hist</i> structure, recording the
+ * date, user, module name and the raster map <i>name</i>
+ * structure. The <i>type</i> is an anachronism from earlier versions
+ * of GRASS and should be specified as "raster".
+ *
+ * <b>Note:</b> This routine only initializes the data structure. It
+ * does not write the history file.
+ *
+ * \param name map name
+ * \param type map type
+ * \param hist pointer to History structure which holds history info
+ */
+void Rast_short_history(const char *name, const char *type, struct History *hist)
+{
+ strncpy(hist->mapid, G_date(), RECORD_LEN);
+ strncpy(hist->title, name, RECORD_LEN);
+ strncpy(hist->mapset, G_mapset(), RECORD_LEN);
+ strncpy(hist->creator, G_whoami(), RECORD_LEN);
+ strncpy(hist->maptype, type, RECORD_LEN);
+
+ sprintf(hist->keywrd, _("generated by %s"), G_program_name());
+ strcpy(hist->datsrc_1, "");
+ strcpy(hist->datsrc_2, "");
+ hist->edlinecnt = 0;
+}
+
+/*!
+ * \brief Save command line to raster history structure
+ *
+ * This routine takes an existing (run Rast_short_history first() history
+ * structure and adds the command line to the end of the comments
+ * array, as cleaned & expanded by the parser.
+ *
+ * History file is limited to [80]x[50], as defined in include/gis.h
+ *
+ * - First version had for loops of [i][j] character assignments and ending
+ * nulls, but using the string libraries is cleaner and less bug prone.
+ * - Second version had white space detection, intelligent wrapping, and
+ * indentation of continued lines, but this proved a pain in the neck for
+ * things like r.patch which can have long strings without any
+ * parser-acceptable breaks.
+ * - This is MK-III, simplified, but that's good: it's cut & paste-able.
+ *
+ * Note: use Rast_write_history() to write the structure.
+ *
+ * Sample Usage:
+ * \code
+ * struct History history;
+ * Rast_short_history(rasterfile, "raster", &history);
+ * Rast_command_history(&history);
+ * Rast_write_history(rasterfile, &history);
+ * \endcode
+ *
+ * \param hist pointer to History structure which holds history info
+ *
+ * \return 0 on success
+ * \return 1 on failure (history file full, no change)
+ * \return 2 on failure (history file full, added as much as we could)
+ */
+int Rast_command_history(struct History *hist)
+{
+ int j, cmdlen;
+ char *cmdlin;
+
+ cmdlin = G_recreate_command();
+ cmdlen = strlen(cmdlin);
+
+ if (hist->edlinecnt > MAXEDLINES - 2) {
+ G_warning(_("Not enough room in history file to record command line"));
+ return 1;
+ }
+
+ if (hist->edlinecnt > 0) { /* add a blank line if preceding history exists */
+ strcpy(hist->edhist[hist->edlinecnt], "");
+ hist->edlinecnt++;
+ }
+
+ if (cmdlen < 70) { /* ie if it will fit on a single line */
+ sprintf(hist->edhist[hist->edlinecnt], G_recreate_command());
+ hist->edlinecnt++;
+ }
+ else { /* multi-line required */
+ j = 0; /* j is the current position in the command line string */
+ while ((cmdlen - j) > 70) {
+ strncpy(hist->edhist[hist->edlinecnt], &cmdlin[j], 68);
+ hist->edhist[hist->edlinecnt][68] = '\0';
+ strcat(hist->edhist[hist->edlinecnt], "\\");
+ j += 68;
+ hist->edlinecnt++;
+ if (hist->edlinecnt > MAXEDLINES - 2) {
+ G_warning(_("Not enough room in history file for command line (truncated)"));
+ return 2;
+ }
+ }
+ if ((cmdlen - j) > 0) { /* ie anything left */
+ strcpy(hist->edhist[hist->edlinecnt], &cmdlin[j]);
+ hist->edlinecnt++;
+ }
+ }
+ return 0;
+}
Copied: grass/trunk/lib/raster/interp.c (from rev 37989, grass/trunk/lib/gis/interp.c)
===================================================================
--- grass/trunk/lib/raster/interp.c (rev 0)
+++ grass/trunk/lib/raster/interp.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,36 @@
+
+#include <grass/gis.h>
+
+DCELL Rast_interp_linear(double u, DCELL c0, DCELL c1)
+{
+ return u * (c1 - c0) + c0;
+}
+
+DCELL Rast_interp_bilinear(double u, double v,
+ DCELL c00, DCELL c01, DCELL c10, DCELL c11)
+{
+ DCELL c0 = Rast_interp_linear(u, c00, c01);
+ DCELL c1 = Rast_interp_linear(u, c10, c11);
+
+ return Rast_interp_linear(v, c0, c1);
+}
+
+DCELL Rast_interp_cubic(double u, DCELL c0, DCELL c1, DCELL c2, DCELL c3)
+{
+ return (u * (u * (u * (c3 - 3 * c2 + 3 * c1 - c0) +
+ (-c3 + 4 * c2 - 5 * c1 + 2 * c0)) + (c2 - c0)) + 2 * c1) / 2;
+}
+
+DCELL Rast_interp_bicubic(double u, double v,
+ DCELL c00, DCELL c01, DCELL c02, DCELL c03,
+ DCELL c10, DCELL c11, DCELL c12, DCELL c13,
+ DCELL c20, DCELL c21, DCELL c22, DCELL c23,
+ DCELL c30, DCELL c31, DCELL c32, DCELL c33)
+{
+ DCELL c0 = Rast_interp_cubic(u, c00, c01, c02, c03);
+ DCELL c1 = Rast_interp_cubic(u, c10, c11, c12, c13);
+ DCELL c2 = Rast_interp_cubic(u, c20, c21, c22, c23);
+ DCELL c3 = Rast_interp_cubic(u, c30, c31, c32, c33);
+
+ return Rast_interp_cubic(v, c0, c1, c2, c3);
+}
Copied: grass/trunk/lib/raster/mask_info.c (from rev 37989, grass/trunk/lib/gis/mask_info.c)
===================================================================
--- grass/trunk/lib/raster/mask_info.c (rev 0)
+++ grass/trunk/lib/raster/mask_info.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,72 @@
+/*
+ *************************************************************
+ * char * Rast_mask_info ()
+ *
+ * returns a printable text of mask information
+ *
+ ************************************************************
+ * Rast__mask_info (name, mapset)
+ *
+ * char name[GNAME_MAX], mapset[GMAPSET_MAX];
+ *
+ * function:
+ * determine the status off the automatic masking
+ * and the name of the cell file which forms the mask
+ *
+ * (the mask file is actually MASK in the current mapset,
+ * but is usually a reclassed cell file, and the reclass
+ * name and mapset are returned)
+ *
+ * returns:
+ * -1 no masking (name, mapset undefined)
+ * name, mapset are undefined
+ *
+ * 1 mask file present, masking on
+ * name, mapset hold mask file name, mapset
+ *
+ ***************************************************************/
+
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+char *Rast_mask_info(void)
+{
+ char text[GNAME_MAX + GMAPSET_MAX + 16];
+ char name[GNAME_MAX];
+ char mapset[GMAPSET_MAX];
+
+ switch (Rast__mask_info(name, mapset)) {
+ case 1:
+ sprintf(text, _("<%s> in mapset <%s>"), name, mapset);
+ break;
+ case -1:
+ strcpy(text, _("none"));
+ break;
+ default:
+ strcpy(text, _("not known"));
+ break;
+ }
+
+ return G_store(text);
+}
+
+int Rast__mask_info(char *name, char *mapset)
+{
+ char rname[GNAME_MAX], rmapset[GMAPSET_MAX];
+
+ strcpy(name, "MASK");
+ strcpy(mapset, G_mapset());
+
+ if (!G_find_cell(name, mapset))
+ return -1;
+
+ if (Rast_is_reclass(name, mapset, rname, rmapset) > 0) {
+ strcpy(name, rname);
+ strcpy(mapset, rmapset);
+ }
+
+ return 1;
+}
Copied: grass/trunk/lib/raster/maskfd.c (from rev 37989, grass/trunk/lib/gis/maskfd.c)
===================================================================
--- grass/trunk/lib/raster/maskfd.c (rev 0)
+++ grass/trunk/lib/raster/maskfd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,31 @@
+/*!
+ * \file gis/maskfd.c
+ *
+ * \brief GIS Library - Mask functions.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+#include "G.h"
+
+/*!
+ * \brief Test for MASK.
+ *
+ * \return -1 if no MASK
+ * \return file descriptor if MASK
+ */
+
+int Rast_maskfd(void)
+{
+ Rast__check_for_auto_masking();
+
+ return G__.auto_mask > 0 ? G__.mask_fd : -1;
+}
Copied: grass/trunk/lib/raster/null_val.c (from rev 37989, grass/trunk/lib/gis/null_val.c)
===================================================================
--- grass/trunk/lib/raster/null_val.c (rev 0)
+++ grass/trunk/lib/raster/null_val.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,507 @@
+/*!
+ * \file gis/null_value.c
+ *
+ * \brief GIS Library - NULL value management
+ *
+ * To provide functionality to handle NULL values for data types CELL,
+ * FCELL, and DCELL. May need more...
+ *
+ * (C) 2001-2009 GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author unknown - probably CERL
+ * \author Justin Hickey - Thailand - jhickey at hpcc.nectec.or.th
+ */
+
+/* System include files */
+#include <string.h>
+
+/* Grass and local include files */
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+static void EmbedGivenNulls(void *, char *, RASTER_MAP_TYPE, int);
+
+/*!
+ \brief To insert null values into a map. Needs more.....
+
+ \param cell raster values
+ \param nulls raster null values
+ \param map_type type of raster - CELL, FCELL, DCELL
+ \param ncols number of columns
+*/
+void EmbedGivenNulls(void *cell, char *nulls, RASTER_MAP_TYPE map_type,
+ int ncols)
+{
+ CELL *c;
+ FCELL *f;
+ DCELL *d;
+ int i;
+
+ c = (CELL *) cell;
+ f = (FCELL *) cell;
+ d = (DCELL *) cell;
+
+ for (i = 0; i < ncols; i++) {
+ if (nulls[i]) {
+ switch (map_type) {
+ case CELL_TYPE:
+ Rast_set_c_null_value((CELL *) (c + i), 1);
+ break;
+
+ case FCELL_TYPE:
+ Rast_set_f_null_value((FCELL *) (f + i), 1);
+ break;
+
+ case DCELL_TYPE:
+ Rast_set_d_null_value((DCELL *) (d + i), 1);
+ break;
+
+ default:
+ G_warning(_("EmbedGivenNulls: wrong data type"));
+ }
+ }
+ }
+}
+
+/*!
+ \brief To set one or more raster values to null.
+
+ It also sets null to zero if null_is_zero is TRUE.
+
+ \param rast pointer to values to set to null
+ \param numVals number of values to set to null
+ \param null_is_zero flag to indicate if NULL = 0
+ \param data_type type of raster - CELL, FCELL, DCELL
+*/
+void Rast__set_null_value(void *rast, int numVals, int null_is_zero,
+ RASTER_MAP_TYPE data_type)
+{
+ if (null_is_zero) {
+ G_zero((char *)rast, numVals * Rast_raster_size(data_type));
+ return;
+ }
+
+ Rast_set_null_value(rast, numVals, data_type);
+}
+
+/*!
+ \brief To set one or more raster values to null.
+
+ \param buf pointer to values to set to null
+ \param numVals number of values to set to null
+ \param data_type type of raster - CELL, FCELL, DCELL
+*/
+void Rast_set_null_value(void *buf, int numVals, RASTER_MAP_TYPE data_type)
+{
+ switch (data_type) {
+ case CELL_TYPE:
+ Rast_set_c_null_value((CELL *) buf, numVals);
+ break;
+
+ case FCELL_TYPE:
+ Rast_set_f_null_value((FCELL *) buf, numVals);
+ break;
+
+ case DCELL_TYPE:
+ Rast_set_d_null_value((DCELL *) buf, numVals);
+ break;
+
+ default:
+ G_warning(_("Rast_set_null_value: wrong data type!"));
+ }
+}
+
+/*!
+ \brief To set a number of CELL raster values to NULL.
+
+ \param cellVals pointer to CELL values to set to null
+ \param numVals number of values to set to null
+*/
+void Rast_set_c_null_value(CELL *cellVals, int numVals)
+{
+ int i; /* counter */
+
+ for (i = 0; i < numVals; i++)
+ cellVals[i] = (int) 0x80000000;
+}
+
+/*!
+ \brief To set a number of FCELL raster values to NULL.
+
+ \param fcellVals pointer to FCELL values to set to null
+ \param numVals number of values to set to null
+*/
+void Rast_set_f_null_value(FCELL *fcellVals, int numVals)
+{
+ static const unsigned char null_bits[4] = {
+ 0xFF, 0xFF, 0xFF, 0xFF};
+ int i;
+
+ for (i = 0; i < numVals; i++)
+ memcpy(&fcellVals[i], null_bits, sizeof(null_bits));
+}
+
+/*!
+ \brief To set a number of DCELL raster values to NULL.
+
+ \param dcellVals pointer to DCELL values to set to null
+ \param numVals number of values to set to null
+*/
+void Rast_set_d_null_value(DCELL *dcellVals, int numVals)
+{
+ static const unsigned char null_bits[8] = {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+ int i;
+
+ for (i = 0; i < numVals; i++)
+ memcpy(&dcellVals[i], null_bits, sizeof(null_bits));
+}
+
+/*!
+ \brief To check if a raster value is set to NULL
+
+ - If the <em>data_type</em> is CELL_TYPE, calls Rast_is_c_null_value()
+ - If the <em>data_type</em> is FCELL_TYPE, calls Rast_is_f_null_value()
+ - If the <em>data_type</em> is DCELL_TYPE, calls Rast_is_d_null_value()
+
+ \param rast raster value to check
+ \param data_type type of raster - CELL, FCELL, DCELL
+
+ \return TRUE if raster value is NULL
+ \return FALSE otherwise
+ */
+int Rast_is_null_value(const void *rast, RASTER_MAP_TYPE data_type)
+{
+ switch (data_type) {
+ case CELL_TYPE:
+ return (Rast_is_c_null_value((CELL *) rast));
+
+ case FCELL_TYPE:
+ return (Rast_is_f_null_value((FCELL *) rast));
+
+ case DCELL_TYPE:
+ return (Rast_is_d_null_value((DCELL *) rast));
+
+ default:
+ G_warning("Rast_is_null_value: wrong data type!");
+ return FALSE;
+ }
+}
+
+/*!
+ \brief To check if a CELL raster value is set to NULL
+
+ Returns 1 if <em>cell</em> is NULL, 0 otherwise. This will test if the
+ value <em>cell</em> is the largest <tt>int</tt>.
+
+ \param cellVal CELL raster value to check
+
+ \return TRUE if CELL raster value is NULL
+ \return FALSE otherwise
+*/
+int Rast_is_c_null_value(const CELL * cellVal)
+{
+ /* Check if the CELL value matches the null pattern */
+ return *cellVal == (CELL) 0x80000000;
+}
+
+/*!
+ \brief To check if a FCELL raster value is set to NULL
+
+ Returns 1 if <em>fcell</em> is NULL, 0 otherwise. This will test if
+ the value <em>fcell</em> is a NaN. It isn't good enough to test for
+ a particular NaN bit pattern since the machine code may change this
+ bit pattern to a different NaN. The test will be
+
+ \code
+ if(fcell==0.0) return 0;
+ if(fcell>0.0) return 0;
+ if(fcell<0.0) return 0;
+ return 1;
+ \endcode
+
+ or (as suggested by Mark Line)
+ \code
+ return (fcell != fcell);
+ \endcode
+
+ \param fcellVal FCELL raster value to check
+
+ \return TRUE if FCELL raster value is NULL
+ \return FALSE otherwise
+*/
+int Rast_is_f_null_value(const FCELL * fcellVal)
+{
+ return *fcellVal != *fcellVal;
+}
+
+/*!
+ \brief To check if a DCELL raster value is set to NULL
+
+ Returns 1 if <em>dcell</em> is NULL, 0 otherwise. This will test if
+ the value <em>dcell</em> is a NaN. Same test as in
+ Rast_is_f_null_value().
+
+ \param dcellVal DCELL raster value to check
+
+ \return TRUE if DCELL raster value is NULL
+ \return FALSE otherwise
+*/
+int Rast_is_d_null_value(const DCELL * dcellVal)
+{
+ return *dcellVal != *dcellVal;
+}
+
+/*!
+ \brief To insert null values into a map.
+
+ - If the <em>data_type</em> is CELL_TYPE, calls Rast_insert_c_null_values()
+ - If the <em>data_type</em> is FCELL_TYPE, calls Rast_insert_f_null_values()
+ - If the <em>data_type</em> is DCELL_TYPE, calls Rast_insert_d_null_values()
+
+ \param rast pointer raster values
+ \param null_row null row
+ \param ncols number of columns
+ \param data_type type of raster - CELL, FCELL, DCELL
+ */
+void Rast_insert_null_values(void *rast, char *null_row, int ncols,
+ RASTER_MAP_TYPE data_type)
+{
+ EmbedGivenNulls(rast, null_row, data_type, ncols);
+}
+
+/*!
+ \brief To insert null values into an integer raster map (CELL)
+
+ For each of the <em>count</em> <em>flags</em> which is true(!=0),
+ set the corresponding <em>cell</em> to the NULL value.
+
+ \param rast pointer raster values
+ \param null_row null row
+ \param ncols number of columns
+*/
+void Rast_insert_c_null_values(CELL * cellVal, char *null_row, int ncols)
+{
+ EmbedGivenNulls((void *)cellVal, null_row, CELL_TYPE, ncols);
+}
+
+/*!
+ \brief To insert null values into an floating-point raster map (FCELL)
+
+ \param fcellVal pointer raster values
+ \param null_row null row
+ \param ncols number of columns
+*/
+void Rast_insert_f_null_values(FCELL * fcellVal, char *null_row, int ncols)
+{
+ EmbedGivenNulls((void *)fcellVal, null_row, FCELL_TYPE, ncols);
+}
+
+/*!
+ \brief To insert null values into an floating-point raster map (FCELL)
+
+ For each for the <em>count</em> <em>flag</em> which is true(!=0), set
+ the corresponding <em>dcell</em> to the NULL value.
+
+ \param dcellVal pointer raster values
+ \param null_row null row
+ \param ncols number of columns
+*/
+void Rast_insert_d_null_values(DCELL * dcellVal, char *null_row, int ncols)
+{
+ EmbedGivenNulls((void *)dcellVal, null_row, DCELL_TYPE, ncols);
+}
+
+/*!
+ \brief Check NULL
+
+ Note: Only for internal use.
+
+ \param flags ?
+ \param bit_num ?
+ \param n ?
+
+ \return -1 on error
+*/
+int Rast__check_null_bit(const unsigned char *flags, int bit_num, int n)
+{
+ int ind;
+ int offset;
+
+ /* find the index of the unsigned char in which this bit appears */
+ ind = Rast__null_bitstream_size(bit_num + 1) - 1;
+
+ /* find how many unsigned chars the buffer with bit_num+1 (counting from 0
+ has and subtract 1 to get unsigned char index */
+ if (ind > Rast__null_bitstream_size(n) - 1) {
+ G_warning("Rast__check_null_bit: Unable to access index %d. "
+ "Size of flags is %d (bit # is %d)",
+ ind, Rast__null_bitstream_size(n) - 1, bit_num);
+ return -1;
+ }
+
+ offset = (ind + 1) * 8 - bit_num - 1;
+
+ return ((flags[ind] & ((unsigned char)1 << offset)) != 0);
+}
+
+/*!
+ \brief Given array of 0/1 of length n starting from column.
+
+ Note: Only for internal use.
+
+ Given array of 0/1 of length n starting from column set the
+ corresponding bits of flags; total number of bits in flags is ncols.
+
+ \param zero_ones
+ \param flags
+ \param col
+ \param n
+ \param ncols
+
+ \return 0
+ \return 1
+*/
+int G__set_flags_from_01_random(const char *zero_ones, unsigned char *flags,
+ int col, int n, int ncols)
+{
+ unsigned char v;
+ int count;
+ int size;
+ int i, k;
+
+ if (col == 0 && n == ncols) {
+ Rast__convert_01_flags(zero_ones, flags, n);
+ return 0;
+ }
+
+ count = 0;
+ size = Rast__null_bitstream_size(ncols);
+
+ for (i = 0; i < size; i++) {
+ v = 0;
+ k = 8;
+
+ while (k-- > 0) {
+ if (count >= col && count < (col + n)) {
+ v = v | ((unsigned char)zero_ones[count - col] << k);
+ }
+ else if (count < ncols) {
+ v = v |
+ ((unsigned char)Rast__check_null_bit(flags, count, ncols) << k);
+ }
+
+ /* otherwise keep this bit the same as it was */
+ count++;
+ }
+
+ flags[i] = v;
+ }
+
+ return 1;
+}
+
+/*!
+ \brief ?
+
+ Note: Only for internal use.
+
+ \param zero_ones
+ \param flags
+ \param n
+*/
+void Rast__convert_01_flags(const char *zero_ones, unsigned char *flags, int n)
+{
+ unsigned char *v;
+ int count;
+ int size;
+ int i, k;
+
+ /* pad the flags with 0's to make size multiple of 8 */
+ v = flags;
+ size = Rast__null_bitstream_size(n);
+ count = 0;
+
+ for (i = 0; i < size; i++) {
+ *v = 0;
+ k = 8;
+
+ while (k-- > 0) {
+ if (count < n) {
+ *v = *v | ((unsigned char)zero_ones[count] << k);
+ }
+
+ count++;
+ }
+
+ v++;
+ }
+}
+
+/*!
+ \brief ?
+
+ Note: Only for internal use.
+
+ \param zero_ones
+ \param flags
+ \param n
+ */
+void Rast__convert_flags_01(char *zero_ones, const unsigned char *flags, int n)
+{
+ const unsigned char *v;
+ int count;
+ int size;
+ int i, k;
+
+ count = 0;
+ v = flags;
+ size = Rast__null_bitstream_size(n);
+
+ for (i = 0; i < size; i++) {
+ k = 8;
+
+ while (k-- > 0) {
+ if (count < n) {
+ zero_ones[count] = ((*v & ((unsigned char)1 << k)) != 0);
+ count++;
+ }
+ }
+
+ v++;
+ }
+}
+
+/*!
+ \brief ?
+
+ Note: Only for internal use.
+
+ \param flags
+ \param cols
+ */
+void Rast__init_null_bits(unsigned char *flags, int cols)
+{
+ unsigned char *v;
+ int size;
+ int i;
+
+ /* pad the flags with 0's to make size multiple of 8 */
+ v = flags;
+ size = Rast__null_bitstream_size(cols);
+
+ for (i = 0; i < size; i++) {
+ if ((i + 1) * 8 <= cols) {
+ *v = (unsigned char)255;
+ }
+ else {
+ *v = (unsigned char)255 << ((i + 1) * 8 - cols);
+ }
+
+ v++;
+ }
+}
Copied: grass/trunk/lib/raster/opencell.c (from rev 37989, grass/trunk/lib/gis/opencell.c)
===================================================================
--- grass/trunk/lib/raster/opencell.c (rev 0)
+++ grass/trunk/lib/raster/opencell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,972 @@
+/*!
+ * \file gis/opencell.c
+ *
+ * \brief GIS Library - Open raster file
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#include <rpc/types.h>
+#include <rpc/xdr.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <grass/config.h>
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+#define FORMAT_FILE "f_format"
+
+static struct fileinfo *new_fileinfo(int fd)
+{
+ int oldsize = G__.fileinfo_count;
+ int newsize = oldsize;
+ int i;
+
+ if (fd < oldsize)
+ return &G__.fileinfo[fd];
+
+ newsize *= 2;
+ if (newsize <= fd)
+ newsize = fd + 20;
+
+ G__.fileinfo = G_realloc(G__.fileinfo, newsize * sizeof(struct fileinfo));
+
+ /* Mark all cell files as closed */
+ for (i = oldsize; i < newsize; i++) {
+ memset(&G__.fileinfo[i], 0, sizeof(struct fileinfo));
+ G__.fileinfo[i].open_mode = -1;
+ }
+
+ G__.fileinfo_count = newsize;
+
+ return &G__.fileinfo[fd];
+}
+
+
+/*!
+ * \brief Open raster file
+ *
+ * Arrange for the NULL-value bitmap to be read as well as the raster
+ * map. If no NULL-value bitmap exists, arrange for the production of
+ * NULL-values based on zeros in the raster map. If the map is
+ * floating-point, arrange for quantization to integer for
+ * Rast_get_c_raster_row(), et. al., by reading the quantization rules
+ * for the map using Rast_read_quant(). If the programmer wants to read
+ * the floating point map using uing quant rules other than the ones
+ * stored in map's quant file, he/she should call Rast_set_quant_rules()
+ * after the call to Rast_open_cell_old().
+ *
+ * \param name map name
+ * \param open_mode mode
+ * \param map_type map type (CELL, FCELL, DCELL)
+ *
+ * \return open file descriptor ( >= 0) if successful
+ * \return negative integer if error
+ */
+
+static int G__open_raster_new(const char *name, int open_mode,
+ RASTER_MAP_TYPE map_type);
+
+/*!
+ \brief Open an existing integer raster map (cell)
+
+ Opens the existing cell file <i>name</i> in the <i>mapset</i> for
+ reading by Rast_get_raster_row() with mapping into the current window.
+
+ This routine opens the raster map <i>name</i> in <i>mapset</i> for
+ reading. A nonnegative file descriptor is returned if the open is
+ successful. Otherwise a diagnostic message is printed and a negative
+ value is returned. This routine does quite a bit of work. Since
+ GRASS users expect that all raster maps will be resampled into the
+ current region, the resampling index for the raster map is prepared
+ by this routine after the file is opened. The resampling is based on
+ the active module region (see also \ref The_Region}. Preparation
+ required for reading the various raster file formats (see \ref
+ Raster_File_Format for an explanation of the various raster file
+ formats) is also done.
+
+ Diagnostics: warning message printed if open fails.
+
+ \param name map name
+ \param mapset mapset name where raster map <i>name</i> lives
+
+ \return nonnegative file descriptor (int)
+ \return -1 on failure
+ */
+int Rast_open_cell_old(const char *name, const char *mapset)
+{
+ int fd;
+
+ if ((fd = Rast__open_cell_old(name, mapset)) < 0) {
+ G_warning(_("Unable to open raster map <%s@%s>"), name, mapset);
+ return fd;
+ }
+
+ /* turn on auto masking, if not already on */
+ Rast__check_for_auto_masking();
+ /*
+ if(G__.auto_mask <= 0)
+ G__.mask_buf = Rast_allocate_cell_buf();
+ now we don't ever free it!, so no need to allocate it (Olga)
+ */
+ /* mask_buf is used for reading MASK file when mask is set and
+ for reading map rows when the null file doesn't exist */
+
+ return fd;
+}
+
+/*! \brief Lower level function, open cell files, supercell files,
+ and the MASK file.
+
+ Actions:
+ - opens the named cell file, following reclass reference if
+ named layer is a reclass layer.
+ - creates the required mapping between the data and the window
+ for use by the get_map_row family of routines.
+
+ Diagnostics: Errors other than actual open failure will cause a
+ diagnostic to be delivered thru G_warning() open failure messages
+ are left to the calling routine since the masking logic will want to
+ issue a different warning.
+
+ Note: This routine does NOT open the MASK layer. If it did we would
+ get infinite recursion. This routine is called to open the mask by
+ Rast__check_for_auto_masking() which is called by Rast_open_cell_old().
+
+ \param name map name
+ \param mapset mapset of cell file to be opened
+
+ \return open file descriptor
+ \return -1 if error
+*/
+int Rast__open_cell_old(const char *name, const char *mapset)
+{
+ struct fileinfo *fcb;
+ int fd;
+ char *cell_dir;
+ const char *r_name;
+ const char *r_mapset;
+ struct Cell_head cellhd;
+ int CELL_nbytes = 0; /* bytes per cell in CELL map */
+ int INTERN_SIZE;
+ int reclass_flag, i;
+ int MAP_NBYTES;
+ RASTER_MAP_TYPE MAP_TYPE;
+ struct Reclass reclass;
+ char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
+ struct GDAL_link *gdal;
+
+ /* make sure window is set */
+ G__init_window();
+
+ G__unqualified_name(name, mapset, xname, xmapset);
+ name = xname;
+ mapset = xmapset;
+
+ if (!G_find_cell2(name, mapset)) {
+ G_warning(_("Unable to find <%s@%s>"), name, mapset);
+ return -1;
+ }
+
+ /* Check for reclassification */
+ reclass_flag = Rast_get_reclass(name, mapset, &reclass);
+
+ switch (reclass_flag) {
+ case 0:
+ r_name = name;
+ r_mapset = mapset;
+ break;
+ case 1:
+ r_name = reclass.name;
+ r_mapset = reclass.mapset;
+ if (G_find_cell2(r_name, r_mapset) == NULL) {
+ G_warning(_("Unable to open raster map <%s@%s> since it is a reclass "
+ "of raster map <%s@%s> which does not exist"),
+ name, mapset, r_name, r_mapset);
+ return -1;
+ }
+ break;
+ default: /* Error reading cellhd/reclass file */
+ return -1;
+ }
+
+ /* read the cell header */
+ if (Rast_get_cellhd(r_name, r_mapset, &cellhd) < 0)
+ return -1;
+
+ /* now check the type */
+ MAP_TYPE = Rast_raster_map_type(r_name, r_mapset);
+ if (MAP_TYPE < 0)
+ return -1;
+
+ if (MAP_TYPE == CELL_TYPE)
+ /* set the number of bytes for CELL map */
+ {
+ CELL_nbytes = cellhd.format + 1;
+ if (CELL_nbytes < 1) {
+ G_warning(_("Raster map <%s@%s>: format field in header file invalid"),
+ r_name, r_mapset);
+ return -1;
+ }
+ }
+
+ if (cellhd.proj != G__.window.proj) {
+ G_warning(_("Raster map <%s@%s> is in different projection than current region. "
+ "Found raster map <%s@%s>, should be <%s>."),
+ name, mapset, name, G__projection_name(cellhd.proj),
+ G__projection_name(G__.window.proj));
+ return -1;
+ }
+ if (cellhd.zone != G__.window.zone) {
+ G_warning(_("Raster map <%s@%s> is in different zone (%d) than current region (%d)"),
+ name, mapset, cellhd.zone, G__.window.zone);
+ return -1;
+ }
+
+ /* when map is int warn if too large cell size */
+ if (MAP_TYPE == CELL_TYPE && (unsigned int) CELL_nbytes > sizeof(CELL)) {
+ G_warning(_("Raster map <%s@%s>: bytes per cell (%d) too large"),
+ name, mapset, CELL_nbytes);
+ return -1;
+ }
+
+ /* record number of bytes per cell */
+ if (MAP_TYPE == FCELL_TYPE) {
+ cell_dir = "fcell";
+ INTERN_SIZE = sizeof(FCELL);
+ MAP_NBYTES = XDR_FLOAT_NBYTES;
+ }
+ else if (MAP_TYPE == DCELL_TYPE) {
+ cell_dir = "fcell";
+ INTERN_SIZE = sizeof(DCELL);
+ MAP_NBYTES = XDR_DOUBLE_NBYTES;
+ }
+ else { /* integer */
+
+ cell_dir = "cell";
+ INTERN_SIZE = sizeof(CELL);
+ MAP_NBYTES = CELL_nbytes;
+ }
+
+ gdal = Rast_get_gdal_link(r_name, r_mapset);
+ if (gdal) {
+#ifdef HAVE_GDAL
+ /* dummy descriptor to reserve the fileinfo slot */
+ fd = open(G_DEV_NULL, O_RDONLY);
+#else
+ G_warning(_("map <%s@%s> is a GDAL link but GRASS is compiled without GDAL support"),
+ r_name, r_mapset);
+ return -1;
+#endif
+ }
+ else
+ /* now actually open file for reading */
+ fd = G_open_old(cell_dir, r_name, r_mapset);
+
+ if (fd < 0)
+ return -1;
+
+ fcb = new_fileinfo(fd);
+
+ fcb->map_type = MAP_TYPE;
+
+ /* Save cell header */
+ G_copy((char *)&fcb->cellhd, (char *)&cellhd, sizeof(cellhd));
+
+ /* allocate null bitstream buffers for reading null rows */
+ for (i = 0; i < NULL_ROWS_INMEM; i++)
+ fcb->NULL_ROWS[i] = Rast__allocate_null_bits(G__.window.cols);
+ /* initialize : no NULL rows in memory */
+ fcb->min_null_row = (-1) * NULL_ROWS_INMEM;
+
+ /* mark closed */
+ fcb->open_mode = -1;
+
+ /* save name and mapset */
+ fcb->name = G_store(name);
+ fcb->mapset = G_store(mapset);
+
+ /* mark no data row in memory */
+ fcb->cur_row = -1;
+ /* fcb->null_cur_row is not used for reading, only for writing */
+ fcb->null_cur_row = -1;
+
+ /* if reclass, copy reclass structure */
+ if ((fcb->reclass_flag = reclass_flag))
+ G_copy(&fcb->reclass, &reclass, sizeof(reclass));
+
+ fcb->gdal = gdal;
+ if (!gdal)
+ /* check for compressed data format, making initial reads if necessary */
+ if (Rast__check_format(fd) < 0) {
+ close(fd); /* warning issued by check_format() */
+ return -1;
+ }
+
+ /* create the mapping from cell file to window */
+ G__create_window_mapping(fd);
+
+ /*
+ * allocate the data buffer
+ * number of bytes per cell is cellhd.format+1
+ */
+
+ /* for reading fcb->data is allocated to be fcb->cellhd.cols * fcb->nbytes
+ (= XDR_FLOAT/DOUBLE_NBYTES) */
+ fcb->data = (unsigned char *)G_calloc(fcb->cellhd.cols, MAP_NBYTES);
+
+ /* initialize/read in quant rules for float point maps */
+ if (fcb->map_type != CELL_TYPE) {
+ if (fcb->reclass_flag)
+ Rast_read_quant(fcb->reclass.name, fcb->reclass.mapset,
+ &(fcb->quant));
+ else
+ Rast_read_quant(fcb->name, fcb->mapset, &(fcb->quant));
+ }
+
+ /* now mark open for read: this must follow create_window_mapping() */
+ fcb->open_mode = OPEN_OLD;
+ fcb->io_error = 0;
+ fcb->map_type = MAP_TYPE;
+ fcb->nbytes = MAP_NBYTES;
+ fcb->null_file_exists = -1;
+
+ if (fcb->map_type != CELL_TYPE)
+ xdrmem_create(&fcb->xdrstream, (caddr_t) fcb->data,
+ (u_int) (fcb->nbytes * fcb->cellhd.cols), XDR_DECODE);
+
+ return fd;
+}
+
+/*!
+ \brief Opens a new cell file in a database (compressed)
+
+ Opens a new cell file <i>name</i> in the current mapset for writing
+ by Rast_put_raster_row().
+
+ The file is created and filled with no data it is assumed that the
+ new cell file is to conform to the current window.
+
+ The file must be written sequentially. Use Rast_open_cell_new_random()
+ for non sequential writes.
+
+ Note: the open actually creates a temporary file Rast_close_cell() will
+ move the temporary file to the cell file and write out the necessary
+ support files (cellhd, cats, hist, etc.).
+
+ Diagnostics: warning message printed if open fails
+
+ Warning: calls to G_set_window() made after opening a new cell file
+ may create confusion and should be avoided the new cell file will be
+ created to conform to the window at the time of the open.
+
+ \param name map name
+
+ \return open file descriptor ( >= 0) if successful
+ \return negative integer if error
+*/
+int Rast_open_cell_new(const char *name)
+{
+ return G__open_raster_new(name, OPEN_NEW_COMPRESSED, CELL_TYPE);
+}
+
+/*!
+ \brief Opens a new cell file in a database (uncompressed)
+
+ See also Rast_open_cell_new().
+
+ \param name map name
+
+ \return open file descriptor ( >= 0) if successful
+ \return negative integer if error
+*/
+int Rast_open_cell_new_uncompressed(const char *name)
+{
+ return G__open_raster_new(name, OPEN_NEW_UNCOMPRESSED, CELL_TYPE);
+}
+
+/*!
+ \brief Save histogram for newly create raster map (cell)
+
+ If newly created cell files should have histograms, set flag=1
+ otherwise set flag=0. Applies to subsequent opens.
+
+ \param flag flag indicator
+*/
+void Rast_want_histogram(int flag)
+{
+ G__.want_histogram = flag;
+}
+
+/*!
+ \brief Sets the format for subsequent opens on new integer cell files
+ (uncompressed and random only).
+
+ Warning: subsequent put_row calls will only write n+1 bytes per
+ cell. If the data requires more, the cell file will be written
+ incorrectly (but with n+1 bytes per cell)
+
+ When writing float map: format is -1
+
+ \param n format
+*/
+void Rast_set_cell_format(int n)
+/* sets the format for integer raster map */
+{
+ G__.nbytes = n + 1;
+ if (G__.nbytes <= 0)
+ G__.nbytes = 1;
+ if (G__.nbytes > sizeof(CELL))
+ G__.nbytes = sizeof(CELL);
+}
+
+/*!
+ \brief Get cell value format
+
+ \param v cell
+
+ \return cell format
+*/
+int Rast_cellvalue_format(CELL v)
+{
+ unsigned int i;
+
+ if (v >= 0)
+ for (i = 0; i < sizeof(CELL); i++)
+ if (!(v /= 256))
+ return i;
+ return sizeof(CELL) - 1;
+}
+
+/*!
+ \brief Opens new fcell file in a database
+
+ Opens a new floating-point map <i>name</i> in the current mapset for
+ writing. The type of the file (i.e. either double or float) is
+ determined and fixed at this point. The default is FCELL_TYPE. In
+ order to change this default
+
+ Use Rast_set_fp_type() where type is one of DCELL_TYPE or FCELL_TYPE.
+
+ See warnings and notes for Rast_open_cell_new().
+
+ \param name map name
+
+ \return nonnegative file descriptor (int)
+ \return -1 on error
+*/
+int Rast_open_fp_cell_new(const char *name)
+{
+ return G__open_raster_new(name, OPEN_NEW_COMPRESSED, G__.fp_type);
+}
+
+/*!
+ \brief Opens new fcell file in a database (uncompressed)
+
+ See Rast_open_fp_cell_new() for details.
+
+ \param name map name
+
+ \return nonnegative file descriptor (int)
+ \return -1 on error
+*/
+int Rast_open_fp_cell_new_uncompressed(const char *name)
+{
+ return G__open_raster_new(name, OPEN_NEW_UNCOMPRESSED, G__.fp_type);
+}
+
+#ifdef HAVE_GDAL
+static int G__open_raster_new_gdal(char *map, char *mapset, RASTER_MAP_TYPE map_type)
+{
+ int fd;
+ struct fileinfo *fcb;
+ int i;
+
+ /* dummy descriptor to reserve the fileinfo slot */
+ fd = open("/dev/null", O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ fcb = new_fileinfo(fd);
+
+ /* mark closed */
+ fcb->map_type = map_type;
+ fcb->open_mode = -1;
+
+ fcb->gdal = Rast_create_gdal_link(map, map_type);
+ if (!fcb->gdal)
+ return -1;
+
+ fcb->cellhd = G__.window;
+ fcb->cellhd.compressed = 0;
+ fcb->nbytes = Rast_raster_size(fcb->map_type);
+ /* for writing fcb->data is allocated to be G__.window.cols *
+ sizeof(CELL or DCELL or FCELL) */
+ fcb->data = G_calloc(G__.window.cols, fcb->nbytes);
+
+ fcb->name = map;
+ fcb->mapset = mapset;
+ fcb->cur_row = 0;
+
+ fcb->row_ptr = NULL;
+ fcb->temp_name = NULL;
+ fcb->null_temp_name = NULL;
+ fcb->null_cur_row = 0;
+ fcb->min_null_row = 0;
+ for (i = 0; i < NULL_ROWS_INMEM; i++)
+ fcb->NULL_ROWS[i] = NULL;
+
+ if (fcb->map_type != CELL_TYPE)
+ Rast_quant_init(&(fcb->quant));
+
+ /* init cell stats */
+ /* now works only for int maps */
+ if (fcb->map_type == CELL_TYPE)
+ if ((fcb->want_histogram = G__.want_histogram))
+ Rast_init_cell_stats(&fcb->statf);
+
+ /* init range and if map is double/float init d/f_range */
+ Rast_init_range(&fcb->range);
+
+ if (fcb->map_type != CELL_TYPE)
+ Rast_init_fp_range(&fcb->fp_range);
+
+ /* mark file as open for write */
+ fcb->open_mode = OPEN_NEW_UNCOMPRESSED;
+ fcb->io_error = 0;
+
+ return fd;
+}
+#endif /* HAVE_GDAL */
+
+static int G__open_raster_new(const char *name, int open_mode,
+ RASTER_MAP_TYPE map_type)
+{
+ char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
+ struct fileinfo *fcb;
+ int i, null_fd, fd;
+ char *tempname;
+ char *map;
+ char *mapset;
+ const char *cell_dir;
+ int nbytes;
+
+ switch (map_type) {
+ case CELL_TYPE:
+ cell_dir = "cell";
+ nbytes = G__.nbytes;
+ break;
+ case FCELL_TYPE:
+ nbytes = XDR_FLOAT_NBYTES;
+ cell_dir = "fcell";
+ break;
+ case DCELL_TYPE:
+ nbytes = XDR_DOUBLE_NBYTES;
+ cell_dir = "fcell";
+ break;
+ default:
+ G_fatal_error(_("Invalid map type <%d>"), map_type);
+ break;
+ }
+
+ if (G__unqualified_name(name, G_mapset(), xname, xmapset) < 0)
+ G_fatal_error(_("Raster map <%s> is not in the current mapset (%s)"),
+ name, G_mapset());
+ map = G_store(xname);
+ mapset = G_store(xmapset);
+
+ /* check for legal grass name */
+ if (G_legal_filename(map) < 0) {
+ G_warning(_("<%s> is an illegal file name"), map);
+ return -1;
+ }
+
+ /* make sure window is set */
+ G__init_window();
+
+#ifdef HAVE_GDAL
+ if (G_find_file2("", "GDAL", G_mapset()))
+ return G__open_raster_new_gdal(map, mapset, map_type);
+#endif
+
+ /* open a tempfile name */
+ tempname = G_tempfile();
+ fd = creat(tempname, 0666);
+ if (fd < 0) {
+ G_warning(_("G__open_raster_new(): no temp files available"));
+ G_free(mapset);
+ G_free(tempname);
+ G_free(map);
+ return -1;
+ }
+
+ fcb = new_fileinfo(fd);
+ /*
+ * since we are bypassing the normal open logic
+ * must create the cell element
+ */
+ G__make_mapset_element(cell_dir);
+
+ /* mark closed */
+ fcb->map_type = map_type;
+ fcb->open_mode = -1;
+ fcb->gdal = NULL;
+
+ /* for writing fcb->data is allocated to be G__.window.cols *
+ sizeof(CELL or DCELL or FCELL) */
+ fcb->data = (unsigned char *)G_calloc(G__.window.cols,
+ Rast_raster_size(fcb->map_type));
+
+ /*
+ * copy current window into cell header
+ * set format to cell/supercell
+ * for compressed writing
+ * allocate space to hold the row address array
+ */
+ G_copy((char *)&fcb->cellhd, (char *)&G__.window, sizeof(fcb->cellhd));
+
+ if (open_mode == OPEN_NEW_COMPRESSED && fcb->map_type == CELL_TYPE) {
+ fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
+ G_zero(fcb->row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));
+ Rast__write_row_ptrs(fd);
+ fcb->cellhd.compressed = G__.compression_type;
+
+ fcb->nbytes = 1; /* to the minimum */
+ }
+ else {
+ fcb->nbytes = nbytes;
+ if (open_mode == OPEN_NEW_COMPRESSED) {
+ fcb->row_ptr = G_calloc(fcb->cellhd.rows + 1, sizeof(off_t));
+ G_zero(fcb->row_ptr, (fcb->cellhd.rows + 1) * sizeof(off_t));
+ Rast__write_row_ptrs(fd);
+ fcb->cellhd.compressed = G__.compression_type;
+ }
+ else
+ fcb->cellhd.compressed = 0;
+
+ if (fcb->map_type != CELL_TYPE) {
+ Rast_quant_init(&(fcb->quant));
+ }
+ }
+
+ /* save name and mapset, and tempfile name */
+ fcb->name = map;
+ fcb->mapset = mapset;
+ fcb->temp_name = tempname;
+
+ /* next row to be written (in order) is zero */
+ fcb->cur_row = 0;
+
+ /* open a null tempfile name */
+ tempname = G_tempfile();
+ null_fd = creat(tempname, 0666);
+ if (null_fd < 0) {
+ G_warning(_("G__open_raster_new(): no temp files available"));
+ G_free(tempname);
+ G_free(fcb->name);
+ G_free(fcb->mapset);
+ G_free(fcb->temp_name);
+ close(fd);
+ return -1;
+ }
+
+ fcb->null_temp_name = tempname;
+ close(null_fd);
+
+ /* next row to be written (in order) is zero */
+ fcb->null_cur_row = 0;
+
+ /* allocate null bitstream buffers for writing */
+ for (i = 0; i < NULL_ROWS_INMEM; i++)
+ fcb->NULL_ROWS[i] = Rast__allocate_null_bits(fcb->cellhd.cols);
+ fcb->min_null_row = (-1) * NULL_ROWS_INMEM;
+
+ /* init cell stats */
+ /* now works only for int maps */
+ if (fcb->map_type == CELL_TYPE)
+ if ((fcb->want_histogram = G__.want_histogram))
+ Rast_init_cell_stats(&fcb->statf);
+
+ /* init range and if map is double/float init d/f_range */
+ Rast_init_range(&fcb->range);
+
+ if (fcb->map_type != CELL_TYPE)
+ Rast_init_fp_range(&fcb->fp_range);
+
+ /* mark file as open for write */
+ fcb->open_mode = open_mode;
+ fcb->io_error = 0;
+
+ return fd;
+}
+
+/*!
+ \brief Set raster map floating-point data format.
+
+ This controls the storage type for floating-point maps. It affects
+ subsequent calls to G_open_fp_map_new(). The <i>type</i> must be
+ one of FCELL_TYPE (float) or DCELL_TYPE (double). The use of this
+ routine by applications is discouraged since its use would override
+ user preferences.
+
+ \param type raster data type
+
+ \return 1 on success
+ \return -1 on error
+*/
+int Rast_set_fp_type(RASTER_MAP_TYPE map_type)
+{
+ switch (map_type) {
+ case FCELL_TYPE:
+ case DCELL_TYPE:
+ G__.fp_type = map_type;
+ return 1;
+ default:
+ G_warning(_("Rast_set_fp_type(): can only be called with FCELL_TYPE or DCELL_TYPE"));
+ return -1;
+ }
+}
+
+/*!
+ \brief Check if raster map is floating-point
+
+ Returns true (1) if raster map <i>name</i> in <i>mapset</i>
+ is a floating-point dataset; false(0) otherwise.
+
+ \param name map name
+ \param mapset mapset name
+
+ \return 1 floating-point
+ \return 0 int
+*/
+int Rast_raster_map_is_fp(const char *name, const char *mapset)
+{
+ char path[GPATH_MAX];
+ const char *xmapset;
+
+ xmapset = G_find_cell2(name, mapset);
+ if (!xmapset) {
+ G_warning(_("Unable to find <%s@%s>"), name, mapset);
+ return -1;
+ }
+ G__file_name(path, "fcell", name, xmapset);
+ if (access(path, 0) == 0)
+ return 1;
+ G__file_name(path, "g3dcell", name, xmapset);
+ if (access(path, 0) == 0)
+ return 1;
+
+ return 0;
+}
+
+/*!
+ \brief Determine raster data type
+
+ Determines if the raster map is floating point or integer. Returns
+ DCELL_TYPE for double maps, FCELL_TYPE for float maps, CELL_TYPE for
+ integer maps, -1 if error has occured
+
+ \param name map name
+ \param mapset mapset where map <i>name</i> lives
+
+ \return raster data type
+*/
+RASTER_MAP_TYPE Rast_raster_map_type(const char *name, const char *mapset)
+{
+ char path[GPATH_MAX];
+ const char *xmapset;
+
+ xmapset = G_find_cell2(name, mapset);
+ if (!xmapset) {
+ if (mapset && *mapset)
+ G_warning(_("Raster map <%s> not found in mapset <%s>"), name, mapset);
+ else
+ G_warning(_("Raster map <%s> not found"), name);
+ return -1;
+ }
+ G__file_name(path, "fcell", name, xmapset);
+
+ if (access(path, 0) == 0)
+ return Rast__check_fp_type(name, xmapset);
+
+ G__file_name(path, "g3dcell", name, xmapset);
+
+ if (access(path, 0) == 0)
+ return DCELL_TYPE;
+
+ return CELL_TYPE;
+}
+
+/*!
+ \brief Determine raster type from descriptor
+
+ Determines if the raster map is floating point or integer. Returns
+ DCELL_TYPE for double maps, FCELL_TYPE for float maps, CELL_TYPE for
+ integer maps, -1 if error has occured
+
+ \param fd file descriptor
+
+ \return raster data type
+ */
+RASTER_MAP_TYPE Rast_get_raster_map_type(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ return fcb->map_type;
+}
+
+/*!
+ \brief Determines whether the floating points cell file has double or float type
+
+ \param name map name
+ \param mapset mapset where map <i>name</i> lives
+
+ \return raster type (fcell, dcell)
+*/
+RASTER_MAP_TYPE Rast__check_fp_type(const char *name, const char *mapset)
+{
+ char path[GPATH_MAX];
+ struct Key_Value *format_keys;
+ int in_stat;
+ const char *str, *str1;
+ RASTER_MAP_TYPE map_type;
+ const char *xmapset;
+
+ xmapset = G_find_cell2(name, mapset);
+ if (!xmapset) {
+ G_warning(_("Unable to find <%s@%s>"), name, mapset);
+ return -1;
+ }
+ G__file_name_misc(path, "cell_misc", FORMAT_FILE, name, xmapset);
+
+ if (access(path, 0) != 0) {
+ G_warning(_("Unable to find '%s'"), path);
+ return -1;
+ }
+ format_keys = G_read_key_value_file(path, &in_stat);
+ if (in_stat != 0) {
+ G_warning(_("Unable to open '%s'"), path);
+ return -1;
+ }
+ if ((str = G_find_key_value("type", format_keys)) != NULL) {
+ if (strcmp(str, "double") == 0)
+ map_type = DCELL_TYPE;
+ else if (strcmp(str, "float") == 0)
+ map_type = FCELL_TYPE;
+ else {
+ G_warning(_("Invalid type: field '%s' in file '%s'"),
+ str, path);
+ G_free_key_value(format_keys);
+ return -1;
+ }
+ }
+ else {
+ G_free_key_value(format_keys);
+ return -1;
+ }
+
+ if ((str1 = G_find_key_value("byte_order", format_keys)) != NULL) {
+ if (strcmp(str1, "xdr") != 0)
+ G_warning(_("Raster map <%s> is not xdr: byte_order: %s"),
+ name, str);
+ /* here read and translate byte order if not using xdr */
+ }
+ G_free_key_value(format_keys);
+ return map_type;
+}
+
+/*!
+ \brief Opens a new raster map
+
+ Opens a new raster map of type <i>wr_type</i>
+
+ See warnings and notes for Rast_open_cell_new().
+
+ Supported data types:
+ - CELL_TYPE
+ - FCELL_TYPE
+ - DCELL_TYPE
+
+ On CELL_TYPE calls Rast_open_cell_new() otherwise Rast_open_fp_cell_new().
+
+ \param name map name
+ \param wr_type raster data type
+
+ \return nonnegative file descriptor (int)
+ \return -1 on error
+*/
+int Rast_open_raster_new(const char *name, RASTER_MAP_TYPE wr_type)
+{
+ return G__open_raster_new(name, OPEN_NEW_COMPRESSED, wr_type);
+}
+
+/*!
+ \brief Opens a new raster map (uncompressed)
+
+ See Rast_open_raster_new().
+
+ \param name map name
+ \param wr_type raster data type
+
+ \return nonnegative file descriptor (int)
+ \return -1 on error
+*/
+int Rast_open_raster_new_uncompressed(const char *name, RASTER_MAP_TYPE wr_type)
+{
+ return G__open_raster_new(name, OPEN_NEW_UNCOMPRESSED, wr_type);
+}
+
+/*!
+ \brief Sets quant translation rules for raster map opened for
+ reading.
+
+ Returned by Rast_open_cell_old(). After calling this function,
+ Rast_get_c_raster_row() and Rast_get_map_row() will use rules defined by q
+ (instead of using rules defined in map's quant file) to convert floats to
+ ints.
+
+ \param fd file descriptor (cell file)
+ \param q pointer to Quant structure
+
+ \return 0 success
+ \return -1 failure
+*/
+int Rast_set_quant_rules(int fd, struct Quant *q)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ CELL cell;
+ DCELL dcell;
+ struct Quant_table *p;
+
+ if (fcb->open_mode != OPEN_OLD) {
+ G_warning(_("Rast_set_quant_rules() can be called only for "
+ "raster maps opened for reading"));
+ return -1;
+ }
+ /* copy all info from q to fcb->quant) */
+ Rast_quant_init(&fcb->quant);
+ if (q->truncate_only) {
+ Rast_quant_truncate(&fcb->quant);
+ return 0;
+ }
+ for (p = &(q->table[q->nofRules - 1]); p >= q->table; p--)
+ Rast_quant_add_rule(&fcb->quant, p->dLow, p->dHigh, p->cLow, p->cHigh);
+ if (Rast_quant_get_neg_infinite_rule(q, &dcell, &cell) > 0)
+ Rast_quant_set_neg_infinite_rule(&fcb->quant, dcell, cell);
+ if (Rast_quant_get_pos_infinite_rule(q, &dcell, &cell) > 0)
+ Rast_quant_set_pos_infinite_rule(&fcb->quant, dcell, cell);
+
+ return 0;
+}
Copied: grass/trunk/lib/raster/put_cellhd.c (from rev 37989, grass/trunk/lib/gis/put_cellhd.c)
===================================================================
--- grass/trunk/lib/raster/put_cellhd.c (rev 0)
+++ grass/trunk/lib/raster/put_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,42 @@
+/*!
+ * \file gis/put_cellhd.c
+ *
+ * \brief GIS Library - Write raster header.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+/*!
+ \brief Writes the raster file header.
+
+ Writes the cell file header information associated with map layer "map"
+ into current mapset from the structure "cellhd".
+
+ \param name name of map
+ \param cellhd structure holding cell header info
+
+ \return 0 on success
+ \return -1 on failure
+*/
+int Rast_put_cellhd(const char *name, struct Cell_head *cellhd)
+{
+ FILE *fd;
+
+ if (!(fd = G_fopen_new("cellhd", name))) {
+ G_warning(_("Unable to create header file for <%s>"), name);
+ return -1;
+ }
+
+ G__write_Cell_head(fd, cellhd, 1);
+ fclose(fd);
+
+ return 0;
+}
Copied: grass/trunk/lib/raster/put_row.c (from rev 37989, grass/trunk/lib/gis/put_row.c)
===================================================================
--- grass/trunk/lib/raster/put_row.c (rev 0)
+++ grass/trunk/lib/raster/put_row.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,878 @@
+
+/**********************************************************************
+ *
+ * G_put_[c/f/d]_raster_row(fd, buf)
+ * int fd file descriptor of the opened map
+ * [F/D]CELL *buf buffer holding row info to be written
+ *
+ * Writes the next row for the cell file opened on 'fd' from 'buf'
+ * All writes go into NEW files that exactly match the current window.
+ * The file must have been opened with Rast_open_cell_new()
+ * and be written sequentially, ie no skipping rows
+ *
+ * when the null values are embeded into the data, corresponding cells are
+ * changed to 0's and the corresponding null value row is written into null
+ * file.
+ *
+ * *** NOTE ***
+ * A map cannot be copied using Rast_get_raster_row() and Rast_put_raster_row().
+ * The former resamples the data of the original map into a row buffer
+ * that matches the current window. The later writes out rows associated
+ * with the window.
+ *
+ * returns: 1 if successful
+ * -1 on fail
+ *
+ * Keeps track of the minimum and maximum cell value for use in updating
+ * the range file upon close of the cell file.
+ * HOWEVER when nulls are not embeded, the cells are considered 0's as far
+ * as updating range is concerned, even if the corresponding cell is null
+ * in the resulting null file, so programmer should be carefult to set all
+ * the null values using Rast_set_null_value() or G_insert_[d/f_]null_values()
+ *
+ **********************************************************************
+ *
+ * Rast_put_map_row(fd, buf)
+ * int fd file descriptor of the opened map
+ * CELL *buf buffer holding row info to be written
+ *
+ * Writes the next row for the cell file opened on 'fd' from 'buf'
+ * All writes go into NEW files that exactly match the current window.
+ * The file must have been opened with Rast_open_cell_new()
+ * and be written sequentially, ie no skipping rows
+ *
+ * NULLS are written into null bitmap file for all cells which are zero,
+ * and cells which have null value (these cells are converted to 0's before
+ * writing)
+ *
+ * *** NOTE ***
+ * A map cannot be copied using Rast_get_map_row() and Rast_put_map_row().
+ * The former resamples the data of the original map into a row buffer
+ * that matches the current window. The later writes out rows associated
+ * with the window.
+ *
+ * returns: 1 if successful
+ * -1 on fail
+ *
+ * Keeps track of the minimum and maximum cell value for use in updating
+ * the range file upon close of the cell file.
+ *
+ ***********************************************************************
+ *
+ * put_null_value_row(fd, buf)
+ * int fd File descriptor where data is to be written
+ * char *buf Buffer holding null data
+ *
+ * converts a buffer of zero's and ones to bitstream and stores this
+ * bitstream in memory. (the null rows from memory are written into null
+ * file after the limit is reached, and the place for new null rows
+ * to be kept in memory is freed. Should not be used by application
+ * programs.
+ *
+ * returns: 0 if successful
+ * -1 on fail
+ **********************************************************************/
+
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <grass/config.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+
+static int put_raster_data(int, char *, const void *, int, int, int,
+ RASTER_MAP_TYPE);
+static int put_data(int, char *, const CELL *, int, int, int);
+static int check_open(const char *, int);
+static void write_error(int, int);
+static int same(const unsigned char *, const unsigned char *, int);
+static void set_file_pointer(int, int);
+static int put_fp_data(int, char *, const void *, int, int, RASTER_MAP_TYPE);
+static int put_null_data(int, const char *, int);
+static int convert_and_write_if(int, const CELL *);
+static int convert_and_write_id(int, const CELL *);
+static int convert_and_write_df(int, const DCELL *);
+static int convert_and_write_fd(int, const FCELL *);
+static int put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type,
+ int zeros_r_nulls);
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static int put_null_value_row(int fd, const char *buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ if (fcb->gdal)
+ G_fatal_error(_("GDAL output doesn't support writing null rows separately"));
+
+ switch (put_null_data(fd, buf, fcb->null_cur_row)) {
+ case -1:
+ return -1;
+ case 0:
+ return 1;
+ }
+
+ fcb->null_cur_row++;
+
+ return 1;
+}
+
+int Rast_put_map_row(int fd, const CELL * buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ if (fcb->map_type != CELL_TYPE) {
+ G_fatal_error(_("Rast_put_map_row: %s is not integer! Use G_put_[f/d]_raster_row()!"),
+ fcb->name);
+ return -1;
+ }
+
+ return put_raster_row(fd, buf, CELL_TYPE, 1);
+}
+
+int Rast_put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type)
+{
+ return put_raster_row(fd, buf, data_type, 0);
+}
+
+int Rast_put_c_raster_row(int fd, const CELL * buf)
+{
+ return Rast_put_raster_row(fd, buf, CELL_TYPE);
+}
+
+int Rast_put_f_raster_row(int fd, const FCELL * buf)
+{
+ return Rast_put_raster_row(fd, buf, FCELL_TYPE);
+}
+
+int Rast_put_d_raster_row(int fd, const DCELL * buf)
+{
+ return Rast_put_raster_row(fd, buf, DCELL_TYPE);
+}
+
+/*--------------------------------------------------------------------------*/
+
+static int check_open(const char *me, int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ switch (fcb->open_mode) {
+ case OPEN_OLD:
+ G_warning(_("%s: map [%s] not open for write - request ignored"), me,
+ fcb->name);
+ break;
+ case OPEN_NEW_COMPRESSED:
+ case OPEN_NEW_UNCOMPRESSED:
+ return 1;
+ break;
+ default:
+ G_warning(_("%s: unopened file descriptor - request ignored"), me);
+ break;
+ }
+
+ return 0;
+}
+
+static void write_error(int fd, int row)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ if (fcb->io_error)
+ return;
+
+ G_warning(_("map [%s] - unable to write row %d"), fcb->name, row);
+
+ fcb->io_error = 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static int write_data(int fd, int row, unsigned char *buf, int n)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ ssize_t nwrite = fcb->nbytes * n;
+
+ if (write(fd, buf, nwrite) != nwrite) {
+ write_error(fd, row);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int write_data_compressed(int fd, int row, unsigned char *buf, int n)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int nwrite = fcb->nbytes * n;
+
+ if (G_zlib_write(fd, buf, nwrite) < 0) {
+ write_error(fd, row);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static void set_file_pointer(int fd, int row)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ fcb->row_ptr[row] = lseek(fd, 0L, SEEK_CUR);
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static int convert_float(XDR * xdrs, char *null_buf, const FCELL * rast,
+ int row, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ FCELL f;
+
+ /* substitute embeded null vals by 0's */
+ if (Rast_is_f_null_value(&rast[i])) {
+ f = 0.;
+ null_buf[i] = 1;
+ }
+ else
+ f = rast[i];
+
+ if (!xdr_float(xdrs, &f)) {
+ G_warning(_("xdr_float failed for index %d of row %d"), i, row);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int convert_double(XDR * xdrs, char *null_buf, const DCELL * rast,
+ int row, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ DCELL d;
+
+ /* substitute embeded null vals by 0's */
+ if (Rast_is_d_null_value(&rast[i])) {
+ d = 0.;
+ null_buf[i] = 1;
+ }
+ else
+ d = rast[i];
+
+ if (!xdr_double(xdrs, &d)) {
+ G_warning(_("xdr_double failed for index %d of row %d"), i, row);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+
+/* writes data to fcell file for either full or partial rows */
+
+static int put_fp_data(int fd, char *null_buf, const void *rast,
+ int row, int n, RASTER_MAP_TYPE data_type)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int compressed = (fcb->open_mode == OPEN_NEW_COMPRESSED);
+ XDR *xdrs = &fcb->xdrstream;
+ char *work_buf;
+
+ if (row < 0 || row >= fcb->cellhd.rows)
+ return 0;
+
+ if (n <= 0)
+ return 0;
+
+ work_buf = G__alloca(G__.window.cols * fcb->nbytes + 1);
+
+ if (compressed)
+ set_file_pointer(fd, row);
+
+ xdrmem_create(xdrs, work_buf,
+ (unsigned int) fcb->nbytes * fcb->cellhd.cols, XDR_ENCODE);
+ xdr_setpos(xdrs, 0);
+
+ if (data_type == FCELL_TYPE) {
+ if (convert_float(xdrs, null_buf, rast, row, n) < 0) {
+ G__freea(work_buf);
+ return -1;
+ }
+ }
+ else {
+ if (convert_double(xdrs, null_buf, rast, row, n) < 0) {
+ G__freea(work_buf);
+ return -1;
+ }
+ }
+
+ xdr_destroy(&fcb->xdrstream);
+
+ if (compressed) {
+ if (write_data_compressed(fd, row, work_buf, n) == -1) {
+ G__freea(work_buf);
+ return -1;
+ }
+ }
+ else if (write_data(fd, row, work_buf, n) == -1) {
+ G__freea(work_buf);
+ return -1;
+ }
+
+ G__freea(work_buf);
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static void convert_int(unsigned char *wk, char *null_buf, const CELL * rast,
+ int n, int len, int zeros_r_nulls)
+{
+ int i;
+
+ /* transform CELL data into non-machine dependent multi-byte format */
+
+ for (i = 0; i < n; i++) {
+ CELL v = rast[i];
+ int neg;
+ int k;
+
+ /* substitute embeded null vals by 0's */
+ if (Rast_is_c_null_value(&v)) {
+ v = 0;
+ null_buf[i] = 1;
+ }
+ else if (zeros_r_nulls && !v)
+ null_buf[i] = 1;
+
+ /* negatives */
+ if (v < 0) {
+ neg = 1;
+ v = -v;
+ }
+ else
+ neg = 0;
+
+ /* copy byte by byte */
+ for (k = len - 1; k >= 0; k--) {
+ wk[k] = v & 0xff;
+ v >>= 8;
+ }
+
+ /* set negative bit in first byte */
+ if (neg)
+ wk[0] |= 0x80;
+
+ wk += len;
+ }
+}
+
+static int count_bytes(const unsigned char *wk, int n, int len)
+{
+ int i, j;
+
+ for (i = 0; i < len - 1; i++)
+ for (j = 0; j < n; j++)
+ if (wk[j * len + i] != 0)
+ return len - i;
+
+ return 1;
+}
+
+static void trim_bytes(unsigned char *wk, int n, int slen, int trim)
+{
+ unsigned char *wk2 = wk;
+ int i, j;
+
+ for (i = 0; i < n; i++) {
+ for (j = 0; j < trim; j++)
+ wk++;
+ for (; j < slen; j++)
+ *wk2++ = *wk++;
+ }
+}
+
+static int same(const unsigned char *x, const unsigned char *y, int n)
+{
+ return (memcmp(x, y, n) == 0);
+}
+
+static int count_run(const unsigned char *src, int n, int nbytes)
+{
+ const unsigned char *cur = src + nbytes;
+ int i;
+
+ for (i = 1; i < n; i++) {
+ if (i == 255 || !same(cur, src, nbytes))
+ return i;
+
+ cur += nbytes;
+ }
+
+ return n;
+}
+
+static int rle_compress(unsigned char *dst, unsigned char *src, int n,
+ int nbytes)
+{
+ int nwrite = 0;
+ int total = nbytes * n;
+
+ while (n > 0) {
+ int count;
+
+ nwrite += nbytes + 1;
+ if (nwrite >= total)
+ return 0;
+
+ count = count_run(src, n, nbytes);
+
+ *dst++ = count;
+ memcpy(dst, src, nbytes);
+ dst += nbytes;
+
+ src += count * nbytes;
+ n -= count;
+ }
+
+ return nwrite;
+}
+
+static int zlib_compress(unsigned char *dst, unsigned char *src, int n,
+ int nbytes)
+{
+ int total = nbytes * n;
+ int nwrite = G_zlib_compress(src, total, dst, total);
+
+ return (nwrite >= total) ? 0 : nwrite;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static int put_data(int fd, char *null_buf, const CELL *cell,
+ int row, int n, int zeros_r_nulls)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int compressed = fcb->cellhd.compressed;
+ int len = compressed ? sizeof(CELL) : fcb->nbytes;
+ unsigned char *work_buf, *wk;
+ ssize_t nwrite;
+
+ if (row < 0 || row >= fcb->cellhd.rows)
+ return 0;
+
+ if (n <= 0)
+ return 0;
+
+ work_buf = G__alloca(G__.window.cols * sizeof(CELL) + 1);
+ wk = work_buf;
+
+ if (compressed)
+ set_file_pointer(fd, row);
+
+ if (compressed)
+ wk++;
+
+ convert_int(wk, null_buf, cell, n, len, zeros_r_nulls);
+
+ if (compressed) {
+ unsigned char *wk = work_buf + 1;
+ int nbytes = count_bytes(wk, n, len);
+ unsigned char *compressed_buf;
+ int total;
+
+ if (fcb->nbytes < nbytes)
+ fcb->nbytes = nbytes;
+
+ /* first trim away zero high bytes */
+ if (nbytes < len)
+ trim_bytes(wk, n, len, len - nbytes);
+
+ total = nbytes * n;
+ compressed_buf = G__alloca(total + 1);
+
+ compressed_buf[0] = work_buf[0] = nbytes;
+
+ /* then compress the data */
+ nwrite = compressed == 1
+ ? rle_compress(compressed_buf + 1, work_buf + 1, n,
+ nbytes)
+ : zlib_compress(compressed_buf + 1, work_buf + 1, n,
+ nbytes);
+
+ if (nwrite > 0) {
+ nwrite++;
+
+ if (write(fd, compressed_buf, nwrite) != nwrite) {
+ write_error(fd, row);
+ G__freea(compressed_buf);
+ G__freea(work_buf);
+ return -1;
+ }
+ }
+ else {
+ nwrite = nbytes * n + 1;
+ if (write(fd, work_buf, nwrite) != nwrite) {
+ write_error(fd, row);
+ G__freea(compressed_buf);
+ G__freea(work_buf);
+ return -1;
+ }
+ }
+
+ G__freea(compressed_buf);
+ }
+ else {
+ nwrite = fcb->nbytes * n;
+
+ if (write(fd, work_buf, nwrite) != nwrite) {
+ write_error(fd, row);
+ G__freea(work_buf);
+ return -1;
+ }
+ }
+
+ G__freea(work_buf);
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+static int put_data_gdal(int fd, const void *rast, int row, int n,
+ int zeros_r_nulls, RASTER_MAP_TYPE map_type)
+{
+#ifdef HAVE_GDAL
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int size = Rast_raster_size(map_type);
+ DCELL null_val = fcb->gdal->null_val;
+ const void *src;
+ void *work_buf, *dst;
+ GDALDataType datatype;
+ CPLErr err;
+ int i;
+
+ if (row < 0 || row >= fcb->cellhd.rows)
+ return 0;
+
+ if (n <= 0)
+ return 0;
+
+ work_buf = G__alloca(n * size);
+
+ switch (map_type) {
+ case CELL_TYPE: datatype = GDT_Int32; break;
+ case FCELL_TYPE: datatype = GDT_Float32; break;
+ case DCELL_TYPE: datatype = GDT_Float64; break;
+ }
+
+ src = rast;
+ dst = work_buf;
+
+ for (i = 0; i < n; i++) {
+ if (Rast_is_null_value(src, map_type) || zeros_r_nulls && !*(CELL *)src)
+ Rast_set_raster_value_d(dst, null_val, map_type);
+ else
+ memcpy(dst, src, size);
+ src = Rast_incr_void_ptr(src, size);
+ dst = Rast_incr_void_ptr(dst, size);
+ }
+
+ err = G_gdal_raster_IO(fcb->gdal->band, GF_Write, 0, row, n, 1, work_buf,
+ n, 1, datatype, 0, 0);
+
+ G__freea(work_buf);
+
+ return err == CE_None ? 1 : -1;
+#else
+ return -1;
+#endif
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static int put_raster_data(int fd, char *null_buf, const void *rast,
+ int row, int n,
+ int zeros_r_nulls, RASTER_MAP_TYPE map_type)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+
+ if (fcb->gdal)
+ return put_data_gdal(fd, rast, row, n, zeros_r_nulls, map_type);
+
+ return (map_type == CELL_TYPE)
+ ? put_data(fd, null_buf, rast, row, n, zeros_r_nulls)
+ : put_fp_data(fd, null_buf, rast, row, n, map_type);
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static int put_null_data(int fd, const char *flags, int row)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int null_fd, i;
+
+ if (fcb->min_null_row + NULL_ROWS_INMEM <= row) {
+ /* the row is out of the range of rows stored in memory */
+ /* write out all the rows kept in memory, and initialize memory
+ for keeping new NULL_ROWS_INMEM rows */
+
+ if (fcb->min_null_row >= 0) {
+ null_fd = Rast__open_null_write(fd);
+ if (null_fd < 0)
+ return -1;
+
+ for (i = 0; i < NULL_ROWS_INMEM; i++) {
+ /* fcb->cellhd.rows doesn't have to be a miultiple of NULL_ROWS_INMEM */
+ if (i + fcb->min_null_row >= fcb->cellhd.rows)
+ break;
+
+ if (Rast__write_null_bits(null_fd, fcb->NULL_ROWS[i],
+ i + fcb->min_null_row,
+ fcb->cellhd.cols, fd) < 0)
+ return -1;
+
+ } /* done writing out memory rows */
+ if (null_fd >= 0)
+ close(null_fd);
+ }
+
+ /* now initialize memory to store new NULL_ROWS_INMEM rows */
+ fcb->min_null_row = fcb->min_null_row + NULL_ROWS_INMEM;
+ /* init memory to store next NULL_ROWS_INMEM rows */
+ }
+
+ /* remember the null row for i for the future writing */
+ Rast__convert_01_flags(flags, fcb->NULL_ROWS[row - fcb->min_null_row],
+ fcb->cellhd.cols);
+
+ return 1;
+}
+
+int Rast__open_null_write(int fd)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ int null_fd;
+
+ if (access(fcb->null_temp_name, 0) != 0) {
+ G_warning(_("unable to find a temporary null file %s"),
+ fcb->null_temp_name);
+ return -1;
+ }
+
+ null_fd = open(fcb->null_temp_name, O_WRONLY);
+ if (null_fd < 0)
+ return -1;
+
+ return null_fd;
+}
+
+int Rast__write_null_bits(int null_fd, const unsigned char *flags, int row,
+ int cols, int fd)
+{
+ off_t offset;
+ size_t size;
+
+ size = Rast__null_bitstream_size(cols);
+ offset = (off_t) size *row;
+
+ if (lseek(null_fd, offset, SEEK_SET) < 0) {
+ G_warning(_("error writing null row %d"), row);
+ return -1;
+ }
+
+ if (write(null_fd, flags, size) != size) {
+ G_warning(_("error writing null row %d"), row);
+ return -1;
+ }
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static int convert_and_write_if(int fd, const CELL * buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ FCELL *p = (FCELL *) fcb->data;
+ int i;
+
+ for (i = 0; i < fcb->cellhd.cols; i++)
+ if (Rast_is_c_null_value(&buf[i]))
+ Rast_set_f_null_value(&p[i], 1);
+ else
+ p[i] = (FCELL) buf[i];
+
+ return Rast_put_f_raster_row(fd, p);
+}
+
+static int convert_and_write_df(int fd, const DCELL * buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ FCELL *p = (FCELL *) fcb->data;
+ int i;
+
+ for (i = 0; i < fcb->cellhd.cols; i++)
+ if (Rast_is_d_null_value(&buf[i]))
+ Rast_set_f_null_value(&p[i], 1);
+ else
+ p[i] = (FCELL) buf[i];
+
+ return Rast_put_f_raster_row(fd, p);
+}
+
+static int convert_and_write_id(int fd, const CELL * buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ DCELL *p = (DCELL *) fcb->data;
+ int i;
+
+ for (i = 0; i < fcb->cellhd.cols; i++)
+ if (Rast_is_c_null_value(&buf[i]))
+ Rast_set_d_null_value(&p[i], 1);
+ else
+ p[i] = (DCELL) buf[i];
+
+ return Rast_put_d_raster_row(fd, p);
+}
+
+static int convert_and_write_fd(int fd, const FCELL * buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ DCELL *p = (DCELL *) fcb->data;
+ int i;
+
+ for (i = 0; i < fcb->cellhd.cols; i++)
+ if (Rast_is_f_null_value(&buf[i]))
+ Rast_set_d_null_value(&p[i], 1);
+ else
+ p[i] = (DCELL) buf[i];
+
+ return Rast_put_d_raster_row(fd, p);
+}
+
+static int convert_and_write_fi(int fd, const FCELL * buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ CELL *p = (CELL *) fcb->data;
+ int i;
+
+ for (i = 0; i < fcb->cellhd.cols; i++)
+ if (Rast_is_f_null_value(&buf[i]))
+ Rast_set_c_null_value(&p[i], 1);
+ else
+ p[i] = (CELL) buf[i];
+
+ return Rast_put_c_raster_row(fd, p);
+}
+
+static int convert_and_write_di(int fd, const DCELL * buf)
+{
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ CELL *p = (CELL *) fcb->data;
+ int i;
+
+ for (i = 0; i < fcb->cellhd.cols; i++)
+ if (Rast_is_d_null_value(&buf[i]))
+ Rast_set_c_null_value(&p[i], 1);
+ else
+ p[i] = (CELL) buf[i];
+
+ return Rast_put_c_raster_row(fd, p);
+}
+
+/*--------------------------------------------------------------------------*/
+
+static int put_raster_row(int fd, const void *buf, RASTER_MAP_TYPE data_type,
+ int zeros_r_nulls)
+{
+ static int (*convert_and_write_FtypeOtype[3][3])() = {
+ {NULL, convert_and_write_if, convert_and_write_id},
+ {convert_and_write_fi, NULL, convert_and_write_fd},
+ {convert_and_write_di, convert_and_write_df, NULL}
+ };
+ struct fileinfo *fcb = &G__.fileinfo[fd];
+ char *null_buf;
+ int stat;
+
+ if (!check_open("put_raster_row", fd))
+ return -1;
+
+ if (fcb->map_type != data_type)
+ return convert_and_write_FtypeOtype[data_type][fcb->map_type] (fd,
+ buf);
+
+ null_buf = G__alloca(fcb->cellhd.cols);
+ G_zero(null_buf, fcb->cellhd.cols);
+
+ switch (put_raster_data(
+ fd, null_buf, buf, fcb->cur_row, fcb->cellhd.cols,
+ zeros_r_nulls, data_type)) {
+ case -1:
+ G__freea(null_buf);
+ return -1;
+ case 0:
+ G__freea(null_buf);
+ return 1;
+ }
+
+ /* only for integer maps */
+ if (data_type == CELL_TYPE) {
+ if (fcb->want_histogram)
+ Rast_update_cell_stats(buf, fcb->cellhd.cols, &fcb->statf);
+ Rast__row_update_range(buf, fcb->cellhd.cols, &fcb->range,
+ zeros_r_nulls);
+ }
+ else
+ Rast_row_update_fp_range(buf, fcb->cellhd.cols, &fcb->fp_range,
+ data_type);
+
+ fcb->cur_row++;
+
+ /* write the null row for the data row */
+ if (fcb->gdal)
+ stat = 0;
+ else
+ stat = put_null_value_row(fd, null_buf);
+ G__freea(null_buf);
+ return stat;
+}
Copied: grass/trunk/lib/raster/put_title.c (from rev 37989, grass/trunk/lib/gis/put_title.c)
===================================================================
--- grass/trunk/lib/raster/put_title.c (rev 0)
+++ grass/trunk/lib/raster/put_title.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,81 @@
+
+/**************************************************************
+ * Rast_put_cell_title (name, title)
+ * char *name name of map file
+ * char *title new title
+ *
+ * changes the title for the cell file 'name' in current mapset
+ *
+ * returns 1 if ok, -1 if error
+ *************************************************************/
+
+#include <string.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+int Rast_put_cell_title(const char *name, const char *title)
+{
+ const char *mapset;
+ FILE *in, *out;
+ char *tempfile;
+ int line;
+ char buf[1024];
+
+ mapset = G_mapset();
+ in = out = 0;
+ in = G_fopen_old("cats", name, mapset);
+ if (!in) {
+ G_warning (_("category information for [%s] in [%s]"
+ " missing or invalid"),
+ name, mapset);
+ return -1;
+ }
+
+ tempfile = G_tempfile();
+ out = fopen(tempfile, "w");
+ if (!out) {
+ fclose(in);
+ G_warning (_("G_put_title - can't create a temp file"));
+ return -1;
+ }
+
+ for (line = 0; G_getl(buf, sizeof buf, in); line++) {
+ if (line == 1) {
+ strcpy(buf, title);
+ G_strip(buf);
+ }
+ fprintf(out, "%s\n", buf);
+ }
+ fclose(in);
+ fclose(out);
+
+ /* must be #cats line, title line, and label for cat 0 */
+ if (line < 3) {
+ G_warning (_("category information for [%s] in [%s] invalid"),
+ name, mapset);
+ return -1;
+ }
+
+ in = fopen(tempfile, "r");
+ if (!in) {
+ G_warning (_("G_put_title - can't reopen temp file"));
+ return -1;
+ }
+
+ out = G_fopen_new("cats", name);
+ if (!out) {
+ fclose(in);
+ G_warning (_("can't write category information for [%s] in [%s]"),
+ name, mapset);
+ return -1;
+ }
+
+ while (fgets(buf, sizeof buf, in))
+ fprintf(out, "%s", buf);
+
+ fclose(in);
+ fclose(out);
+ remove(tempfile);
+
+ return 1;
+}
Copied: grass/trunk/lib/raster/quant.c (from rev 37989, grass/trunk/lib/gis/quant.c)
===================================================================
--- grass/trunk/lib/raster/quant.c (rev 0)
+++ grass/trunk/lib/raster/quant.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,792 @@
+/*!
+ * \file gis/quant.c
+ *
+ * \brief GIS Library - Quantization rules.
+ *
+ * The quantization table is stored as a linear array. rules are added
+ * starting from index 0. redundant rules are not eliminated. rules
+ * are tested from the highest index downto 0. there are two
+ * "infinite" rules. support is provided to reverse the order of the
+ * rules.
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#include <stdlib.h>
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+static int double_comp(const void *, const void *);
+
+#define USE_LOOKUP 1
+#define MAX_LOOKUP_TABLE_SIZE 2048
+#define NO_DATA (Rast_set_c_null_value (&tmp, 1), (CELL) tmp)
+
+#undef MIN
+#undef MAX
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+#define NO_LEFT_INFINITE_RULE (! q->infiniteLeftSet)
+#define NO_RIGHT_INFINITE_RULE (! q->infiniteRightSet)
+#define NO_FINITE_RULE (q->nofRules <= 0)
+#define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
+ NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
+
+/*!
+ \brief Resets the number of defined rules and number of infinite rules to 0
+
+ \param q pointer to Quant structure to be reset
+*/
+void Rast_quant_clear(struct Quant *q)
+{
+ q->nofRules = 0;
+ q->infiniteRightSet = q->infiniteLeftSet = 0;
+}
+
+/*!
+ \brief Resets and frees allocated memory
+
+ Resets the number of defined rules to 0 and free's space allocated
+ for rules. Calls Rast_quant_clear().
+
+ \param q pointer to Quant structure to be reset
+*/
+void Rast_quant_free(struct Quant *q)
+{
+ Rast_quant_clear(q);
+
+ if (q->maxNofRules > 0)
+ G_free(q->table);
+ if (q->fp_lookup.active) {
+ G_free(q->fp_lookup.vals);
+ G_free(q->fp_lookup.rules);
+ q->fp_lookup.nalloc = 0;
+ q->fp_lookup.active = 0;
+ }
+ q->maxNofRules = 0;
+}
+
+/*!
+ * \brief Organized fp_lookup table.
+ *
+ * Organizes fp_lookup table for faster (logarithmic) lookup time
+ * G_quant_organize_fp_lookup() creates a list of min and max for
+ * each quant rule, sorts this list, and stores the pointer to quant
+ * rule that should be used inbetween any 2 numbers in this list.
+ * Also it stores extreme points for 2 infinite rules, if exist.
+ * After the call to G_quant_organize_fp_lookup()
+ * instead of linearly searching through list of rules to find
+ * a rule to apply, quant lookup will perform a binary search
+ * to find an interval containing floating point value, and then use
+ * the rule associated with this interval.
+ * when the value doesn't fall within any interval, check for the
+ * infinite rules.
+ *
+ * \param q pointer to Quant structure which holds quant rules info
+ *
+ * \return 1 on success
+ */
+int Rast__quant_organize_fp_lookup(struct Quant *q)
+{
+ int i;
+ DCELL val;
+ CELL tmp;
+ struct Quant_table *p;
+
+ if (q->nofRules * 2 > MAX_LOOKUP_TABLE_SIZE)
+ return -1;
+ if (q->nofRules == 0)
+ return -1;
+ q->fp_lookup.vals = (DCELL *)
+ G_calloc(q->nofRules * 2, sizeof(DCELL));
+ /* 2 endpoints for each rule */
+ q->fp_lookup.rules = (struct Quant_table **)
+ G_calloc(q->nofRules * 2, sizeof(struct Quant_table *));
+
+ /* first we organize finite rules into a table */
+ if (!NO_FINITE_RULE) {
+ i = 0;
+ /* get the list of DCELL values from set of all dLows and dHighs
+ of all rules */
+ /* NOTE: if dLow==DHigh in a rule, the value appears twice in a list
+ but if dLow==DHigh of the previous, rule the value appears only once */
+
+ for (p = &(q->table[q->nofRules - 1]); p >= q->table; p--) {
+ /* check if the min is the same as previous maximum */
+ if (i == 0 || p->dLow != q->fp_lookup.vals[i - 1])
+ q->fp_lookup.vals[i++] = p->dLow;
+ q->fp_lookup.vals[i++] = p->dHigh;
+ }
+ q->fp_lookup.nalloc = i;
+
+ /* now sort the values */
+ qsort((char *)q->fp_lookup.vals, q->fp_lookup.nalloc,
+ sizeof(DCELL), double_comp);
+
+ /* now find the rule to apply inbetween each 2 values in a list */
+ for (i = 0; i < q->fp_lookup.nalloc - 1; i++) {
+ /*debug
+ fprintf (stderr, "%lf %lf ", q->fp_lookup.vals[i], q->fp_lookup.vals[i+1]);
+ */
+ val = (q->fp_lookup.vals[i] + q->fp_lookup.vals[i + 1]) / 2.;
+ q->fp_lookup.rules[i] =
+ Rast__quant_get_rule_for_d_raster_val(q, val);
+ /* debug
+ if(q->fp_lookup.rules[i])
+ fprintf (stderr, "%lf %lf %d %d\n", q->fp_lookup.rules[i]->dLow, q->fp_lookup.rules[i]->dHigh, q->fp_lookup.rules[i]->cLow, q->fp_lookup.rules[i]->cHigh);
+ else fprintf (stderr, "null\n");
+ */
+
+ }
+ } /* organizing finite rules */
+
+ if (!NO_LEFT_INFINITE_RULE) {
+ q->fp_lookup.inf_dmin = q->infiniteDLeft;
+ q->fp_lookup.inf_min = q->infiniteCLeft;
+ }
+ else {
+ if (q->fp_lookup.nalloc)
+ q->fp_lookup.inf_dmin = q->fp_lookup.vals[0];
+ q->fp_lookup.inf_min = NO_DATA;
+ }
+
+ if (!NO_RIGHT_INFINITE_RULE) {
+ if (q->fp_lookup.nalloc)
+ q->fp_lookup.inf_dmax = q->infiniteDRight;
+ q->fp_lookup.inf_max = q->infiniteCRight;
+ }
+ else {
+ q->fp_lookup.inf_dmax = q->fp_lookup.vals[q->fp_lookup.nalloc - 1];
+ q->fp_lookup.inf_max = NO_DATA;
+ }
+ q->fp_lookup.active = 1;
+ return 1;
+}
+
+/*!
+ * \brief Initialize the structure
+ *
+ * Initializes the <i>q</i> struct.
+ *
+ * \param quant pointer to Quant structure to be initialized
+ */
+void Rast_quant_init(struct Quant *quant)
+{
+ quant->fp_lookup.active = 0;
+ quant->maxNofRules = 0;
+ quant->truncate_only = 0;
+ quant->round_only = 0;
+ Rast_quant_clear(quant);
+}
+
+/*!
+ \brief Returns wether or not quant rules are set to truncate map
+
+ \param quant pointer to Quant structure which holds quant rules info
+
+ \return 1 if truncate is enable
+ \return 0 if not truncated
+*/
+int Rast_quant_is_truncate(const struct Quant *quant)
+{
+ return quant->truncate_only;
+}
+
+/*!
+ \brief Returns wether or not quant rules are set to round map
+ \param quant pointer to Quant structure which holds quant rules info
+
+ \return 1 is round
+ \return 0 not round
+*/
+int Rast_quant_is_round(const struct Quant *quant)
+{
+ return quant->round_only;
+}
+
+/*!
+ * \brief Sets the quant rules to perform simple truncation on floats.
+ *
+ * Sets the quant for <i>q</i> rules to perform simple truncation on
+ * floats.
+ *
+ * \param quant pointer to Quant structure which holds quant rules info
+ */
+void Rast_quant_truncate(struct Quant *quant)
+{
+ quant->truncate_only = 1;
+}
+
+/*!
+ * \brief Sets the quant rules to perform simple rounding on floats.
+ *
+ * Sets the quant for <i>q</i> rules to perform simple rounding on
+ * floats.
+ *
+ * \param quant pointer to Quant structure which holds quant rules info
+ */
+void Rast_quant_round(struct Quant *quant)
+{
+ quant->round_only = 1;
+}
+
+static void quant_set_limits(struct Quant *q,
+ DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
+{
+ q->dMin = dLow;
+ q->dMax = dHigh;
+ q->cMin = cLow;
+ q->cMax = cHigh;
+}
+
+static void quant_update_limits(struct Quant *q,
+ DCELL dLow, DCELL dHigh,
+ CELL cLow, DCELL cHigh)
+{
+ if (NO_EXPLICIT_RULE) {
+ quant_set_limits(q, dLow, dHigh, cLow, cHigh);
+ return;
+ }
+
+ q->dMin = MIN(q->dMin, MIN(dLow, dHigh));
+ q->dMax = MAX(q->dMax, MAX(dLow, dHigh));
+ q->cMin = MIN(q->cMin, MIN(cLow, cHigh));
+ q->cMax = MAX(q->cMax, MAX(cLow, cHigh));
+}
+
+/*!
+ * \brief Returns the minimum and maximum cell and dcell values of all
+ * the ranges defined.
+ *
+ * Extracts the minimum and maximum floating-point and integer values
+ * from all the rules (except the "infinite" rules) in <i>q</i> into
+ * <i>dmin</i>, <i>dmax</i>, <i>cmin</i>, and <i>cmax</i>.
+ *
+ * \param quant pointer to Quant structure which holds quant rules info
+ * \param[out] dmin minimum fp value
+ * \param[out] dmax maximum fp value
+ * \param[out] cmin minimum value
+ * \param[out] cmax maximum value
+ *
+ * \return -1 if q->truncate or q->round are true or after
+ * Rast_quant_init (), or any call to Rast_quant_clear () or Rast_quant_free()
+ * no explicit rules have been added. In this case the returned
+ * minimum and maximum CELL and DCELL values are null.
+ * \return 1 if there are any explicit rules
+ * \return 0 if there are no explicit rules (this includes cases when
+ * q is set to truncate or round map), and sets <i>dmin</i>,
+ * <i>dmax</i>, <i>cmin</i>, and <i>cmax</i> to NULL.
+ */
+int Rast_quant_get_limits(const struct Quant *q,
+ DCELL * dMin, DCELL * dMax, CELL * cMin, CELL * cMax)
+{
+ if (NO_EXPLICIT_RULE) {
+ Rast_set_c_null_value(cMin, 1);
+ Rast_set_c_null_value(cMax, 1);
+ Rast_set_d_null_value(dMin, 1);
+ Rast_set_d_null_value(dMax, 1);
+ return -1;
+ }
+
+ *dMin = q->dMin;
+ *dMax = q->dMax;
+ *cMin = q->cMin;
+ *cMax = q->cMax;
+
+ return 1;
+}
+
+/*!
+ \brief Returns the number of quantization rules defined.
+
+ This number does not include the 2 infinite intervals.
+
+ \param q pointer to Quant structure which holds quant rules info
+
+ \return number of quantization rules
+*/
+int Rast_quant_nof_rules(const struct Quant *q)
+{
+ return q->nofRules;
+}
+
+/*!
+ \brief Returns the i'th quantization rule.
+
+ For 0 <= i < Rast_quant_nof_rules(). A larger value for i means that
+ the rule has been added later.
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param i index
+ \param[out] dLow minimum fp value
+ \param[out] dHigh maximum fp value
+ \param[out] cLow minimum value
+ \param[out] cHigh maximum value
+*/
+void Rast_quant_get_ith_rule(const struct Quant *q,
+ int i,
+ DCELL * dLow, DCELL * dHigh,
+ CELL * cLow, CELL * cHigh)
+{
+ *dLow = q->table[i].dLow;
+ *dHigh = q->table[i].dHigh;
+ *cLow = q->table[i].cLow;
+ *cHigh = q->table[i].cHigh;
+}
+
+static void quant_table_increase(struct Quant *q)
+{
+ if (q->nofRules < q->maxNofRules)
+ return;
+
+ if (q->maxNofRules == 0) {
+ q->maxNofRules = 50;
+ q->table = (struct Quant_table *)
+ G_malloc(q->maxNofRules * sizeof(struct Quant_table));
+ }
+ else {
+ q->maxNofRules += 50;
+ q->table = (struct Quant_table *)
+ G_realloc((char *)q->table,
+ q->maxNofRules * sizeof(struct Quant_table));
+ }
+}
+
+/*!
+ \brief Defines a rule for values "dLeft" and smaller.
+
+ Values in this range are mapped to "c" if none of the "finite"
+ quantization rules applies.
+
+ \param q pointer to Quant structure which holds quant rules info
+
+ \param dLeft fp value
+ \param c value
+*/
+void Rast_quant_set_neg_infinite_rule(struct Quant *q, DCELL dLeft, CELL c)
+{
+ q->infiniteDLeft = dLeft;
+ q->infiniteCLeft = c;
+ quant_update_limits(q, dLeft, dLeft, c, c);
+
+ /* update lookup table */
+ if (q->fp_lookup.active) {
+ q->fp_lookup.inf_dmin = q->infiniteDLeft;
+ q->fp_lookup.inf_min = q->infiniteCLeft;
+ }
+ q->infiniteLeftSet = 1;
+}
+
+/*!
+ \brief Returns in "dLeft" and "c" the rule values.
+
+ For the negative infinite interval (see Rast_quant_set_neg_infinite_rule()).
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param[out] dLeft fp value
+ \param[out] c value
+
+ \return 0 if this rule is not defined
+ \return 1 otherwise
+*/
+int Rast_quant_get_neg_infinite_rule(const struct Quant *q,
+ DCELL * dLeft, CELL * c)
+{
+ if (q->infiniteLeftSet == 0)
+ return 0;
+
+ *dLeft = q->infiniteDLeft;
+ *c = q->infiniteCLeft;
+
+ return 1;
+}
+
+/*!
+ \brief Defines a rule for values "dRight" and larger.
+
+ Values in this range are mapped to "c" if none of the "finite"
+ quantization rules or the negative infinite rule applies.
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param dRight fp value
+ \param c value
+*/
+void Rast_quant_set_pos_infinite_rule(struct Quant *q, DCELL dRight, CELL c)
+{
+ q->infiniteDRight = dRight;
+ q->infiniteCRight = c;
+ quant_update_limits(q, dRight, dRight, c, c);
+
+ /* update lookup table */
+ if (q->fp_lookup.active) {
+ q->fp_lookup.inf_dmax = q->infiniteDRight;
+ q->fp_lookup.inf_max = q->infiniteCRight;
+ }
+ q->infiniteRightSet = 1;
+}
+
+/*!
+ \brief Returns in "dRight" and "c" the rule values.
+
+ For the positive infinite interval (see Rast_quant_set_pos_infinite_rule()).
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param[out] dRight fp value
+ \param[out] c value
+
+ \return 0 if this rule is not defined
+ \return 1 otherwise
+*/
+int Rast_quant_get_pos_infinite_rule(const struct Quant *q,
+ DCELL * dRight, CELL * c)
+{
+ if (q->infiniteRightSet == 0)
+ return 0;
+
+ *dRight = q->infiniteDRight;
+ *c = q->infiniteCRight;
+
+ return 1;
+}
+
+/*!
+ \brief Adds a new rule to the set of quantization rules.
+
+ If dLow < dHigh the rule will be stored with the low and high values
+ interchanged.
+
+ Note: currently no cleanup of rules is performed, i.e. redundant
+ rules are not removed. This can't be changed because Categories
+ structure HEAVILY depends of quant rules stored in exactly the same
+ order they are entered. So if the cleanup or rearrangement is done in
+ the future make a flag for add_rule wether or not to do it, then
+ quant will not set this flag.
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param dLow minimum fp value
+ \param dHigh maximum fp value
+ \param cLow minimum value
+ \param cHigh maximum value
+*/
+void Rast_quant_add_rule(struct Quant *q,
+ DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
+{
+ int i;
+ struct Quant_table *p;
+
+ quant_table_increase(q);
+
+ i = q->nofRules;
+
+ p = &(q->table[i]);
+ if (dHigh >= dLow) {
+ p->dLow = dLow;
+ p->dHigh = dHigh;
+ p->cLow = cLow;
+ p->cHigh = cHigh;
+ }
+ else {
+ p->dLow = dHigh;
+ p->dHigh = dLow;
+ p->cLow = cHigh;
+ p->cHigh = cLow;
+ }
+
+ /* destroy lookup table, it has to be rebuilt */
+ if (q->fp_lookup.active) {
+ G_free(q->fp_lookup.vals);
+ G_free(q->fp_lookup.rules);
+ q->fp_lookup.active = 0;
+ q->fp_lookup.nalloc = 0;
+ }
+
+ quant_update_limits(q, dLow, dHigh, cLow, cHigh);
+
+ q->nofRules++;
+}
+
+/*!
+ \brief Rreverses the order in which the qunatization rules are stored.
+
+ See also Rast_quant_get_ith_rule() and Rast_quant_perform_d()).
+
+ \param q pointer to Quant rules which holds quant rules info
+*/
+void Rast_quant_reverse_rule_order(struct Quant *q)
+{
+ struct Quant_table tmp;
+ struct Quant_table *pLeft, *pRight;
+
+ pLeft = q->table;
+ pRight = &(q->table[q->nofRules - 1]);
+
+ while (pLeft < pRight) {
+ tmp.dLow = pLeft->dLow;
+ tmp.dHigh = pLeft->dHigh;
+ tmp.cLow = pLeft->cLow;
+ tmp.cHigh = pLeft->cHigh;
+
+ pLeft->dLow = pRight->dLow;
+ pLeft->dHigh = pRight->dHigh;
+ pLeft->cLow = pRight->cLow;
+ pLeft->cHigh = pRight->cHigh;
+
+ pRight->dLow = tmp.dLow;
+ pRight->dHigh = tmp.dHigh;
+ pRight->cLow = tmp.cLow;
+ pRight->cHigh = tmp.cHigh;
+
+ pLeft++;
+ pRight--;
+ }
+}
+
+static CELL quant_interpolate(DCELL dLow, DCELL dHigh,
+ CELL cLow, CELL cHigh, DCELL dValue)
+{
+ if (cLow == cHigh)
+ return cLow;
+ if (dLow == dHigh)
+ return cLow;
+
+ return (CELL) ((dValue - dLow) / (dHigh - dLow) * (DCELL) (cHigh - cLow) +
+ (DCELL) cLow);
+}
+
+static int less_or_equal(double x, double y)
+{
+ if (x <= y)
+ return 1;
+ else
+ return 0;
+}
+
+static int less(double x, double y)
+{
+ if (x < y)
+ return 1;
+ else
+ return 0;
+}
+
+/*!
+ * \brief
+ *
+ *
+ * Returns a CELL category for the floating-point <i>value</i> based
+ * on the quantization rules in <i>q</i>. The first rule found that
+ * applies is used. The rules are searched in the reverse order they
+ * are added to <i>q</i>. If no rule is found, the <i>value</i>
+ * is first tested against the negative infinite rule, and finally
+ * against the positive infinite rule. If none of these rules apply,
+ * the NULL-value is returned.
+ *
+ * <b>Note:</b> See G_quant_organize_fp_lookup() for details on how
+ * the values are looked up from fp_lookup table when it is
+ * active. Right now fp_lookup is automatically organized during the
+ * first call to Rast_quant_get_cell_value().
+ *
+ * \param q pointer to Quant structure which holds quant rules info
+ * \param dcellValue fp cell value
+ *
+ * \return cell value (integer)
+ */
+CELL Rast_quant_get_cell_value(struct Quant * q, DCELL dcellVal)
+{
+ CELL tmp;
+ DCELL dtmp;
+ int try, min_ind, max_ind;
+ struct Quant_table *p;
+ int (*lower) ();
+
+ dtmp = dcellVal;
+ /* I know the functions which call me already check for null values,
+ but I am a public function, and can be called from outside */
+ if (Rast_is_d_null_value(&dtmp))
+ return NO_DATA;
+
+ if (q->truncate_only)
+ return (CELL) dtmp;
+
+ if (q->round_only) {
+ if (dcellVal > 0)
+ return (CELL) (dcellVal + .5);
+ return (CELL) (dcellVal - .5);
+ }
+
+ if (NO_EXPLICIT_RULE)
+ return NO_DATA;
+ if (NO_EXPLICIT_RULE)
+ return NO_DATA;
+
+ if (USE_LOOKUP &&
+ (q->fp_lookup.active || Rast__quant_organize_fp_lookup(q) > 0)) {
+ /* first check if values fall within range */
+ /* if value is below the range */
+ if (dcellVal < q->fp_lookup.vals[0]) {
+ if (dcellVal <= q->fp_lookup.inf_dmin)
+ return q->fp_lookup.inf_min;
+ else
+ return NO_DATA;
+ }
+ /* if value is below above range */
+ if (dcellVal > q->fp_lookup.vals[q->fp_lookup.nalloc - 1]) {
+ if (dcellVal >= q->fp_lookup.inf_dmax)
+ return q->fp_lookup.inf_max;
+ else
+ return NO_DATA;
+ }
+ /* make binary search to find which interval our value belongs to
+ and apply the rule for this interval */
+ try = (q->fp_lookup.nalloc - 1) / 2;
+ min_ind = 0;
+ max_ind = q->fp_lookup.nalloc - 2;
+ while (1) {
+ /* DEBUG
+ fprintf (stderr, "%d %d %d\n", min_ind, max_ind, try);
+ */
+ /* when the ruke for the interval is NULL, we exclude the end points.
+ when it exists, we include the end-points */
+ if (q->fp_lookup.rules[try])
+ lower = less;
+ else
+ lower = less_or_equal;
+
+ if (lower(q->fp_lookup.vals[try + 1], dcellVal)) { /* recurse to the second half */
+ min_ind = try + 1;
+ /* must be still < nalloc-1, since number is within the range */
+ try = (max_ind + min_ind) / 2;
+ continue;
+ }
+ if (lower(dcellVal, q->fp_lookup.vals[try])) { /* recurse to the second half */
+ max_ind = try - 1;
+ /* must be still >= 0, since number is within the range */
+ try = (max_ind + min_ind) / 2;
+ continue;
+ }
+ /* the value fits into the interval! */
+ p = q->fp_lookup.rules[try];
+ if (p)
+ return quant_interpolate(p->dLow, p->dHigh, p->cLow, p->cHigh,
+ dcellVal);
+ /* otherwise when finite rule for this interval doesn't exist */
+ else { /* first check if maybe infinite rule applies */
+ if (dcellVal <= q->fp_lookup.inf_dmin)
+ return q->fp_lookup.inf_min;
+ if (dcellVal >= q->fp_lookup.inf_dmax)
+ return q->fp_lookup.inf_max;
+ else
+ return NO_DATA;
+ }
+ } /* while */
+ } /* looking up in fp_lookup */
+
+ if (!NO_FINITE_RULE) {
+ p = Rast__quant_get_rule_for_d_raster_val(q, dcellVal);
+ if (!p)
+ return NO_DATA;
+ return quant_interpolate(p->dLow, p->dHigh, p->cLow, p->cHigh,
+ dcellVal);
+ }
+
+ if ((!NO_LEFT_INFINITE_RULE) && (dcellVal <= q->infiniteDLeft))
+ return q->infiniteCLeft;
+
+ if ((NO_RIGHT_INFINITE_RULE) || (dcellVal < q->infiniteDRight))
+ return NO_DATA;
+
+ return q->infiniteCRight;
+}
+
+/*!
+ \brief Returns in "cell" the quantized CELL values.
+
+ Returns in "cell" the quantized CELL values corresponding to the
+ DCELL values stored in "dcell". the number of elements quantized
+ is n. quantization is performed by repeated application of
+ Rast_quant_get_cell_value().
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param dcell pointer to fp cell values array
+ \param[out] cell pointer cell values array
+ \param n number of cells
+*/
+void Rast_quant_perform_d(struct Quant *q,
+ const DCELL * dcell, CELL * cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, dcell++)
+ if (!Rast_is_d_null_value(dcell))
+ *cell++ = Rast_quant_get_cell_value(q, *dcell);
+ else
+ Rast_set_c_null_value(cell++, 1);
+}
+
+/*!
+ \brief Same as Rast_quant_perform_d(), except the type.
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param fcell pointer to fp cell values array
+ \param[out] cell pointer cell values array
+ \param n number of cells
+*/
+void Rast_quant_perform_f(struct Quant *q,
+ const FCELL * fcell, CELL * cell, int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++, fcell++)
+ if (!Rast_is_f_null_value(fcell))
+ *cell++ = Rast_quant_get_cell_value(q, (DCELL) * fcell);
+ else
+ Rast_set_c_null_value(cell++, 1);
+}
+
+static int double_comp(const void *xx, const void *yy)
+{
+ const DCELL *x = xx;
+ const DCELL *y = yy;
+
+ if (Rast_is_d_null_value(x))
+ return 0;
+ if (*x < *y)
+ return -1;
+ else if (*x == *y)
+ return 0;
+ else
+ return 1;
+}
+
+/*!
+ \brief Returns quant rule which will be applied.
+
+ Returns quant rule which will be applied when looking up the integer
+ quant value for val (used when organizing fp_lookup).
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param val fp cell value
+
+ \return pointer to the Quant_table (color rule)
+ \return NULL otherwise
+*/
+struct Quant_table *Rast__quant_get_rule_for_d_raster_val(const struct Quant *q,
+ DCELL val)
+{
+ const struct Quant_table *p;
+
+ for (p = &(q->table[q->nofRules - 1]); p >= q->table; p--)
+ if ((val >= p->dLow) && (val <= p->dHigh))
+ break;
+ if (p >= q->table)
+ return (struct Quant_table *)p;
+ else
+ return (struct Quant_table *)NULL;
+}
Copied: grass/trunk/lib/raster/quant_io.c (from rev 37989, grass/trunk/lib/gis/quant_io.c)
===================================================================
--- grass/trunk/lib/raster/quant_io.c (rev 0)
+++ grass/trunk/lib/raster/quant_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,318 @@
+
+/**********************************************************************
+ *
+ * int
+ * Rast__quant_import (name, mapset, quant)
+ *
+ * char *name;
+ * char *mapset;
+ * struct Quant *quant;
+ *
+ * reads quantization rules for "name" in "mapset" and stores them
+ * in the quantization structure "quant". If the map is in another
+ * mapset, first checks for quant2 table for this map in current
+ * mapset.
+ *
+ * returns: -2 if raster map is of type integer.
+ * -1 if (! G__name_is_fully_qualified ()).
+ * 0 if quantization file does not exist, or the file is empty,
+ * 1 if non-empty quantization file exists.
+ * read.
+ *
+ * note: in the case of negative return value, the result of using the
+ * quantization structure is not defined.
+ * in case of return value 0, calls to Rast_quant_perform_d ()
+ * and Rast_quant_perform_f () return NO_DATA (see description of
+ * Rast_quant_perform_d () for more details). in case of
+ * return values 2 and 3, the explicit rule for quant is set:
+ * floating range is mapped to integer range.
+ *
+ * note: use Rast_quant_init () to allocate and initialize the quantization
+ * staructure quant before the first usage of G_quant_import ().
+ *
+ * note: this function uses Rast_quant_free () to clear all previously
+ * stored rules in quant.
+ *
+ **********************************************************************
+ *
+ * int
+ * Rast__quant_export (name, mapset, quant)
+ *
+ * char *name, *mapset;
+ * struct Quant *quant;
+ *
+ * writes the quantization rules stored in "quant" for "name" . if the
+ * mapset is the same as the current mapset, the quant file is created
+ * in cell_misc/name directory, otherwise it is created in quant2/mapset
+ * directory, much like writing colors for map in another mapset.
+ * The rules are written in decreasing order
+ * of priority (i.e. rules added earlier are written later).
+ *
+ * returns: -1 if (! G__name_is_fully_qualified) or file could not be
+ * opened.
+ * 1 otherwise.
+ *
+ * note: if no rules are defined an empty file is created.
+ *
+ **********************************************************************/
+
+/*--------------------------------------------------------------------------*/
+
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+/*--------------------------------------------------------------------------*/
+
+#define QUANT_FILE_NAME "f_quant"
+
+/*--------------------------------------------------------------------------*/
+
+static int quant_parse_file(FILE *, struct Quant *);
+
+#if 0
+static int
+/* redundant: integer range doesn't exist now: it is defined by
+ the quant rules */
+quant_load_range(struct Quant *quant, const char *name, const char *mapset)
+{
+ struct FPRange fprange;
+ struct Range range;
+ char buf[300];
+ DCELL dMin, dMax;
+ CELL min, max;
+
+ if (Rast_read_fp_range(name, mapset, &fprange) <= 0)
+ return 0;
+ Rast_get_fp_range_min_max(&fprange, &dMin, &dMax);
+ if (Rast_is_d_null_value(&dMin) || Rast_is_d_null_value(&dMax)) {
+ G_warning (_("The floating data range for %s@%s is empty"),
+ name, mapset);
+ return -3;
+ }
+
+ if (Rast_read_range(name, mapset, &range) < 0)
+ return 0;
+ Rast_get_range_min_max(&range, &min, &max);
+ if (Rast_is_c_null_value(&min) && Rast_is_c_null_value(&max)) {
+ G_warning (_("The integer data range for %s@%s is empty"),
+ name, mapset);
+ return -3;
+ }
+
+ Rast_quant_add_rule(quant, dMin, dMax, min, max);
+
+ return 1;
+}
+#endif
+
+/*--------------------------------------------------------------------------*/
+
+int Rast__quant_import(const char *name, const char *mapset, struct Quant *quant)
+{
+ char buf[1024];
+ char *err;
+ char xname[GNAME_MAX], xmapset[GMAPSET_MAX], element[GNAME_MAX + 7];
+ int parsStat;
+ FILE *fd;
+
+ Rast_quant_free(quant);
+
+ if (Rast_raster_map_type(name, mapset) == CELL_TYPE) {
+ G_warning (_("Rast__quant_import: attempt to open quantization"
+ " table for CELL_TYPE file [%s] in mapset {%s]"),
+ name, mapset);
+ return -2;
+ }
+
+ if (G__name_is_fully_qualified(name, xname, xmapset)) {
+ if (strcmp(xmapset, mapset) != 0)
+ return -1;
+ name = xname;
+ }
+
+ /* first check if quant2/mapset/name exists in the current mapset */
+ sprintf(element, "quant2/%s", mapset);
+ if ((fd = G_fopen_old(element, name, G_mapset()))) {
+ parsStat = quant_parse_file(fd, quant);
+ fclose(fd);
+ if (parsStat)
+ return 1;
+ sprintf(buf,
+ "quantization file in quant2 for [%s] in mapset [%s] is empty",
+ name, mapset);
+ }
+
+ /* now try reading regular : cell_misc/name/quant file */
+ if (!(fd = G_fopen_old_misc("cell_misc", QUANT_FILE_NAME, name, mapset))) {
+
+ /* int range doesn't exist anymore if (quant_load_range (quant, name, mapset)>0) return 3; */
+ err = "missing";
+
+ }
+ else {
+ parsStat = quant_parse_file(fd, quant);
+ fclose(fd);
+
+ if (parsStat)
+ return 1;
+ /* int range doesn't exist anymore if (quant_load_range (quant, name, mapset)>0) return 2; */
+
+ err = "empty";
+ }
+
+ G_warning (_("quantization file [%s] in mapset [%s] %s"),
+ name, mapset, err);
+
+ return 0;
+}
+
+/*--------------------------------------------------------------------------*/
+
+/* parse input lines with the following formats
+ *
+ * d_high:d_low:c_high:c_low
+ * d_high:d_low:c_val (i.e. c_high == c_low)
+ * *:d_val:c_val (interval [inf, d_val]) (**)
+ * d_val:*:c_val (interval [d_val, inf]) (**)
+ *
+ * all other lines are ignored
+ *
+ * (**) only the first appearances in the file are considered.
+ *
+ */
+
+/*--------------------------------------------------------------------------*/
+
+static int quant_parse_file(FILE * fd, struct Quant *quant)
+{
+ CELL cLow, cHigh;
+ DCELL dLow, dHigh;
+ char buf[1024];
+ int foundNegInf = 0, foundPosInf = 0;
+
+ while (fgets(buf, sizeof(buf), fd)) {
+ if (strncmp(buf, "truncate", 8) == 0) {
+ quant->truncate_only = 1;
+ return 1;
+ }
+ if (strncmp(buf, "round", 5) == 0) {
+ quant->round_only = 1;
+ return 1;
+ }
+ switch (sscanf(buf, "%lf:%lf:%d:%d", &dLow, &dHigh, &cLow, &cHigh)) {
+ case 3:
+ Rast_quant_add_rule(quant, dLow, dHigh, cLow, cLow);
+ break;
+ case 4:
+ Rast_quant_add_rule(quant, dLow, dHigh, cLow, cHigh);
+ break;
+ default:
+ switch (sscanf(buf, "*:%lf:%d", &dLow, &cLow)) {
+ case 2:
+ if (!foundNegInf) {
+ Rast_quant_set_neg_infinite_rule(quant, dLow, cLow);
+ foundNegInf = 1;
+ }
+ break;
+ default:
+ switch (sscanf(buf, "%lf:*:%d", &dLow, &cLow)) {
+ case 2:
+ if (!foundPosInf) {
+ Rast_quant_set_pos_infinite_rule(quant, dLow, cLow);
+ foundPosInf = 1;
+ }
+ break;
+ default:
+ continue; /* other lines are ignored */
+ }
+ }
+ }
+ }
+
+ if (Rast_quant_nof_rules(quant) > 0)
+ Rast_quant_reverse_rule_order(quant);
+
+ return ((Rast_quant_nof_rules(quant) > 0) ||
+ (Rast_quant_get_neg_infinite_rule(quant, &dLow, &cLow) > 0) ||
+ (Rast_quant_get_pos_infinite_rule(quant, &dLow, &cLow) > 0));
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+static void quant_write(FILE * fd, const struct Quant *quant)
+{
+ DCELL dLow, dHigh;
+ CELL cLow, cHigh;
+ int i;
+
+ if (quant->truncate_only) {
+ fprintf(fd, "truncate");
+ return;
+ }
+ if (quant->round_only) {
+ fprintf(fd, "round");
+ return;
+ }
+ if (Rast_quant_get_neg_infinite_rule(quant, &dLow, &cLow) > 0)
+ fprintf(fd, "*:%.20g:%d\n", dLow, cLow);
+
+ if (Rast_quant_get_pos_infinite_rule(quant, &dLow, &cLow) > 0)
+ fprintf(fd, "%.20g:*:%d\n", dLow, cLow);
+
+ for (i = Rast_quant_nof_rules(quant) - 1; i >= 0; i--) {
+ Rast_quant_get_ith_rule(quant, i, &dLow, &dHigh, &cLow, &cHigh);
+ fprintf(fd, "%.20g:%.20g:%d", dLow, dHigh, cLow);
+ if (cLow != cHigh)
+ fprintf(fd, ":%d", cHigh);
+ fprintf(fd, "\n");
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+int
+Rast__quant_export(const char *name, const char *mapset,
+ const struct Quant *quant)
+{
+ char element[GNAME_MAX + 7];
+ char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
+ FILE *fd;
+
+ if (G__name_is_fully_qualified(name, xname, xmapset)) {
+ if (strcmp(xmapset, mapset) != 0)
+ return -1;
+ name = xname;
+ }
+
+ if (strcmp(G_mapset(), mapset) == 0) {
+ G_remove_misc("cell_misc", QUANT_FILE_NAME, name);
+ G__make_mapset_element_misc("cell_misc", name);
+ if (!(fd = G_fopen_new_misc("cell_misc", QUANT_FILE_NAME, name)))
+ return -1;
+ }
+ else {
+ sprintf(element, "quant2/%s", mapset);
+ G_remove(element, name);
+ G__make_mapset_element(element);
+ if (!(fd = G_fopen_new(element, name)))
+ return -1;
+ }
+
+
+
+ quant_write(fd, quant);
+ fclose(fd);
+
+ return 1;
+}
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
Copied: grass/trunk/lib/raster/quant_rw.c (from rev 37989, grass/trunk/lib/gis/quant_rw.c)
===================================================================
--- grass/trunk/lib/raster/quant_rw.c (rev 0)
+++ grass/trunk/lib/raster/quant_rw.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,229 @@
+/*!
+ * \file gis/quant_rw.c
+ *
+ * \brief GIS Library - Quantization rules (read/write).
+ *
+ * (C) 1999-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ * \author USACERL and many others
+ */
+
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+/*!
+ \brief Writes the quant rules.
+
+ Writes the quant rules which indicate that all floating numbers
+ should be truncated instead of applying any quant rules from
+ floats to integers.
+
+ \param name map name
+ \param mapset mapset name
+
+ \return -1 on error
+ \return 1 on success
+*/
+int Rast_truncate_fp_map(const char *name, const char *mapset)
+{
+ struct Quant quant;
+
+ Rast_quant_init(&quant);
+ Rast_quant_truncate(&quant);
+ /* quantize the map */
+ if (Rast_write_quant(name, mapset, &quant) < 0) {
+ G_warning(_("Unable to write quant rules for raster map <%s>"),
+ name);
+ return -1;
+ }
+ return 1;
+}
+
+/*!
+ \brief Writes the quant rules.
+
+ Writes the quant rules which indicate that all floating numbers
+ should be rounded instead of applying any quant rules from
+ floats to integers.
+
+ \param name map name
+ \param mapset mapset name
+
+ \return -1 on error
+ \return 1 on success
+*/
+int Rast_round_fp_map(const char *name, const char *mapset)
+{
+ struct Quant quant;
+
+ Rast_quant_init(&quant);
+ Rast_quant_round(&quant);
+ /* round the map */
+ if (Rast_write_quant(name, mapset, &quant) < 0) {
+ G_warning(_("Unable to write quant rules for raster map <%s>"),
+ name);
+ return -1;
+ }
+ return 1;
+}
+
+/*!
+ * \brief Write quant rules (f_quant) for floating-point raster map.
+ *
+ * Writes the <tt>f_quant</tt> file for the raster map <em>name</em>
+ * with one rule. The rule is generated using the floating-point range
+ * in <tt>f_range</tt> producing the integer range
+ * [<em>cmin,cmax</em>].
+ *
+ * Make a rule for map <name> that maps floating range (d_min, d_max)
+ * into integer range (min, max)
+ * This function is useful when the quant rule doesn't depend of the
+ * range of produced float data, for example the slope map whould
+ * want to have a quant rule: 0.0, 90.0 -> 0 , 90
+ * no matter what the min and max slope of this map is.
+
+ * \param name map name
+ * \param mapset mapset name
+ * \param cmin minimum value
+ * \param cmax maximum value
+ *
+ * \return -1 on error
+ * \return 1 on success
+ */
+int Rast_quantize_fp_map(const char *name, const char *mapset,
+ CELL min, CELL max)
+{
+ DCELL d_min, d_max;
+ struct FPRange fp_range;
+
+ if (Rast_read_fp_range(name, mapset, &fp_range) < 0) {
+ G_warning(_("Unable to read fp range for raster map <%s>"),
+ G_fully_qualified_name(name, mapset));
+ return -1;
+ }
+ Rast_get_fp_range_min_max(&fp_range, &d_min, &d_max);
+ if (Rast_is_d_null_value(&d_min) || Rast_is_d_null_value(&d_max)) {
+ G_warning(_("Raster map <%s> is empty"),
+ G_fully_qualified_name(name, mapset));
+ return -1;
+ }
+ return Rast_quantize_fp_map_range(name, mapset, d_min, d_max, min, max);
+}
+
+/*!
+ * \brief Write quant rules (f_quant) for floating-point raster map.
+ *
+ * Writes the <tt>f_quant</tt> file for the raster map
+ * <em>name</em> with one rule. The rule is generated using the floating-point
+ * range [<em>dmin,dmax</em>] and the integer range
+ * [<em>min,max</em>].
+ * This routine differs from the one above in that the application controls the
+ * floating-point range. For example, r.slope.aspect will use this routine to
+ * quantize the slope map from [0.0, 90.0] to [0,
+ * 90] even if the range of slopes is not 0-90. The aspect map would be
+ * quantized from [0.0, 360.0] to [0, 360].
+ *
+ * Make a rule for map <name> that maps floating range (d_min, d_max)
+ * into integer range (min, max)
+ * This function is useful when the quant rule doesn't depend of the
+ * range of produced float data, for example the slope map whould
+ * want to have a quant rule: 0.0, 90.0 -> 0 , 90
+ * no matter what the min and max slope of this map is.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param d_min minimum fp value
+ * \param d_max maximum fp value
+ * \param min minimum value
+ * \param max maximum value
+ *
+ * \return -1 on error
+ * \return 1 on success
+ */
+int Rast_quantize_fp_map_range(const char *name, const char *mapset,
+ DCELL d_min, DCELL d_max, CELL min, CELL max)
+{
+ struct Quant quant;
+
+ Rast_quant_init(&quant);
+ Rast_quant_add_rule(&quant, d_min, d_max, min, max);
+ /* quantize the map */
+ if (Rast_write_quant(name, mapset, &quant) < 0) {
+ G_warning(_("Unable to write quant rules for raster map <%s>"),
+ name);
+ return -1;
+ }
+ return 1;
+}
+
+/*!
+ * \brief Writes the quant rule table for the raster map
+ *
+ * Writes the <tt>f_quant</tt> file for the raster map <em>name</em>
+ * from <em>q</em>. if mapset==G_mapset() i.e. the map is in current
+ * mapset, then the original quant file in cell_misc/map/f_quant is
+ * written. Otherwise <em>q</em> is written into quant2/mapset/name
+ * (much like colr2 element). This results in map at mapset being read
+ * using quant rules stored in <em>q</em> from G_mapset(). See
+ * Rast_read_quant() for detailes.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param quant pointer to Quant structure which hold quant rules info
+ *
+ * \return -1 on error
+ * \return 1 on success
+ */
+int Rast_write_quant(const char *name, const char *mapset,
+ const struct Quant *quant)
+{
+ CELL cell_min, cell_max;
+ DCELL d_min, d_max;
+
+ if (Rast_raster_map_type(name, mapset) == CELL_TYPE) {
+ G_warning(_("Unable to write quant rules: raster map <%s> is integer"),
+ name);
+ return -1;
+ }
+
+ Rast_quant_get_limits(quant, &d_min, &d_max, &cell_min, &cell_max);
+
+ /* first actually write the rules */
+ if (Rast__quant_export(name, mapset, quant) < 0) {
+ G_warning (_("Unable to write quant rules for raster map <%s>"),
+ name);
+ return -1;
+ }
+
+ return 1;
+}
+
+/*!
+ * \brief
+ *
+ * Reads quantization rules for <i>name</i> in <i>mapset</i> and
+ * stores them in the quantization structure. If the map is in another
+ * mapset, first checks for quant2 table for this map in current
+ * mapset.
+ * \param name
+ * \param mapset
+ * \param q
+ *
+ * \return -2 if raster map is of type integer
+ * \return -1 if (!G__name_is_fully_qualified())
+ * \return 0 if quantization file does not exist, or the file is empty or has wrong format
+ * \return 1 if non-empty quantization file exists
+ *
+ */
+int Rast_read_quant(const char *name, const char *mapset, struct Quant *quant)
+{
+ Rast_quant_init(quant);
+ return Rast__quant_import(name, mapset, quant);
+}
Copied: grass/trunk/lib/raster/range.c (from rev 37989, grass/trunk/lib/gis/range.c)
===================================================================
--- grass/trunk/lib/raster/range.c (rev 0)
+++ grass/trunk/lib/raster/range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,603 @@
+/*!
+ * \file gis/range.c
+ *
+ * \brief GIS Library - Raster range file management
+ *
+ * (C) 2001-2009 GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <unistd.h>
+#include <rpc/types.h> /* need this for sgi */
+#include <rpc/xdr.h>
+
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#include "G.h"
+
+#define DEFAULT_CELL_MIN 1
+#define DEFAULT_CELL_MAX 255
+
+/*!
+ \brief Remove floating-point range
+
+ Note: For internal use only.
+
+ \param name map name
+*/
+void Rast__remove_fp_range(const char *name)
+{
+ G_remove_misc("cell_misc", "f_range", name);
+}
+
+/*!
+ * \brief Construct default range
+ *
+ * Sets the integer range to [1,255]
+ *
+ * \param[out] r pointer to Range structure which holds range info
+ */
+void Rast_construct_default_range(struct Range *range)
+{
+ Rast_update_range(DEFAULT_CELL_MIN, range);
+ Rast_update_range(DEFAULT_CELL_MAX, range);
+}
+
+/*!
+ * \brief Read floating-point range
+ *
+ * Read the floating point range file <i>drange</i>. This file is
+ * written in binary using XDR format.
+ *
+ * An empty range file indicates that the min, max are undefined. This
+ * is a valid case, and the result should be an initialized range
+ * struct with no defined min/max. If the range file is missing and
+ * the map is a floating-point map, this function will create a
+ * default range by calling G_construct_default_range().
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param drange pointer to FPRange structure which holds fp range
+ *
+ * \return 1 on success
+ * \return 2 range is empty
+ * \return -1 on error
+ */
+int Rast_read_fp_range(const char *name, const char *mapset,
+ struct FPRange *drange)
+{
+ struct Range range;
+ int fd;
+ char xdr_buf[100];
+ DCELL dcell1, dcell2;
+ XDR xdr_str;
+
+ Rast_init_fp_range(drange);
+
+ if (Rast_raster_map_type(name, mapset) == CELL_TYPE) {
+ /* if map is integer
+ read integer range and convert it to double */
+
+ if (Rast_read_range(name, mapset, &range) >= 0) {
+ /* if the integer range is empty */
+ if (range.first_time)
+ return 2;
+
+ Rast_update_fp_range((DCELL) range.min, drange);
+ Rast_update_fp_range((DCELL) range.max, drange);
+ return 1;
+ }
+ return -1;
+ }
+
+ fd = -1;
+
+ if (G_find_file2_misc("cell_misc", "f_range", name, mapset)) {
+ fd = G_open_old_misc("cell_misc", "f_range", name, mapset);
+ if (fd < 0) {
+ G_warning(_("Unable to read fp range file for <%s@%s>"),
+ name, mapset);
+ return -1;
+ }
+
+ if (read(fd, xdr_buf, 2 * XDR_DOUBLE_NBYTES) != 2 * XDR_DOUBLE_NBYTES)
+ return 2;
+
+ xdrmem_create(&xdr_str, xdr_buf, (u_int) XDR_DOUBLE_NBYTES * 2,
+ XDR_DECODE);
+
+ /* if the f_range file exists, but empty */
+ if (!xdr_double(&xdr_str, &dcell1) || !xdr_double(&xdr_str, &dcell2)) {
+ if (fd)
+ close(fd);
+ G_warning(_("Unable to read fp range file for <%s@%s>"),
+ name, mapset);
+ return -1;
+ }
+
+ Rast_update_fp_range(dcell1, drange);
+ Rast_update_fp_range(dcell2, drange);
+ close(fd);
+ }
+
+ return 1;
+}
+
+/*!
+ * \brief Read raster range (CELL)
+ *
+ * This routine reads the range information for the raster map
+ * <i>name</i> in <i>mapset</i> into the <i>range</i> structure.
+ *
+ * A diagnostic message is printed and -1 is returned if there is an error
+ * reading the range file. Otherwise, 0 is returned.
+ *
+ * Old range file (those with 4 numbers) should treat zeros in this
+ * file as NULL-values. New range files (those with just 2 numbers)
+ * should treat these numbers as real data (zeros are real data in
+ * this case). An empty range file indicates that the min, max are
+ * undefined. This is a valid case, and the result should be an
+ * initialized range struct with no defined min/max. If the range file
+ * is missing and the map is a floating-point map, this function will
+ * create a default range by calling G_construct_default_range().
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param range pointer to Range structure which holds range info
+ *
+ * \return -1 on error
+ * \return 1 on success
+ * \return 2 if range is empty
+ * \return 3 if raster map is floating-point, get range from quant rules
+ */
+int Rast_read_range(const char *name, const char *mapset, struct Range *range)
+{
+ FILE *fd;
+ CELL x[4];
+ char buf[200];
+ int n, count;
+ struct Quant quant;
+ struct FPRange drange;
+
+ Rast_init_range(range);
+ fd = NULL;
+
+ /* if map is not integer, read quant rules, and get limits */
+ if (Rast_raster_map_type(name, mapset) != CELL_TYPE) {
+ DCELL dmin, dmax;
+
+ if (Rast_read_quant(name, mapset, &quant) < 0) {
+ G_warning(_("Unable to read quant rules for raster map <%s@%s>"),
+ name, mapset);
+ return -1;
+ }
+ if (Rast_quant_is_truncate(&quant) || Rast_quant_is_round(&quant)) {
+ if (Rast_read_fp_range(name, mapset, &drange) >= 0) {
+ Rast_get_fp_range_min_max(&drange, &dmin, &dmax);
+ if (Rast_quant_is_truncate(&quant)) {
+ x[0] = (CELL) dmin;
+ x[1] = (CELL) dmax;
+ }
+ else { /* round */
+
+ if (dmin > 0)
+ x[0] = (CELL) (dmin + .5);
+ else
+ x[0] = (CELL) (dmin - .5);
+ if (dmax > 0)
+ x[1] = (CELL) (dmax + .5);
+ else
+ x[1] = (CELL) (dmax - .5);
+ }
+ }
+ else
+ return -1;
+ }
+ else
+ Rast_quant_get_limits(&quant, &dmin, &dmax, &x[0], &x[1]);
+
+ Rast_update_range(x[0], range);
+ Rast_update_range(x[1], range);
+ return 3;
+ }
+
+ if (G_find_file2_misc("cell_misc", "range", name, mapset)) {
+ fd = G_fopen_old_misc("cell_misc", "range", name, mapset);
+ if (!fd) {
+ G_warning(_("Unable to read range file for <%s@%s>"),
+ name, mapset);
+ return -1;
+ }
+
+ /* if range file exists but empty */
+ if (!fgets(buf, sizeof buf, fd))
+ return 2;
+
+ x[0] = x[1] = x[2] = x[3] = 0;
+ count = sscanf(buf, "%d%d%d%d", &x[0], &x[1], &x[2], &x[3]);
+
+ /* if wrong format */
+ if (count <= 0) {
+ if (fd)
+ fclose(fd);
+
+ G_warning(_("Unable to read range file for <%s@%s>"),
+ name, mapset);
+ return -1;
+ }
+
+ for (n = 0; n < count; n++) {
+ /* if count==4, the range file is old (4.1) and 0's in it
+ have to be ignored */
+ if (count < 4 || x[n])
+ Rast_update_range((CELL) x[n], range);
+ }
+ fclose(fd);
+ }
+
+ return 1;
+}
+
+/*!
+ * \brief Write raster range file
+ *
+ * This routine writes the range information for the raster map
+ * <i>name</i> in the current mapset from the <i>range</i> structure.
+ * A diagnostic message is printed and -1 is returned if there is an
+ * error writing the range file. Otherwise, 0 is returned.
+ *
+ * This routine only writes 2 numbers (min,max) to the range
+ * file, instead of the 4 (pmin,pmax,nmin,nmax) previously written.
+ * If there is no defined min,max, an empty file is written.
+ *
+ * \param name map name
+ * \param range pointer to Range structure which holds range info
+ *
+ * \return -1 on error (or raster map is floating-point)
+ * \return 0 on success
+ */
+int Rast_write_range(const char *name, const struct Range *range)
+{
+ FILE *fd;
+
+ if (Rast_raster_map_type(name, G_mapset()) != CELL_TYPE) {
+ G_remove_misc("cell_misc", "range", name); /* remove the old file with this name */
+ G_warning(_("Unable to write range file for <%s>"),
+ name);
+ return -1;
+ }
+
+ fd = G_fopen_new_misc("cell_misc", "range", name);
+ if (!fd) {
+ G_remove_misc("cell_misc", "range", name); /* remove the old file with this name */
+ G_warning(_("Unable to write range file for <%s>"),
+ name);
+ return -1;
+ }
+
+ /* if range hasn't been updated */
+ if (range->first_time) {
+ fclose(fd);
+ return 0;
+ }
+
+ fprintf(fd, "%ld %ld\n", (long)range->min, (long)range->max);
+ fclose(fd);
+
+ return 0;
+}
+
+/*!
+ * \brief Write raster range file (floating-point)
+ *
+ * Write the floating point range file <tt>f_range</tt>. This file is
+ * written in binary using XDR format. If there is no defined min/max
+ * in <em>range</em>, an empty <tt>f_range</tt> file is created.
+ *
+ * \param name map name
+ * \param range pointer to FPRange which holds fp range info
+ *
+ * \return 0 on success
+ * \return -1 on error
+ */
+int Rast_write_fp_range(const char *name, const struct FPRange *range)
+{
+ int fd;
+ char xdr_buf[100];
+ XDR xdr_str;
+
+ fd = G_open_new_misc("cell_misc", "f_range", name);
+ if (fd < 0) {
+ G_remove_misc("cell_misc", "f_range", name);
+ G_warning(_("Unable to write range file for <%s>"),
+ name);
+ return -1;
+ }
+
+ /* if range hasn't been updated, write empty file meaning Nulls */
+ if (range->first_time) {
+ close(fd);
+ return 0;
+ }
+
+ xdrmem_create(&xdr_str, xdr_buf, (u_int) XDR_DOUBLE_NBYTES * 2,
+ XDR_ENCODE);
+
+ if (!xdr_double(&xdr_str, (double *)&(range->min))) {
+ G_remove_misc("cell_misc", "f_range", name);
+ G_warning(_("Unable to write range file for <%s>"),
+ name);
+ return -1;
+ }
+
+ if (!xdr_double(&xdr_str, (double *)&(range->max))) {
+ G_remove_misc("cell_misc", "f_range", name);
+ G_warning(_("Unable to write range file for <%s>"),
+ name);
+ return -1;
+ }
+
+ write(fd, xdr_buf, XDR_DOUBLE_NBYTES * 2);
+ close(fd);
+
+ return 0;
+}
+
+/*!
+ * \brief Update range structure (CELL)
+ *
+ * Compares the <i>cat</i> value with the minimum and maximum values
+ * in the <i>range</i> structure, modifying the range if <i>cat</i>
+ * extends the range.
+ *
+ * NULL-values must be detected and ignored.
+ *
+ * \param cat raster value
+ * \param range pointer to Range structure which holds range info
+ */
+void Rast_update_range(CELL cat, struct Range *range)
+{
+ if (!Rast_is_c_null_value(&cat)) {
+ if (range->first_time) {
+ range->first_time = 0;
+ range->min = cat;
+ range->max = cat;
+ return;
+ }
+ if (cat < range->min)
+ range->min = cat;
+ if (cat > range->max)
+ range->max = cat;
+ }
+}
+
+/*!
+ * \brief Update range structure (floating-point)
+ *
+ * Compares the <i>cat</i> value with the minimum and maximum values
+ * in the <i>range</i> structure, modifying the range if <i>cat</i>
+ * extends the range.
+ *
+ * NULL-values must be detected and ignored.
+ *
+ * \param val raster value
+ * \param range pointer to Range structure which holds range info
+ */
+void Rast_update_fp_range(DCELL val, struct FPRange *range)
+{
+ if (!Rast_is_d_null_value(&val)) {
+ if (range->first_time) {
+ range->first_time = 0;
+ range->min = val;
+ range->max = val;
+ return;
+ }
+ if (val < range->min)
+ range->min = val;
+ if (val > range->max)
+ range->max = val;
+ }
+}
+
+/*!
+ * \brief Update range structure based on raster row (CELL)
+ *
+ * This routine updates the <i>range</i> data just like
+ * Rast_update_range(), but for <i>n</i> values from the <i>cell</i>
+ * array.
+ *
+ * \param cell raster values
+ * \param n number of values
+ * \param range pointer to Range structure which holds range info
+ */
+void Rast_row_update_range(const CELL *cell, int n, struct Range *range)
+{
+ Rast__row_update_range(cell, n, range, 0);
+}
+
+/*!
+ * \brief Update range structure based on raster row
+ *
+ * Note: for internal use only.
+ *
+ * \param cell raster values
+ * \param n number of values
+ * \param range pointer to Range structure which holds range info
+ * \param ignore_zeros ignore zeros
+ */
+void Rast__row_update_range(const CELL *cell, int n,
+ struct Range *range, int ignore_zeros)
+{
+ CELL cat;
+
+ while (n-- > 0) {
+ cat = *cell++;
+ if (Rast_is_c_null_value(&cat) || (ignore_zeros && !cat))
+ continue;
+ if (range->first_time) {
+ range->first_time = 0;
+ range->min = cat;
+ range->max = cat;
+ continue;
+ }
+ if (cat < range->min)
+ range->min = cat;
+ if (cat > range->max)
+ range->max = cat;
+ }
+}
+
+/*!
+ * \brief Update range structure based on raster row (floating-point)
+ *
+ * This routine updates the <i>range</i> data just like
+ * Rast_update_range(), but for <i>n</i> values from the <i>cell</i>
+ * array.
+ *
+ * \param cell raster values
+ * \param n number of values
+ * \param range pointer to Range structure which holds range info
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast_row_update_fp_range(const void *rast, int n,
+ struct FPRange *range, RASTER_MAP_TYPE data_type)
+{
+ DCELL val = 0L;
+
+ while (n-- > 0) {
+ switch (data_type) {
+ case CELL_TYPE:
+ val = (DCELL) * ((CELL *) rast);
+ break;
+ case FCELL_TYPE:
+ val = (DCELL) * ((FCELL *) rast);
+ break;
+ case DCELL_TYPE:
+ val = *((DCELL *) rast);
+ break;
+ }
+
+ if (Rast_is_null_value(rast, data_type)) {
+ rast = Rast_incr_void_ptr(rast, Rast_raster_size(data_type));
+ continue;
+ }
+ if (range->first_time) {
+ range->first_time = 0;
+ range->min = val;
+ range->max = val;
+ }
+ else {
+ if (val < range->min)
+ range->min = val;
+ if (val > range->max)
+ range->max = val;
+ }
+
+ rast = Rast_incr_void_ptr(rast, Rast_raster_size(data_type));
+ }
+}
+
+/*!
+ * \brief Initialize range structure
+ *
+ * Initializes the <i>range</i> structure for updates by
+ * Rast_update_range() and Rast_row_update_range().
+ *
+ * Must set a flag in the range structure that indicates that no
+ * min/max have been defined - probably a <tt>"first"</tt> boolean
+ * flag.
+ *
+ * \param range pointer to Range structure which holds range info
+ */
+void Rast_init_range(struct Range *range)
+{
+ Rast_set_c_null_value(&(range->min), 1);
+ Rast_set_c_null_value(&(range->max), 1);
+ range->first_time = 1;
+}
+
+/*!
+ * \brief Get range min and max
+ *
+ * The mininum and maximum CELL values are extracted from the
+ * <i>range</i> structure.
+ *
+ * If the range structure has no defined min/max (first!=0) there will
+ * not be a valid range. In this case the min and max returned must be
+ * the NULL-value.
+ *
+ * \param range pointer to Range structure which holds range info
+ * \param[out] min minimum value
+ * \param[out] max maximum value
+ */
+void Rast_get_range_min_max(const struct Range *range, CELL * min, CELL * max)
+{
+ if (range->first_time) {
+ Rast_set_c_null_value(min, 1);
+ Rast_set_c_null_value(max, 1);
+ }
+ else {
+ if (Rast_is_c_null_value(&(range->min)))
+ Rast_set_c_null_value(min, 1);
+ else
+ *min = range->min;
+
+ if (Rast_is_c_null_value(&(range->max)))
+ Rast_set_c_null_value(max, 1);
+ else
+ *max = range->max;
+ }
+}
+
+/*!
+ * \brief Initialize fp range
+ *
+ * Must set a flag in the range structure that indicates that no
+ * min/max have been defined - probably a <tt>"first"</tt> boolean
+ * flag.
+ *
+ * \param range pointer to FPRange which holds fp range info
+ */
+void Rast_init_fp_range(struct FPRange *range)
+{
+ Rast_set_d_null_value(&(range->min), 1);
+ Rast_set_d_null_value(&(range->max), 1);
+ range->first_time = 1;
+}
+
+/*!
+ * \brief Get minumum and maximum value from fp range
+ *
+ * Extract the min/max from the range structure <i>range</i>. If the
+ * range structure has no defined min/max (first!=0) there will not be
+ * a valid range. In this case the min and max returned must be the
+ * NULL-value.
+ *
+ * \param range pointer to FPRange which holds fp range info
+ * \param[out] min minimum value
+ * \param[out] max maximum value
+ */
+void Rast_get_fp_range_min_max(const struct FPRange *range,
+ DCELL *min, DCELL *max)
+{
+ if (range->first_time) {
+ Rast_set_d_null_value(min, 1);
+ Rast_set_d_null_value(max, 1);
+ }
+ else {
+ if (Rast_is_d_null_value(&(range->min)))
+ Rast_set_d_null_value(min, 1);
+ else
+ *min = range->min;
+
+ if (Rast_is_d_null_value(&(range->max)))
+ Rast_set_d_null_value(max, 1);
+ else
+ *max = range->max;
+ }
+}
Copied: grass/trunk/lib/raster/raster.c (from rev 37989, grass/trunk/lib/gis/raster.c)
===================================================================
--- grass/trunk/lib/raster/raster.c (rev 0)
+++ grass/trunk/lib/raster/raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,321 @@
+/*!
+ * \file gis/raster.c
+ *
+ * \brief GIS Library - Raster cell value routines.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <stdlib.h>
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Advance void pointer
+ *
+ * Advances void pointer by <i>size</i> bytes. Returns new pointer
+ * value.
+ *
+ * Useful in raster row processing loops, substitutes
+ *
+ \code
+ CELL *cell;
+ cell += n;
+ \endcode
+ *
+ * Now
+ \code
+ rast = Rast_incr_void_ptr(rast, Rast_raster_size(data_type))
+ \endcode
+ *
+ * (where rast is void* and <i>data_type</i> is RASTER_MAP_TYPE can be
+ * used instead of rast++.)
+ *
+ * Very useful to generalize the row processing - loop i.e.
+ * \code
+ * void * buf_ptr += Rast_raster_size(data_type)
+ * \endcode
+ *
+ * \param ptr pointer
+ * \param size buffer size
+ *
+ * \return pointer to the data
+ */
+void *Rast_incr_void_ptr(const void *ptr, const size_t size)
+{
+ /* assuming that the size of unsigned char is 1 */
+ return (void *)((const unsigned char *)ptr + size);
+}
+
+/*!
+ * \brief Compares raster values.
+ *
+ * \param v1,v2 values to be compared
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ *
+ * \return 1 if p > q or only q is null value
+ * \return -1 if p < q or only p is null value
+ * \return 0 if p == q or p==q==null value
+ */
+int Rast_raster_cmp(const void *v1, const void *v2, RASTER_MAP_TYPE data_type)
+{
+ if (Rast_is_null_value(v1, data_type)) {
+ if (Rast_is_null_value(v2, data_type))
+ return 0;
+ else
+ return -1;
+ }
+ else if (Rast_is_null_value(v2, data_type))
+ return 1;
+
+ switch (data_type) {
+ case CELL_TYPE:
+ if (*((const CELL *)v1) > *((const CELL *)v2))
+ return 1;
+ else if (*((const CELL *)v1) == *((const CELL *)v2))
+ return 0;
+ else
+ return -1;
+ case FCELL_TYPE:
+ if (*((const FCELL *)v1) > *((const FCELL *)v2))
+ return 1;
+ else if (*((const FCELL *)v1) == *((const FCELL *)v2))
+ return 0;
+ else
+ return -1;
+ case DCELL_TYPE:
+ if (*((const DCELL *)v1) > *((const DCELL *)v2))
+ return 1;
+ else if (*((const DCELL *)v1) == *((const DCELL *)v2))
+ return 0;
+ else
+ return -1;
+ }
+
+ return 0;
+}
+
+/*!
+ * \brief Copies raster values.
+ *
+ * If v2 is null value, sets v2 to null value.
+ *
+ * \param v1, v2 raster values
+ * \param n ?
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast_raster_cpy(void *v1, const void *v2, int n, RASTER_MAP_TYPE data_type)
+{
+ G_copy(v1, v2, n * Rast_raster_size(data_type));
+}
+
+/*!
+ * \brief Places a CELL raster value
+ *
+ * If Rast_is_c_null_value() is true, sets p to null value. Converts CELL
+ * val to data_type (type of p) and stores result in p. Used for
+ * assigning CELL values to raster cells of any type.
+ *
+ * \param rast pointer to raster cell value
+ * \param cval value to set
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast_set_raster_value_c(void *rast, CELL cval, RASTER_MAP_TYPE data_type)
+{
+ CELL c;
+
+ c = cval;
+ if (Rast_is_c_null_value(&c)) {
+ Rast_set_null_value(rast, 1, data_type);
+ return;
+ }
+ switch (data_type) {
+ case CELL_TYPE:
+ *((CELL *) rast) = cval;
+ break;
+ case FCELL_TYPE:
+ *((FCELL *) rast) = (FCELL) cval;
+ break;
+ case DCELL_TYPE:
+ *((DCELL *) rast) = (DCELL) cval;
+ break;
+ }
+}
+
+/*!
+ * \brief Places a FCELL raster value
+ *
+ * If Rast_is_f_null_value() is true, sets p to null value. Converts
+ * FCELL val to data_type (type of p) and stores result in p. Used for
+ * assigning FCELL values to raster cells of any type.
+ *
+ * \param rast pointer to raster cell value
+ * \param fval value to set
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast_set_raster_value_f(void *rast, FCELL fval, RASTER_MAP_TYPE data_type)
+{
+ FCELL f;
+
+ f = fval;
+ if (Rast_is_f_null_value(&f)) {
+ Rast_set_null_value(rast, 1, data_type);
+ return;
+ }
+ switch (data_type) {
+ case CELL_TYPE:
+ *((CELL *) rast) = (CELL) fval;
+ break;
+ case FCELL_TYPE:
+ *((FCELL *) rast) = fval;
+ break;
+ case DCELL_TYPE:
+ *((DCELL *) rast) = (DCELL) fval;
+ break;
+ }
+}
+
+
+/*!
+ * \brief Places a DCELL raster value
+ *
+ * If Rast_is_d_null_value() is true, sets p to null value. Converts
+ * DCELL val to data_type (type of p) and stores result in p. Used for
+ * assigning DCELL values to raster cells of any type.
+ *
+ * \param rast pointer to raster cell value
+ * \param fval value to set
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast_set_raster_value_d(void *rast, DCELL dval, RASTER_MAP_TYPE data_type)
+{
+ DCELL d;
+
+ d = dval;
+ if (Rast_is_d_null_value(&d)) {
+ Rast_set_null_value(rast, 1, data_type);
+ return;
+ }
+ switch (data_type) {
+ case CELL_TYPE:
+ *((CELL *) rast) = (CELL) dval;
+ break;
+ case FCELL_TYPE:
+ *((FCELL *) rast) = (FCELL) dval;
+ break;
+ case DCELL_TYPE:
+ *((DCELL *) rast) = dval;
+ break;
+ }
+}
+
+/*!
+ * \brief Retrieves the value of give type from pointer p
+ *
+ * Retrieves the value of type data_type from pointer p, converts it
+ * to CELL type and returns the result. If null value is stored in p,
+ * returns CELL null value.
+ *
+ * Used for retrieving CELL values from raster cells of any type.
+ *
+ * Note: when data_type != CELL_TYPE, no quantization is used, only
+ * type conversion.
+ *
+ * \param rast pointer to raster cell value
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ *
+ * \return raster value
+ */
+CELL Rast_get_raster_value_c(const void *rast, RASTER_MAP_TYPE data_type)
+{
+ CELL c;
+
+ if (Rast_is_null_value(rast, data_type)) {
+ Rast_set_c_null_value(&c, 1);
+ return c;
+ }
+ switch (data_type) {
+ case CELL_TYPE:
+ return *((const CELL *)rast);
+ case FCELL_TYPE:
+ return (CELL) *((const FCELL *)rast);
+ case DCELL_TYPE:
+ return (CELL) *((const DCELL *)rast);
+ }
+
+ return 0;
+}
+
+/*!
+ * \brief Retrieves the value of given raster type from pointer p (FCELL)
+ *
+ * Retrieves the value of type data_type from pointer p, converts it
+ * to FCELL type and returns the result. If null value is stored in p,
+ * returns FCELL null value.
+ *
+ * Used for retrieving FCELL values from raster cells of any type.
+ *
+ * \param rast pointer to raster cell value
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ *
+ * \return raster value
+ */
+FCELL Rast_get_raster_value_f(const void *rast, RASTER_MAP_TYPE data_type)
+{
+ FCELL f;
+
+ if (Rast_is_null_value(rast, data_type)) {
+ Rast_set_f_null_value(&f, 1);
+ return f;
+ }
+ switch (data_type) {
+ case CELL_TYPE:
+ return (FCELL) * ((const CELL *)rast);
+ case FCELL_TYPE:
+ return *((const FCELL *)rast);
+ case DCELL_TYPE:
+ return (FCELL) * ((const DCELL *)rast);
+ }
+
+ return 0;
+}
+
+
+/*!
+ * \brief Retrieves the value of given type from pointer p (DCELL)
+ *
+ * Retrieves the value of type data_type from pointer p, converts it
+ * to DCELL type and returns the result. If null value is stored in p,
+ * returns DCELL null value.
+
+ * Used for retrieving DCELL values from raster cells of any type.
+ *
+ * \param rast pointer to raster cell value
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ *
+ * \return raster value
+ */
+DCELL Rast_get_raster_value_d(const void *rast, RASTER_MAP_TYPE data_type)
+{
+ DCELL d;
+
+ if (Rast_is_null_value(rast, data_type)) {
+ Rast_set_d_null_value(&d, 1);
+ return d;
+ }
+ switch (data_type) {
+ case CELL_TYPE:
+ return (DCELL) * ((const CELL *)rast);
+ case FCELL_TYPE:
+ return (DCELL) * ((const FCELL *)rast);
+ case DCELL_TYPE:
+ return *((const DCELL *)rast);
+ }
+
+ return 0;
+}
Copied: grass/trunk/lib/raster/raster_metadata.c (from rev 37989, grass/trunk/lib/gis/raster_metadata.c)
===================================================================
--- grass/trunk/lib/raster/raster_metadata.c (rev 0)
+++ grass/trunk/lib/raster/raster_metadata.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,154 @@
+/* raster_metadata.c
+ *
+ * PURPOSE: functions to read and write raster "units" and "vertical datum"
+ * meta-data info
+ *
+ * Copyright (C) 2007 by Hamish Bowman, and the GRASS Development Team
+ * Author(s): Hamish Bowman, Dunedin, New Zealand
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ */
+#include <stdio.h>
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+
+/*!
+ * \brief Get a raster map's units metadata string
+ *
+ * Read the raster's units metadata file and put string in str
+ *
+ * \param name
+ * \param mapset
+ * \param *str string to be populated with data
+ * \return 0 on success
+ * \return -1, EOF (fclose() result) on error
+ */
+int Rast_read_raster_units(const char *name, const char *mapset, char *str)
+{
+ return Rast__raster_misc_read_line("units", name, mapset, str);
+}
+
+
+/*!
+ * \brief Write a string to a raster map's units metadata file
+ *
+ * Map must exist in the current mapset.
+ *
+ * \param name
+ * \param *str string containing data to be written
+ * \return 0 on success
+ * \return -1, EOF (fclose() result) on error
+ */
+int Rast_write_raster_units(const char *name, const char *str)
+{
+ return Rast__raster_misc_write_line("units", name, str);
+}
+
+
+/*!
+ * \brief Get a raster map's vertical datum metadata string
+ *
+ * Read the raster's vertical datum metadata file and put string in str
+ *
+ * \param name
+ * \param mapset
+ * \param *str string to be populated with data
+ * \return 0 on success
+ * \return -1, EOF (fclose() result) on error
+ */
+int Rast_read_raster_vdatum(const char *name, const char *mapset, char *str)
+{
+ return Rast__raster_misc_read_line("vertical_datum", name, mapset, str);
+}
+
+
+/*!
+ * \brief Write a string into a raster's vertical datum metadata file
+ *
+ * Map must exist in the current mapset.
+ *
+ * \param name
+ * \param *str string containing data to be written
+ * \return 0 on success
+ * \return -1, EOF (fclose() result) on error
+ */
+int Rast_write_raster_vdatum(const char *name, const char *str)
+{
+ return Rast__raster_misc_write_line("vertical_datum", name, str);
+}
+
+
+
+/*!
+ * \brief Read the first line of a file in cell_misc/
+ *
+ * Read the first line of data from a cell_misc/ meta-data file.
+ *
+ * \param element metadata component filename
+ * \param name
+ * \param mapset
+ * \param *str string to be populated with data
+ * \return 0 on success
+ * \return -1, EOF (fclose() result) on error
+ */
+int Rast__raster_misc_read_line(const char *elem, const char *name,
+ const char *mapset, char *str)
+{
+ FILE *fd;
+ char buff[GNAME_MAX];
+
+ buff[0] = '\0';
+
+ if (G_find_file2_misc("cell_misc", elem, name, mapset) == NULL)
+ return -1;
+
+ fd = G_fopen_old_misc("cell_misc", elem, name, mapset);
+ if (!fd) {
+ G_warning(_("Can't read %s for [%s in %s]"), elem, name, mapset);
+ return -1;
+ }
+ if (G_getl2(buff, sizeof(buff) - 1, fd) == 0) {
+ /* file is empty */
+ return fclose(fd);
+ }
+
+ strcpy(str, buff);
+
+ return fclose(fd);
+}
+
+
+/*!
+ * \brief Write a line to a raster map metadata file
+ *
+ * Write (including overwrite) a string into a raster map's metadata file
+ * found in in cell_misc/ in the current mapset.
+ *
+ * \param element metadata component filename
+ * \param name
+ * \param *str string containing data to be written
+ * \return 0 on success
+ * \return -1, EOF (fclose() result) on error
+ */
+int Rast__raster_misc_write_line(const char *elem, const char *name,
+ const char *str)
+{
+ FILE *fd;
+
+ fd = G_fopen_new_misc("cell_misc", elem, name);
+ if (fd == NULL) {
+ G_warning(_("Can't create %s metadata file for [%s in %s]"),
+ elem, name, G_mapset());
+ return -1;
+ }
+
+ fprintf(fd, "%s", str);
+
+ return fclose(fd);
+}
Copied: grass/trunk/lib/raster/rd_cellhd.c (from rev 37989, grass/trunk/lib/gis/rd_cellhd.c)
===================================================================
--- grass/trunk/lib/raster/rd_cellhd.c (rev 0)
+++ grass/trunk/lib/raster/rd_cellhd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,434 @@
+/* read cell header, or window.
+ returns NULL if ok, error message otherwise
+ note: the error message can be freed using G_free ().
+ */
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+#define ERROR(x,line) return error(x,line)
+static int scan_item(const char *, char *, char *);
+static int scan_int(const char *, int *);
+static double scan_double(const char *, double *);
+static char *error(const char *, int);
+
+#define F_PROJ 1
+#define F_ZONE 2
+#define F_NORTH 3
+#define F_SOUTH 4
+#define F_EAST 5
+#define F_WEST 6
+#define F_EWRES 7
+#define F_NSRES 8
+#define F_FORMAT 9
+#define F_COMP 10
+#define F_COLS 11
+#define F_ROWS 12
+
+#define F_EWRES3 13
+#define F_NSRES3 14
+#define F_COLS3 15
+#define F_ROWS3 16
+#define F_TOP 17
+#define F_BOTTOM 18
+#define F_TBRES 19
+#define F_DEPTHS 20
+
+#define SET(x) flags|=(1<<x)
+#define TEST(x) (flags&(1<<x))
+
+char *Rast__read_Cell_head_array(char **array,
+ struct Cell_head *cellhd, int is_cellhd);
+
+char *Rast__read_Cell_head(FILE * fd, struct Cell_head *cellhd, int is_cellhd)
+{
+ int count;
+ char *result, **array;
+ char buf[1024];
+
+ G_debug(2, "Rast__read_Cell_head");
+
+ /* Count lines */
+ count = 0;
+ fseek(fd, 0L, 0);
+ while (G_getl(buf, sizeof(buf), fd))
+ count++;
+
+ array = (char **)G_calloc(count + 1, sizeof(char **));
+
+ count = 0;
+ fseek(fd, 0L, 0);
+ while (G_getl(buf, sizeof(buf), fd)) {
+ array[count] = G_store(buf);
+ count++;
+ }
+
+ result = Rast__read_Cell_head_array(array, cellhd, is_cellhd);
+
+ count = 0;
+ while (array[count]) {
+ G_free(array[count]);
+ count++;
+ }
+ G_free(array);
+
+ return result;
+}
+
+/* Read window from NULL terminated array of strings */
+char *Rast__read_Cell_head_array(char **array,
+ struct Cell_head *cellhd, int is_cellhd)
+{
+ char *buf;
+ char label[200];
+ char value[200];
+ int i, line;
+ int flags;
+ const char *err;
+
+ G_debug(2, "Rast__read_Cell_head_array");
+
+ flags = 0;
+
+ /* initialize the cell header */
+ cellhd->format = 0;
+ cellhd->rows = 0;
+ cellhd->rows3 = 0;
+ cellhd->cols = 0;
+ cellhd->cols3 = 0;
+ cellhd->depths = 1;
+ cellhd->proj = -1;
+ cellhd->zone = -1;
+ cellhd->compressed = -1;
+ cellhd->ew_res = 0.0;
+ cellhd->ew_res3 = 1.0;
+ cellhd->ns_res = 0.0;
+ cellhd->ns_res3 = 1.0;
+ cellhd->tb_res = 1.0;
+ cellhd->north = 0.0;
+ cellhd->south = 0.0;
+ cellhd->east = 0.0;
+ cellhd->west = 0.0;
+ cellhd->top = 1.0;
+ cellhd->bottom = 0.0;
+
+ /* determine projection, zone first */
+
+ i = 0;
+ for (line = 1; (buf = array[i++]); line++) {
+ if (TEST(F_PROJ) && TEST(F_ZONE))
+ break;
+
+ switch (scan_item(buf, label, value)) {
+ case -1:
+ ERROR(buf, line);
+ case 0:
+ continue;
+ case 1:
+ break;
+ }
+ if (strncmp(label, "proj", 4) == 0) {
+ if (TEST(F_PROJ))
+ ERROR(_("duplicate projection field"), line);
+
+ if (!scan_int(value, &cellhd->proj))
+ ERROR(buf, line);
+
+ SET(F_PROJ);
+ continue;
+ }
+ if (strncmp(label, "zone", 4) == 0) {
+ if (TEST(F_ZONE))
+ ERROR(_("duplicate zone field"), line);
+
+ if (!scan_int(value, &cellhd->zone))
+ ERROR(buf, line);
+
+ SET(F_ZONE);
+ continue;
+ }
+ }
+ if (!TEST(F_PROJ))
+ ERROR(_("projection field missing"), 0);
+ if (!TEST(F_ZONE))
+ ERROR(_("zone field missing"), 0);
+
+ /* read the other info */
+ i = 0;
+ for (line = 1; (buf = array[i++]); line++) {
+ G_debug(3, "region item: %s", buf);
+ switch (scan_item(buf, label, value)) {
+ case -1:
+ ERROR(buf, line);
+ case 0:
+ continue;
+ case 1:
+ break;
+ }
+
+ if (strncmp(label, "proj", 4) == 0)
+ continue;
+ if (strncmp(label, "zone", 4) == 0)
+ continue;
+
+ if (strncmp(label, "nort", 4) == 0) {
+ if (TEST(F_NORTH))
+ ERROR(_("duplicate north field"), line);
+ if (!G_scan_northing(value, &cellhd->north, cellhd->proj))
+ ERROR(buf, line);
+ SET(F_NORTH);
+ continue;
+ }
+ if (strncmp(label, "sout", 4) == 0) {
+ if (TEST(F_SOUTH))
+ ERROR(_("duplicate south field"), line);
+ if (!G_scan_northing(value, &cellhd->south, cellhd->proj))
+ ERROR(buf, line);
+ SET(F_SOUTH);
+ continue;
+ }
+ if (strncmp(label, "east", 4) == 0) {
+ if (TEST(F_EAST))
+ ERROR(_("duplicate east field"), line);
+ if (!G_scan_easting(value, &cellhd->east, cellhd->proj))
+ ERROR(buf, line);
+ SET(F_EAST);
+ continue;
+ }
+ if (strncmp(label, "west", 4) == 0) {
+ if (TEST(F_WEST))
+ ERROR(_("duplicate west field"), line);
+ if (!G_scan_easting(value, &cellhd->west, cellhd->proj))
+ ERROR(buf, line);
+ SET(F_WEST);
+ continue;
+ }
+ if (strncmp(label, "top", 3) == 0) {
+ if (TEST(F_TOP))
+ ERROR(_("duplicate top field"), line);
+ if (!scan_double(value, &cellhd->top))
+ ERROR(buf, line);
+ SET(F_TOP);
+ continue;
+ }
+ if (strncmp(label, "bottom", 6) == 0) {
+ if (TEST(F_BOTTOM))
+ ERROR(_("duplicate bottom field"), line);
+ if (!scan_double(value, &cellhd->bottom))
+ ERROR(buf, line);
+ SET(F_BOTTOM);
+ continue;
+ }
+ if (strncmp(label, "e-w ", 4) == 0 && strlen(label) == 9) {
+ if (TEST(F_EWRES))
+ ERROR(_("duplicate e-w resolution field"), line);
+ if (!G_scan_resolution(value, &cellhd->ew_res, cellhd->proj))
+ ERROR(buf, line);
+ if (cellhd->ew_res <= 0.0)
+ ERROR(buf, line);
+ SET(F_EWRES);
+ continue;
+ }
+ if (strncmp(label, "e-w resol3", 10) == 0) {
+ if (TEST(F_EWRES3))
+ ERROR(_("duplicate 3D e-w resolution field"), line);
+ if (!G_scan_resolution(value, &cellhd->ew_res3, cellhd->proj))
+ ERROR(buf, line);
+ if (cellhd->ew_res3 <= 0.0)
+ ERROR(buf, line);
+ SET(F_EWRES3);
+ continue;
+ }
+ if (strncmp(label, "n-s ", 4) == 0 && strlen(label) == 9) {
+ if (TEST(F_NSRES))
+ ERROR(_("duplicate n-s resolution field"), line);
+ if (!G_scan_resolution(value, &cellhd->ns_res, cellhd->proj))
+ ERROR(buf, line);
+ if (cellhd->ns_res <= 0.0)
+ ERROR(buf, line);
+ SET(F_NSRES);
+ continue;
+ }
+ if (strncmp(label, "n-s resol3", 10) == 0) {
+ if (TEST(F_NSRES3))
+ ERROR(_("duplicate 3D n-s resolution field"), line);
+ if (!G_scan_resolution(value, &cellhd->ns_res3, cellhd->proj))
+ ERROR(buf, line);
+ if (cellhd->ns_res3 <= 0.0)
+ ERROR(buf, line);
+ SET(F_NSRES3);
+ continue;
+ }
+ if (strncmp(label, "t-b ", 4) == 0) {
+ if (TEST(F_TBRES))
+ ERROR(_("duplicate t-b resolution field"), line);
+ if (!scan_double(value, &cellhd->tb_res))
+ ERROR(buf, line);
+ if (cellhd->tb_res <= 0.0)
+ ERROR(buf, line);
+ SET(F_TBRES);
+ continue;
+ }
+ if (strncmp(label, "rows", 4) == 0 && strlen(label) == 4) {
+ if (TEST(F_ROWS))
+ ERROR(_("duplicate rows field"), line);
+ if (!scan_int(value, &cellhd->rows))
+ ERROR(buf, line);
+ if (cellhd->rows <= 0)
+ ERROR(buf, line);
+ SET(F_ROWS);
+ continue;
+ }
+ if (strncmp(label, "rows3", 5) == 0) {
+ if (TEST(F_ROWS3))
+ ERROR(_("duplicate 3D rows field"), line);
+ if (!scan_int(value, &cellhd->rows3))
+ ERROR(buf, line);
+ if (cellhd->rows3 <= 0)
+ ERROR(buf, line);
+ SET(F_ROWS3);
+ continue;
+ }
+ if (strncmp(label, "cols", 4) == 0 && strlen(label) == 4) {
+ if (TEST(F_COLS))
+ ERROR(_("duplicate cols field"), line);
+ if (!scan_int(value, &cellhd->cols))
+ ERROR(buf, line);
+ if (cellhd->cols <= 0)
+ ERROR(buf, line);
+ SET(F_COLS);
+ continue;
+ }
+ if (strncmp(label, "cols3", 5) == 0) {
+ if (TEST(F_COLS3))
+ ERROR(_("duplicate 3D cols field"), line);
+ if (!scan_int(value, &cellhd->cols3))
+ ERROR(buf, line);
+ if (cellhd->cols3 <= 0)
+ ERROR(buf, line);
+ SET(F_COLS3);
+ continue;
+ }
+ if (strncmp(label, "depths", 6) == 0) {
+ if (TEST(F_DEPTHS))
+ ERROR(_("duplicate depths field"), line);
+ if (!scan_int(value, &cellhd->depths))
+ ERROR(buf, line);
+ if (cellhd->depths <= 0)
+ ERROR(buf, line);
+ SET(F_DEPTHS);
+ continue;
+ }
+ if (strncmp(label, "form", 4) == 0) {
+ if (TEST(F_FORMAT))
+ ERROR(_("duplicate format field"), line);
+ if (!scan_int(value, &cellhd->format))
+ ERROR(buf, line);
+ SET(F_FORMAT);
+ continue;
+ }
+ if (strncmp(label, "comp", 4) == 0) {
+ if (TEST(F_COMP))
+ ERROR(_("duplicate compressed field"), line);
+ if (!scan_int(value, &cellhd->compressed))
+ ERROR(buf, line);
+ SET(F_COMP);
+ continue;
+ }
+ ERROR(buf, line);
+ }
+
+ /* check some of the fields */
+ if (!TEST(F_NORTH))
+ ERROR(_("north field missing"), 0);
+ if (!TEST(F_SOUTH))
+ ERROR(_("south field missing"), 0);
+ if (!TEST(F_WEST))
+ ERROR(_("west field missing"), 0);
+ if (!TEST(F_EAST))
+ ERROR(_("east field missing"), 0);
+ if (!TEST(F_EWRES) && !TEST(F_COLS))
+ ERROR(_("cols field missing"), 0);
+ if (!TEST(F_NSRES) && !TEST(F_ROWS))
+ ERROR(_("rows field missing"), 0);
+ /* This next stmt is commented out to allow wr_cellhd.c to write
+ * headers that will be readable by GRASS 3.1
+ if ((TEST(F_ROWS) && TEST(F_NSRES))
+ || (TEST(F_COLS) && TEST(F_EWRES)))
+ ERROR ("row/col and resolution information can not both appear ",0);
+ */
+
+ /* 3D defined? */
+ if (TEST(F_EWRES3) || TEST(F_NSRES3) || TEST(F_COLS3) || TEST(F_ROWS3)) {
+ if (!TEST(F_EWRES3))
+ ERROR(_("ewres3 field missing"), 0);
+ if (!TEST(F_NSRES3))
+ ERROR(_("nsres3 field missing"), 0);
+ if (!TEST(F_COLS3))
+ ERROR(_("cols3 field missing"), 0);
+ if (!TEST(F_ROWS3))
+ ERROR(_("rows3 field missing"), 0);
+ }
+ else { /* use 2D */
+ cellhd->ew_res3 = cellhd->ew_res;
+ cellhd->ns_res3 = cellhd->ns_res;
+ cellhd->cols3 = cellhd->cols;
+ cellhd->rows3 = cellhd->rows;
+ }
+
+ /* Adjust and complete the cell header */
+ if ((err = Rast_adjust_Cell_head(cellhd, TEST(F_ROWS), TEST(F_COLS))))
+ ERROR(err, 0);
+
+
+ return NULL;
+}
+
+static int scan_item(const char *buf, char *label, char *value)
+{
+ /* skip blank lines */
+ if (sscanf(buf, "%1s", label) != 1)
+ return 0;
+
+ /* skip comment lines */
+ if (*label == '#')
+ return 0;
+
+ /* must be label: value */
+ if (sscanf(buf, "%[^:]:%[^\n]", label, value) != 2)
+ return -1;
+
+ G_strip(label);
+ G_strip(value);
+ return 1;
+}
+
+static int scan_int(const char *buf, int *n)
+{
+ char dummy[3];
+
+ *dummy = 0;
+ return (sscanf(buf, "%d%1s", n, dummy) == 1 && *dummy == 0);
+}
+
+static double scan_double(const char *buf, double *n)
+{
+ char dummy[3];
+
+ *dummy = 0;
+ return (sscanf(buf, "%lf%1s", n, dummy) == 1 && *dummy == 0);
+}
+
+static char *error(const char *msg, int line)
+{
+ char buf[1024];
+
+ if (line)
+ sprintf(buf, _("line %d: <%s>"), line, msg);
+ else
+ sprintf(buf, "<%s>", msg);
+
+ return G_store(buf);
+}
Copied: grass/trunk/lib/raster/reclass.c (from rev 37989, grass/trunk/lib/gis/reclass.c)
===================================================================
--- grass/trunk/lib/raster/reclass.c (rev 0)
+++ grass/trunk/lib/raster/reclass.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,405 @@
+/*!
+ * \file gis/reclass.c
+ *
+ * \brief GIS Library - Check if raster map is reclassified
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <string.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+static const char NULL_STRING[] = "null";
+static int reclass_type(FILE *, char **, char **);
+static FILE *fopen_cellhd_old(const char *, const char *);
+static FILE *fopen_cellhd_new(const char *);
+static int get_reclass_table(FILE *, struct Reclass *);
+
+/*!
+ * \brief Check if raster map is reclassified
+ *
+ * This function determines if the raster map <i>name</i> in
+ * <i>mapset</i> is a reclass file. If it is, then the name and mapset
+ * of the referenced raster map are copied into the <i>r_name</i> and
+ * <i>r_mapset</i> buffers.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param[out] r_name name of reference map
+ * \param[out] r_mapset mapset where reference map lives
+ *
+ * \returns 1 if it is a reclass file
+ * \return 0 if it is not
+ * \return -1 if there was a problem reading the raster header
+ */
+int Rast_is_reclass(const char *name, const char *mapset, char *rname,
+ char *rmapset)
+{
+ FILE *fd;
+ int type;
+
+ fd = fopen_cellhd_old(name, mapset);
+ if (fd == NULL)
+ return -1;
+
+ type = reclass_type(fd, &rname, &rmapset);
+ fclose(fd);
+ if (type < 0)
+ return -1;
+ else
+ return type != 0;
+}
+
+/*!
+ * \brief Get child reclass maps list
+ *
+ * This function generates a child reclass maps list from the
+ * cell_misc/reclassed_to file which stores this list. The
+ * cell_misc/reclassed_to file is written by Rast_put_reclass().
+ * Rast_is_reclassed_to() is used by <tt>g.rename</tt>, <tt>g.remove</tt>
+ * and <tt>r.reclass</tt> to prevent accidentally deleting the parent
+ * map of a reclassed raster map.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param[out] nrmaps number of reference maps
+ * \param[out] rmaps array of names of reference maps
+ *
+ * \return number of reference maps
+ * \return -1 on error
+ */
+int Rast_is_reclassed_to(const char *name, const char *mapset, int *nrmaps,
+ char ***rmaps)
+{
+ FILE *fd;
+ int i, j, k, l;
+ char buf2[256], buf3[256];
+
+ fd = G_fopen_old_misc("cell_misc", "reclassed_to", name, mapset);
+
+ if (fd == NULL) {
+ return -1;
+ }
+
+ if (rmaps)
+ *rmaps = NULL;
+ for (i = 0; !feof(fd) && fgets(buf2, 255, fd);) {
+ l = strlen(buf2);
+ for (j = 0, k = 0; j < l; j++) {
+ if (buf2[j] == '#' ||
+ ((buf2[j] == ' ' || buf2[j] == '\t' || buf2[j] == '\n') && k))
+ break;
+ else if (buf2[j] != ' ' && buf2[j] != '\t')
+ buf3[k++] = buf2[j];
+ }
+
+ if (k) {
+ buf3[k] = 0;
+ i++;
+ if (rmaps) {
+ *rmaps = (char **)G_realloc(*rmaps, i * sizeof(char *));
+ (*rmaps)[i - 1] = (char *)G_malloc(k + 1);
+ strncpy((*rmaps)[i - 1], buf3, k);
+ (*rmaps)[i - 1][k] = 0;
+ }
+ }
+ }
+
+ if (nrmaps)
+ *nrmaps = i;
+
+ if (i && rmaps) {
+ i++;
+ *rmaps = (char **)G_realloc(*rmaps, i * sizeof(char *));
+ (*rmaps)[i - 1] = NULL;
+ }
+
+ return i;
+}
+
+/*!
+ \brief Get reclass
+
+ \param name map name
+ \param mapset mapset name
+ \param[out] reclass pointer to Reclass structure
+
+ \return -1 on error
+ \return type code
+*/
+int Rast_get_reclass(const char *name, const char *mapset,
+ struct Reclass *reclass)
+{
+ FILE *fd;
+ int stat;
+
+ fd = fopen_cellhd_old(name, mapset);
+ if (fd == NULL)
+ return -1;
+ reclass->name = NULL;
+ reclass->mapset = NULL;
+ reclass->type = reclass_type(fd, &reclass->name, &reclass->mapset);
+ if (reclass->type <= 0) {
+ fclose(fd);
+ return reclass->type;
+ }
+
+ switch (reclass->type) {
+ case RECLASS_TABLE:
+ stat = get_reclass_table(fd, reclass);
+ break;
+ default:
+ stat = -1;
+ }
+
+ fclose(fd);
+ if (stat < 0) {
+ if (stat == -2)
+ G_warning(_("Too many reclass categories for <%s@%s>"),
+ name, mapset);
+ else
+ G_warning(_("Illegal reclass format in header file for <%s@%s>"),
+ name, mapset);
+ stat = -1;
+ }
+ return stat;
+}
+
+/*!
+ \brief Free Reclass structure
+
+ \param reclass pointer to Reclass structure
+*/
+void Rast_free_reclass(struct Reclass *reclass)
+{
+ switch (reclass->type) {
+ case RECLASS_TABLE:
+ if (reclass->num > 0)
+ G_free(reclass->table);
+ reclass->num = 0;
+ if (reclass->name)
+ G_free(reclass->name);
+ if (reclass->mapset)
+ G_free(reclass->mapset);
+ reclass->name = NULL;
+ reclass->mapset = NULL;
+ break;
+ default:
+ break;
+ }
+}
+
+static int reclass_type(FILE * fd, char **rname, char **rmapset)
+{
+ char buf[128];
+ char label[128], arg[128];
+ int i;
+ int type;
+
+ /* Check to see if this is a reclass file */
+ if (fgets(buf, sizeof(buf), fd) == NULL)
+ return 0;
+ if (strncmp(buf, "reclas", 6))
+ return 0;
+ /* later may add other types of reclass */
+ type = RECLASS_TABLE;
+
+ /* Read the mapset and file name of the REAL cell file */
+ if (*rname)
+ **rname = '\0';
+ if (*rmapset)
+ **rmapset = '\0';
+ for (i = 0; i < 2; i++) {
+ if (fgets(buf, sizeof buf, fd) == NULL)
+ return -1;
+ if (sscanf(buf, "%[^:]:%s", label, arg) != 2)
+ return -1;
+ if (strncmp(label, "maps", 4) == 0) {
+ if (*rmapset)
+ strcpy(*rmapset, arg);
+ else
+ *rmapset = G_store(arg);
+ }
+ else if (strncmp(label, "name", 4) == 0) {
+ if (*rname)
+ strcpy(*rname, arg);
+ else
+ *rname = G_store(arg);
+ }
+ else
+ return -1;
+ }
+ if (**rmapset && **rname)
+ return type;
+ else
+ return -1;
+}
+
+static FILE *fopen_cellhd_old(const char *name, const char *mapset)
+{
+ return G_fopen_old("cellhd", name, mapset);
+}
+
+/*!
+ \brief Put reclass
+
+ \param name map name
+ \param reclass pointer to Reclass structure
+
+ \return -1 on error
+ \return 1 on success
+*/
+int Rast_put_reclass(const char *name, const struct Reclass *reclass)
+{
+ FILE *fd;
+ long min, max;
+ int i;
+ char buf1[GPATH_MAX], buf2[GNAME_MAX], buf3[GNAME_MAX], *p;
+
+ switch (reclass->type) {
+ case RECLASS_TABLE:
+ if (reclass->min > reclass->max || reclass->num <= 0) {
+ G_fatal_error(_("Illegal reclass request"));
+ return -1;
+ }
+ break;
+ default:
+ G_fatal_error(_("Illegal reclass type"));
+ return -1;
+ }
+
+ fd = fopen_cellhd_new(name);
+ if (fd == NULL) {
+ G_warning(_("Unable to create header file for <%s@%s>"),
+ name, G_mapset());
+ return -1;
+ }
+
+ fprintf(fd, "reclass\n");
+ fprintf(fd, "name: %s\n", reclass->name);
+ fprintf(fd, "mapset: %s\n", reclass->mapset);
+
+ /* find first non-null entry */
+ for (min = 0; min < reclass->num; min++)
+ if (!Rast_is_c_null_value(&reclass->table[min]))
+ break;
+ /* find last non-zero entry */
+ for (max = reclass->num - 1; max >= 0; max--)
+ if (!Rast_is_c_null_value(&reclass->table[max]))
+ break;
+
+ /*
+ * if the resultant table is empty, write out a dummy table
+ * else write out the table
+ * first entry is #min
+ * rest are translations for cat min+i
+ */
+ if (min > max)
+ fprintf(fd, "0\n");
+ else {
+ fprintf(fd, "#%ld\n", (long)reclass->min + min);
+ while (min <= max) {
+ if (Rast_is_c_null_value(&reclass->table[min]))
+ fprintf(fd, "%s\n", NULL_STRING);
+ else
+ fprintf(fd, "%ld\n", (long)reclass->table[min]);
+ min++;
+ }
+ }
+ fclose(fd);
+
+ strcpy(buf2, reclass->name);
+ if ((p = strchr(buf2, '@')))
+ *p = 0;
+
+ G__file_name_misc(buf1, "cell_misc", "reclassed_to", reclass->name,
+ reclass->mapset);
+
+ fd = fopen(buf1, "a+");
+ if (fd == NULL) {
+#if 0
+ G_warning(_("Unable to create dependency file in <%s@%s>"),
+ buf2, reclass->mapset);
+#endif
+ return 1;
+ }
+
+ fseek(fd, 0L, SEEK_SET);
+
+ sprintf(buf2, "%s@%s\n", name, G_mapset());
+ for (i = 0; !feof(fd) && fgets(buf3, 255, fd);) {
+ if (!(strcmp(buf2, buf3))) {
+ i = 1;
+ break;
+ }
+ }
+
+ if (!i) {
+ fprintf(fd, "%s@%s\n", name, G_mapset());
+ }
+
+ fclose(fd);
+
+ return 1;
+}
+
+static FILE *fopen_cellhd_new(const char *name)
+{
+ return G_fopen_new("cellhd", name);
+}
+
+static int get_reclass_table(FILE * fd, struct Reclass *reclass)
+{
+ char buf[128];
+ int n;
+ int first, null_str_size;
+ CELL cat;
+ long len;
+
+ /*
+ * allocate the table, expanding as each entry is read
+ * note that G_realloc() will become G_malloc() if ptr in
+ * NULL
+ */
+ reclass->min = 0;
+ reclass->table = NULL;
+ null_str_size = strlen(NULL_STRING);
+ n = 0;
+ first = 1;
+ while (fgets(buf, sizeof buf, fd)) {
+ if (first) {
+ first = 0;
+ if (sscanf(buf, "#%d", &cat) == 1) {
+ reclass->min = cat;
+ continue;
+ }
+ }
+ if (strncmp(buf, NULL_STRING, null_str_size) == 0)
+ Rast_set_c_null_value(&cat, 1);
+ else {
+ if (sscanf(buf, "%d", &cat) != 1)
+ return -1;
+ }
+ n++;
+ len = (long)n *sizeof(CELL);
+
+ if (len != (int)len) { /* check for int overflow */
+ if (reclass->table != NULL)
+ G_free(reclass->table);
+ return -2;
+ }
+ reclass->table = (CELL *) G_realloc((char *)reclass->table, (int)len);
+ reclass->table[n - 1] = cat;
+ }
+ reclass->max = reclass->min + n - 1;
+ reclass->num = n;
+ return 1;
+}
Copied: grass/trunk/lib/raster/sample.c (from rev 37989, grass/trunk/lib/gis/sample.c)
===================================================================
--- grass/trunk/lib/raster/sample.c (rev 0)
+++ grass/trunk/lib/raster/sample.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,340 @@
+/*!
+ \file gis/sample.c
+
+ \brief GIS library - Sampling methods (extract a cell value from
+ raster map)
+
+ 1/2006: moved to libgis from v.sample/v.drape for clone removal
+
+ (C) 2001-2009 by the GRASS Development Team
+
+ This program is free software under the GNU General Public License
+ (>=v2). Read the file COPYING that comes with GRASS for details.
+
+ \author James Darrell McCauley <darrell mccauley-usa.com>, http://mccauley-usa.com/
+*/
+
+#include <string.h>
+#include <unistd.h>
+#include <math.h>
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/glocale.h>
+
+/* prototypes */
+static double scancatlabel(const char *);
+static void raster_row_error(const struct Cell_head *window, double north,
+ double east);
+
+/*!
+ * \brief Extract a cell value from raster map.
+ *
+ * Extract a cell value from raster map at given northing and easting
+ * with a sampled 3x3 window using a specified interpolation method.
+ *
+ * - NEAREST neighbor interpolation
+ * - BILINEAR bilinear interpolation
+ * - CUBIC cubic interpolation
+ *
+ * \param fd file descriptor
+ * \param window region settings
+ * \param cats categories
+ * \param north northing position
+ * \param east easting position
+ * \param usedesc flag to scan category label
+ * \param itype interpolation method
+ *
+ * \return cell value at given position
+ */
+DCELL Rast_get_raster_sample(int fd,
+ const struct Cell_head *window,
+ struct Categories *cats,
+ double north, double east,
+ int usedesc, INTERP_TYPE itype)
+{
+ double retval;
+
+ switch (itype) {
+ case NEAREST:
+ retval = Rast_get_raster_sample_nearest(fd, window, cats, north, east, usedesc);
+ break;
+ case BILINEAR:
+ retval = Rast_get_raster_sample_bilinear(fd, window, cats, north, east, usedesc);
+ break;
+ case CUBIC:
+ retval = Rast_get_raster_sample_cubic(fd, window, cats, north, east, usedesc);
+ break;
+ default:
+ G_fatal_error("Rast_get_raster_sample: %s",
+ _("Unknown interpolation type"));
+ }
+
+ return retval;
+}
+
+/*!
+ * \brief Extract a cell value from raster map (neighbor interpolation)
+ *
+ * Extract a cell value from raster map at given northing and easting
+ * with a sampled 3x3 window using a neighbor interpolation.
+ *
+ * \param fd file descriptor
+ * \param window region settings
+ * \param cats categories
+ * \param north northing position
+ * \param east easting position
+ * \param usedesc flag to scan category label
+ *
+ * \return cell value at given position
+ */
+DCELL Rast_get_raster_sample_nearest(int fd,
+ const struct Cell_head *window,
+ struct Categories *cats,
+ double north, double east, int usedesc)
+{
+ int row, col;
+ DCELL result;
+ DCELL *maprow = Rast_allocate_d_raster_buf();
+
+ /* convert northing and easting to row and col, resp */
+ row = (int)floor(G_northing_to_row(north, window));
+ col = (int)floor(G_easting_to_col(east, window));
+
+ if (row < 0 || row >= G_window_rows() ||
+ col < 0 || col >= G_window_cols()) {
+ Rast_set_d_null_value(&result, 1);
+ goto done;
+ }
+
+ if (Rast_get_d_raster_row(fd, maprow, row) < 0)
+ raster_row_error(window, north, east);
+
+ if (Rast_is_d_null_value(&maprow[col])) {
+ Rast_set_d_null_value(&result, 1);
+ goto done;
+ }
+
+ if (usedesc) {
+ char *buf = Rast_get_cat(maprow[col], cats);
+
+ G_squeeze(buf);
+ result = scancatlabel(buf);
+ }
+ else
+ result = maprow[col];
+
+done:
+ G_free(maprow);
+
+ return result;
+}
+
+
+/*!
+ * \brief Extract a cell value from raster map (bilinear interpolation).
+ *
+ * Extract a cell value from raster map at given northing and easting
+ * with a sampled 3x3 window using a bilinear interpolation.
+ *
+ * \param fd file descriptor
+ * \param window region settings
+ * \param cats categories
+ * \param north northing position
+ * \param east easting position
+ * \param usedesc flag to scan category label
+ *
+ * \return cell value at given position
+ */
+DCELL Rast_get_raster_sample_bilinear(int fd,
+ const struct Cell_head *window,
+ struct Categories *cats,
+ double north, double east, int usedesc)
+{
+ int row, col;
+ double grid[2][2];
+ DCELL *arow = Rast_allocate_d_raster_buf();
+ DCELL *brow = Rast_allocate_d_raster_buf();
+ double frow, fcol, trow, tcol;
+ DCELL result;
+
+ frow = G_northing_to_row(north, window);
+ fcol = G_easting_to_col(east, window);
+
+ /* convert northing and easting to row and col, resp */
+ row = (int)floor(frow - 0.5);
+ col = (int)floor(fcol - 0.5);
+
+ trow = frow - row - 0.5;
+ tcol = fcol - col - 0.5;
+
+ if (row < 0 || row + 1 >= G_window_rows() ||
+ col < 0 || col + 1 >= G_window_cols()) {
+ Rast_set_d_null_value(&result, 1);
+ goto done;
+ }
+
+ if (Rast_get_d_raster_row(fd, arow, row) < 0)
+ raster_row_error(window, north, east);
+ if (Rast_get_d_raster_row(fd, brow, row + 1) < 0)
+ raster_row_error(window, north, east);
+
+ if (Rast_is_d_null_value(&arow[col]) || Rast_is_d_null_value(&arow[col + 1]) ||
+ Rast_is_d_null_value(&brow[col]) || Rast_is_d_null_value(&brow[col + 1])) {
+ Rast_set_d_null_value(&result, 1);
+ goto done;
+ }
+
+ /*-
+ * now were ready to do bilinear interpolation over
+ * arow[col], arow[col+1],
+ * brow[col], brow[col+1]
+ */
+
+ if (usedesc) {
+ char *buf;
+
+ G_squeeze(buf = Rast_get_cat((int)arow[col], cats));
+ grid[0][0] = scancatlabel(buf);
+ G_squeeze(buf = Rast_get_cat((int)arow[col + 1], cats));
+ grid[0][1] = scancatlabel(buf);
+ G_squeeze(buf = Rast_get_cat((int)brow[col], cats));
+ grid[1][0] = scancatlabel(buf);
+ G_squeeze(buf = Rast_get_cat((int)brow[col + 1], cats));
+ grid[1][1] = scancatlabel(buf);
+ }
+ else {
+ grid[0][0] = arow[col];
+ grid[0][1] = arow[col + 1];
+ grid[1][0] = brow[col];
+ grid[1][1] = brow[col + 1];
+ }
+
+ result = Rast_interp_bilinear(tcol, trow,
+ grid[0][0], grid[0][1], grid[1][0], grid[1][1]);
+
+done:
+ G_free(arow);
+ G_free(brow);
+
+ return result;
+}
+
+/*!
+ * \brief Extract a cell value from raster map (cubic interpolation).
+ *
+ * Extract a cell value from raster map at given northing and easting
+ * with a sampled 3x3 window using a cubic interpolation.
+ *
+ * \param fd file descriptor
+ * \param window region settings
+ * \param cats categories
+ * \param north northing position
+ * \param east easting position
+ * \param usedesc flag to scan category label
+ *
+ * \return cell value at given position
+ */
+DCELL Rast_get_raster_sample_cubic(int fd,
+ const struct Cell_head *window,
+ struct Categories *cats,
+ double north, double east, int usedesc)
+{
+ int i, j, row, col;
+ double grid[4][4];
+ DCELL *rows[4];
+ double frow, fcol, trow, tcol;
+ DCELL result;
+
+ for (i = 0; i < 4; i++)
+ rows[i] = Rast_allocate_d_raster_buf();
+
+ frow = G_northing_to_row(north, window);
+ fcol = G_easting_to_col(east, window);
+
+ /* convert northing and easting to row and col, resp */
+ row = (int)floor(frow - 1.5);
+ col = (int)floor(fcol - 1.5);
+
+ trow = frow - row - 1.5;
+ tcol = fcol - col - 1.5;
+
+ if (row < 0 || row + 3 >= G_window_rows() ||
+ col < 0 || col + 3 >= G_window_cols()) {
+ Rast_set_d_null_value(&result, 1);
+ goto done;
+ }
+
+ for (i = 0; i < 4; i++)
+ if (Rast_get_d_raster_row(fd, rows[i], row + i) < 0)
+ raster_row_error(window, north, east);
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++)
+ if (Rast_is_d_null_value(&rows[i][col + j])) {
+ Rast_set_d_null_value(&result, 1);
+ goto done;
+ }
+
+ /*
+ * now were ready to do cubic interpolation over
+ * arow[col], arow[col+1], arow[col+2], arow[col+3],
+ * brow[col], brow[col+1], brow[col+2], brow[col+3],
+ * crow[col], crow[col+1], crow[col+2], crow[col+3],
+ * drow[col], drow[col+1], drow[col+2], drow[col+3],
+ */
+
+ if (usedesc) {
+ char *buf;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ G_squeeze(buf = Rast_get_cat(rows[i][col + j], cats));
+ grid[i][j] = scancatlabel(buf);
+ }
+ }
+ }
+ else {
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++)
+ grid[i][j] = rows[i][col + j];
+ }
+
+ result = Rast_interp_bicubic(tcol, trow,
+ grid[0][0], grid[0][1], grid[0][2], grid[0][3],
+ grid[1][0], grid[1][1], grid[1][2], grid[1][3],
+ grid[2][0], grid[2][1], grid[2][2], grid[2][3],
+ grid[3][0], grid[3][1], grid[3][2], grid[3][3]);
+
+done:
+ for (i = 0; i < 4; i++)
+ G_free(rows[i]);
+
+ return result;
+}
+
+
+static double scancatlabel(const char *str)
+{
+ double val;
+
+ if (strcmp(str, "no data") != 0)
+ sscanf(str, "%lf", &val);
+ else {
+ G_warning(_("\"no data\" label found; setting to zero"));
+ val = 0.0;
+ }
+
+ return val;
+}
+
+
+static void raster_row_error(const struct Cell_head *window, double north,
+ double east)
+{
+ G_debug(3, "DIAG: \tRegion is: n=%g s=%g e=%g w=%g",
+ window->north, window->south, window->east, window->west);
+ G_debug(3, " \tData point is north=%g east=%g", north, east);
+
+ G_fatal_error(_("Problem reading raster map"));
+}
Copied: grass/trunk/lib/raster/zero_cell.c (from rev 37989, grass/trunk/lib/gis/zero_cell.c)
===================================================================
--- grass/trunk/lib/raster/zero_cell.c (rev 0)
+++ grass/trunk/lib/raster/zero_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -0,0 +1,56 @@
+/*!
+ * \file gis/zero_cell.c
+ *
+ * \brief GIS Library - Zero cell buffer functions.
+ *
+ * (C) 2001-2009 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public License
+ * (>=v2). Read the file COPYING that comes with GRASS for details.
+ *
+ * \author Original author CERL
+ */
+
+#include <grass/gis.h>
+#include <grass/Rast.h>
+
+/*!
+ * \brief Zero a raster CELL buffer.
+ *
+ * This routines assigns each member of the raster buffer array
+ * <i>buf</i> to zero. It assumes that <i>buf</i> has been allocated
+ * using Rast_allocate_cell_buf().
+ *
+ * \param buf data buffer
+ */
+
+void Rast_zero_cell_buf(CELL * buf)
+{
+ int i = G_window_cols();
+
+ while (i--)
+ *buf++ = 0;
+}
+
+/*!
+ * \brief Zero a raster buffer.
+ *
+ * This routines assigns each member of the raster buffer array
+ * <i>rast</i> to zero. It assumes that <i>rast</i> has been allocated
+ * using Rast_allocate_cell_buf().
+ *
+ * \param rast data buffer
+ * \param data_type raster type (CELL, FCELL, DCELL)
+ */
+void Rast_zero_raster_buf(void *rast, RASTER_MAP_TYPE data_type)
+{
+ int i;
+ unsigned char *ptr;
+
+ /* assuming that the size of unsigned char is 1 byte */
+ i = G_window_cols() * Rast_raster_size(data_type);
+ ptr = (unsigned char *)rast;
+
+ while (i--)
+ *ptr++ = 0;
+}
Modified: grass/trunk/lib/rst/interp_float/input2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/input2d.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/rst/interp_float/input2d.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,7 +17,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/site.h>
#include <grass/bitmap.h>
#include <grass/linkm.h>
@@ -33,8 +35,8 @@
CELL *cellmask, *MASK;
struct BM *bitmask;
- if ((MASKfd = G_maskfd()) >= 0)
- MASK = G_allocate_cell_buf();
+ if ((MASKfd = Rast_maskfd()) >= 0)
+ MASK = Rast_allocate_cell_buf();
else
MASK = NULL;
@@ -47,8 +49,8 @@
G_fatal_error(_("Mask raster map <%s> not found"),
params->maskmap);
- cellmask = G_allocate_cell_buf();
- cfmask = G_open_cell_old(params->maskmap, mapsetm);
+ cellmask = Rast_allocate_cell_buf();
+ cfmask = Rast_open_cell_old(params->maskmap, mapsetm);
}
else
cellmask = NULL;
@@ -56,9 +58,9 @@
for (i = 0; i < params->nsizr; i++) {
irev = params->nsizr - i - 1;
if (cellmask)
- G_get_map_row(cfmask, cellmask, i);
+ Rast_get_map_row(cfmask, cellmask, i);
if (MASK)
- G_get_map_row(MASKfd, MASK, i);
+ Rast_get_map_row(MASKfd, MASK, i);
for (j = 0; j < params->nsizc; j++) {
if ((cellmask && cellmask[j] == 0) || (MASK && MASK[j] == 0))
BM_set(bitmask, j, irev, 0);
Modified: grass/trunk/lib/rst/interp_float/interp2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/interp2d.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/rst/interp_float/interp2d.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,7 +26,9 @@
#include <stdio.h>
#include <math.h>
#include <unistd.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/bitmap.h>
#include <grass/interpf.h>
@@ -236,16 +238,16 @@
}
else {
- G_set_d_null_value(params->az + l, 1);
+ Rast_set_d_null_value(params->az + l, 1);
/* fprintf (stderr, "zz=%f, az[l]=%f, c=%d\n", zz, params->az[l], l); */
if (cond1) {
- G_set_d_null_value(params->adx + l, 1);
- G_set_d_null_value(params->ady + l, 1);
+ Rast_set_d_null_value(params->adx + l, 1);
+ Rast_set_d_null_value(params->ady + l, 1);
if (cond2) {
- G_set_d_null_value(params->adxx + l, 1);
- G_set_d_null_value(params->adyy + l, 1);
- G_set_d_null_value(params->adxy + l, 1);
+ Rast_set_d_null_value(params->adxx + l, 1);
+ Rast_set_d_null_value(params->adyy + l, 1);
+ Rast_set_d_null_value(params->adxy + l, 1);
}
}
}
Modified: grass/trunk/lib/rst/interp_float/output2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/output2d.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/rst/interp_float/output2d.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,7 +15,9 @@
#include <stdio.h>
#include <math.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/bitmap.h>
#include <grass/linkm.h>
@@ -54,13 +56,13 @@
|| (params->mcurv != NULL));
cond1 = ((params->slope != NULL) || (params->aspect != NULL) || cond2);
- cell1 = G_allocate_f_raster_buf();
+ cell1 = Rast_allocate_f_raster_buf();
/*
* G_set_embedded_null_value_mode(1);
*/
if (params->elev != NULL) {
- cf1 = G_open_fp_cell_new(params->elev);
+ cf1 = Rast_open_fp_cell_new(params->elev);
if (cf1 < 0) {
fprintf(stderr, "unable to create raster map %s\n", params->elev);
return -1;
@@ -68,7 +70,7 @@
}
if (params->slope != NULL) {
- cf2 = G_open_fp_cell_new(params->slope);
+ cf2 = Rast_open_fp_cell_new(params->slope);
if (cf2 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->slope);
@@ -77,7 +79,7 @@
}
if (params->aspect != NULL) {
- cf3 = G_open_fp_cell_new(params->aspect);
+ cf3 = Rast_open_fp_cell_new(params->aspect);
if (cf3 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->aspect);
@@ -86,7 +88,7 @@
}
if (params->pcurv != NULL) {
- cf4 = G_open_fp_cell_new(params->pcurv);
+ cf4 = Rast_open_fp_cell_new(params->pcurv);
if (cf4 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->pcurv);
@@ -95,7 +97,7 @@
}
if (params->tcurv != NULL) {
- cf5 = G_open_fp_cell_new(params->tcurv);
+ cf5 = Rast_open_fp_cell_new(params->tcurv);
if (cf5 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->tcurv);
@@ -104,7 +106,7 @@
}
if (params->mcurv != NULL) {
- cf6 = G_open_fp_cell_new(params->mcurv);
+ cf6 = Rast_open_fp_cell_new(params->mcurv);
if (cf6 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->mcurv);
@@ -157,7 +159,7 @@
* for(j=0;j<params->nsizc;j++) fprintf(stderr,"%f ",cell1[j]);
* fprintf(stderr,"\n");
*/
- G_put_f_raster_row(cf1, cell1);
+ Rast_put_f_raster_row(cf1, cell1);
}
}
@@ -174,7 +176,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dx);
- G_put_f_raster_row(cf2, cell1);
+ Rast_put_f_raster_row(cf2, cell1);
}
}
@@ -190,7 +192,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dy);
- G_put_f_raster_row(cf3, cell1);
+ Rast_put_f_raster_row(cf3, cell1);
}
}
@@ -206,7 +208,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xx);
- G_put_f_raster_row(cf4, cell1);
+ Rast_put_f_raster_row(cf4, cell1);
}
}
@@ -222,7 +224,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_yy);
- G_put_f_raster_row(cf5, cell1);
+ Rast_put_f_raster_row(cf5, cell1);
}
}
@@ -238,49 +240,49 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xy);
- G_put_f_raster_row(cf6, cell1);
+ Rast_put_f_raster_row(cf6, cell1);
}
}
if (cf1)
- G_close_cell(cf1);
+ Rast_close_cell(cf1);
if (cf2)
- G_close_cell(cf2);
+ Rast_close_cell(cf2);
if (cf3)
- G_close_cell(cf3);
+ Rast_close_cell(cf3);
if (cf4)
- G_close_cell(cf4);
+ Rast_close_cell(cf4);
if (cf5)
- G_close_cell(cf5);
+ Rast_close_cell(cf5);
if (cf6)
- G_close_cell(cf6);
+ Rast_close_cell(cf6);
/* colortable for elevations */
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
zstep = (FCELL) (zmaxac - zminac) / 5.;
for (i = 1; i <= 5; i++) {
data1 = (FCELL) (zminac + (i - 1) * zstep);
data2 = (FCELL) (zminac + i * zstep);
switch (i) {
case 1:
- G_add_f_raster_color_rule(&data1, 0, 191, 191,
+ Rast_add_f_raster_color_rule(&data1, 0, 191, 191,
&data2, 0, 255, 0, &colors);
break;
case 2:
- G_add_f_raster_color_rule(&data1, 0, 255, 0,
+ Rast_add_f_raster_color_rule(&data1, 0, 255, 0,
&data2, 255, 255, 0, &colors);
break;
case 3:
- G_add_f_raster_color_rule(&data1, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&data1, 255, 255, 0,
&data2, 255, 127, 0, &colors);
break;
case 4:
- G_add_f_raster_color_rule(&data1, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&data1, 255, 127, 0,
&data2, 191, 127, 63, &colors);
break;
case 5:
- G_add_f_raster_color_rule(&data1, 191, 127, 63,
+ Rast_add_f_raster_color_rule(&data1, 191, 127, 63,
&data2, 20, 20, 20, &colors);
break;
}
@@ -292,8 +294,8 @@
fprintf(stderr, "file [%s] not found\n", params->elev);
return -1;
}
- G_write_colors(params->elev, mapset, &colors);
- G_quantize_fp_map_range(params->elev, mapset,
+ Rast_write_colors(params->elev, mapset, &colors);
+ Rast_quantize_fp_map_range(params->elev, mapset,
(DCELL) zminac - 0.5, (DCELL) zmaxac + 0.5,
(CELL) (zminac - 0.5), (CELL) (zmaxac + 0.5));
}
@@ -303,53 +305,53 @@
if (!params->deriv) {
/*
* smin = (CELL) ((int)(gmin*scig)); smax = (CELL) gmax; fprintf
- * (stderr, "min %d max %d \n", smin,smax); G_make_rainbow_colors
+ * (stderr, "min %d max %d \n", smin,smax); Rast_make_rainbow_colors
* (&colors,smin,smax);
*/
- G_init_colors(&colors);
- G_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
- G_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
- G_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
- G_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
- G_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
- G_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
- G_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
+ Rast_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
+ Rast_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
+ Rast_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
+ Rast_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
+ Rast_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
+ Rast_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
}
else {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) - 5.0; /* replace by min dx, amin1 (c1min,
* c2min); */
dat2 = (FCELL) - 0.1;
- G_add_f_raster_color_rule(&dat1, 127, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 127, 0, 255,
&dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255,
&dat2, 0, 127, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.001;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255,
&dat2, 0, 255, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.0;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255,
&dat2, 200, 255, 200, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 200, 255, 200,
+ Rast_add_f_raster_color_rule(&dat1, 200, 255, 200,
&dat2, 255, 255, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0,
&dat2, 255, 127, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.1;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0,
&dat2, 255, 0, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 5.0; /* replace by max dx, amax1 (c1max,
* c2max); */
- G_add_f_raster_color_rule(&dat1, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0,
&dat2, 255, 0, 200, &colors);
}
@@ -359,11 +361,11 @@
fprintf(stderr, "file [%s] not found\n", params->slope);
return -1;
}
- G_write_colors(params->slope, mapset, &colors);
- G_quantize_fp_map_range(params->slope, mapset, 0., 90., 0, 90);
+ Rast_write_colors(params->slope, mapset, &colors);
+ Rast_quantize_fp_map_range(params->slope, mapset, 0., 90., 0, 90);
type = "raster";
- G_short_history(params->slope, type, &hist1);
+ Rast_short_history(params->slope, type, &hist1);
if (params->elev != NULL)
sprintf(hist1.edhist[0], "The elevation map is %s",
params->elev);
@@ -373,8 +375,8 @@
sprintf(hist1.datsrc_1, "site file %s", input);
hist1.edlinecnt = 1;
- G_command_history(&hist1);
- G_write_history(params->slope, &hist1);
+ Rast_command_history(&hist1);
+ Rast_write_history(params->slope, &hist1);
if (params->ts)
G_write_raster_timestamp(params->slope, params->ts);
@@ -382,48 +384,48 @@
/* colortable for aspect */
if (!params->deriv) {
- G_init_colors(&colors);
- G_add_color_rule(0, 255, 255, 255, 0, 255, 255, 255, &colors);
- G_add_color_rule(1, 255, 255, 0, 90, 0, 255, 0, &colors);
- G_add_color_rule(90, 0, 255, 0, 180, 0, 255, 255, &colors);
- G_add_color_rule(180, 0, 255, 255, 270, 255, 0, 0, &colors);
- G_add_color_rule(270, 255, 0, 0, 360, 255, 255, 0, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0, 255, 255, 255, 0, 255, 255, 255, &colors);
+ Rast_add_color_rule(1, 255, 255, 0, 90, 0, 255, 0, &colors);
+ Rast_add_color_rule(90, 0, 255, 0, 180, 0, 255, 255, &colors);
+ Rast_add_color_rule(180, 0, 255, 255, 270, 255, 0, 0, &colors);
+ Rast_add_color_rule(270, 255, 0, 0, 360, 255, 255, 0, &colors);
}
else {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) - 5.0; /* replace by min dy, amin1 (c1min,
* c2min); */
dat2 = (FCELL) - 0.1;
- G_add_f_raster_color_rule(&dat1, 127, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 127, 0, 255,
&dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255,
&dat2, 0, 127, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.001;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255,
&dat2, 0, 255, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.0;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255,
&dat2, 200, 255, 200, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 200, 255, 200,
+ Rast_add_f_raster_color_rule(&dat1, 200, 255, 200,
&dat2, 255, 255, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0,
&dat2, 255, 127, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.1;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0,
&dat2, 255, 0, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 5.0; /* replace by max dy, amax1 (c1max,
* c2max); */
- G_add_f_raster_color_rule(&dat1, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0,
&dat2, 255, 0, 200, &colors);
}
@@ -433,11 +435,11 @@
fprintf(stderr, "file [%s] not found\n", params->aspect);
return -1;
}
- G_write_colors(params->aspect, mapset, &colors);
- G_quantize_fp_map_range(params->aspect, mapset, 0., 360., 0, 360);
+ Rast_write_colors(params->aspect, mapset, &colors);
+ Rast_quantize_fp_map_range(params->aspect, mapset, 0., 360., 0, 360);
type = "raster";
- G_short_history(params->aspect, type, &hist2);
+ Rast_short_history(params->aspect, type, &hist2);
if (params->elev != NULL)
sprintf(hist2.edhist[0], "The elevation map is %s",
params->elev);
@@ -447,48 +449,48 @@
sprintf(hist2.datsrc_1, "site file %s", input);
hist2.edlinecnt = 1;
- G_command_history(&hist2);
- G_write_history(params->aspect, &hist2);
+ Rast_command_history(&hist2);
+ Rast_write_history(params->aspect, &hist2);
if (params->ts)
G_write_raster_timestamp(params->aspect, params->ts);
}
/* colortable for curvatures */
if (cond2) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) amin1(c1min, c2min); /* for derivatives use min
* dxx,dyy,dxy */
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 127, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 127, 0, 255,
&dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.001;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255,
&dat2, 0, 127, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.00001;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255,
&dat2, 0, 255, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.0;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255,
&dat2, 200, 255, 200, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.00001;
- G_add_f_raster_color_rule(&dat1, 200, 255, 200,
+ Rast_add_f_raster_color_rule(&dat1, 200, 255, 200,
&dat2, 255, 255, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0,
&dat2, 255, 127, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0,
&dat2, 255, 0, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) amax1(c1max, c2max); /* for derivatives use max
* dxx,dyy,dxy */
- G_add_f_raster_color_rule(&dat1, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0,
&dat2, 255, 0, 200, &colors);
if (params->pcurv != NULL) {
@@ -497,13 +499,13 @@
fprintf(stderr, "file [%s] not found\n", params->pcurv);
return -1;
}
- G_write_colors(params->pcurv, mapset, &colors);
- G_quantize_fp_map_range(params->pcurv, mapset, dat1, dat2,
+ Rast_write_colors(params->pcurv, mapset, &colors);
+ Rast_quantize_fp_map_range(params->pcurv, mapset, dat1, dat2,
(CELL) (dat1 * MULT),
(CELL) (dat2 * MULT));
type = "raster";
- G_short_history(params->pcurv, type, &hist3);
+ Rast_short_history(params->pcurv, type, &hist3);
if (params->elev != NULL)
sprintf(hist3.edhist[0], "The elevation map is %s",
params->elev);
@@ -513,8 +515,8 @@
sprintf(hist3.datsrc_1, "site file %s", input);
hist3.edlinecnt = 1;
- G_command_history(&hist3);
- G_write_history(params->pcurv, &hist3);
+ Rast_command_history(&hist3);
+ Rast_write_history(params->pcurv, &hist3);
if (params->ts)
G_write_raster_timestamp(params->pcurv, params->ts);
}
@@ -525,13 +527,13 @@
fprintf(stderr, "file [%s] not found\n", params->tcurv);
return -1;
}
- G_write_colors(params->tcurv, mapset, &colors);
- G_quantize_fp_map_range(params->tcurv, mapset, dat1, dat2,
+ Rast_write_colors(params->tcurv, mapset, &colors);
+ Rast_quantize_fp_map_range(params->tcurv, mapset, dat1, dat2,
(CELL) (dat1 * MULT),
(CELL) (dat2 * MULT));
type = "raster";
- G_short_history(params->tcurv, type, &hist4);
+ Rast_short_history(params->tcurv, type, &hist4);
if (params->elev != NULL)
sprintf(hist4.edhist[0], "The elevation map is %s",
params->elev);
@@ -541,8 +543,8 @@
sprintf(hist4.datsrc_1, "site file %s", input);
hist4.edlinecnt = 1;
- G_command_history(&hist4);
- G_write_history(params->tcurv, &hist4);
+ Rast_command_history(&hist4);
+ Rast_write_history(params->tcurv, &hist4);
if (params->ts)
G_write_raster_timestamp(params->tcurv, params->ts);
}
@@ -553,13 +555,13 @@
fprintf(stderr, "file [%s] not found\n", params->mcurv);
return -1;
}
- G_write_colors(params->mcurv, mapset, &colors);
- G_quantize_fp_map_range(params->mcurv, mapset, dat1, dat2,
+ Rast_write_colors(params->mcurv, mapset, &colors);
+ Rast_quantize_fp_map_range(params->mcurv, mapset, dat1, dat2,
(CELL) (dat1 * MULT),
(CELL) (dat2 * MULT));
type = "raster";
- G_short_history(params->mcurv, type, &hist5);
+ Rast_short_history(params->mcurv, type, &hist5);
if (params->elev != NULL)
sprintf(hist5.edhist[0], "The elevation map is %s",
params->elev);
@@ -569,8 +571,8 @@
sprintf(hist5.datsrc_1, "site file %s", input);
hist5.edlinecnt = 1;
- G_command_history(&hist5);
- G_write_history(params->mcurv, &hist5);
+ Rast_command_history(&hist5);
+ Rast_write_history(params->mcurv, &hist5);
if (params->ts)
G_write_raster_timestamp(params->mcurv, params->ts);
}
@@ -584,7 +586,7 @@
return -1;
}
type = "raster";
- G_short_history(params->elev, type, &hist);
+ Rast_short_history(params->elev, type, &hist);
params->dmin = sqrt(params->dmin);
fprintf(stdout, "history initiated\n");
@@ -641,14 +643,14 @@
else
sprintf(hist.datsrc_1, "site file %s", input);
- G_command_history(&hist);
- G_write_history(params->elev, &hist);
+ Rast_command_history(&hist);
+ Rast_write_history(params->elev, &hist);
if (params->ts)
G_write_raster_timestamp(params->elev, params->ts);
}
/*
- * if (title) G_put_cell_title (output, title);
+ * if (title) Rast_put_cell_title (output, title);
*/
return 1;
}
Modified: grass/trunk/lib/rst/interp_float/resout2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/resout2d.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/rst/interp_float/resout2d.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,10 +15,11 @@
#include <stdio.h>
#include <math.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/bitmap.h>
#include <grass/linkm.h>
-
#include <grass/interpf.h>
@@ -63,10 +64,10 @@
}
mapset = G_mapset();
- cell1 = G_allocate_f_raster_buf();
+ cell1 = Rast_allocate_f_raster_buf();
if (params->elev != NULL) {
- cf1 = G_open_fp_cell_new(params->elev);
+ cf1 = Rast_open_fp_cell_new(params->elev);
if (cf1 < 0) {
fprintf(stderr, "unable to create raster map %s\n", params->elev);
return -1;
@@ -74,7 +75,7 @@
}
if (params->slope != NULL) {
- cf2 = G_open_fp_cell_new(params->slope);
+ cf2 = Rast_open_fp_cell_new(params->slope);
if (cf2 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->slope);
@@ -83,7 +84,7 @@
}
if (params->aspect != NULL) {
- cf3 = G_open_fp_cell_new(params->aspect);
+ cf3 = Rast_open_fp_cell_new(params->aspect);
if (cf3 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->aspect);
@@ -92,7 +93,7 @@
}
if (params->pcurv != NULL) {
- cf4 = G_open_fp_cell_new(params->pcurv);
+ cf4 = Rast_open_fp_cell_new(params->pcurv);
if (cf4 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->pcurv);
@@ -101,7 +102,7 @@
}
if (params->tcurv != NULL) {
- cf5 = G_open_fp_cell_new(params->tcurv);
+ cf5 = Rast_open_fp_cell_new(params->tcurv);
if (cf5 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->tcurv);
@@ -110,7 +111,7 @@
}
if (params->mcurv != NULL) {
- cf6 = G_open_fp_cell_new(params->mcurv);
+ cf6 = Rast_open_fp_cell_new(params->mcurv);
if (cf6 < 0) {
fprintf(stderr, "unable to create raster map %s\n",
params->mcurv);
@@ -143,7 +144,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_z);
- if (G_put_f_raster_row(cf1, cell1) < 0) {
+ if (Rast_put_f_raster_row(cf1, cell1) < 0) {
fprintf(stderr, "cannot write file\n");
return -1;
}
@@ -166,7 +167,7 @@
* fprintf(stderr,"%f ",cell1[ii]); }
* fprintf(stderr,"params->nsizc=%d \n",params->nsizc);
*/
- if (G_put_f_raster_row(cf2, cell1) < 0) {
+ if (Rast_put_f_raster_row(cf2, cell1) < 0) {
fprintf(stderr, "cannot write file\n");
return -1;
}
@@ -184,7 +185,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_dy);
- if (G_put_f_raster_row(cf3, cell1) < 0) {
+ if (Rast_put_f_raster_row(cf3, cell1) < 0) {
fprintf(stderr, "cannot write file\n");
return -1;
}
@@ -202,7 +203,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xx);
- if (G_put_f_raster_row(cf4, cell1) < 0) {
+ if (Rast_put_f_raster_row(cf4, cell1) < 0) {
fprintf(stderr, "cannot write file\n");
return -1;
}
@@ -220,7 +221,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_yy);
- if (G_put_f_raster_row(cf5, cell1) < 0) {
+ if (Rast_put_f_raster_row(cf5, cell1) < 0) {
fprintf(stderr, "cannot write file\n");
return -1;
}
@@ -238,7 +239,7 @@
return -1;
}
fread(cell1, sizeof(FCELL), params->nsizc, params->Tmp_fd_xy);
- if (G_put_f_raster_row(cf6, cell1) < 0) {
+ if (Rast_put_f_raster_row(cf6, cell1) < 0) {
fprintf(stderr, "cannot write file\n");
return -1;
}
@@ -246,17 +247,17 @@
}
if (cf1)
- G_close_cell(cf1);
+ Rast_close_cell(cf1);
if (cf2)
- G_close_cell(cf2);
+ Rast_close_cell(cf2);
if (cf3)
- G_close_cell(cf3);
+ Rast_close_cell(cf3);
if (cf4)
- G_close_cell(cf4);
+ Rast_close_cell(cf4);
if (cf5)
- G_close_cell(cf5);
+ Rast_close_cell(cf5);
if (cf6)
- G_close_cell(cf6);
+ Rast_close_cell(cf6);
/* write colormaps and history for output cell files */
/* colortable for elevations */
@@ -267,12 +268,12 @@
fprintf(stderr, "file [%s] not found\n", input);
return -1;
}
- G_init_colors(&colors2);
+ Rast_init_colors(&colors2);
/*
- * G_mark_colors_as_fp(&colors2);
+ * Rast_mark_colors_as_fp(&colors2);
*/
- if (G_read_colors(input, maps, &colors) >= 0) {
+ if (Rast_read_colors(input, maps, &colors) >= 0) {
if (colors.modular.rules) {
rule = colors.modular.rules;
@@ -282,7 +283,7 @@
for (; rule; rule = rule->prev) {
value1 = rule->low.value * params->zmult;
value2 = rule->high.value * params->zmult;
- G_add_modular_d_raster_color_rule(&value1, rule->low.red,
+ Rast_add_modular_d_raster_color_rule(&value1, rule->low.red,
rule->low.grn,
rule->low.blu, &value2,
rule->high.red,
@@ -301,7 +302,7 @@
for (; rule; rule = rule->prev) {
value1 = rule->low.value * params->zmult;
value2 = rule->high.value * params->zmult;
- G_add_d_raster_color_rule(&value1, rule->low.red,
+ Rast_add_d_raster_color_rule(&value1, rule->low.red,
rule->low.grn, rule->low.blu,
&value2, rule->high.red,
rule->high.grn, rule->high.blu,
@@ -316,11 +317,11 @@
return -1;
}
- if (G_write_colors(params->elev, maps, &colors2) < 0) {
+ if (Rast_write_colors(params->elev, maps, &colors2) < 0) {
fprintf(stderr, "Cannot write color table\n");
return -1;
}
- G_quantize_fp_map_range(params->elev, mapset,
+ Rast_quantize_fp_map_range(params->elev, mapset,
zminac - 0.5, zmaxac + 0.5,
(CELL) (zminac - 0.5),
(CELL) (zmaxac + 0.5));
@@ -332,14 +333,14 @@
/* colortable for slopes */
if (cond1 & (!params->deriv)) {
- G_init_colors(&colors);
- G_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
- G_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
- G_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
- G_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
- G_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
- G_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
- G_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
+ Rast_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
+ Rast_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
+ Rast_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
+ Rast_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
+ Rast_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
+ Rast_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
if (params->slope != NULL) {
maps = NULL;
@@ -348,11 +349,11 @@
fprintf(stderr, "file [%s] not found\n", params->slope);
return -1;
}
- G_write_colors(params->slope, maps, &colors);
- G_quantize_fp_map_range(params->slope, mapset, 0., 90., 0, 90);
+ Rast_write_colors(params->slope, maps, &colors);
+ Rast_quantize_fp_map_range(params->slope, mapset, 0., 90., 0, 90);
type = "raster";
- G_short_history(params->slope, type, &hist1);
+ Rast_short_history(params->slope, type, &hist1);
if (params->elev != NULL)
sprintf(hist1.edhist[0], "The elevation map is %s",
params->elev);
@@ -360,16 +361,16 @@
sprintf(hist1.datsrc_1, "raster map %s", input);
hist1.edlinecnt = 1;
- G_write_history(params->slope, &hist1);
+ Rast_write_history(params->slope, &hist1);
}
/* colortable for aspect */
- G_init_colors(&colors);
- G_add_color_rule(0, 255, 255, 255, 0, 255, 255, 255, &colors);
- G_add_color_rule(1, 255, 255, 0, 90, 0, 255, 0, &colors);
- G_add_color_rule(90, 0, 255, 0, 180, 0, 255, 255, &colors);
- G_add_color_rule(180, 0, 255, 255, 270, 255, 0, 0, &colors);
- G_add_color_rule(270, 255, 0, 0, 360, 255, 255, 0, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0, 255, 255, 255, 0, 255, 255, 255, &colors);
+ Rast_add_color_rule(1, 255, 255, 0, 90, 0, 255, 0, &colors);
+ Rast_add_color_rule(90, 0, 255, 0, 180, 0, 255, 255, &colors);
+ Rast_add_color_rule(180, 0, 255, 255, 270, 255, 0, 0, &colors);
+ Rast_add_color_rule(270, 255, 0, 0, 360, 255, 255, 0, &colors);
if (params->aspect != NULL) {
maps = NULL;
@@ -378,11 +379,11 @@
fprintf(stderr, "file [%s] not found\n", params->aspect);
return -1;
}
- G_write_colors(params->aspect, maps, &colors);
- G_quantize_fp_map_range(params->aspect, mapset, 0., 360., 0, 360);
+ Rast_write_colors(params->aspect, maps, &colors);
+ Rast_quantize_fp_map_range(params->aspect, mapset, 0., 360., 0, 360);
type = "raster";
- G_short_history(params->aspect, type, &hist2);
+ Rast_short_history(params->aspect, type, &hist2);
if (params->elev != NULL)
sprintf(hist2.edhist[0], "The elevation map is %s",
params->elev);
@@ -390,45 +391,45 @@
sprintf(hist2.datsrc_1, "raster map %s", input);
hist2.edlinecnt = 1;
- G_write_history(params->aspect, &hist2);
+ Rast_write_history(params->aspect, &hist2);
}
/* colortable for curvatures */
if (cond2) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) amin1(c1min, c2min);
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 50, 0, 155,
+ Rast_add_f_raster_color_rule(&dat1, 50, 0, 155,
&dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.001;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255,
&dat2, 0, 127, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.00001;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255,
&dat2, 0, 255, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.00;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255,
&dat2, 200, 255, 200, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.00001;
- G_add_f_raster_color_rule(&dat1, 200, 255, 200,
+ Rast_add_f_raster_color_rule(&dat1, 200, 255, 200,
&dat2, 255, 255, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0,
&dat2, 255, 127, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0,
&dat2, 255, 0, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) amax1(c1max, c2max);
- G_add_f_raster_color_rule(&dat1, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0,
&dat2, 155, 0, 20, &colors);
maps = NULL;
if (params->pcurv != NULL) {
@@ -437,16 +438,16 @@
fprintf(stderr, "file [%s] not found\n", params->pcurv);
return -1;
}
- G_write_colors(params->pcurv, maps, &colors);
+ Rast_write_colors(params->pcurv, maps, &colors);
fprintf(stderr, "color map written\n");
- G_quantize_fp_map_range(params->pcurv, mapset,
+ Rast_quantize_fp_map_range(params->pcurv, mapset,
dat1, dat2,
(CELL) (dat1 * MULT),
(CELL) (dat2 * MULT));
type = "raster";
- G_short_history(params->pcurv, type, &hist3);
+ Rast_short_history(params->pcurv, type, &hist3);
if (params->elev != NULL)
sprintf(hist3.edhist[0], "The elevation map is %s",
params->elev);
@@ -454,7 +455,7 @@
sprintf(hist3.datsrc_1, "raster map %s", input);
hist3.edlinecnt = 1;
- G_write_history(params->pcurv, &hist3);
+ Rast_write_history(params->pcurv, &hist3);
}
if (params->tcurv != NULL) {
@@ -464,13 +465,13 @@
fprintf(stderr, "file [%s] not found\n", params->tcurv);
return -1;
}
- G_write_colors(params->tcurv, maps, &colors);
- G_quantize_fp_map_range(params->tcurv, mapset,
+ Rast_write_colors(params->tcurv, maps, &colors);
+ Rast_quantize_fp_map_range(params->tcurv, mapset,
dat1, dat2, (CELL) (dat1 * MULT),
(CELL) (dat2 * MULT));
type = "raster";
- G_short_history(params->tcurv, type, &hist4);
+ Rast_short_history(params->tcurv, type, &hist4);
if (params->elev != NULL)
sprintf(hist4.edhist[0], "The elevation map is %s",
params->elev);
@@ -478,7 +479,7 @@
sprintf(hist4.datsrc_1, "raster map %s", input);
hist4.edlinecnt = 1;
- G_write_history(params->tcurv, &hist4);
+ Rast_write_history(params->tcurv, &hist4);
}
if (params->mcurv != NULL) {
@@ -488,14 +489,14 @@
fprintf(stderr, "file [%s] not found\n", params->mcurv);
return -1;
}
- G_write_colors(params->mcurv, maps, &colors);
- G_quantize_fp_map_range(params->mcurv, mapset,
+ Rast_write_colors(params->mcurv, maps, &colors);
+ Rast_quantize_fp_map_range(params->mcurv, mapset,
dat1, dat2,
(CELL) (dat1 * MULT),
(CELL) (dat2 * MULT));
type = "raster";
- G_short_history(params->mcurv, type, &hist5);
+ Rast_short_history(params->mcurv, type, &hist5);
if (params->elev != NULL)
sprintf(hist5.edhist[0], "The elevation map is %s",
params->elev);
@@ -503,7 +504,7 @@
sprintf(hist5.datsrc_1, "raster map %s", input);
hist5.edlinecnt = 1;
- G_write_history(params->mcurv, &hist5);
+ Rast_write_history(params->mcurv, &hist5);
}
}
}
@@ -514,7 +515,7 @@
fprintf(stderr, "file [%s] not found \n", params->elev);
return -1;
}
- G_short_history(params->elev, "raster", &hist);
+ Rast_short_history(params->elev, "raster", &hist);
if (smooth != NULL)
sprintf(hist.edhist[0], "tension=%f, smoothing=%s",
@@ -532,7 +533,7 @@
hist.edlinecnt = 5;
- G_write_history(params->elev, &hist);
+ Rast_write_history(params->elev, &hist);
}
/* change region to initial region */
Modified: grass/trunk/lib/rst/interp_float/ressegm2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/ressegm2d.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/rst/interp_float/ressegm2d.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,7 +21,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/interpf.h>
#include <grass/gmath.h>
@@ -168,7 +170,7 @@
0, params->KMAX2);
m1 = 0;
for (k = 1; k <= p_size; k++) {
- if (!G_is_f_null_value(&(in_points[k - 1].z))) {
+ if (!Rast_is_f_null_value(&(in_points[k - 1].z))) {
data->points[m1].x = in_points[k - 1].x / (*dnorm);
data->points[m1].y = in_points[k - 1].y / (*dnorm);
/* data->points[m1].z = (double) (in_points[k - 1].z) / (*dnorm); */
@@ -316,7 +318,7 @@
for (k = 0; k <= last_row - first_row; k++) {
for (l = first_col - 1; l < last_col; l++) {
index = k * inp_cols + l;
- if (!G_is_f_null_value(&(in_points[index].z))) {
+ if (!Rast_is_f_null_value(&(in_points[index].z))) {
/* if the point is inside the segment (not overlapping) */
if ((in_points[index].x - x_or >= 0) &&
(in_points[index].y - y_or >= 0) &&
@@ -491,19 +493,19 @@
{
double x, y, sm; /* input data and smoothing */
int m1, m2; /* loop counters */
- int ret_val, ret_val1; /* return values of G_get_map_row */
+ int ret_val, ret_val1; /* return values of Rast_get_map_row */
static FCELL *cellinp = NULL; /* cell buffer for input data */
static FCELL *cellsmooth = NULL; /* cell buffer for smoothing */
if (!cellinp)
- cellinp = G_allocate_f_raster_buf();
+ cellinp = Rast_allocate_f_raster_buf();
if (!cellsmooth)
- cellsmooth = G_allocate_f_raster_buf();
+ cellsmooth = Rast_allocate_f_raster_buf();
for (m1 = 0; m1 <= last_row - first_row; m1++) {
ret_val =
- G_get_f_raster_row(fdinp, cellinp, inp_rows - m1 - first_row);
+ Rast_get_f_raster_row(fdinp, cellinp, inp_rows - m1 - first_row);
if (ret_val < 0) {
fprintf(stderr, "Cannot get row %d (return value = %d)\n", m1,
ret_val);
@@ -511,7 +513,7 @@
}
if (fdsmooth >= 0) {
ret_val1 =
- G_get_f_raster_row(fdsmooth, cellsmooth,
+ Rast_get_f_raster_row(fdsmooth, cellsmooth,
inp_rows - m1 - first_row);
if (ret_val1 < 0) {
fprintf(stderr, "Cannot get smoothing row\n");
@@ -530,12 +532,12 @@
points[m1 * inp_cols + m2].x = x - params->x_orig;
points[m1 * inp_cols + m2].y = y - params->y_orig;
- if (!G_is_f_null_value(cellinp + m2)) {
+ if (!Rast_is_f_null_value(cellinp + m2)) {
points[m1 * inp_cols + m2].z =
cellinp[m2] * params->zmult - zmin;
}
else {
- G_set_f_null_value(&(points[m1 * inp_cols + m2].z), 1);
+ Rast_set_f_null_value(&(points[m1 * inp_cols + m2].z), 1);
}
/* fprintf (stdout,"sm: %f\n",sm); */
@@ -585,17 +587,17 @@
/*
* params->az[l] = 0.;
*/
- G_set_d_null_value(params->az + l, 1);
+ Rast_set_d_null_value(params->az + l, 1);
if (cond1) {
/*
* params->adx[l] = (FCELL)0.; params->ady[l] = (FCELL)0.;
*/
- G_set_d_null_value(params->adx + l, 1);
- G_set_d_null_value(params->ady + l, 1);
+ Rast_set_d_null_value(params->adx + l, 1);
+ Rast_set_d_null_value(params->ady + l, 1);
if (cond2) {
- G_set_d_null_value(params->adxx + l, 1);
- G_set_d_null_value(params->adyy + l, 1);
- G_set_d_null_value(params->adxy + l, 1);
+ Rast_set_d_null_value(params->adxx + l, 1);
+ Rast_set_d_null_value(params->adyy + l, 1);
+ Rast_set_d_null_value(params->adxy + l, 1);
/*
* params->adxx[l] = (FCELL)0.; params->adyy[l] = (FCELL)0.;
* params->adxy[l] = (FCELL)0.;
Modified: grass/trunk/lib/stats/c_ave.c
===================================================================
--- grass/trunk/lib/stats/c_ave.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_ave.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_ave(DCELL * result, DCELL * values, int n, const void *closure)
{
@@ -10,7 +11,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
sum += values[i];
@@ -18,7 +19,7 @@
}
if (count == 0)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
else
*result = sum / count;
}
@@ -33,7 +34,7 @@
count = 0.0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
sum += values[i][0] * values[i][1];
@@ -41,7 +42,7 @@
}
if (count == 0)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
else
*result = sum / count;
}
Modified: grass/trunk/lib/stats/c_count.c
===================================================================
--- grass/trunk/lib/stats/c_count.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_count.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_count(DCELL * result, DCELL * values, int n, const void *closure)
{
@@ -8,7 +9,7 @@
count = 0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i]))
+ if (!Rast_is_d_null_value(&values[i]))
count++;
*result = count;
@@ -22,7 +23,7 @@
count = 0.0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i][0]))
+ if (!Rast_is_d_null_value(&values[i][0]))
count += values[i][1];
*result = count;
Modified: grass/trunk/lib/stats/c_intr.c
===================================================================
--- grass/trunk/lib/stats/c_intr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_intr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/stats.h>
void c_intr(DCELL * result, DCELL * values, int n, const void *closure)
@@ -8,8 +9,8 @@
int diff;
int i;
- if (G_is_d_null_value(&values[n / 2])) {
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&values[n / 2])) {
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -18,7 +19,7 @@
diff = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
count++;
Modified: grass/trunk/lib/stats/c_kurt.c
===================================================================
--- grass/trunk/lib/stats/c_kurt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_kurt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_kurt(DCELL * result, DCELL * values, int n, const void *closure)
{
@@ -10,7 +11,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
sum += values[i];
@@ -18,7 +19,7 @@
}
if (count == 0) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -29,7 +30,7 @@
for (i = 0; i < n; i++) {
DCELL d;
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
d = values[i] - ave;
@@ -52,7 +53,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
sum += values[i][0] * values[i][1];
@@ -60,7 +61,7 @@
}
if (count == 0) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -71,7 +72,7 @@
for (i = 0; i < n; i++) {
DCELL d;
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
d = values[i][0] - ave;
Modified: grass/trunk/lib/stats/c_max.c
===================================================================
--- grass/trunk/lib/stats/c_max.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_max.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,22 +1,23 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_max(DCELL * result, DCELL * values, int n, const void *closure)
{
DCELL max;
int i;
- G_set_d_null_value(&max, 1);
+ Rast_set_d_null_value(&max, 1);
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
- if (G_is_d_null_value(&max) || max < values[i])
+ if (Rast_is_d_null_value(&max) || max < values[i])
max = values[i];
}
- if (G_is_d_null_value(&max))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&max))
+ Rast_set_d_null_value(result, 1);
else
*result = max;
}
@@ -26,18 +27,18 @@
DCELL max;
int i;
- G_set_d_null_value(&max, 1);
+ Rast_set_d_null_value(&max, 1);
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
- if (G_is_d_null_value(&max) || max < values[i][0])
+ if (Rast_is_d_null_value(&max) || max < values[i][0])
max = values[i][0];
}
- if (G_is_d_null_value(&max))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&max))
+ Rast_set_d_null_value(result, 1);
else
*result = max;
}
Modified: grass/trunk/lib/stats/c_maxx.c
===================================================================
--- grass/trunk/lib/stats/c_maxx.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_maxx.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,25 +1,26 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_maxx(DCELL * result, DCELL * values, int n, const void *closure)
{
DCELL max, maxx;
int i;
- G_set_d_null_value(&max, 1);
- G_set_d_null_value(&maxx, 1);
+ Rast_set_d_null_value(&max, 1);
+ Rast_set_d_null_value(&maxx, 1);
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
- if (G_is_d_null_value(&max) || max < values[i]) {
+ if (Rast_is_d_null_value(&max) || max < values[i]) {
max = values[i];
maxx = i;
}
}
- if (G_is_d_null_value(&maxx))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&maxx))
+ Rast_set_d_null_value(result, 1);
else
*result = maxx;
}
Modified: grass/trunk/lib/stats/c_median.c
===================================================================
--- grass/trunk/lib/stats/c_median.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_median.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/stats.h>
void c_median(DCELL * result, DCELL * values, int n, const void *closure)
@@ -6,7 +7,7 @@
n = sort_cell(values, n);
if (n < 1)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
else
*result = (values[(n - 1) / 2] + values[n / 2]) / 2;
}
@@ -20,7 +21,7 @@
n = sort_cell_w(values, n);
if (n < 1) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
Modified: grass/trunk/lib/stats/c_min.c
===================================================================
--- grass/trunk/lib/stats/c_min.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_min.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,22 +1,23 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_min(DCELL * result, DCELL * values, int n, const void *closure)
{
DCELL min;
int i;
- G_set_d_null_value(&min, 1);
+ Rast_set_d_null_value(&min, 1);
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
- if (G_is_d_null_value(&min) || min > values[i])
+ if (Rast_is_d_null_value(&min) || min > values[i])
min = values[i];
}
- if (G_is_d_null_value(&min))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&min))
+ Rast_set_d_null_value(result, 1);
else
*result = min;
}
@@ -26,18 +27,18 @@
DCELL min;
int i;
- G_set_d_null_value(&min, 1);
+ Rast_set_d_null_value(&min, 1);
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
- if (G_is_d_null_value(&min) || min > values[i][0])
+ if (Rast_is_d_null_value(&min) || min > values[i][0])
min = values[i][0];
}
- if (G_is_d_null_value(&min))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&min))
+ Rast_set_d_null_value(result, 1);
else
*result = min;
}
Modified: grass/trunk/lib/stats/c_minx.c
===================================================================
--- grass/trunk/lib/stats/c_minx.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_minx.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,26 +1,26 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
-
void c_minx(DCELL * result, DCELL * values, int n, const void *closure)
{
DCELL min, minx;
int i;
- G_set_d_null_value(&min, 1);
- G_set_d_null_value(&minx, 1);
+ Rast_set_d_null_value(&min, 1);
+ Rast_set_d_null_value(&minx, 1);
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
- if (G_is_d_null_value(&min) || min > values[i]) {
+ if (Rast_is_d_null_value(&min) || min > values[i]) {
min = values[i];
minx = i;
}
}
- if (G_is_d_null_value(&minx))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&minx))
+ Rast_set_d_null_value(result, 1);
else
*result = minx;
}
Modified: grass/trunk/lib/stats/c_mode.c
===================================================================
--- grass/trunk/lib/stats/c_mode.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_mode.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/stats.h>
void c_mode(DCELL * result, DCELL * values, int n, const void *closure)
@@ -29,7 +30,7 @@
}
if (max == 0)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
else
*result = mode;
}
@@ -62,7 +63,7 @@
}
if (max == 0.0)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
else
*result = mode;
}
Modified: grass/trunk/lib/stats/c_percentile.c
===================================================================
--- grass/trunk/lib/stats/c_percentile.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_percentile.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,7 @@
#include <math.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/stats.h>
void c_quant(DCELL * result, DCELL * values, int n, const void *closure)
@@ -11,7 +13,7 @@
n = sort_cell(values, n);
if (n < 1) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -52,7 +54,7 @@
n = sort_cell_w(values, n);
if (n < 1) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
Modified: grass/trunk/lib/stats/c_range.c
===================================================================
--- grass/trunk/lib/stats/c_range.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,26 +1,27 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_range(DCELL * result, DCELL * values, int n, const void *closure)
{
DCELL min, max;
int i;
- G_set_d_null_value(&min, 1);
- G_set_d_null_value(&max, 1);
+ Rast_set_d_null_value(&min, 1);
+ Rast_set_d_null_value(&max, 1);
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
- if (G_is_d_null_value(&min) || min > values[i])
+ if (Rast_is_d_null_value(&min) || min > values[i])
min = values[i];
- if (G_is_d_null_value(&max) || max < values[i])
+ if (Rast_is_d_null_value(&max) || max < values[i])
max = values[i];
}
- if (G_is_d_null_value(&min) || G_is_d_null_value(&max))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&min) || Rast_is_d_null_value(&max))
+ Rast_set_d_null_value(result, 1);
else
*result = max - min;
}
Modified: grass/trunk/lib/stats/c_reg.c
===================================================================
--- grass/trunk/lib/stats/c_reg.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_reg.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#define REGRESSION_SLOPE 0
#define REGRESSION_OFFSET 1
@@ -16,7 +17,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
xsum += i;
@@ -25,7 +26,7 @@
}
if (count < 2) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -34,13 +35,13 @@
numer = 0.0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i]))
+ if (!Rast_is_d_null_value(&values[i]))
numer += i * values[i];
numer -= count * xbar * ybar;
denom = 0.0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i]))
+ if (!Rast_is_d_null_value(&values[i]))
denom += (DCELL) i *i;
denom -= count * xbar * xbar;
@@ -48,7 +49,7 @@
if (which == REGRESSION_COEFF_DET) {
denom2 = 0.0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i]))
+ if (!Rast_is_d_null_value(&values[i]))
denom2 += values[i] * values[i];
denom2 -= count * ybar * ybar;
}
@@ -64,13 +65,13 @@
*result = (numer * numer) / (denom * denom2);
break;
default:
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
break;
}
/* Check for NaN */
if (*result != *result)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
}
void c_reg_m(DCELL * result, DCELL * values, int n, const void *closure)
@@ -100,7 +101,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
xsum += i * values[i][1];
@@ -109,7 +110,7 @@
}
if (count < 2) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -118,13 +119,13 @@
numer = 0.0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i][0]))
+ if (!Rast_is_d_null_value(&values[i][0]))
numer += i * values[i][0] * values[i][1];
numer -= count * xbar * ybar;
denom = 0.0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i][0]))
+ if (!Rast_is_d_null_value(&values[i][0]))
denom += (DCELL) i *i * values[i][1];
denom -= count * xbar * xbar;
@@ -132,7 +133,7 @@
if (which == REGRESSION_COEFF_DET) {
denom2 = 0.0;
for (i = 0; i < n; i++)
- if (!G_is_d_null_value(&values[i][0]))
+ if (!Rast_is_d_null_value(&values[i][0]))
denom2 += values[i][0] * values[i][0] * values[i][1];
denom2 -= count * ybar * ybar;
}
@@ -148,13 +149,13 @@
*result = (numer * numer) / (denom * denom2);
break;
default:
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
break;
}
/* Check for NaN */
if (*result != *result)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
}
void w_reg_m(DCELL * result, DCELL(*values)[2], int n, const void *closure)
Modified: grass/trunk/lib/stats/c_skew.c
===================================================================
--- grass/trunk/lib/stats/c_skew.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_skew.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,7 @@
#include <math.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_skew(DCELL * result, DCELL * values, int n, const void *closure)
{
@@ -11,7 +13,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
sum += values[i];
@@ -19,7 +21,7 @@
}
if (count == 0) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -30,7 +32,7 @@
for (i = 0; i < n; i++) {
DCELL d;
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
d = values[i] - ave;
@@ -53,7 +55,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
sum += values[i][0] * values[i][1];
@@ -61,7 +63,7 @@
}
if (count == 0) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -72,7 +74,7 @@
for (i = 0; i < n; i++) {
DCELL d;
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
d = values[i][0] - ave;
Modified: grass/trunk/lib/stats/c_stddev.c
===================================================================
--- grass/trunk/lib/stats/c_stddev.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_stddev.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,7 @@
#include <math.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/stats.h>
void c_stddev(DCELL * result, DCELL * values, int n, const void *closure)
@@ -8,8 +10,8 @@
c_var(&var, values, n, closure);
- if (G_is_d_null_value(&var))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&var))
+ Rast_set_d_null_value(result, 1);
else
*result = sqrt(var);
}
@@ -20,8 +22,8 @@
w_var(&var, values, n, closure);
- if (G_is_d_null_value(&var))
- G_set_d_null_value(result, 1);
+ if (Rast_is_d_null_value(&var))
+ Rast_set_d_null_value(result, 1);
else
*result = sqrt(var);
}
Modified: grass/trunk/lib/stats/c_sum.c
===================================================================
--- grass/trunk/lib/stats/c_sum.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_sum.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_sum(DCELL * result, DCELL * values, int n, const void *closure)
{
@@ -10,7 +11,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
sum += values[i];
@@ -18,7 +19,7 @@
}
if (count == 0)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
else
*result = sum;
}
@@ -33,7 +34,7 @@
count = 0.0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
sum += values[i][0] * values[i][1];
@@ -41,7 +42,7 @@
}
if (count == 0)
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
else
*result = sum;
}
Modified: grass/trunk/lib/stats/c_var.c
===================================================================
--- grass/trunk/lib/stats/c_var.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/c_var.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
void c_var(DCELL * result, DCELL * values, int n, const void *closure)
{
@@ -10,7 +11,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
sum += values[i];
@@ -18,7 +19,7 @@
}
if (count == 0) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -29,7 +30,7 @@
for (i = 0; i < n; i++) {
DCELL d;
- if (G_is_d_null_value(&values[i]))
+ if (Rast_is_d_null_value(&values[i]))
continue;
d = values[i] - ave;
@@ -49,7 +50,7 @@
count = 0;
for (i = 0; i < n; i++) {
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
sum += values[i][0] * values[i][1];
@@ -57,7 +58,7 @@
}
if (count == 0) {
- G_set_d_null_value(result, 1);
+ Rast_set_d_null_value(result, 1);
return;
}
@@ -68,7 +69,7 @@
for (i = 0; i < n; i++) {
DCELL d;
- if (G_is_d_null_value(&values[i][0]))
+ if (Rast_is_d_null_value(&values[i][0]))
continue;
d = values[i][0] - ave;
Modified: grass/trunk/lib/stats/sort_cell.c
===================================================================
--- grass/trunk/lib/stats/sort_cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/lib/stats/sort_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,18 +1,20 @@
#include <stdlib.h>
+
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/stats.h>
static int ascending(const void *aa, const void *bb)
{
const DCELL *a = aa, *b = bb;
- if (G_is_d_null_value((DCELL *) a) && G_is_d_null_value((DCELL *) b))
+ if (Rast_is_d_null_value((DCELL *) a) && Rast_is_d_null_value((DCELL *) b))
return 0;
- if (G_is_d_null_value((DCELL *) a))
+ if (Rast_is_d_null_value((DCELL *) a))
return 1;
- if (G_is_d_null_value((DCELL *) b))
+ if (Rast_is_d_null_value((DCELL *) b))
return -1;
return (*a < *b) ? -1 : (*a > *b) ? 1 : 0;
@@ -25,7 +27,7 @@
qsort(array, n, sizeof(DCELL), ascending);
for (i = 0; i < n; i++)
- if (G_is_d_null_value(&array[i]))
+ if (Rast_is_d_null_value(&array[i]))
break;
return i;
@@ -38,7 +40,7 @@
qsort(array, n, 2 * sizeof(DCELL), ascending);
for (i = 0; i < n; i++)
- if (G_is_d_null_value(&array[i][0]))
+ if (Rast_is_d_null_value(&array[i][0]))
break;
return i;
Modified: grass/trunk/ps/ps.map/catval.c
===================================================================
--- grass/trunk/ps/ps.map/catval.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/catval.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
*****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/ps/ps.map/distance.c
===================================================================
--- grass/trunk/ps/ps.map/distance.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/distance.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
double distance(double east, double west)
{
Modified: grass/trunk/ps/ps.map/do_geogrid.c
===================================================================
--- grass/trunk/ps/ps.map/do_geogrid.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/do_geogrid.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/gprojects.h>
Modified: grass/trunk/ps/ps.map/do_header.c
===================================================================
--- grass/trunk/ps/ps.map/do_header.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/do_header.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -129,7 +129,7 @@
apply(G_whoami(), fmt, text);
break;
case 'x':
- apply(G_mask_info(), fmt, text);
+ apply(Rast_mask_info(), fmt, text);
break;
case 0:
continue;
Modified: grass/trunk/ps/ps.map/do_labels.c
===================================================================
--- grass/trunk/ps/ps.map/do_labels.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/do_labels.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -238,7 +238,7 @@
}
if (FIELD("color")) {
- ret = G_str_to_color(value, &r, &g, &b);
+ ret = Rast_str_to_color(value, &r, &g, &b);
if (ret == 1)
set_color(&color, r, g, b);
else
@@ -248,7 +248,7 @@
}
if (FIELD("hcolor")) {
- ret = G_str_to_color(value, &r, &g, &b);
+ ret = Rast_str_to_color(value, &r, &g, &b);
if (ret == 1)
set_color(&hcolor, r, g, b);
else if (ret == 2)
@@ -279,7 +279,7 @@
/*
if(strncmp(value, "none", 4)==0) opaque = 0;
*/
- ret = G_str_to_color(value, &r, &g, &b);
+ ret = Rast_str_to_color(value, &r, &g, &b);
if (ret == 1)
set_color(&background, r, g, b);
else if (ret == 2)
@@ -289,7 +289,7 @@
}
if (FIELD("border")) {
- ret = G_str_to_color(value, &r, &g, &b);
+ ret = Rast_str_to_color(value, &r, &g, &b);
if (ret == 1)
set_color(&border, r, g, b);
else if (ret == 2)
Modified: grass/trunk/ps/ps.map/do_masking.c
===================================================================
--- grass/trunk/ps/ps.map/do_masking.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/do_masking.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
Modified: grass/trunk/ps/ps.map/do_plt.c
===================================================================
--- grass/trunk/ps/ps.map/do_plt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/do_plt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/symbol.h>
#include "clr.h"
Modified: grass/trunk/ps/ps.map/do_psfiles.c
===================================================================
--- grass/trunk/ps/ps.map/do_psfiles.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/do_psfiles.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
Modified: grass/trunk/ps/ps.map/do_vectors.c
===================================================================
--- grass/trunk/ps/ps.map/do_vectors.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/do_vectors.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/Vect.h>
#include <grass/symbol.h>
Modified: grass/trunk/ps/ps.map/error.c
===================================================================
--- grass/trunk/ps/ps.map/error.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/error.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
extern FILE *tracefd;
Modified: grass/trunk/ps/ps.map/get_font.c
===================================================================
--- grass/trunk/ps/ps.map/get_font.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/get_font.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
int get_font(char *data)
{
Modified: grass/trunk/ps/ps.map/input.c
===================================================================
--- grass/trunk/ps/ps.map/input.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/input.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
extern FILE *tracefd;
Modified: grass/trunk/ps/ps.map/main.c
===================================================================
--- grass/trunk/ps/ps.map/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <signal.h>
#include <errno.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "map_info.h"
@@ -408,11 +409,11 @@
b = 255.0 * B;
if (strncmp(catsbuf, "null", 4) == 0) {
- G_set_null_value_color(r, g, b, &PS.colors);
+ Rast_set_null_value_color(r, g, b, &PS.colors);
continue;
}
if (strncmp(catsbuf, "default", 7) == 0) {
- G_set_default_color(r, g, b, &PS.colors);
+ Rast_set_default_color(r, g, b, &PS.colors);
continue;
}
if ((count = parse_val_list(catsbuf, &val_list)) < 0) {
@@ -422,7 +423,7 @@
for (i = 0; i < count; i += 2) {
dmin = val_list[i];
dmax = val_list[i + 1];
- G_add_d_raster_color_rule(&dmin, r, g, b, &dmax, r, g, b,
+ Rast_add_d_raster_color_rule(&dmin, r, g, b, &dmax, r, g, b,
&PS.colors);
}
G_free(val_list);
@@ -709,7 +710,7 @@
if (KEY("maskcolor")) {
int ret, r, g, b;
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
PS.mask_r = r / 255.0;
PS.mask_g = g / 255.0;
Modified: grass/trunk/ps/ps.map/makeprocs.c
===================================================================
--- grass/trunk/ps/ps.map/makeprocs.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/makeprocs.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -6,6 +6,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
Modified: grass/trunk/ps/ps.map/map_setup.c
===================================================================
--- grass/trunk/ps/ps.map/map_setup.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/map_setup.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
#include "group.h"
Modified: grass/trunk/ps/ps.map/outl_io.c
===================================================================
--- grass/trunk/ps/ps.map/outl_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/outl_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
#include "local_proto.h"
@@ -40,13 +41,13 @@
blank_line(buf);
}
else {
- G_set_null_value(ptr, 1, map_type);
- ptr = G_incr_void_ptr(ptr, raster_size);
+ Rast_set_null_value(ptr, 1, map_type);
+ ptr = Rast_incr_void_ptr(ptr, raster_size);
- G_get_raster_row(in_file_d, ptr, row_count++, map_type);
+ Rast_get_raster_row(in_file_d, ptr, row_count++, map_type);
- ptr = G_incr_void_ptr(ptr, raster_size * (row_length + 1));
- G_set_null_value(ptr, 1, map_type);
+ ptr = Rast_incr_void_ptr(ptr, raster_size * (row_length + 1));
+ Rast_set_null_value(ptr, 1, map_type);
}
}
return (row_length + 2);
@@ -54,7 +55,7 @@
static int blank_line(void *buf)
{
- G_set_null_value(buf, row_length + 2, map_type);
+ Rast_set_null_value(buf, row_length + 2, map_type);
return 0;
}
@@ -63,11 +64,11 @@
{
/* open raster map */
sscanf(cell, "%s", cell_name);
- if ((in_file_d = G_open_cell_old(cell_name, "")) < 0)
+ if ((in_file_d = Rast_open_cell_old(cell_name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), cell_name);
- map_type = G_get_raster_map_type(in_file_d);
- raster_size = G_raster_size(map_type);
+ map_type = Rast_get_raster_map_type(in_file_d);
+ raster_size = Rast_raster_size(map_type);
first_read = 1;
last_read = 0;
row_count = 0;
@@ -77,7 +78,7 @@
int o_close_file(void)
{
- G_close_cell(in_file_d);
+ Rast_close_cell(in_file_d);
return 0;
}
Modified: grass/trunk/ps/ps.map/parse_list.c
===================================================================
--- grass/trunk/ps/ps.map/parse_list.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/parse_list.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
* count will be negative if list is not valid
********************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
int parse_val_list(char *buf, DCELL ** list)
{
Modified: grass/trunk/ps/ps.map/ps_clrtbl.c
===================================================================
--- grass/trunk/ps/ps.map/ps_clrtbl.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_clrtbl.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -30,18 +30,18 @@
G_message(_("Creating color table for <%s in %s>..."),
ct.name, ct.mapset);
- if (G_read_cats(ct.name, ct.mapset, &PS.cats) == -1) {
+ if (Rast_read_cats(ct.name, ct.mapset, &PS.cats) == -1) {
G_warning(_("Category file for <%s> not available"), ct.name);
return 1;
}
- if (G_read_colors(ct.name, ct.mapset, &colors) == -1)
+ if (Rast_read_colors(ct.name, ct.mapset, &colors) == -1)
G_warning(_("Unable to read colors for colorbar"));
do_color = (PS.grey == 0 && PS.level == 2);
/* How many categories to show */
- num_cats = G_number_of_raster_cats(&PS.cats);
+ num_cats = Rast_number_of_raster_cats(&PS.cats);
G_debug(3, "clrtbl: %d categories", num_cats);
if (!num_cats) {
G_warning(_("Your cats/ file is invalid. A cats/ file with categories "
@@ -88,7 +88,7 @@
fprintf(PS.fp, "(%s)\n", "no data");
else
fprintf(PS.fp, "(%s)\n",
- G_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax));
+ Rast_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax));
}
fprintf(PS.fp, "] def\n");
@@ -135,7 +135,7 @@
/* fill box and outline in black */
if (i)
- label = G_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax);
+ label = Rast_get_ith_d_raster_cat(&PS.cats, i - 1, &dmin, &dmax);
x1 = l + (double)j *72.0 * col_width;
@@ -146,9 +146,9 @@
{
/* set box fill color */
if (!i)
- G_get_null_value_color(&R, &G, &B, &colors);
+ Rast_get_null_value_color(&R, &G, &B, &colors);
else
- G_get_d_raster_color(&dmin, &R, &G, &B, &colors);
+ Rast_get_d_raster_color(&dmin, &R, &G, &B, &colors);
if (do_color)
fprintf(PS.fp, "%.3f %.3f %.3f C\n",
@@ -179,7 +179,7 @@
/* set box fill color */
val = dmin + (double)jj *(dmax - dmin) / NSTEPS;
- G_get_d_raster_color(&val, &R, &G, &B, &colors);
+ Rast_get_d_raster_color(&val, &R, &G, &B, &colors);
fprintf(PS.fp, "%.3f %.3f %.3f C\n",
(double)R / 255., (double)G / 255.,
(double)B / 255.);
@@ -222,7 +222,7 @@
if (PS.min_y > y)
PS.min_y = y;
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
return 0;
}
Modified: grass/trunk/ps/ps.map/ps_fclrtbl.c
===================================================================
--- grass/trunk/ps/ps.map/ps_fclrtbl.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_fclrtbl.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -47,12 +47,12 @@
ct.name, ct.mapset);
/* Get color range */
- if (G_read_fp_range(ct.name, ct.mapset, &range) == -1) {
+ if (Rast_read_fp_range(ct.name, ct.mapset, &range) == -1) {
G_warning(_("Range information not available (run r.support)"));
return 1;
}
- G_get_fp_range_min_max(&range, &dmin, &dmax);
+ Rast_get_fp_range_min_max(&range, &dmin, &dmax);
/* override if range command is set */
if (ct.range_override) {
@@ -65,7 +65,7 @@
return 1;
}
- if (G_read_colors(ct.name, ct.mapset, &colors) == -1)
+ if (Rast_read_colors(ct.name, ct.mapset, &colors) == -1)
G_warning(_("Unable to read colors for colorbar"));
do_color = (PS.grey == 0 && PS.level == 2);
@@ -132,7 +132,7 @@
for (i = 0; i < ncols; i++) {
/* val = dmin + i * step; flip */
val = dmax - i * step;
- G_get_d_raster_color(&val, &R, &G, &B, &colors);
+ Rast_get_d_raster_color(&val, &R, &G, &B, &colors);
if (do_color)
fprintf(PS.fp, "%.3f %.3f %.3f C\n", (double)R / 255.,
@@ -248,7 +248,7 @@
/* print units label, if present */
- if (G_read_raster_units(ct.name, ct.mapset, units) != 0)
+ if (Rast_read_raster_units(ct.name, ct.mapset, units) != 0)
units[0] = '\0';
if(strlen(units)) {
@@ -322,7 +322,7 @@
fprintf(PS.fp, "TIB\n");
}
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
return 0;
}
Modified: grass/trunk/ps/ps.map/ps_header.c
===================================================================
--- grass/trunk/ps/ps.map/ps_header.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_header.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ps_info.h"
static long bb_offset;
@@ -18,7 +19,7 @@
int cats_ok;
if (PS.do_raster)
- cats_ok = G_read_cats(PS.cell_name, PS.cell_mapset, &cats) >= 0;
+ cats_ok = Rast_read_cats(PS.cell_name, PS.cell_mapset, &cats) >= 0;
/* write PostScript header */
/*fprintf(PS.fp, "%%!PS-Adobe-2.0 EPSF-1.2\n"); */
Modified: grass/trunk/ps/ps.map/ps_info.h
===================================================================
--- grass/trunk/ps/ps.map/ps_info.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_info.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/* Font sizes */
#define PS_FONT_MAX_SIZE 50
Modified: grass/trunk/ps/ps.map/ps_outline.c
===================================================================
--- grass/trunk/ps/ps.map/ps_outline.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_outline.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
#include "local_proto.h"
@@ -113,7 +114,7 @@
bottom = 1; /* line from raster map */
scan_length = read_next();
k = 0;
- raster_size = G_raster_size(map_type);
+ raster_size = Rast_raster_size(map_type);
while (read_next()) { /* read rest of file, one row at *//* a time */
n1 = G_row_to_northing((double)row - 1., &(PS.w));
n2 = G_row_to_northing((double)row, &(PS.w));
@@ -123,13 +124,13 @@
e1 = G_col_to_easting((double)col - 1., &(PS.w));
e2 = G_col_to_easting((double)col, &(PS.w));
e3 = G_col_to_easting((double)col + 1., &(PS.w));
- tl = G_incr_void_ptr(buffer[top], col * raster_size);
+ tl = Rast_incr_void_ptr(buffer[top], col * raster_size);
/* top left in window */
- tr = G_incr_void_ptr(buffer[top], (col + 1) * raster_size);
+ tr = Rast_incr_void_ptr(buffer[top], (col + 1) * raster_size);
/* top right in window */
- bl = G_incr_void_ptr(buffer[bottom], col * raster_size);
+ bl = Rast_incr_void_ptr(buffer[bottom], col * raster_size);
/* bottom left in window */
- br = G_incr_void_ptr(buffer[bottom], (col + 1) * raster_size);
+ br = Rast_incr_void_ptr(buffer[bottom], (col + 1) * raster_size);
/* bottom right in window */
draw_boundaries();
if (k == 3)
@@ -144,9 +145,9 @@
static int draw_boundaries(void)
{
- if (G_raster_cmp(bl, br, map_type) != 0)
+ if (Rast_raster_cmp(bl, br, map_type) != 0)
draw_bot();
- if (G_raster_cmp(tr, br, map_type) != 0)
+ if (Rast_raster_cmp(tr, br, map_type) != 0)
draw_rite();
return 0;
Modified: grass/trunk/ps/ps.map/ps_raster.c
===================================================================
--- grass/trunk/ps/ps.map/ps_raster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,7 +2,7 @@
**
** Author: Paul W. Carlson 3/92
**
- ** ps_get_map_row is substituted by G_get_map_row_nomask
+ ** ps_get_map_row is substituted by Rast_get_map_row_nomask
** writing mask file is done separately by function ps_write_mask_row
** which used code previously in ps_get_map_row. This is done because
** sometimes the raster map is not drawn, but we still need a mask
@@ -12,6 +12,7 @@
*/
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
#include "group.h"
@@ -26,7 +27,7 @@
CELL *maskbuf;
int maskfd, r, g, b;
- maskfd = G_maskfd();
+ maskfd = Rast_maskfd();
if (maskfd < 0)
/* there is no mask */
{
@@ -35,7 +36,7 @@
return 0;
}
if (maskfd >= 0)
- maskbuf = G_allocate_cell_buf();
+ maskbuf = Rast_allocate_cell_buf();
/* if masked, open a file to hold the PostScript mask data */
if (maskfd >= 0 && PS.mask_needed) {
@@ -43,13 +44,13 @@
G_fatal_error(_("Can't create temporary PostScript mask file."));
/* get no data rgb values for mask */
- G_get_null_value_color(&r, &g, &b, &PS.colors);
+ Rast_get_null_value_color(&r, &g, &b, &PS.colors);
PS.r0 = (double)r / 255.0;
PS.g0 = (double)g / 255.0;
PS.b0 = (double)b / 255.0;
for (row = 0; row < PS.w.rows; row++) {
- G_get_map_row_nomask(maskfd, maskbuf, row);
+ Rast_get_map_row_nomask(maskfd, maskbuf, row);
ps_write_mask_row(maskbuf);
}
fclose(ps_mask_fp);
@@ -107,15 +108,15 @@
/* build the image RGB string */
if (PS.do_raster) {
- map_type = G_get_raster_map_type(PS.cell_fd);
- cellbuf = G_allocate_raster_buf(map_type);
+ map_type = Rast_get_raster_map_type(PS.cell_fd);
+ cellbuf = Rast_allocate_raster_buf(map_type);
n = 0;
for (row = 0; row < PS.w.rows; row++) {
- G_get_raster_row(PS.cell_fd, cellbuf, row, map_type);
+ Rast_get_raster_row(PS.cell_fd, cellbuf, row, map_type);
if ((row % PS.row_delta) == 0) {
ptr = cellbuf;
for (col = 0; col < PS.w.cols; col += PS.col_delta) {
- G_get_raster_color(ptr, &r, &g, &b, &PS.colors, map_type);
+ Rast_get_raster_color(ptr, &r, &g, &b, &PS.colors, map_type);
/* if color raster */
if (doing_color) {
@@ -137,8 +138,8 @@
}
}
ptr =
- G_incr_void_ptr(ptr,
- G_raster_size(map_type) *
+ Rast_incr_void_ptr(ptr,
+ Rast_raster_size(map_type) *
PS.col_delta);
}
}
@@ -148,20 +149,20 @@
void *cptr[3];
for (i = 0; i < 3; i++) {
- grp_map_type[i] = G_get_raster_map_type(grp.fd[i]);
- cbuf[i] = G_allocate_raster_buf(grp_map_type[i]);
+ grp_map_type[i] = Rast_get_raster_map_type(grp.fd[i]);
+ cbuf[i] = Rast_allocate_raster_buf(grp_map_type[i]);
}
n = 0;
for (row = 0; row < PS.w.rows; row++) {
for (i = 0; i < 3; i++) {
- G_get_raster_row(grp.fd[i], cbuf[i], row, grp_map_type[i]);
+ Rast_get_raster_row(grp.fd[i], cbuf[i], row, grp_map_type[i]);
cptr[i] = cbuf[i];
}
if ((row % PS.row_delta) == 0) {
for (col = 0; col < PS.w.cols; col += PS.col_delta) {
for (i = 0; i < 3; i++) {
- G_get_raster_color(cptr[i], &rr, &gg, &bb,
+ Rast_get_raster_color(cptr[i], &rr, &gg, &bb,
&(grp.colors[i]), grp_map_type[i]);
if (i == 0)
r = rr;
@@ -169,8 +170,8 @@
g = gg;
if (i == 2)
b = bb;
- cptr[i] = G_incr_void_ptr(cptr[i],
- G_raster_size(grp_map_type
+ cptr[i] = Rast_incr_void_ptr(cptr[i],
+ Rast_raster_size(grp_map_type
[0]) *
PS.col_delta);
}
@@ -192,14 +193,14 @@
/* we're done with the cell stuff */
if (PS.do_raster) {
if (!PS.do_colortable)
- G_free_colors(&PS.colors);
- G_close_cell(PS.cell_fd);
+ Rast_free_colors(&PS.colors);
+ Rast_close_cell(PS.cell_fd);
G_free(cellbuf);
}
else {
for (i = 0; i < 3; i++) {
- G_free_colors(&(grp.colors[i]));
- G_close_cell(grp.fd[i]);
+ Rast_free_colors(&(grp.colors[i]));
+ Rast_close_cell(grp.fd[i]);
G_free(cbuf[i]);
}
I_free_group_ref(&grp.ref);
Modified: grass/trunk/ps/ps.map/ps_vareas.c
===================================================================
--- grass/trunk/ps/ps.map/ps_vareas.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_vareas.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
@@ -103,7 +104,7 @@
else {
rgbstring = db_get_string(cv_rgb->val.s);
if (rgbstring == NULL ||
- G_str_to_color(rgbstring, &red, &grn, &blu) != 1) {
+ Rast_str_to_color(rgbstring, &red, &grn, &blu) != 1) {
G_warning(_("Invalid RGB color definition in column <%s> for category [%d]"),
vector.layer[vec].rgbcol, cat);
rgbstring = NULL;
Modified: grass/trunk/ps/ps.map/ps_vlines.c
===================================================================
--- grass/trunk/ps/ps.map/ps_vlines.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_vlines.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -6,6 +6,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
@@ -120,7 +121,7 @@
else {
rgbstring = db_get_string(cv_rgb->val.s);
if (rgbstring == NULL ||
- G_str_to_color(rgbstring, &red, &grn, &blu) != 1) {
+ Rast_str_to_color(rgbstring, &red, &grn, &blu) != 1) {
G_warning(_("Invalid RGB color definition in column <%s> for category [%d]"),
vector.layer[vec].rgbcol, cat);
rgbstring = NULL;
Modified: grass/trunk/ps/ps.map/ps_vpoints.c
===================================================================
--- grass/trunk/ps/ps.map/ps_vpoints.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/ps_vpoints.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -201,7 +201,7 @@
else {
rgbstring = db_get_string(cv_rgb->val.s);
if (rgbstring == NULL ||
- G_str_to_color(rgbstring, &red, &grn, &blu) != 1) {
+ Rast_str_to_color(rgbstring, &red, &grn, &blu) != 1) {
G_warning(_("Invalid RGB color definition in column <%s> for category [%d]"),
vector.layer[vec].rgbcol, cat);
rgbstring = NULL;
Modified: grass/trunk/ps/ps.map/r_border.c
===================================================================
--- grass/trunk/ps/ps.map/r_border.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_border.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -43,7 +43,7 @@
continue;
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
color_R = r / 255.;
color_G = g / 255.;
Modified: grass/trunk/ps/ps.map/r_cell.c
===================================================================
--- grass/trunk/ps/ps.map/r_cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -14,28 +14,28 @@
PS.do_colortable = 0;
if (PS.cell_fd >= 0) {
- G_close_cell(PS.cell_fd);
+ Rast_close_cell(PS.cell_fd);
G_free(PS.cell_name);
- G_free_colors(&PS.colors);
+ Rast_free_colors(&PS.colors);
PS.cell_fd = -1;
}
sprintf(fullname, "%s in %s", name, mapset);
- if (G_read_colors(name, mapset, &PS.colors) == -1) {
+ if (Rast_read_colors(name, mapset, &PS.colors) == -1) {
error(fullname, "", "can't read color table");
return 0;
}
- G_get_color_range(&PS.min_color, &PS.max_color, &PS.colors);
+ Rast_get_color_range(&PS.min_color, &PS.max_color, &PS.colors);
/* open raster map for reading */
- if ((PS.cell_fd = G_open_cell_old(name, mapset)) < 0) {
+ if ((PS.cell_fd = Rast_open_cell_old(name, mapset)) < 0) {
error(fullname, "", "can't open raster map");
- G_free_colors(&PS.colors);
+ Rast_free_colors(&PS.colors);
return 0;
}
- strcpy(PS.celltitle, G_get_cell_title(name, mapset));
+ strcpy(PS.celltitle, Rast_get_cell_title(name, mapset));
G_strip(PS.celltitle);
if (PS.celltitle[0] == 0)
sprintf(PS.celltitle, "(%s)", name);
Modified: grass/trunk/ps/ps.map/r_colortable.c
===================================================================
--- grass/trunk/ps/ps.map/r_colortable.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_colortable.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -168,7 +168,7 @@
/* set default if legend type was not specified */
if (ct.discrete == -1) {
- if (G_raster_map_is_fp(ct.name, ct.mapset))
+ if (Rast_raster_map_is_fp(ct.name, ct.mapset))
ct.discrete = FALSE;
else
ct.discrete = TRUE;
Modified: grass/trunk/ps/ps.map/r_group.c
===================================================================
--- grass/trunk/ps/ps.map/r_group.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_group.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
#include "group.h"
@@ -18,9 +19,9 @@
PS.do_raster = 0;
PS.do_colortable = 0;
if (PS.cell_fd >= 0) {
- G_close_cell(PS.cell_fd);
+ Rast_close_cell(PS.cell_fd);
G_free(PS.cell_name);
- G_free_colors(&PS.colors);
+ Rast_free_colors(&PS.colors);
PS.cell_fd = -1;
}
@@ -41,7 +42,7 @@
/* read in colors */
for (i = 0; i < 3; i++) {
- if (G_read_colors(grp.name[i], grp.mapset[i], &(grp.colors[i])) == -1) {
+ if (Rast_read_colors(grp.name[i], grp.mapset[i], &(grp.colors[i])) == -1) {
sprintf(fullname, "%s in %s", grp.name[i], grp.mapset[i]);
error(fullname, "", "can't read color table");
return 0;
@@ -50,10 +51,10 @@
/* open raster maps for reading */
for (i = 0; i < 3; i++) {
- if ((grp.fd[i] = G_open_cell_old(grp.name[i], grp.mapset[i])) < 0) {
+ if ((grp.fd[i] = Rast_open_cell_old(grp.name[i], grp.mapset[i])) < 0) {
sprintf(fullname, "%s in %s", grp.name[i], grp.mapset[i]);
error(fullname, "", "can't open raster map");
- G_free_colors(&(grp.colors[i]));
+ Rast_free_colors(&(grp.colors[i]));
return 0;
}
}
Modified: grass/trunk/ps/ps.map/r_labels.c
===================================================================
--- grass/trunk/ps/ps.map/r_labels.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_labels.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "labels.h"
#include "local_proto.h"
Modified: grass/trunk/ps/ps.map/r_plt.c
===================================================================
--- grass/trunk/ps/ps.map/r_plt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_plt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -44,7 +44,7 @@
continue;
}
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
color_R = r;
color_G = g;
@@ -58,7 +58,7 @@
continue;
}
if (KEY("fcolor")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
fcolor_R = r;
fcolor_G = g;
@@ -220,7 +220,7 @@
}
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
color_R = r;
color_G = g;
@@ -292,7 +292,7 @@
}
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
color_R = r;
color_G = g;
@@ -307,7 +307,7 @@
}
if (KEY("fcolor")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
fcolor_R = r;
fcolor_G = g;
Modified: grass/trunk/ps/ps.map/r_rgb.c
===================================================================
--- grass/trunk/ps/ps.map/r_rgb.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_rgb.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,9 +23,9 @@
PS.do_raster = 0;
PS.do_colortable = 0;
if (PS.cell_fd >= 0) {
- G_close_cell(PS.cell_fd);
+ Rast_close_cell(PS.cell_fd);
G_free(PS.cell_name);
- G_free_colors(&PS.colors);
+ Rast_free_colors(&PS.colors);
PS.cell_fd = -1;
}
@@ -66,17 +66,17 @@
grp.mapset[i] = G_store(mapset);
/* read in colors */
- if (G_read_colors(grp.name[i], grp.mapset[i], &(grp.colors[i])) == -1) {
+ if (Rast_read_colors(grp.name[i], grp.mapset[i], &(grp.colors[i])) == -1) {
sprintf(fullname, "%s in %s", grp.name[i], grp.mapset[i]);
error(fullname, "", "can't read color table");
return 0;
}
/* open raster maps for reading */
- if ((grp.fd[i] = G_open_cell_old(grp.name[i], grp.mapset[i])) < 0) {
+ if ((grp.fd[i] = Rast_open_cell_old(grp.name[i], grp.mapset[i])) < 0) {
sprintf(fullname, "%s in %s", grp.name[i], grp.mapset[i]);
error(fullname, "", "can't open raster map");
- G_free_colors(&(grp.colors[i]));
+ Rast_free_colors(&(grp.colors[i]));
return 0;
}
}
Modified: grass/trunk/ps/ps.map/r_text.c
===================================================================
--- grass/trunk/ps/ps.map/r_text.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_text.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -97,7 +97,7 @@
}
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&color, r, g, b);
else if (ret == 2)
@@ -109,7 +109,7 @@
}
if (KEY("hcolor")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&hcolor, r, g, b);
else if (ret == 2)
@@ -123,7 +123,7 @@
}
if (KEY("background")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&background, r, g, b);
else if (ret == 2) {
@@ -137,7 +137,7 @@
}
if (KEY("border")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&border, r, g, b);
else if (ret == 2)
Modified: grass/trunk/ps/ps.map/r_vareas.c
===================================================================
--- grass/trunk/ps/ps.map/r_vareas.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_vareas.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include "vector.h"
@@ -125,7 +126,7 @@
}
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&(vector.layer[vec].color), r, g, b);
else if (ret == 2)
@@ -143,7 +144,7 @@
}
if (KEY("fcolor")) { /* area color */
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&(vector.layer[vec].fcolor), r, g, b);
else if (ret == 2)
Modified: grass/trunk/ps/ps.map/r_vlines.c
===================================================================
--- grass/trunk/ps/ps.map/r_vlines.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_vlines.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -247,7 +247,7 @@
}
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&(vector.layer[vec].color), r, g, b);
else if (ret == 2)
@@ -265,7 +265,7 @@
}
if (KEY("hcolor")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&(vector.layer[vec].hcolor), r, g, b);
else if (ret == 2)
Modified: grass/trunk/ps/ps.map/r_vpoints.c
===================================================================
--- grass/trunk/ps/ps.map/r_vpoints.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_vpoints.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
#include "vector.h"
@@ -148,7 +149,7 @@
}
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&(vector.layer[vec].color), r, g, b);
else if (ret == 2)
@@ -160,7 +161,7 @@
}
if (KEY("fcolor")) { /* fill color */
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1)
set_color(&(vector.layer[vec].fcolor), r, g, b);
else if (ret == 2)
Modified: grass/trunk/ps/ps.map/r_wind.c
===================================================================
--- grass/trunk/ps/ps.map/r_wind.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/r_wind.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -53,7 +53,7 @@
if (KEY("color")) {
- ret = G_str_to_color(data, &r, &g, &b);
+ ret = Rast_str_to_color(data, &r, &g, &b);
if (ret == 1) {
color_R = r;
color_G = g;
Modified: grass/trunk/ps/ps.map/read_cfg.c
===================================================================
--- grass/trunk/ps/ps.map/read_cfg.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/read_cfg.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ps_info.h"
#include "paper.h"
Modified: grass/trunk/ps/ps.map/scale.c
===================================================================
--- grass/trunk/ps/ps.map/scale.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/scale.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
#include "ps_info.h"
Modified: grass/trunk/ps/ps.map/scan_gis.c
===================================================================
--- grass/trunk/ps/ps.map/scan_gis.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/scan_gis.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
int scan_gis(char *element, char *desc, char *key, char *data,
Modified: grass/trunk/ps/ps.map/session.c
===================================================================
--- grass/trunk/ps/ps.map/session.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/session.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
static char cur[2000];
Modified: grass/trunk/ps/ps.map/vect.c
===================================================================
--- grass/trunk/ps/ps.map/vect.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/vect.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
#include <math.h>
#include <grass/Vect.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "vector.h"
#define LENGTH(DX, DY) ( sqrt( (DX*DX)+(DY*DY) ) )
Modified: grass/trunk/ps/ps.map/vector.c
===================================================================
--- grass/trunk/ps/ps.map/vector.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/ps/ps.map/vector.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "vector.h"
Modified: grass/trunk/raster/r.basins.fill/main.c
===================================================================
--- grass/trunk/raster/r.basins.fill/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.basins.fill/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -27,6 +27,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
@@ -89,8 +90,8 @@
drain_name = drain_opt->answer;
- /* this isn't a nice thing to do. G_align_window() should be used first */
- G_get_cellhd(drain_name, "", &window);
+ /* this isn't a nice thing to do. Rast_align_window() should be used first */
+ Rast_get_cellhd(drain_name, "", &window);
G_set_window(&window);
nrows = G_window_rows();
@@ -103,7 +104,7 @@
drain = read_map(drain_name, NOMASK, nrows, ncols);
ridge = read_map(ridge_name, NOMASK, nrows, ncols);
- partfd = G_open_cell_new(part_name);
+ partfd = Rast_open_cell_new(part_name);
if (partfd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), part_name);
@@ -152,10 +153,10 @@
/* write out partitioned watershed map */
for (row = 0; row < nrows; row++)
- G_put_raster_row(partfd, drain + (row * ncols), CELL_TYPE);
+ Rast_put_raster_row(partfd, drain + (row * ncols), CELL_TYPE);
G_message(_("Creating support files for <%s>..."), part_name);
- G_close_cell(partfd);
+ Rast_close_cell(partfd);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.basins.fill/read_map.c
===================================================================
--- grass/trunk/raster/r.basins.fill/read_map.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.basins.fill/read_map.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -32,16 +33,16 @@
map = (CELL *) G_malloc(nrows * ncols * sizeof(CELL));
/* open the map */
- if ((fd = G_open_cell_old(name, "")) < 0)
+ if ((fd = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open <%s>"), name);
/* read the map */
G_message(_("Reading <%s> ... "), name);
if (nomask)
- get_row = G_get_map_row_nomask;
+ get_row = Rast_get_map_row_nomask;
else
- get_row = G_get_map_row;
+ get_row = Rast_get_map_row;
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 10);
@@ -50,7 +51,7 @@
}
G_percent(nrows, nrows, 10);
- G_close_cell(fd);
+ Rast_close_cell(fd);
return map;
}
Modified: grass/trunk/raster/r.bitpattern/main.c
===================================================================
--- grass/trunk/raster/r.bitpattern/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.bitpattern/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
extern CELL f_c(CELL);
@@ -96,24 +97,24 @@
patv = atoi(patval->answer);
/*if Gispf() error */
- if ((infd = G_open_cell_old(name, "")) < 0)
+ if ((infd = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
/* determine the inputmap type (CELL/FCELL/DCELL) */
- data_type = G_get_raster_map_type(infd);
+ data_type = Rast_get_raster_map_type(infd);
- if (G_get_cellhd(name, "", &cellhd) < 0)
+ if (Rast_get_cellhd(name, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), name);
/* Allocate input buffer */
- inrast = G_allocate_raster_buf(data_type);
+ inrast = Rast_allocate_raster_buf(data_type);
/* Allocate output buffer, use input map data_type */
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_raster_buf(data_type);
+ outrast = Rast_allocate_raster_buf(data_type);
- if ((outfd = G_open_raster_new(result, data_type)) < 0)
+ if ((outfd = Rast_open_raster_new(result, data_type)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
for (row = 0; row < nrows; row++) {
@@ -123,7 +124,7 @@
G_percent(row, nrows, 2);
/* read input map */
- if (G_get_raster_row(infd, inrast, row, data_type) < 0)
+ if (Rast_get_raster_row(infd, inrast, row, data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"), name,
row);
@@ -139,14 +140,14 @@
}
- if (G_put_raster_row(outfd, outrast, data_type) < 0)
+ if (Rast_put_raster_row(outfd, outrast, data_type) < 0)
G_fatal_error(_("Unable to write to <%s>"), result);
}
G_free(inrast);
G_free(outrast);
- G_close_cell(infd);
- G_close_cell(outfd);
+ Rast_close_cell(infd);
+ Rast_close_cell(outfd);
return (EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.buffer/distance.h
===================================================================
--- grass/trunk/raster/r.buffer/distance.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.buffer/distance.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,8 @@
#define __DISTANCE_H__
#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/Rast.h>
struct Distance
{
Modified: grass/trunk/raster/r.buffer/find_dist.c
===================================================================
--- grass/trunk/raster/r.buffer/find_dist.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.buffer/find_dist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "distance.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.buffer/init.c
===================================================================
--- grass/trunk/raster/r.buffer/init.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.buffer/init.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include "distance.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
int init_grass(void)
{
Modified: grass/trunk/raster/r.buffer/main.c
===================================================================
--- grass/trunk/raster/r.buffer/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.buffer/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -160,15 +160,15 @@
make_support_files(output, units);
/* write map history (meta data) */
- G_short_history(output, "raster", &hist);
+ Rast_short_history(output, "raster", &hist);
sprintf(hist.datsrc_1, "%s", input);
if (strlen(opt3->answer) < (RECORD_LEN - 14)) {
sprintf(hist.edhist[0], "Buffer distance%s:", ndist > 1 ? "s" : "");
sprintf(hist.edhist[1], " %s %s", opt3->answer, units);
hist.edlinecnt = 2;
}
- G_command_history(&hist);
- G_write_history(output, &hist);
+ Rast_command_history(&hist);
+ Rast_write_history(output, &hist);
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.buffer/read_map.c
===================================================================
--- grass/trunk/raster/r.buffer/read_map.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.buffer/read_map.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include "distance.h"
#include <grass/glocale.h>
+#include <grass/glocale.h>
/* read the input map. convert non-nulls to 1 */
@@ -37,11 +38,11 @@
map = (MAPTYPE *) G_malloc(window.rows * window.cols * sizeof(MAPTYPE));
- fd = G_open_cell_old(input, mapset);
+ fd = Rast_open_cell_old(input, mapset);
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), input);
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
ptr = map;
@@ -59,7 +60,7 @@
hit = 0;
G_percent(row, window.rows, 2);
- if (G_get_c_raster_row(fd, cell, row) < 0)
+ if (Rast_get_c_raster_row(fd, cell, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
G_fully_qualified_name(input, mapset), row);
@@ -81,7 +82,7 @@
}
else { /* use NULL */
- if ((*ptr++ = !G_is_c_null_value(cell++))) {
+ if ((*ptr++ = !Rast_is_c_null_value(cell++))) {
if (minrow < 0)
minrow = row;
maxrow = row;
@@ -99,7 +100,7 @@
cell -= window.cols;
}
G_percent(row, window.rows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(cell);
return 0;
Modified: grass/trunk/raster/r.buffer/support.c
===================================================================
--- grass/trunk/raster/r.buffer/support.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.buffer/support.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -29,9 +29,9 @@
CELL cat;
char label[128];
- G_init_cats((CELL) 1, "Distance Zones", &pcats);
+ Rast_init_cats((CELL) 1, "Distance Zones", &pcats);
- G_set_cat(cat = 1, "distances calculated from these locations", &pcats);
+ Rast_set_cat(cat = 1, "distances calculated from these locations", &pcats);
for (cat = 0; cat < ndist; cat++) {
if (cat == 0)
sprintf(label, "0-%s %s", distances[cat].label, units);
@@ -50,11 +50,11 @@
distances[cat].label, units);
}
- G_set_cat(cat + ZONE_INCR, label, &pcats);
+ Rast_set_cat(cat + ZONE_INCR, label, &pcats);
}
- G_write_cats(output, &pcats);
- G_free_cats(&pcats);
+ Rast_write_cats(output, &pcats);
+ Rast_free_cats(&pcats);
return 0;
}
Modified: grass/trunk/raster/r.buffer/write_map.c
===================================================================
--- grass/trunk/raster/r.buffer/write_map.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.buffer/write_map.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -35,16 +35,16 @@
register MAPTYPE *ptr;
int k;
- fd_out = G_open_cell_new(output);
+ fd_out = Rast_open_cell_new(output);
if (fd_out < 0)
G_fatal_error(_("Unable to create raster map <%s>"), output);
if (offset) {
- fd_in = G_open_cell_old(output, G_mapset());
+ fd_in = Rast_open_cell_old(output, G_mapset());
if (fd_in < 0)
G_fatal_error(_("Unable to open raster map <%s>"), output);
}
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
G_message(_("Writing output raster map <%s>..."), output);
ptr = map;
@@ -57,7 +57,7 @@
*cell++ = (CELL) * ptr++;
}
else {
- if (G_get_map_row_nomask(fd_in, cell, row) < 0)
+ if (Rast_get_map_row_nomask(fd_in, cell, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
output, row);
@@ -72,9 +72,9 @@
/* set 0 to NULL */
for (k = 0; k < window.cols; k++)
if (cell[k] == 0)
- G_set_null_value(&cell[k], 1, CELL_TYPE);
+ Rast_set_null_value(&cell[k], 1, CELL_TYPE);
- if (G_put_raster_row(fd_out, cell, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(fd_out, cell, CELL_TYPE) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"), output,
row);
}
@@ -83,9 +83,9 @@
G_free(cell);
if (offset)
- G_close_cell(fd_in);
+ Rast_close_cell(fd_in);
- G_close_cell(fd_out);
+ Rast_close_cell(fd_out);
return 0;
}
Modified: grass/trunk/raster/r.carve/enforce.h
===================================================================
--- grass/trunk/raster/r.carve/enforce.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.carve/enforce.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/bitmap.h>
#include <grass/Vect.h>
Modified: grass/trunk/raster/r.carve/enforce_ds.c
===================================================================
--- grass/trunk/raster/r.carve/enforce_ds.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.carve/enforce_ds.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "enforce.h"
@@ -73,7 +74,7 @@
/* allocate and clear memory for entire raster */
rbuf =
G_calloc(G_window_rows() * G_window_cols(),
- G_raster_size(parm->raster_type));
+ Rast_raster_size(parm->raster_type));
/* first read whole elevation file into buf */
read_raster(rbuf, infd, parm->raster_type);
@@ -315,7 +316,7 @@
rastrows = G_window_rows();
rastcols = G_window_cols();
- G_set_d_null_value(&min, 1);
+ Rast_set_d_null_value(&min, 1);
/* kludge - fix for lat_lon */
rowoff = rad / wind.ns_res;
@@ -335,7 +336,7 @@
{
CELL *cbuf = data;
- if (!(G_is_c_null_value(&cbuf[row1 * rastcols + col1])))
+ if (!(Rast_is_c_null_value(&cbuf[row1 * rastcols + col1])))
min = cbuf[row1 * rastcols + col1];
}
break;
@@ -343,7 +344,7 @@
{
FCELL *fbuf = data;
- if (!(G_is_f_null_value(&fbuf[row1 * rastcols + col1])))
+ if (!(Rast_is_f_null_value(&fbuf[row1 * rastcols + col1])))
min = fbuf[row1 * rastcols + col1];
}
break;
@@ -351,7 +352,7 @@
{
DCELL *dbuf = data;
- if (!(G_is_d_null_value(&dbuf[row1 * rastcols + col1])))
+ if (!(Rast_is_d_null_value(&dbuf[row1 * rastcols + col1])))
min = dbuf[row1 * rastcols + col1];
}
break;
@@ -370,12 +371,12 @@
{
CELL *cbuf = data;
- if (G_is_d_null_value(&min)) {
- if (!(G_is_c_null_value(&cbuf[r * rastcols + c])))
+ if (Rast_is_d_null_value(&min)) {
+ if (!(Rast_is_c_null_value(&cbuf[r * rastcols + c])))
min = cbuf[r * rastcols + c];
}
else {
- if (!(G_is_c_null_value(&cbuf[r * rastcols + c])))
+ if (!(Rast_is_c_null_value(&cbuf[r * rastcols + c])))
if (cbuf[r * rastcols + c] < min)
min = cbuf[r * rastcols + c];
}
@@ -385,12 +386,12 @@
{
FCELL *fbuf = data;
- if (G_is_d_null_value(&min)) {
- if (!(G_is_f_null_value(&fbuf[r * rastcols + c])))
+ if (Rast_is_d_null_value(&min)) {
+ if (!(Rast_is_f_null_value(&fbuf[r * rastcols + c])))
min = fbuf[r * rastcols + c];
}
else {
- if (!(G_is_f_null_value(&fbuf[r * rastcols + c])))
+ if (!(Rast_is_f_null_value(&fbuf[r * rastcols + c])))
if (fbuf[r * rastcols + c] < min)
min = fbuf[r * rastcols + c];
}
@@ -400,12 +401,12 @@
{
DCELL *dbuf = data;
- if (G_is_d_null_value(&min)) {
- if (!(G_is_d_null_value(&dbuf[r * rastcols + c])))
+ if (Rast_is_d_null_value(&min)) {
+ if (!(Rast_is_d_null_value(&dbuf[r * rastcols + c])))
min = dbuf[r * rastcols + c];
}
else {
- if (!(G_is_d_null_value(&dbuf[r * rastcols + c])))
+ if (!(Rast_is_d_null_value(&dbuf[r * rastcols + c])))
if (dbuf[r * rastcols + c] < min)
min = dbuf[r * rastcols + c];
}
Modified: grass/trunk/raster/r.carve/main.c
===================================================================
--- grass/trunk/raster/r.carve/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.carve/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <errno.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "enforce.h"
@@ -160,15 +161,15 @@
if ((rmapset = G_find_file2("cell", parm.inrast->answer, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), parm.inrast->answer);
- if ((infd = G_open_cell_old(parm.inrast->answer, rmapset)) == -1)
+ if ((infd = Rast_open_cell_old(parm.inrast->answer, rmapset)) == -1)
G_fatal_error(_("Unable to open raster map <%s>"),
parm.inrast->answer);
- parm.raster_type = G_get_raster_map_type(infd);
+ parm.raster_type = Rast_get_raster_map_type(infd);
/* open new map for output */
if ((outfd =
- G_open_raster_new(parm.outrast->answer, parm.raster_type)) < 0)
+ Rast_open_raster_new(parm.outrast->answer, parm.raster_type)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
parm.outrast->answer);
@@ -178,8 +179,8 @@
enforce_downstream(infd, outfd, &Map, &outMap, &parm);
- G_close_cell(infd);
- G_close_cell(outfd);
+ Rast_close_cell(infd);
+ Rast_close_cell(outfd);
close_vect(&Map, 0);
if (parm.outvect->answer)
Modified: grass/trunk/raster/r.carve/raster.c
===================================================================
--- grass/trunk/raster/r.carve/raster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.carve/raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -14,9 +15,9 @@
for (i = 0; i < rows; i++) {
G_percent(i + 1, rows, 10);
- G_get_raster_row(fd, tmpbuf, i, rtype);
+ Rast_get_raster_row(fd, tmpbuf, i, rtype);
tmpbuf =
- G_incr_void_ptr(tmpbuf, G_raster_size(rtype) * G_window_cols());
+ Rast_incr_void_ptr(tmpbuf, Rast_raster_size(rtype) * G_window_cols());
}
return tmpbuf;
@@ -34,9 +35,9 @@
for (i = 0; i < rows; i++) {
G_percent(i, rows, 10);
- G_put_raster_row(fd, tmpbuf, rtype);
+ Rast_put_raster_row(fd, tmpbuf, rtype);
tmpbuf =
- G_incr_void_ptr(tmpbuf, G_raster_size(rtype) * G_window_cols());
+ Rast_incr_void_ptr(tmpbuf, Rast_raster_size(rtype) * G_window_cols());
}
return tmpbuf;
Modified: grass/trunk/raster/r.carve/support.c
===================================================================
--- grass/trunk/raster/r.carve/support.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.carve/support.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "enforce.h"
@@ -35,13 +36,13 @@
struct History hist;
/* write command line to history */
- G_short_history(parm->outrast->answer, "raster", &hist);
+ Rast_short_history(parm->outrast->answer, "raster", &hist);
sprintf(hist.edhist[0], "%s version %.2f", G_program_name(), APP_VERSION);
sprintf(hist.edhist[1], "stream width: %.2f", parm->swidth * 2);
sprintf(hist.datsrc_1, "raster elevation file: %s", parm->inrast->answer);
sprintf(hist.datsrc_2, "vector stream file: %s", parm->invect->answer);
hist.edlinecnt = 2;
- G_command_history(&hist);
+ Rast_command_history(&hist);
- return G_write_history(parm->outrast->answer, &hist);
+ return Rast_write_history(parm->outrast->answer, &hist);
}
Modified: grass/trunk/raster/r.carve/vect.c
===================================================================
--- grass/trunk/raster/r.carve/vect.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.carve/vect.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "enforce.h"
Modified: grass/trunk/raster/r.category/cats.c
===================================================================
--- grass/trunk/raster/r.category/cats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.category/cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -31,37 +32,37 @@
struct Cell_head cellhd;
/* set the window to the cell header */
- if (G_get_cellhd(name, mapset, &cellhd) < 0)
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0)
G_fatal_error(_("Cannot read header of raster map <%s> in <%s>"),
name, mapset);
G_set_window(&cellhd);
/* open the raster map */
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd < 0)
G_fatal_error(_("Cannot open cell file of raster map <%s> in <%s>"),
name, mapset);
nrows = G_window_rows();
ncols = G_window_cols();
- cell = G_allocate_cell_buf();
- G_init_cell_stats(&statf);
+ cell = Rast_allocate_cell_buf();
+ Rast_init_cell_stats(&statf);
/* read the raster map */
G_verbose_message(_("Reading <%s> in <%s>"), name, mapset);
for (row = 0; row < nrows; row++) {
if (G_verbose() > G_verbose_std())
G_percent(row, nrows, 2);
- if (G_get_c_raster_row_nomask(fd, cell, row) < 0)
+ if (Rast_get_c_raster_row_nomask(fd, cell, row) < 0)
exit(EXIT_SUCCESS);
- G_update_cell_stats(cell, ncols, &statf);
+ Rast_update_cell_stats(cell, ncols, &statf);
}
/* done */
if (G_verbose() > G_verbose_std())
G_percent(row, nrows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(cell);
- G_rewind_cell_stats(&statf);
+ Rast_rewind_cell_stats(&statf);
return 0;
}
@@ -71,7 +72,7 @@
long count;
CELL cat;
- if (G_next_cell_stat(&cat, &count, &statf)) {
+ if (Rast_next_cell_stat(&cat, &count, &statf)) {
*x = cat;
return 1;
}
Modified: grass/trunk/raster/r.category/main.c
===================================================================
--- grass/trunk/raster/r.category/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.category/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -124,7 +125,7 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
- map_type = G_raster_map_type(name, mapset);
+ map_type = Rast_raster_map_type(name, mapset);
/* create category labels */
@@ -146,20 +147,20 @@
G_fatal_error(_("Raster map <%s> not found"),
parm.raster->answer);
- if ((fd = G_open_cell_old(name, mapset)) < 0)
+ if ((fd = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- G_init_raster_cats("", &cats);
+ Rast_init_raster_cats("", &cats);
- if (0 > G_read_cats(parm.raster->answer, cmapset, &cats))
+ if (0 > Rast_read_cats(parm.raster->answer, cmapset, &cats))
G_fatal_error(_("Unable to read category file of raster map <%s@%s>"),
parm.raster->answer, cmapset);
- if (G_write_cats(name, &cats) >= 0)
+ if (Rast_write_cats(name, &cats) >= 0)
G_message(_("Category table for <%s> set from <%s>"), name,
parm.raster->answer);
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
/* load cats from rules file */
@@ -178,7 +179,7 @@
parm.file->answer);
}
- G_init_raster_cats("", &cats);
+ Rast_init_raster_cats("", &cats);
for (;;) {
char buf[1024], label[1024];
@@ -188,12 +189,12 @@
break;
if (sscanf(buf, "%lf:%lf:%[^\n]", &d1, &d2, label) == 3)
- G_set_d_raster_cat(&d1, &d2, label, &cats);
+ Rast_set_d_raster_cat(&d1, &d2, label, &cats);
else if (sscanf(buf, "%lf:%[^\n]", &d1, label) == 2)
- G_set_d_raster_cat(&d1, &d1, label, &cats);
+ Rast_set_d_raster_cat(&d1, &d1, label, &cats);
}
- if (G_write_cats(name, &cats) < 0)
+ if (Rast_write_cats(name, &cats) < 0)
G_fatal_error(_("Cannot create category file for <%s>"),
name);
@@ -207,9 +208,9 @@
double m1, a1, m2, a2;
/* read existing values */
- G_init_raster_cats("", &cats);
+ Rast_init_raster_cats("", &cats);
- if (0 > G_read_cats(name, G_mapset(), &cats))
+ if (0 > Rast_read_cats(name, G_mapset(), &cats))
G_warning(_("Unable to read category file of raster map <%s@%s>"),
name, G_mapset());
@@ -237,18 +238,18 @@
a2 = atof(parm.fmt_coeff->answers[3]);
}
- G_set_cats_fmt(fmt_str, m1, a1, m2, a2, &cats);
+ Rast_set_cats_fmt(fmt_str, m1, a1, m2, a2, &cats);
- if (G_write_cats(name, &cats) != 1)
+ if (Rast_write_cats(name, &cats) != 1)
G_fatal_error(_("Cannot create category file for <%s>"),
name);
}
- G_free_cats(&cats);
+ Rast_free_cats(&cats);
exit(EXIT_SUCCESS);
}
else {
- if (G_read_cats(name, mapset, &cats) < 0)
+ if (Rast_read_cats(name, mapset, &cats) < 0)
G_fatal_error(_("Unable to read category file of raster map <%s> in <%s>"),
name, mapset);
}
@@ -301,7 +302,7 @@
{
char *label;
- G_squeeze(label = G_get_cat((CELL) x, &cats));
+ G_squeeze(label = Rast_get_cat((CELL) x, &cats));
fprintf(stdout, "%ld%c%s\n", x, fs, label);
return 0;
@@ -313,7 +314,7 @@
DCELL dtmp;
dtmp = x;
- G_squeeze(label = G_get_d_raster_cat(&dtmp, &cats));
+ G_squeeze(label = Rast_get_d_raster_cat(&dtmp, &cats));
sprintf(tmp, "%.10f", x);
G_trim_decimal(tmp);
fprintf(stdout, "%s%c%s\n", tmp, fs, label);
Modified: grass/trunk/raster/r.circle/main.c
===================================================================
--- grass/trunk/raster/r.circle/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.circle/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <strings.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
typedef int FILEDESC;
@@ -123,7 +124,7 @@
G_get_set_window(&w);
- if ((cellfile = G_open_cell_new(out_file->answer)) == -1)
+ if ((cellfile = Rast_open_cell_new(out_file->answer)) == -1)
G_fatal_error(_("Unable to create raster map <%s>"),
out_file->answer);
@@ -140,17 +141,17 @@
int_buf[c] =
(int)(distance(pt, cur, fmin, fmax, binary) * fmult);
if (int_buf[c] == 0)
- G_set_null_value(&int_buf[c], 1, CELL_TYPE);
+ Rast_set_null_value(&int_buf[c], 1, CELL_TYPE);
}
- G_put_raster_row(cellfile, int_buf, CELL_TYPE);
+ Rast_put_raster_row(cellfile, int_buf, CELL_TYPE);
}
}
G_free(int_buf);
- G_close_cell(cellfile);
- G_short_history(out_file->answer, "raster", &history);
- G_command_history(&history);
- G_write_history(out_file->answer, &history);
+ Rast_close_cell(cellfile);
+ Rast_short_history(out_file->answer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out_file->answer, &history);
G_done_msg(_("Raster map <%s> created."),
out_file->answer);
Modified: grass/trunk/raster/r.clump/clump.c
===================================================================
--- grass/trunk/raster/r.clump/clump.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.clump/clump.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <time.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -97,7 +98,7 @@
G_message(_("Pass %d..."), pass);
for (row = 0; row < nrows; row++) {
- if (G_get_map_row(in_fd, cur_in + 1, row) < 0)
+ if (Rast_get_map_row(in_fd, cur_in + 1, row) < 0)
G_fatal_error(_("Unable to read raster map row %d "),
row);
@@ -220,7 +221,7 @@
for (col = 1; col <= ncols; col++)
out_cell[col] = index[cur_clump[col]];
- if (G_put_raster_row (out_fd, out_cell+1, CELL_TYPE) < 0)
+ if (Rast_put_raster_row (out_fd, out_cell+1, CELL_TYPE) < 0)
G_fatal_error (_("Unable to properly write output raster map"));
*/
col = ncols;
@@ -232,9 +233,9 @@
for (column = 0; column < ncols; column++) {
if (out_cell[column] == 0)
- G_set_null_value(&out_cell[column], 1, CELL_TYPE);
+ Rast_set_null_value(&out_cell[column], 1, CELL_TYPE);
}
- if (G_put_raster_row(out_fd, out_cell, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(out_fd, out_cell, CELL_TYPE) < 0)
G_fatal_error(_("Failed writing raster map row %d"),
row);
}
Modified: grass/trunk/raster/r.clump/main.c
===================================================================
--- grass/trunk/raster/r.clump/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.clump/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -66,11 +67,11 @@
strcpy(name, INPUT);
- in_fd = G_open_cell_old(name, "");
+ in_fd = Rast_open_cell_old(name, "");
if (in_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), INPUT);
- out_fd = G_open_cell_new(OUTPUT);
+ out_fd = Rast_open_cell_new(OUTPUT);
if (out_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), OUTPUT);
@@ -78,8 +79,8 @@
G_debug(1, "Creating support files...");
- G_close_cell(in_fd);
- G_close_cell(out_fd);
+ Rast_close_cell(in_fd);
+ Rast_close_cell(out_fd);
/* build title */
@@ -88,11 +89,11 @@
else
sprintf(title, "clump of <%s@%s>", name, G_mapset());
- G_put_cell_title(OUTPUT, title);
- G_read_range(OUTPUT, G_mapset(), &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_random_colors(&colr, min, max);
- G_write_colors(OUTPUT, G_mapset(), &colr);
+ Rast_put_cell_title(OUTPUT, title);
+ Rast_read_range(OUTPUT, G_mapset(), &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_random_colors(&colr, min, max);
+ Rast_write_colors(OUTPUT, G_mapset(), &colr);
G_done_msg(_("%d clumps."), range.max);
Modified: grass/trunk/raster/r.coin/coin.h
===================================================================
--- grass/trunk/raster/r.coin/coin.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.coin/coin.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,8 @@
#define __COIN_H__
#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/Rast.h>
struct stats_table
{
Modified: grass/trunk/raster/r.coin/main.c
===================================================================
--- grass/trunk/raster/r.coin/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.coin/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "coin.h"
@@ -103,7 +104,7 @@
/* now make a temorary region with the same boundaries only 1 x 1 */
window.rows = 1;
window.cols = 1;
- G_adjust_Cell_head(&window, 1, 1);
+ Rast_adjust_Cell_head(&window, 1, 1);
G_set_window(&window);
G_begin_cell_area_calculations();
Modified: grass/trunk/raster/r.coin/make_coin.c
===================================================================
--- grass/trunk/raster/r.coin/make_coin.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.coin/make_coin.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include "coin.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
static int cmp(const void *, const void *);
@@ -132,8 +133,8 @@
reversed = 1;
}
- title1 = G_get_cell_title(map1name, "");
- title2 = G_get_cell_title(map2name, "");
+ title1 = Rast_get_cell_title(map1name, "");
+ title2 = Rast_get_cell_title(map2name, "");
/* determine where no data (cat 0) is */
for (no_data1 = ncat1 - 1; no_data1 >= 0; no_data1--)
Modified: grass/trunk/raster/r.coin/print_hdr.c
===================================================================
--- grass/trunk/raster/r.coin/print_hdr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.coin/print_hdr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -70,7 +70,7 @@
fprintf(dumpfile, "|%78.78s|\n", fill);
fprintf(dumpfile, "| Layer 1: %-15.15s-- %-50.49s|\n", map1name, title1);
fprintf(dumpfile, "| Layer 2: %-15.15s-- %-50.49s|\n", map2name, title2);
- fprintf(dumpfile, "| Mask: %-68.68s|\n", G_mask_info());
+ fprintf(dumpfile, "| Mask: %-68.68s|\n", Rast_mask_info());
fprintf(dumpfile, "|%78.78s|\n", fill);
fprintf(dumpfile, "| Units: %-68.68s|\n", unit_type);
fprintf(dumpfile, "|%78.78s|\n", midline);
Modified: grass/trunk/raster/r.colors/local_proto.h
===================================================================
--- grass/trunk/raster/r.colors/local_proto.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.colors/local_proto.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#define __LOCAL_PROTO_H__
#include <grass/gis.h>
+#include <grass/Rast.h>
/* stats.c */
int get_stats(const char *, const char *, struct Cell_stats *);
Modified: grass/trunk/raster/r.colors/main.c
===================================================================
--- grass/trunk/raster/r.colors/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.colors/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,6 +26,7 @@
#include <string.h>
#include <sys/types.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -265,7 +266,7 @@
G_fatal_error(_("Raster map <%s> not found"), name);
if (remove) {
- int stat = G_remove_colors(name, mapset);
+ int stat = Rast_remove_colors(name, mapset);
if (stat < 0)
G_fatal_error(_("Unable to remove color table of raster map <%s>"), name);
@@ -275,18 +276,18 @@
}
G_suppress_warnings(1);
- have_colors = G_read_colors(name, mapset, &colors);
+ have_colors = Rast_read_colors(name, mapset, &colors);
/*if (have_colors >= 0)
- G_free_colors(&colors); */
+ Rast_free_colors(&colors); */
if (have_colors > 0 && !overwrite)
exit(EXIT_SUCCESS);
G_suppress_warnings(0);
- fp = G_raster_map_is_fp(name, mapset);
- G_read_fp_range(name, mapset, &range);
- G_get_fp_range_min_max(&range, &min, &max);
+ fp = Rast_raster_map_is_fp(name, mapset);
+ Rast_read_fp_range(name, mapset, &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
if (is_from_stdin) {
if (!read_color_rules(stdin, &colors, min, max, fp))
@@ -299,37 +300,37 @@
if (strcmp(style, "random") == 0) {
if (fp)
G_fatal_error(_("Color table 'random' is not supported for floating point raster map"));
- G_make_random_colors(&colors, (CELL) min, (CELL) max);
+ Rast_make_random_colors(&colors, (CELL) min, (CELL) max);
}
else if (strcmp(style, "grey.eq") == 0) {
if (fp)
G_fatal_error(_("Color table 'grey.eq' is not supported for floating point raster map"));
if (!have_stats)
have_stats = get_stats(name, mapset, &statf);
- G_make_histogram_eq_colors(&colors, &statf);
+ Rast_make_histogram_eq_colors(&colors, &statf);
}
else if (strcmp(style, "grey.log") == 0) {
if (fp)
G_fatal_error(_("Color table 'grey.log' is not supported for floating point raster map"));
if (!have_stats)
have_stats = get_stats(name, mapset, &statf);
- G_make_histogram_log_colors(&colors, &statf, (CELL) min,
+ Rast_make_histogram_log_colors(&colors, &statf, (CELL) min,
(CELL) max);
}
else if (find_rule(style))
- G_make_fp_colors(&colors, style, min, max);
+ Rast_make_fp_colors(&colors, style, min, max);
else
G_fatal_error(_("Unknown color request '%s'"), style);
}
else if (rules) {
- if (!G_load_fp_colors(&colors, rules, min, max)) {
+ if (!Rast_load_fp_colors(&colors, rules, min, max)) {
/* for backwards compatibility try as std name; remove for GRASS 7 */
char path[GPATH_MAX];
/* don't bother with native dirsep as not needed for backwards compatibility */
sprintf(path, "%s/etc/colors/%s", G_gisbase(), rules);
- if (!G_load_fp_colors(&colors, path, min, max))
+ if (!Rast_load_fp_colors(&colors, path, min, max))
G_fatal_error(_("Unable to load rules file <%s>"), rules);
}
}
@@ -339,44 +340,44 @@
if (cmapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), cmap);
- if (G_read_colors(cmap, cmapset, &colors) < 0)
+ if (Rast_read_colors(cmap, cmapset, &colors) < 0)
G_fatal_error(_("Unable to read color table for raster map <%s>"), cmap);
}
if (fp)
- G_mark_colors_as_fp(&colors);
+ Rast_mark_colors_as_fp(&colors);
if (flag.n->answer)
- G_invert_colors(&colors);
+ Rast_invert_colors(&colors);
if (flag.e->answer) {
if (fp) {
struct FP_stats fpstats;
get_fp_stats(name, mapset, &fpstats, min, max, flag.g->answer, flag.a->answer);
- G_histogram_eq_colors_fp(&colors_tmp, &colors, &fpstats);
+ Rast_histogram_eq_colors_fp(&colors_tmp, &colors, &fpstats);
}
else {
if (!have_stats)
have_stats = get_stats(name, mapset, &statf);
- G_histogram_eq_colors(&colors_tmp, &colors, &statf);
+ Rast_histogram_eq_colors(&colors_tmp, &colors, &statf);
}
colors = colors_tmp;
}
if (flag.g->answer) {
- G_log_colors(&colors_tmp, &colors, 100);
+ Rast_log_colors(&colors_tmp, &colors, 100);
colors = colors_tmp;
}
if (flag.a->answer) {
- G_abs_log_colors(&colors_tmp, &colors, 100);
+ Rast_abs_log_colors(&colors_tmp, &colors, 100);
colors = colors_tmp;
}
if (fp)
- G_mark_colors_as_fp(&colors);
+ Rast_mark_colors_as_fp(&colors);
- if (G_write_colors(name, mapset, &colors) >= 0)
+ if (Rast_write_colors(name, mapset, &colors) >= 0)
G_message(_("Color table for raster map <%s> set to '%s'"), name,
is_from_stdin ? "rules" : style ? style : rules ? rules :
cmap);
Modified: grass/trunk/raster/r.colors/rules.c
===================================================================
--- grass/trunk/raster/r.colors/rules.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.colors/rules.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -56,10 +57,10 @@
(long)max);
}
- if (!G_read_color_rules(colors, min, max, read_rule, fp))
+ if (!Rast_read_color_rules(colors, min, max, read_rule, fp))
return 0;
- G_get_d_color_range(&rulemin, &rulemax, colors);
+ Rast_get_d_color_range(&rulemin, &rulemax, colors);
G_debug(3, "rulemin=%.1f rulemax=%.1f", rulemin, rulemax);
if (rulemin > min || rulemax < max)
@@ -116,7 +117,7 @@
}
ret =
- G_parse_color_rule(min, max, buf, val, r, g, b, norm, nval, dflt);
+ Rast_parse_color_rule(min, max, buf, val, r, g, b, norm, nval, dflt);
if (ret == 0)
return 1;
@@ -128,7 +129,7 @@
static void badrule(int tty, const char *s, int code)
{
- const char *err = G_parse_color_rule_error(code);
+ const char *err = Rast_parse_color_rule_error(code);
if (tty)
G_warning(_("bad rule (%s); rule not added"), err);
Modified: grass/trunk/raster/r.colors/stats.c
===================================================================
--- grass/trunk/raster/r.colors/stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.colors/stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <math.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -29,26 +30,26 @@
int row, nrows, ncols;
int fd;
- if ((fd = G_open_cell_old(name, mapset)) < 0)
+ if ((fd = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
G_fully_qualified_name(name, mapset));
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
nrows = G_window_rows();
ncols = G_window_cols();
- G_init_cell_stats(statf);
+ Rast_init_cell_stats(statf);
G_verbose_message(_("Reading raster map <%s>..."),
G_fully_qualified_name(name, mapset));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_c_raster_row(fd, cell, row) < 0)
+ if (Rast_get_c_raster_row(fd, cell, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
G_fully_qualified_name(name, mapset), row);
- G_update_cell_stats(cell, ncols, statf);
+ Rast_update_cell_stats(cell, ncols, statf);
}
G_percent(row, nrows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(cell);
return 1;
@@ -62,11 +63,11 @@
int row, col, nrows, ncols;
int fd;
- if ((fd = G_open_cell_old(name, mapset)) < 0)
+ if ((fd = Rast_open_cell_old(name, mapset)) < 0)
G_fatal_error("Unable to open raster map <%s>",
G_fully_qualified_name(name, mapset));
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
nrows = G_window_rows();
ncols = G_window_cols();
@@ -109,7 +110,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_d_raster_row(fd, dcell, row) < 0)
+ if (Rast_get_d_raster_row(fd, dcell, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
G_fully_qualified_name(name, mapset), row);
@@ -117,7 +118,7 @@
DCELL x;
int i;
- if (G_is_d_null_value(&dcell[col]))
+ if (Rast_is_d_null_value(&dcell[col]))
continue;
x = dcell[col];
@@ -135,6 +136,6 @@
}
G_percent(row, nrows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(dcell);
}
Modified: grass/trunk/raster/r.colors.out/main.c
===================================================================
--- grass/trunk/raster/r.colors.out/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.colors.out/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
static FILE *fp;
@@ -83,11 +84,11 @@
file = opt.file->answer;
perc = flag.p->answer ? 1 : 0;
- if (G_read_colors(name, "", &colors) < 0)
+ if (Rast_read_colors(name, "", &colors) < 0)
G_fatal_error(_("Can't read color table for <%s>"));
- G_read_fp_range(name, "", &range);
- G_get_fp_range_min_max(&range, &min, &max);
+ Rast_read_fp_range(name, "", &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
if (!file || strcmp(file, "-") == 0)
fp = stdout;
@@ -101,23 +102,23 @@
/* 3.0 format */
CELL lo, hi;
- G_get_color_range(&lo, &hi, &colors);
+ Rast_get_color_range(&lo, &hi, &colors);
for (i = lo; i <= hi; i++) {
unsigned char r, g, b, set;
DCELL val = (DCELL) i;
- G_lookup_colors(&i, &r, &g, &b, &set, 1, &colors);
+ Rast_lookup_colors(&i, &r, &g, &b, &set, 1, &colors);
write_rule(&val, r, g, b);
}
}
else {
- count = G_colors_count(&colors);
+ count = Rast_colors_count(&colors);
for (i = 0; i < count; i++) {
DCELL val1, val2;
unsigned char r1, g1, b1, r2, g2, b2;
- G_get_f_color_rule(
+ Rast_get_f_color_rule(
&val1, &r1, &g1, &b1,
&val2, &r2, &g2, &b2,
&colors, count - 1 - i);
@@ -129,9 +130,9 @@
{
int r, g, b;
- G_get_null_value_color(&r, &g, &b, &colors);
+ Rast_get_null_value_color(&r, &g, &b, &colors);
fprintf(fp, "nv %d %d %d\n", r, g, b);
- G_get_default_color(&r, &g, &b, &colors);
+ Rast_get_default_color(&r, &g, &b, &colors);
fprintf(fp, "default %d %d %d\n", r, g, b);
}
Modified: grass/trunk/raster/r.composite/main.c
===================================================================
--- grass/trunk/raster/r.composite/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.composite/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct band
@@ -150,15 +151,15 @@
b->name = b->opt_name->answer;
/* Make sure map is available */
- if ((b->file = G_open_cell_old(b->name, "")) == -1)
+ if ((b->file = Rast_open_cell_old(b->name, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), b->name);
- b->type = G_get_raster_map_type(b->file);
+ b->type = Rast_get_raster_map_type(b->file);
- b->size = G_raster_size(b->type);
+ b->size = Rast_raster_size(b->type);
/* Reading color lookup table */
- if (G_read_colors(b->name, "", &b->colors) == -1)
+ if (Rast_read_colors(b->name, "", &b->colors) == -1)
G_fatal_error(_("Unable to read color file of raster map <%s>"), b->name);
for (j = 0; j < 3; j++)
@@ -179,10 +180,10 @@
/* open output files */
out_name = opt_out->answer;
- if ((out_file = G_open_cell_new(out_name)) < 0)
+ if ((out_file = Rast_open_cell_new(out_name)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), out_name);
- out_array = G_allocate_cell_buf();
+ out_array = Rast_allocate_cell_buf();
/* Make color table */
make_color_cube(&out_colors);
@@ -195,7 +196,7 @@
for (i = 0; i < 3; i++) {
struct band *b = &B[i];
- if (G_get_raster_row_colors(b->file, atrow, &b->colors,
+ if (Rast_get_raster_row_colors(b->file, atrow, &b->colors,
b->array[0],
b->array[1], b->array[2], nulls) < 0)
G_fatal_error(_("Error reading raster map <%s>"),
@@ -215,7 +216,7 @@
int val[3];
if (nulls[atcol]) {
- G_set_c_null_value(&out_array[atcol], 1);
+ Rast_set_c_null_value(&out_array[atcol], 1);
continue;
}
@@ -245,21 +246,21 @@
(val[2] * B[1].levels + val[1]) * B[0].levels + val[0];
}
- if (G_put_raster_row(out_file, out_array, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(out_file, out_array, CELL_TYPE) < 0)
G_fatal_error(_("Failed writing raster map <%s>"), out_name);
}
G_percent(window.rows, window.rows, 1);
/* Close the input files */
for (i = 0; i < 3; i++)
- G_close_cell(B[i].file);
+ Rast_close_cell(B[i].file);
/* Close the output file */
- G_close_cell(out_file);
- G_write_colors(out_name, G_mapset(), &out_colors);
- G_short_history(out_name, "raster", &history);
- G_command_history(&history);
- G_write_history(out_name, &history);
+ Rast_close_cell(out_file);
+ Rast_write_colors(out_name, G_mapset(), &out_colors);
+ Rast_short_history(out_name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out_name, &history);
G_done_msg(_("Raster map <%s> created."), out_name);
@@ -283,7 +284,7 @@
int g, b;
int i = 0;
- G_init_colors(colors);
+ Rast_init_colors(colors);
G_message(_("Creating color table for output raster map..."));
@@ -296,7 +297,7 @@
CELL i0 = i;
CELL i1 = i + mr;
- G_add_c_raster_color_rule(&i0, 0, grn, blu,
+ Rast_add_c_raster_color_rule(&i0, 0, grn, blu,
&i1, 255, grn, blu, colors);
i += nr;
Modified: grass/trunk/raster/r.compress/main.c
===================================================================
--- grass/trunk/raster/r.compress/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.compress/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -27,7 +27,7 @@
* Next byte(s): category number. The number of bytes is determined
* by the number of bytes in a cell
*
- * The normal G_open_cell(), and G_put_raster_row() do the compression
+ * The normal G_open_cell(), and Rast_put_raster_row() do the compression
* This program must only check that the file is not a reclass file and
* is not already compressed.
*
@@ -40,6 +40,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
static off_t newsize, oldsize;
@@ -102,7 +103,7 @@
G_warning(_("[%s] not found"), name);
return 1;
}
- if (G_is_reclass(name, G_mapset(), rname, rmapset) > 0) {
+ if (Rast_is_reclass(name, G_mapset(), rname, rmapset) > 0) {
G_warning(uncompress
?
_("[%s] is a reclass file of map <%s> in mapset <%s> - can't uncompress")
@@ -112,16 +113,16 @@
return 1;
}
- map_type = G_raster_map_type(name, G_mapset());
+ map_type = Rast_raster_map_type(name, G_mapset());
G_suppress_warnings(1);
- colr_ok = G_read_colors(name, G_mapset(), &colr) > 0;
- hist_ok = G_read_history(name, G_mapset(), &hist) >= 0;
- cats_ok = G_read_cats(name, G_mapset(), &cats) >= 0;
+ colr_ok = Rast_read_colors(name, G_mapset(), &colr) > 0;
+ hist_ok = Rast_read_history(name, G_mapset(), &hist) >= 0;
+ cats_ok = Rast_read_cats(name, G_mapset(), &cats) >= 0;
if (map_type != CELL_TYPE) {
- G_quant_init(&quant);
- quant_ok = G_read_quant(name, G_mapset(), &quant);
+ Rast_quant_init(&quant);
+ quant_ok = Rast_read_quant(name, G_mapset(), &quant);
G_suppress_warnings(0);
}
@@ -129,18 +130,18 @@
return 1;
if (colr_ok) {
- G_write_colors(name, G_mapset(), &colr);
- G_free_colors(&colr);
+ Rast_write_colors(name, G_mapset(), &colr);
+ Rast_free_colors(&colr);
}
if (hist_ok)
- G_write_history(name, &hist);
+ Rast_write_history(name, &hist);
if (cats_ok) {
- cats.num = G_number_of_cats(name, G_mapset());
- G_write_cats(name, &cats);
- G_free_cats(&cats);
+ cats.num = Rast_number_of_cats(name, G_mapset());
+ Rast_write_cats(name, &cats);
+ Rast_free_cats(&cats);
}
if (map_type != CELL_TYPE && quant_ok)
- G_write_quant(name, G_mapset(), &quant);
+ Rast_write_quant(name, G_mapset(), &quant);
diff = newsize - oldsize;
if (diff < 0)
@@ -170,7 +171,7 @@
int new, old, nrows, row;
void *rast;
- if (G_get_cellhd(name, G_mapset(), &cellhd) < 0) {
+ if (Rast_get_cellhd(name, G_mapset(), &cellhd) < 0) {
G_warning("Problem reading cell header for [%s]", name);
return 1;
}
@@ -190,48 +191,48 @@
G_set_window(&cellhd);
- old = G_open_cell_old(name, G_mapset());
+ old = Rast_open_cell_old(name, G_mapset());
if (old < 0)
return 1;
if (uncompress) {
if (map_type == CELL_TYPE) {
- G_set_cell_format(cellhd.format);
- new = G_open_cell_new_uncompressed(name);
+ Rast_set_cell_format(cellhd.format);
+ new = Rast_open_cell_new_uncompressed(name);
}
else {
- G_set_fp_type(map_type);
- new = G_open_fp_cell_new_uncompressed(name);
+ Rast_set_fp_type(map_type);
+ new = Rast_open_fp_cell_new_uncompressed(name);
}
}
else
- new = G_open_raster_new(name, map_type);
+ new = Rast_open_raster_new(name, map_type);
if (new < 0)
return 1;
nrows = G_window_rows();
- rast = G_allocate_raster_buf(map_type);
+ rast = Rast_allocate_raster_buf(map_type);
oldsize = lseek(old, (off_t) 0, SEEK_END);
/* the null file is written automatically */
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row_nomask(old, rast, row, map_type) < 0)
+ if (Rast_get_raster_row_nomask(old, rast, row, map_type) < 0)
break;
- if (G_put_raster_row(new, rast, map_type) < 0)
+ if (Rast_put_raster_row(new, rast, map_type) < 0)
break;
}
G_free(rast);
- G_close_cell(old);
+ Rast_close_cell(old);
if (row < nrows) {
- G_unopen_cell(new);
+ Rast_unopen_cell(new);
return 1;
}
- G_close_cell(new);
+ Rast_close_cell(new);
newsize = 0;
- old = G_open_cell_old(name, G_mapset());
+ old = Rast_open_cell_old(name, G_mapset());
newsize = lseek(old, (off_t) 0, SEEK_END);
- G_close_cell(old);
+ Rast_close_cell(old);
return 0;
}
Modified: grass/trunk/raster/r.contour/cont.c
===================================================================
--- grass/trunk/raster/r.contour/cont.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.contour/cont.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -339,11 +340,11 @@
p1 = curr->edge;
p2 = (curr->edge + 1) % 4;
- if (G_raster_cmp(&curr->z[p1], &curr->z[p2], DCELL_TYPE) == 0)
+ if (Rast_raster_cmp(&curr->z[p1], &curr->z[p2], DCELL_TYPE) == 0)
ratio = 1;
- else if (G_is_d_null_value(&curr->z[p1]))
+ else if (Rast_is_d_null_value(&curr->z[p1]))
ratio = 1 / 2;
- else if (G_is_d_null_value(&curr->z[p2]))
+ else if (Rast_is_d_null_value(&curr->z[p2]))
ratio = 1 / 2;
else
ratio = (level - curr->z[p1]) / (curr->z[p2] - curr->z[p1]);
Modified: grass/trunk/raster/r.contour/main.c
===================================================================
--- grass/trunk/raster/r.contour/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.contour/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -45,6 +45,7 @@
#include <ctype.h>
#include <float.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -131,11 +132,11 @@
name = map->answer;
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- if (G_read_fp_range(name, "", &range) < 0)
+ if (Rast_read_fp_range(name, "", &range) < 0)
G_fatal_error(_("Unable to read fp range of raster map <%s>"),
name);
@@ -219,7 +220,7 @@
for (i = 0; i < nrow; i++) {
z_array[i] = (DCELL *) G_malloc(ncol * sizeof(DCELL));
- G_get_d_raster_row(fd, z_array[i], i);
+ Rast_get_d_raster_row(fd, z_array[i], i);
G_percent(i + 1, nrow, 2);
}
return z_array;
@@ -238,9 +239,9 @@
double *lev;
double tmp;
- G_get_fp_range_min_max(range, &zmin, &zmax);
+ Rast_get_fp_range_min_max(range, &zmin, &zmax);
- if (!G_is_d_null_value(&zmin) && !G_is_d_null_value(&zmax))
+ if (!Rast_is_d_null_value(&zmin) && !Rast_is_d_null_value(&zmax))
G_verbose_message(_("Range of data: min=%f, max=%f"), zmin, zmax);
else
G_verbose_message(_("Range of data: empty"));
Modified: grass/trunk/raster/r.cost/btree.c
===================================================================
--- grass/trunk/raster/r.cost/btree.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cost/btree.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -38,6 +38,7 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include "memory.h"
#include <stdlib.h>
Modified: grass/trunk/raster/r.cost/main.c
===================================================================
--- grass/trunk/raster/r.cost/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cost/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -61,6 +61,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/site.h>
#include <grass/segment.h>
#include "cost.h"
@@ -260,7 +261,7 @@
H_DIAG_fac =
(double)sqrt((double)(NS_fac * NS_fac + 4 * EW_fac * EW_fac));
- G_set_d_null_value(&null_cost, 1);
+ Rast_set_d_null_value(&null_cost, 1);
if (flag2->answer)
total_reviewed = 16;
@@ -303,7 +304,7 @@
if ((opt6->answer == NULL) ||
(sscanf(opt6->answer, "%lf", &null_cost) != 1)) {
G_debug(1, "Null cells excluded from cost evaluation");
- G_set_d_null_value(&null_cost, 1);
+ Rast_set_d_null_value(&null_cost, 1);
}
else if (keep_nulls)
G_debug(1, "Null cell will be retained into output raster map");
@@ -314,10 +315,10 @@
G_fatal_error(_("Vector map <%s> not found"), opt7->answer);
}
- if (!G_is_d_null_value(&null_cost)) {
+ if (!Rast_is_d_null_value(&null_cost)) {
if (null_cost < 0.0) {
G_warning(_("Assigning negative cost to null cell. Null cells excluded."));
- G_set_d_null_value(&null_cost, 1);
+ Rast_set_d_null_value(&null_cost, 1);
}
}
else {
@@ -347,13 +348,13 @@
/* Open cost cell layer for reading */
- cost_fd = G_open_cell_old(cost_layer, cost_mapset);
+ cost_fd = Rast_open_cell_old(cost_layer, cost_mapset);
if (cost_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), cost_layer);
- data_type = G_get_raster_map_type(cost_fd);
- cell = G_allocate_raster_buf(data_type);
+ data_type = Rast_get_raster_map_type(cost_fd);
+ cell = Rast_allocate_raster_buf(data_type);
/* Parameters for map submatrices */
@@ -419,12 +420,12 @@
int i;
double p;
- dsize = G_raster_size(data_type);
+ dsize = Rast_raster_size(data_type);
p = 0.0;
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(cost_fd, cell, row, data_type) < 0)
+ if (Rast_get_raster_row(cost_fd, cell, row, data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cost_layer, row);
@@ -433,39 +434,39 @@
switch (data_type) {
case CELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, data_type)) {
+ if (Rast_is_null_value(ptr2, data_type)) {
p = null_cost;
}
else {
p = *(int *)ptr2;
}
segment_put(&in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, dsize);
}
break;
case FCELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, data_type)) {
+ if (Rast_is_null_value(ptr2, data_type)) {
p = null_cost;
}
else {
p = *(float *)ptr2;
}
segment_put(&in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, dsize);
}
break;
case DCELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, data_type)) {
+ if (Rast_is_null_value(ptr2, data_type)) {
p = null_cost;
}
else {
p = *(double *)ptr2;
}
segment_put(&in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, dsize);
}
break;
}
@@ -485,7 +486,7 @@
fbuff = (double *)G_malloc(ncols * sizeof(double));
- G_set_d_null_value(fbuff, ncols);
+ Rast_set_d_null_value(fbuff, ncols);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
@@ -506,7 +507,7 @@
int i;
fbuff =
(double *)G_malloc((unsigned int)(ncols * sizeof(double)));
- G_set_d_null_value(fbuff, ncols);
+ Rast_set_d_null_value(fbuff, ncols);
for (row = 0; row < nrows; row++) {
{
G_percent(row, nrows, 2);
@@ -629,16 +630,16 @@
search_mapset = G_find_file("cell", opt9->answer, "");
- fd = G_open_cell_old(opt9->answer, search_mapset);
+ fd = Rast_open_cell_old(opt9->answer, search_mapset);
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
opt9->answer);
- data_type2 = G_get_raster_map_type(fd);
+ data_type2 = Rast_get_raster_map_type(fd);
- dsize2 = G_raster_size(data_type2);
+ dsize2 = Rast_raster_size(data_type2);
- cell2 = G_allocate_raster_buf(data_type2);
+ cell2 = Rast_allocate_raster_buf(data_type2);
if (!cell2)
G_fatal_error(_("Unable to allocate memory"));
@@ -646,17 +647,17 @@
G_message(_("Reading raster map <%s>..."), opt9->answer);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(fd, cell2, row, data_type2) < 0)
+ if (Rast_get_raster_row(fd, cell2, row, data_type2) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
opt9->answer, row);
ptr2 = cell2;
for (col = 0; col < ncols; col++) {
/* Did I understand that concept of cummulative cost map? - (pmx) 12 april 2000 */
- if (!G_is_null_value(ptr2, data_type2)) {
+ if (!Rast_is_null_value(ptr2, data_type2)) {
double cellval;
if (start_with_raster_vals == 1) {
- cellval = G_get_raster_value_d(ptr2, data_type2);
+ cellval = Rast_get_raster_value_d(ptr2, data_type2);
new_cell = insert(cellval, row, col);
segment_put(&out_seg, &cellval, row, col);
}
@@ -667,12 +668,12 @@
}
got_one = 1;
}
- ptr2 = G_incr_void_ptr(ptr2, dsize2);
+ ptr2 = Rast_incr_void_ptr(ptr2, dsize2);
}
}
G_percent(1, 1, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(cell2);
if (!got_one)
@@ -724,7 +725,7 @@
/* If I've already been updated, delete me */
segment_get(&out_seg, &old_min_cost, pres_cell->row, pres_cell->col);
- if (!G_is_d_null_value(&old_min_cost)) {
+ if (!Rast_is_d_null_value(&old_min_cost)) {
if (pres_cell->min_cost > old_min_cost) {
delete(pres_cell);
pres_cell = get_lowest();
@@ -929,7 +930,7 @@
break;
}
- if (G_is_d_null_value(&min_cost))
+ if (Rast_is_d_null_value(&min_cost))
continue;
segment_get(&out_seg, &old_min_cost, row, col);
@@ -937,7 +938,7 @@
segment_get(&out_seg2, &old_cur_dir, row, col);
}
- if (G_is_d_null_value(&old_min_cost)) {
+ if (Rast_is_d_null_value(&old_min_cost)) {
segment_put(&out_seg, &min_cost, row, col);
new_cell = insert(min_cost, row, col);
if (dir == 1) {
@@ -974,11 +975,11 @@
OUT:
/* Open cumulative cost layer for writing */
- cum_fd = G_open_raster_new(cum_cost_layer, data_type);
+ cum_fd = Rast_open_raster_new(cum_cost_layer, data_type);
if (dir == 1) {
- dir_fd = G_open_raster_new(move_dir_layer, dir_data_type);
- dir_cell = G_allocate_raster_buf(dir_data_type);
+ dir_fd = Rast_open_raster_new(move_dir_layer, dir_data_type);
+ dir_cell = Rast_allocate_raster_buf(dir_data_type);
}
/* Write pending updates by segment_put() to output map */
@@ -992,7 +993,7 @@
G_message(_("Writing raster map <%s>..."), cum_cost_layer);
if (keep_nulls) {
- cell2 = G_allocate_raster_buf(data_type);
+ cell2 = Rast_allocate_raster_buf(data_type);
}
if (data_type == CELL_TYPE) {
@@ -1002,7 +1003,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
if (keep_nulls) {
- if (G_get_raster_row(cost_fd, cell2, row, data_type) < 0)
+ if (Rast_get_raster_row(cost_fd, cell2, row, data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cost_layer, row);
}
@@ -1010,14 +1011,14 @@
p2 = cell2;
for (col = 0; col < ncols; col++) {
if (keep_nulls) {
- if (G_is_null_value(p2++, data_type)) {
- G_set_null_value((p + col), 1, data_type);
+ if (Rast_is_null_value(p2++, data_type)) {
+ Rast_set_null_value((p + col), 1, data_type);
continue;
}
}
segment_get(&out_seg, &min_cost, row, col);
- if (G_is_d_null_value(&min_cost)) {
- G_set_null_value((p + col), 1, data_type);
+ if (Rast_is_d_null_value(&min_cost)) {
+ Rast_set_null_value((p + col), 1, data_type);
}
else {
if (min_cost > peak)
@@ -1025,7 +1026,7 @@
*(p + col) = (int)(min_cost + .5);
}
}
- G_put_raster_row(cum_fd, cell, data_type);
+ Rast_put_raster_row(cum_fd, cell, data_type);
}
}
else if (data_type == FCELL_TYPE) {
@@ -1035,7 +1036,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
if (keep_nulls) {
- if (G_get_raster_row(cost_fd, cell2, row, data_type) < 0)
+ if (Rast_get_raster_row(cost_fd, cell2, row, data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cost_layer, row);
}
@@ -1043,14 +1044,14 @@
p2 = cell2;
for (col = 0; col < ncols; col++) {
if (keep_nulls) {
- if (G_is_null_value(p2++, data_type)) {
- G_set_null_value((p + col), 1, data_type);
+ if (Rast_is_null_value(p2++, data_type)) {
+ Rast_set_null_value((p + col), 1, data_type);
continue;
}
}
segment_get(&out_seg, &min_cost, row, col);
- if (G_is_d_null_value(&min_cost)) {
- G_set_null_value((p + col), 1, data_type);
+ if (Rast_is_d_null_value(&min_cost)) {
+ Rast_set_null_value((p + col), 1, data_type);
}
else {
if (min_cost > peak)
@@ -1058,7 +1059,7 @@
*(p + col) = (float)(min_cost);
}
}
- G_put_raster_row(cum_fd, cell, data_type);
+ Rast_put_raster_row(cum_fd, cell, data_type);
}
}
else if (data_type == DCELL_TYPE) {
@@ -1068,7 +1069,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
if (keep_nulls) {
- if (G_get_raster_row(cost_fd, cell2, row, data_type) < 0)
+ if (Rast_get_raster_row(cost_fd, cell2, row, data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cost_layer, row);
}
@@ -1076,14 +1077,14 @@
p2 = cell2;
for (col = 0; col < ncols; col++) {
if (keep_nulls) {
- if (G_is_null_value(p2++, data_type)) {
- G_set_null_value((p + col), 1, data_type);
+ if (Rast_is_null_value(p2++, data_type)) {
+ Rast_set_null_value((p + col), 1, data_type);
continue;
}
}
segment_get(&out_seg, &min_cost, row, col);
- if (G_is_d_null_value(&min_cost)) {
- G_set_null_value((p + col), 1, data_type);
+ if (Rast_is_d_null_value(&min_cost)) {
+ Rast_set_null_value((p + col), 1, data_type);
}
else {
if (min_cost > peak)
@@ -1091,7 +1092,7 @@
*(p + col) = min_cost;
}
}
- G_put_raster_row(cum_fd, cell, data_type);
+ Rast_put_raster_row(cum_fd, cell, data_type);
}
}
G_percent(1, 1, 1);
@@ -1106,7 +1107,7 @@
segment_get(&out_seg2, &cur_dir, row, col);
*(p + col) = cur_dir;
}
- G_put_raster_row(dir_fd, dir_cell, dir_data_type);
+ Rast_put_raster_row(dir_fd, dir_cell, dir_data_type);
G_percent(row, nrows, 2);
}
}
@@ -1117,10 +1118,10 @@
if (dir == 1) {
segment_release(&out_seg2);
}
- G_close_cell(cost_fd);
- G_close_cell(cum_fd);
+ Rast_close_cell(cost_fd);
+ Rast_close_cell(cum_fd);
if (dir == 1) {
- G_close_cell(dir_fd);
+ Rast_close_cell(dir_fd);
}
close(in_fd); /* close all files */
close(out_fd);
@@ -1133,22 +1134,22 @@
unlink(dir_out_file);
}
- G_short_history(cum_cost_layer, "raster", &history);
- G_command_history(&history);
- G_write_history(cum_cost_layer, &history);
+ Rast_short_history(cum_cost_layer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(cum_cost_layer, &history);
if (dir == 1) {
- G_short_history(move_dir_layer, "raster", &history);
- G_command_history(&history);
- G_write_history(move_dir_layer, &history);
+ Rast_short_history(move_dir_layer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(move_dir_layer, &history);
}
/* Create colours for output map */
/*
- * G_read_range (cum_cost_layer, current_mapset, &range);
- * G_get_range_min_max(&range, &min, &max);
+ * Rast_read_range (cum_cost_layer, current_mapset, &range);
+ * Rast_get_range_min_max(&range, &min, &max);
* G_make_color_wave(&colors,min, max);
- * G_write_colors (cum_cost_layer,current_mapset,&colors);
+ * Rast_write_colors (cum_cost_layer,current_mapset,&colors);
*/
G_done_msg(_("Peak cost value: %f."), peak);
Modified: grass/trunk/raster/r.cost/memory.c
===================================================================
--- grass/trunk/raster/r.cost/memory.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cost/memory.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,6 +26,7 @@
#include <string.h>
#include <errno.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "memory.h"
#define NUM_IN_BLOCK 1024*8
Modified: grass/trunk/raster/r.covar/main.c
===================================================================
--- grass/trunk/raster/r.covar/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.covar/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -73,9 +74,9 @@
sum2 = (double **)G_malloc(nfiles * sizeof(double *));
for (i = 0; i < nfiles; i++) {
sum2[i] = (double *)G_calloc(nfiles, sizeof(double));
- dcell[i] = G_allocate_d_raster_buf();
+ dcell[i] = Rast_allocate_d_raster_buf();
name = maps->answers[i];
- fd[i] = G_open_cell_old(name, "");
+ fd[i] = Rast_open_cell_old(name, "");
if (fd[i] < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
}
@@ -88,13 +89,13 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
for (i = 0; i < nfiles; i++) {
- if (G_get_d_raster_row(fd[i], dcell[i], row) < 0)
+ if (Rast_get_d_raster_row(fd[i], dcell[i], row) < 0)
exit(1);
}
for (col = 0; col < ncols; col++) {
/* ignore cells where any of the maps has null value */
for (i = 0; i < nfiles; i++)
- if (G_is_d_null_value(&dcell[i][col]))
+ if (Rast_is_d_null_value(&dcell[i][col]))
break;
if (i != nfiles)
continue;
Modified: grass/trunk/raster/r.cross/cats.c
===================================================================
--- grass/trunk/raster/r.cross/cats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cross/cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -48,7 +48,7 @@
lbl = get_label(cat[i], &labels[i]);
strcat(buf, lbl);
}
- G_set_cat(result, buf, pcats);
+ Rast_set_cat(result, buf, pcats);
return 0;
}
@@ -57,7 +57,7 @@
char *lbl;
static char temp[256];
- lbl = G_get_cat(cat, labels);
+ lbl = Rast_get_cat(cat, labels);
if (*lbl == 0)
sprintf(lbl = temp, "category %ld", (long)cat);
return lbl;
Modified: grass/trunk/raster/r.cross/cross.c
===================================================================
--- grass/trunk/raster/r.cross/cross.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cross/cross.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -38,7 +38,7 @@
/* allocate i/o buffers for each raster map */
for (i = 0; i < nfiles; i++)
- cell[i] = G_allocate_cell_buf();
+ cell[i] = Rast_allocate_cell_buf();
result_cell = cell[0];
/* initialize the reclass table */
@@ -54,13 +54,13 @@
G_percent(row, nrows, 5);
/* read the primary file first, even if not first in the list */
- if (G_get_map_row(fd[primary], cell[0], row) < 0)
+ if (Rast_get_map_row(fd[primary], cell[0], row) < 0)
exit(1);
/* read the others */
col = 1;
for (i = 0; i < nfiles; i++)
- if (i != primary && G_get_map_row(fd[i], cell[col++], row) < 0)
+ if (i != primary && Rast_get_map_row(fd[i], cell[col++], row) < 0)
exit(1);
for (col = 0; col < ncols; col++) {
zero = 1;
@@ -170,7 +170,7 @@
pnode->right = N; /* add right */
}
}
- G_put_raster_row(outfd, result_cell, CELL_TYPE);
+ Rast_put_raster_row(outfd, result_cell, CELL_TYPE);
}
G_percent(nrows, nrows, 5);
Modified: grass/trunk/raster/r.cross/glob.h
===================================================================
--- grass/trunk/raster/r.cross/glob.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cross/glob.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,8 @@
#define __R_CROSS_GLOB_H__
#include <grass/gis.h>
+#include <grass/Rast.h>
+#include <grass/Rast.h>
#define NFILES 30 /* maximum number of layers */
#define SHIFT 6 /* 2^SHIFT cats per node */
Modified: grass/trunk/raster/r.cross/main.c
===================================================================
--- grass/trunk/raster/r.cross/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cross/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -107,10 +107,10 @@
if (!mapset)
G_fatal_error(_("Raster map <%s> not found"), name);
names[nfiles] = name;
- fd[nfiles] = G_open_cell_old(name, mapset);
+ fd[nfiles] = Rast_open_cell_old(name, mapset);
if (fd[nfiles] < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- G_read_range(name, mapset, &range);
+ Rast_read_range(name, mapset, &range);
ncats = range.max - range.min;
if (nfiles == 0 || ncats > max_cats) {
@@ -122,7 +122,7 @@
if (nfiles <= 1)
G_fatal_error(_("Must specify 2 or more input maps"));
output = parm.output->answer;
- outfd = G_open_cell_new(output);
+ outfd = Rast_open_cell_new(output);
if (outfd < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
@@ -135,7 +135,7 @@
}
strcat(buf, " and ");
strcat(buf, names[i]);
- G_init_cats((CELL) 0, buf, &pcats);
+ Rast_init_cats((CELL) 0, buf, &pcats);
/* first step is cross product, but un-ordered */
result = cross(fd, non_zero, primary, outfd);
@@ -145,8 +145,8 @@
/* now close all files */
for (i = 0; i < nfiles; i++)
- G_close_cell(fd[i]);
- G_close_cell(outfd);
+ Rast_close_cell(fd[i]);
+ Rast_close_cell(outfd);
if (result <= 0)
exit(0);
@@ -157,7 +157,7 @@
table = (CELL *) G_calloc(result + 1, sizeof(CELL));
for (i = 0; i < nfiles; i++) {
mapset = G_find_cell2(names[i], "");
- G_read_cats(names[i], mapset, &labels[i]);
+ Rast_read_cats(names[i], mapset, &labels[i]);
}
for (ncats = 0; ncats <= result; ncats++) {
@@ -166,22 +166,22 @@
}
for (i = 0; i < nfiles; i++)
- G_free_cats(&labels[i]);
+ Rast_free_cats(&labels[i]);
/* reopen the output cell for reading and for writing */
- fd[0] = G_open_cell_old(output, G_mapset());
- outfd = G_open_cell_new(output);
+ fd[0] = Rast_open_cell_old(output, G_mapset());
+ outfd = Rast_open_cell_new(output);
renumber(fd[0], outfd);
G_message(_("Creating support files for <%s>..."), output);
- G_close_cell(fd[0]);
- G_close_cell(outfd);
- G_write_cats(output, &pcats);
- G_free_cats(&pcats);
+ Rast_close_cell(fd[0]);
+ Rast_close_cell(outfd);
+ Rast_write_cats(output, &pcats);
+ Rast_free_cats(&pcats);
if (result > 0) {
- G_make_random_colors(&pcolr, (CELL) 1, result);
- G_write_colors(output, G_mapset(), &pcolr);
+ Rast_make_random_colors(&pcolr, (CELL) 1, result);
+ Rast_write_colors(output, G_mapset(), &pcolr);
}
G_message(_("%ld categories"), (long)result);
Modified: grass/trunk/raster/r.cross/renumber.c
===================================================================
--- grass/trunk/raster/r.cross/renumber.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.cross/renumber.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -27,19 +27,19 @@
CELL *cell, *c;
int row, col;
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
G_message(_("%s: STEP 3 ... "), G_program_name());
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 5);
- if (G_get_map_row(in, c = cell, row) < 0)
+ if (Rast_get_map_row(in, c = cell, row) < 0)
exit(1);
col = ncols;
while (col-- > 0) {
*c = table[*c];
c++;
}
- if (G_put_raster_row(out, cell, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(out, cell, CELL_TYPE) < 0)
exit(1);
}
G_percent(row, nrows, 10);
Modified: grass/trunk/raster/r.describe/describe.c
===================================================================
--- grass/trunk/raster/r.describe/describe.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.describe/describe.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
***************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -39,25 +40,25 @@
int (*get_row)(int, CELL *, int);
if (windowed) {
- get_row = G_get_c_raster_row;
+ get_row = Rast_get_c_raster_row;
}
else {
- if (G_get_cellhd(name, "", &window) < 0)
+ if (Rast_get_cellhd(name, "", &window) < 0)
G_fatal_error(_("Unable to get cell header for <%s>"), name);
G_set_window(&window);
- get_row = G_get_c_raster_row_nomask;
+ get_row = Rast_get_c_raster_row_nomask;
}
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
return 0;
- map_type = G_get_raster_map_type(fd);
+ map_type = Rast_get_raster_map_type(fd);
if (as_int)
map_type = CELL_TYPE; /* read as int */
/* allocate the cell buffer */
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
if (map_type != CELL_TYPE && range)
/* this will make it report fp range */
@@ -68,7 +69,7 @@
/* start the cell stats */
if (!range) {
- G_init_cell_stats(&statf);
+ Rast_init_cell_stats(&statf);
}
else {
zero = 0;
@@ -83,11 +84,11 @@
/* set up quantization rules */
if (map_type != CELL_TYPE) {
- G_quant_init(&q);
- G_read_fp_range(name, "", &r);
- G_get_fp_range_min_max(&r, &dmin, &dmax);
- G_quant_add_rule(&q, dmin, dmax, 1, nsteps);
- G_set_quant_rules(fd, &q);
+ Rast_quant_init(&q);
+ Rast_read_fp_range(name, "", &r);
+ Rast_get_fp_range_min_max(&r, &dmin, &dmax);
+ Rast_quant_add_rule(&q, dmin, dmax, 1, nsteps);
+ Rast_set_quant_rules(fd, &q);
}
nrows = G_window_rows();
@@ -100,7 +101,7 @@
break;
if (range) {
for (col = ncols; col-- > 0; b++) {
- if (G_is_c_null_value(b))
+ if (Rast_is_c_null_value(b))
null = 1;
else if (*b == 0)
zero = 1;
@@ -123,10 +124,10 @@
}
}
else
- G_update_cell_stats(buf, ncols, &statf);
+ Rast_update_cell_stats(buf, ncols, &statf);
}
G_percent(nrows, nrows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(buf);
if (range) {
@@ -138,7 +139,7 @@
no_data_str, skip_nulls);
}
else {
- G_rewind_cell_stats(&statf);
+ Rast_rewind_cell_stats(&statf);
if (compact)
compact_list(&statf, dmin, dmax, no_data_str, skip_nulls,
@@ -147,7 +148,7 @@
long_list(&statf, dmin, dmax, no_data_str, skip_nulls, map_type,
nsteps);
- G_free_cell_stats(&statf);
+ Rast_free_cell_stats(&statf);
}
return 1;
}
Modified: grass/trunk/raster/r.describe/dumplist.c
===================================================================
--- grass/trunk/raster/r.describe/dumplist.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.describe/dumplist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
static int show(CELL, CELL, int *, DCELL, DCELL, RASTER_MAP_TYPE, int);
@@ -30,11 +31,11 @@
CELL cat;
long count; /* not used, but required by cell stats call */
- G_get_stats_for_null_value(&count, statf);
+ Rast_get_stats_for_null_value(&count, statf);
if (count != 0 && !skip_nulls)
fprintf(stdout, "%s\n", no_data_str);
- while (G_next_cell_stat(&cat, &count, statf)) {
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
if (map_type != CELL_TYPE)
fprintf(stdout, "%f-%f\n",
dmin + (double)(cat - 1) * (dmax - dmin) / nsteps,
@@ -56,16 +57,16 @@
long count; /* not used, but required by cell stats call */
len = 0;
- G_get_stats_for_null_value(&count, statf);
+ Rast_get_stats_for_null_value(&count, statf);
if (count != 0 && !skip_nulls)
fprintf(stdout, "%s ", no_data_str);
- if (!G_next_cell_stat(&cat1, &count, statf))
+ if (!Rast_next_cell_stat(&cat1, &count, statf))
/* map doesn't contain any non-null data */
return 1;
cat2 = cat1;
- while (G_next_cell_stat(&temp, &count, statf)) {
+ while (Rast_next_cell_stat(&temp, &count, statf)) {
if (temp != cat2 + (CELL) 1) {
show(cat1, cat2, &len, dmin, dmax, map_type, nsteps);
cat1 = temp;
Modified: grass/trunk/raster/r.describe/main.c
===================================================================
--- grass/trunk/raster/r.describe/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.describe/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.describe/tree.c
===================================================================
--- grass/trunk/raster/r.describe/tree.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.describe/tree.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
***************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#define INCR 10
Modified: grass/trunk/raster/r.digit/digitize.c
===================================================================
--- grass/trunk/raster/r.digit/digitize.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.digit/digitize.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -27,7 +27,7 @@
int any;
struct Categories labels;
- G_init_cats((CELL) 0, "", &labels);
+ Rast_init_cats((CELL) 0, "", &labels);
any = 0;
for (;;) {
switch (get_type()) {
Modified: grass/trunk/raster/r.digit/get_label.c
===================================================================
--- grass/trunk/raster/r.digit/get_label.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.digit/get_label.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -44,7 +44,7 @@
for (;;) {
fprintf(stdout, _("Enter a label for category %ld [%s] "),
- cat, G_get_cat((CELL) cat, labels));
+ cat, Rast_get_cat((CELL) cat, labels));
if (!G_gets(buffer))
continue;;
G_strip(buffer);
@@ -64,10 +64,10 @@
cat = get_cat(type);
lbl = get_label(cat, labels);
fprintf(stdout, "%ld [%s]\n", cat,
- *lbl ? lbl : G_get_cat((CELL) cat, labels));
+ *lbl ? lbl : Rast_get_cat((CELL) cat, labels));
} while (!G_yes(_("Look ok? "), 1));
if (*lbl)
- G_set_cat((CELL) cat, lbl, labels);
+ Rast_set_cat((CELL) cat, lbl, labels);
fprintf(fd, "= %ld %s\n", cat, lbl);
return (0);
Modified: grass/trunk/raster/r.distance/defs.h
===================================================================
--- grass/trunk/raster/r.distance/defs.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.distance/defs.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#define __R_DIST_DEFS_H__
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct EdgeList /* keep track of edge cells */
Modified: grass/trunk/raster/r.distance/distance.c
===================================================================
--- grass/trunk/raster/r.distance/distance.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.distance/distance.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -86,14 +86,14 @@
/* NOTE: no need to controll, if the map exists. it should be checked in edge.c */
mapset = G_find_cell2(name1, "");
- maptype1 = G_raster_map_type(name1, mapset);
- mapd1 = G_open_cell_old(name1, mapset);
- inrast1 = G_allocate_raster_buf(maptype1);
+ maptype1 = Rast_raster_map_type(name1, mapset);
+ mapd1 = Rast_open_cell_old(name1, mapset);
+ inrast1 = Rast_allocate_raster_buf(maptype1);
mapset = G_find_cell2(name2, "");
- maptype2 = G_raster_map_type(name2, mapset);
- mapd2 = G_open_cell_old(name2, mapset);
- inrast2 = G_allocate_raster_buf(maptype2);
+ maptype2 = Rast_raster_map_type(name2, mapset);
+ mapd2 = Rast_open_cell_old(name2, mapset);
+ inrast2 = Rast_allocate_raster_buf(maptype2);
G_message(_("Reading maps <%s,%s> while finding 0 distance ..."), name1,
name2);
@@ -105,9 +105,9 @@
G_percent(row, nrows, 2);
- if (G_get_raster_row(mapd1, inrast1, row, maptype1) < 0)
+ if (Rast_get_raster_row(mapd1, inrast1, row, maptype1) < 0)
G_fatal_error("Could not read from <%s>", name1);
- if (G_get_raster_row(mapd2, inrast2, row, maptype2) < 0)
+ if (Rast_get_raster_row(mapd2, inrast2, row, maptype2) < 0)
G_fatal_error("Could not read from <%s>", name2);
for (col = 0; col < ncols; col++) {
@@ -137,8 +137,8 @@
break;
}
- if (!G_is_null_value(&cell1, maptype1) &&
- !G_is_null_value(&cell2, maptype2)) {
+ if (!Rast_is_null_value(&cell1, maptype1) &&
+ !Rast_is_null_value(&cell2, maptype2)) {
*zerro_row = row;
*zerro_col = col;
@@ -148,8 +148,8 @@
G_free(inrast2);
/* closing raster maps */
- G_close_cell(mapd1);
- G_close_cell(mapd2);
+ Rast_close_cell(mapd1);
+ Rast_close_cell(mapd2);
return 1;
}
}
@@ -159,8 +159,8 @@
G_free(inrast2);
/* closing raster maps */
- G_close_cell(mapd1);
- G_close_cell(mapd2);
+ Rast_close_cell(mapd1);
+ Rast_close_cell(mapd2);
return 0;
}
Modified: grass/trunk/raster/r.distance/edges.c
===================================================================
--- grass/trunk/raster/r.distance/edges.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.distance/edges.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -54,7 +54,7 @@
buf2[col] = 0;
}
- fd = G_open_cell_old(map->name, map->mapset);
+ fd = Rast_open_cell_old(map->name, map->mapset);
if (fd < 0)
exit(1);
@@ -69,7 +69,7 @@
buf2 = tmp;
/* read a row */
- if (G_get_map_row(fd, &buf1[1], row) < 0)
+ if (Rast_get_map_row(fd, &buf1[1], row) < 0)
exit(1);
for (col = 1; col <= ncols; col++) {
@@ -83,7 +83,7 @@
}
G_percent(row, nrows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(buf0);
G_free(buf1);
Modified: grass/trunk/raster/r.distance/labels.c
===================================================================
--- grass/trunk/raster/r.distance/labels.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.distance/labels.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,13 +21,13 @@
void read_labels(struct Map *map)
{
- if (G_read_cats(map->name, map->mapset, &map->labels) < 0)
+ if (Rast_read_cats(map->name, map->mapset, &map->labels) < 0)
exit(1);
}
char *get_label(struct Map *map, CELL cat)
{
- char *G_get_cat();
+ char *Rast_get_cat();
- return G_get_cat(cat, &map->labels);
+ return Rast_get_cat(cat, &map->labels);
}
Modified: grass/trunk/raster/r.distance/main.c
===================================================================
--- grass/trunk/raster/r.distance/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.distance/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdio.h>
#include "defs.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int main(int argc, char *argv[])
Modified: grass/trunk/raster/r.distance/parse.c
===================================================================
--- grass/trunk/raster/r.distance/parse.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.distance/parse.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdio.h>
#include "defs.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
void parse(int argc, char *argv[], struct Parms *parms)
Modified: grass/trunk/raster/r.drain/filldir.c
===================================================================
--- grass/trunk/raster/r.drain/filldir.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.drain/filldir.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <limits.h>
#include <float.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "tinf.h"
#include "local.h"
@@ -45,7 +46,7 @@
offset = j * bpe();
center = bnd->b[1] + offset;
if (is_null(center)) {
- G_set_c_null_value(dir + j, 1);
+ Rast_set_c_null_value(dir + j, 1);
continue;
}
Modified: grass/trunk/raster/r.drain/main.c
===================================================================
--- grass/trunk/raster/r.drain/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.drain/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -40,6 +40,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/site.h>
#include <grass/glocale.h>
#include <grass/Vect.h>
@@ -180,7 +181,7 @@
("Direction raster not specified, if direction flag is on, a direction raster must be given"));
}
strcpy(dir_name, opt3->answer);
- dir_data_type = G_raster_map_type(dir_name, "");
+ dir_data_type = Rast_raster_map_type(dir_name, "");
}
if (costmode == 0) {
if (opt3->answer) {
@@ -202,7 +203,7 @@
Vect_hist_command(&vout);
}
/* allocate cell buf for the map layer */
- in_type = G_raster_map_type(map_name, "");
+ in_type = Rast_raster_map_type(map_name, "");
/* set the pointers for multi-typed functions */
set_func_pointers(in_type);
@@ -342,7 +343,7 @@
in_buf = get_buf();
/* open the original map and get its file id */
- map_id = G_open_cell_old(map_name, "");
+ map_id = Rast_open_cell_old(map_name, "");
/* get some temp files */
tempfile1 = G_tempfile();
@@ -356,19 +357,19 @@
get_row(map_id, in_buf, i);
write(fe, in_buf, bnd.sz);
}
- G_close_cell(map_id);
+ Rast_close_cell(map_id);
if (costmode == 1) {
- dir_buf = G_allocate_d_raster_buf();
- dir_id = G_open_cell_old(dir_name, "");
+ dir_buf = Rast_allocate_d_raster_buf();
+ dir_id = Rast_open_cell_old(dir_name, "");
tempfile3 = G_tempfile();
dir_fd = open(tempfile3, O_RDWR | O_CREAT, 0666);
for (i = 0; i < nrows; i++) {
- G_get_d_raster_row(dir_id, dir_buf, i);
+ Rast_get_d_raster_row(dir_id, dir_buf, i);
write(dir_fd, dir_buf, ncols * sizeof(DCELL));
}
- G_close_cell(dir_id);
+ Rast_close_cell(dir_id);
}
/* only necessary for non-dir drain */
@@ -415,8 +416,8 @@
/* Output will be a cell map */
/* open a new file and allocate an output buffer */
- new_id = G_open_cell_new(new_map_name);
- out_buf = G_allocate_c_raster_buf();
+ new_id = Rast_open_cell_new(new_map_name);
+ out_buf = Rast_allocate_c_raster_buf();
/* mark each cell */
thispoint = list;
@@ -446,21 +447,21 @@
new_map_name);
for (i = 0; i < nrows; i++) {
G_percent(i, nrows, 2);
- G_set_c_null_value(out_buf, ncols);
+ Rast_set_c_null_value(out_buf, ncols);
thispoint = list;
while (thispoint->next != NULL) {
if (thispoint->row == i)
out_buf[thispoint->col] = (int)thispoint->value;
thispoint = thispoint->next;
}
- G_put_c_raster_row(new_id, out_buf);
+ Rast_put_c_raster_row(new_id, out_buf);
}
G_percent(1, 1, 1);
}
else { /* mode = 1 or 2 */
/* Output will be of the same type as input */
/* open a new file and allocate an output buffer */
- new_id = G_open_raster_new(new_map_name, in_type);
+ new_id = Rast_open_raster_new(new_map_name, in_type);
out_buf = get_buf();
bsz = ncols * bpe();
@@ -545,13 +546,13 @@
}
/* close files and free buffers */
- G_close_cell(new_id);
+ Rast_close_cell(new_id);
- G_put_cell_title(new_map_name, "Surface flow trace");
+ Rast_put_cell_title(new_map_name, "Surface flow trace");
- G_short_history(new_map_name, "raster", &history);
- G_command_history(&history);
- G_write_history(new_map_name, &history);
+ Rast_short_history(new_map_name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(new_map_name, &history);
close(fe);
close(fd);
@@ -577,7 +578,7 @@
CELL direction;
CELL *dir;
- dir = G_allocate_c_raster_buf();
+ dir = Rast_allocate_c_raster_buf();
next_row = list->row;
next_col = list->col;
@@ -643,7 +644,7 @@
DCELL direction;
DCELL *dir_buf;
- dir_buf = G_allocate_d_raster_buf();
+ dir_buf = Rast_allocate_d_raster_buf();
next_row = list->row;
next_col = list->col;
Modified: grass/trunk/raster/r.drain/resolve.c
===================================================================
--- grass/trunk/raster/r.drain/resolve.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.drain/resolve.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "tinf.h"
CELL select_dir(CELL i)
@@ -38,7 +39,7 @@
int k;
cwork = p2[j];
- if (G_is_c_null_value(p2 + j) || cwork >= 0 || cwork == -256)
+ if (Rast_is_c_null_value(p2 + j) || cwork >= 0 || cwork == -256)
return;
cwork = -cwork;
@@ -110,7 +111,7 @@
read(fd, bnd->b[0], bnd->sz);
for (j = 1; j < bnd->ns - 1; j += 1) {
offset = j * isz;
- if (G_is_c_null_value((void *)(bnd->b[0] + offset)))
+ if (Rast_is_c_null_value((void *)(bnd->b[0] + offset)))
continue;
memcpy(&cvalue, bnd->b[0] + offset, isz);
if (cvalue > 0)
Modified: grass/trunk/raster/r.drain/tinf.c
===================================================================
--- grass/trunk/raster/r.drain/tinf.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.drain/tinf.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <float.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "tinf.h"
int (*is_null) (void *);
@@ -92,29 +93,29 @@
/* check for null values */
int is_null_c(void *value)
{
- return G_is_c_null_value((CELL *) value);
+ return Rast_is_c_null_value((CELL *) value);
}
int is_null_f(void *value)
{
- return G_is_f_null_value((FCELL *) value);
+ return Rast_is_f_null_value((FCELL *) value);
}
int is_null_d(void *value)
{
- return G_is_d_null_value((DCELL *) value);
+ return Rast_is_d_null_value((DCELL *) value);
}
/* set null values in buffer */
void set_null_value_c(void *value, int num)
{
- G_set_c_null_value((CELL *) value, num);
+ Rast_set_c_null_value((CELL *) value, num);
}
void set_null_value_f(void *value, int num)
{
- G_set_f_null_value((FCELL *) value, num);
+ Rast_set_f_null_value((FCELL *) value, num);
}
void set_null_value_d(void *value, int num)
{
- G_set_d_null_value((DCELL *) value, num);
+ Rast_set_d_null_value((DCELL *) value, num);
}
/* return the size of the current type */
@@ -198,49 +199,49 @@
/* Read one line from a raster map */
int get_row_c(int fd, void *row, int n)
{
- return G_get_c_raster_row(fd, (CELL *) row, n);
+ return Rast_get_c_raster_row(fd, (CELL *) row, n);
}
int get_row_f(int fd, void *row, int n)
{
- return G_get_f_raster_row(fd, (FCELL *) row, n);
+ return Rast_get_f_raster_row(fd, (FCELL *) row, n);
}
int get_row_d(int fd, void *row, int n)
{
- return G_get_d_raster_row(fd, (DCELL *) row, n);
+ return Rast_get_d_raster_row(fd, (DCELL *) row, n);
}
/* Write one row to a raster map */
int put_row_c(int fd, void *row)
{
- return G_put_c_raster_row(fd, (CELL *) row);
+ return Rast_put_c_raster_row(fd, (CELL *) row);
}
int put_row_f(int fd, void *row)
{
- return G_put_f_raster_row(fd, (FCELL *) row);
+ return Rast_put_f_raster_row(fd, (FCELL *) row);
}
int put_row_d(int fd, void *row)
{
- return G_put_d_raster_row(fd, (DCELL *) row);
+ return Rast_put_d_raster_row(fd, (DCELL *) row);
}
/* Allocate memory for one line of data */
void *get_buf_c(void)
{
- return (void *)G_allocate_c_raster_buf();
+ return (void *)Rast_allocate_c_raster_buf();
}
void *get_buf_f(void)
{
- return (void *)G_allocate_f_raster_buf();
+ return (void *)Rast_allocate_f_raster_buf();
}
void *get_buf_d(void)
{
- return (void *)G_allocate_d_raster_buf();
+ return (void *)Rast_allocate_d_raster_buf();
}
/* initialize memory to a minimum value */
@@ -336,7 +337,7 @@
rc = -HUGE_VAL;
pedge = (CELL *) line2;
- if (!G_is_c_null_value(pedge)) {
+ if (!Rast_is_c_null_value(pedge)) {
rc = (*(CELL *) line1 - *pedge) / cnst;
}
return rc;
@@ -349,7 +350,7 @@
rc = -HUGE_VAL;
pedge = (FCELL *) line2;
- if (!G_is_f_null_value(pedge)) {
+ if (!Rast_is_f_null_value(pedge)) {
rc = (*(FCELL *) line1 - *pedge) / cnst;
}
return rc;
@@ -362,7 +363,7 @@
rc = -HUGE_VAL;
pedge = (DCELL *) line2;
- if (!G_is_d_null_value(pedge)) {
+ if (!Rast_is_d_null_value(pedge)) {
rc = (*(DCELL *) line1 - *pedge) / cnst;
}
return rc;
Modified: grass/trunk/raster/r.external/main.c
===================================================================
--- grass/trunk/raster/r.external/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.external/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <math.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
@@ -318,7 +319,7 @@
if(!(bGotMin && bGotMax))
GDALComputeRasterMinMax(hBand, !exact_range, info->range);
- G_init_colors(&info->colors);
+ Rast_init_colors(&info->colors);
if (GDALGetRasterColorTable(hBand) != NULL) {
GDALColorTableH hCT;
@@ -336,7 +337,7 @@
if (sEntry.c4 == 0)
continue;
- G_set_color(i, sEntry.c1, sEntry.c2, sEntry.c3, &info->colors);
+ Rast_set_color(i, sEntry.c1, sEntry.c2, sEntry.c3, &info->colors);
}
}
else {
@@ -344,13 +345,13 @@
/* set full 0..255 range to grey scale: */
G_verbose_message(_("Setting grey color table for <%s> (full 8bit range)"),
output);
- G_make_grey_scale_colors(&info->colors, 0, 255);
+ Rast_make_grey_scale_colors(&info->colors, 0, 255);
}
else {
/* set data range to grey scale: */
G_verbose_message(_("Setting grey color table for <%s> (data range)"),
output);
- G_make_grey_scale_colors(&info->colors,
+ Rast_make_grey_scale_colors(&info->colors,
(int) info->range[0], (int) info->range[1]);
}
}
@@ -447,10 +448,10 @@
{
struct Quant quant;
- G_quant_init(&quant);
- G_quant_round(&quant);
+ Rast_quant_init(&quant);
+ Rast_quant_round(&quant);
- if (G_write_quant(output, G_mapset(), &quant) < 0)
+ if (Rast_write_quant(output, G_mapset(), &quant) < 0)
G_warning(_("Unable to write quant file"));
}
@@ -460,7 +461,7 @@
{
struct History history;
- G_put_cellhd(output, cellhd);
+ Rast_put_cellhd(output, cellhd);
make_cell(output, info);
@@ -471,27 +472,27 @@
range.min = (CELL)info->range[0];
range.max = (CELL)info->range[1];
range.first_time = 0;
- G_write_range(output, &range);
+ Rast_write_range(output, &range);
}
else {
struct FPRange fprange;
fprange.min = info->range[0];
fprange.max = info->range[1];
fprange.first_time = 0;
- G_write_fp_range(output, &fprange);
+ Rast_write_fp_range(output, &fprange);
write_fp_format(output, info);
write_fp_quant(output);
}
G_verbose_message(_("Creating support files for %s"), output);
- G_short_history(output, "raster", &history);
- G_command_history(&history);
- G_write_history(output, &history);
+ Rast_short_history(output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(output, &history);
- G_write_colors(output, G_mapset(), &info->colors);
+ Rast_write_colors(output, G_mapset(), &info->colors);
if (title)
- G_put_cell_title(output, title);
+ Rast_put_cell_title(output, title);
G_message(_("<%s> created"), output);
Modified: grass/trunk/raster/r.fill.dir/dopolys.c
===================================================================
--- grass/trunk/raster/r.fill.dir/dopolys.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.fill.dir/dopolys.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
void recurse_list(int flag, int *cells, int sz, int start)
@@ -54,7 +55,7 @@
for (i = 1; i < nl - 1; i += 1) {
read(fd, dir, bufsz);
for (j = 1; j < ns - 1; j += 1) {
- if (G_is_c_null_value(&dir[j]) || dir[j] >= 0)
+ if (Rast_is_c_null_value(&dir[j]) || dir[j] >= 0)
continue;
cells[found++] = i;
cells[found++] = j;
Modified: grass/trunk/raster/r.fill.dir/filldir.c
===================================================================
--- grass/trunk/raster/r.fill.dir/filldir.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.fill.dir/filldir.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
#include <limits.h>
#include <float.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "tinf.h"
/* get the slope between two cells and return a slope direction */
@@ -89,7 +90,7 @@
offset = j * bpe();
center = bnd->b[1] + offset;
if (is_null(center)) {
- G_set_c_null_value(dir + j, 1);
+ Rast_set_c_null_value(dir + j, 1);
continue;
}
Modified: grass/trunk/raster/r.fill.dir/main.c
===================================================================
--- grass/trunk/raster/r.fill.dir/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.fill.dir/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -48,6 +48,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define DEBUG
@@ -173,10 +174,10 @@
G_fatal_error(_("Raster map <%s> not found"), map_name);
/* open the maps and get their file id */
- map_id = G_open_cell_old(map_name, map_mapset);
+ map_id = Rast_open_cell_old(map_name, map_mapset);
/* allocate cell buf for the map layer */
- in_type = G_get_raster_map_type(map_id);
+ in_type = Rast_get_raster_map_type(map_id);
/* set the pointers for multi-typed functions */
set_func_pointers(in_type);
@@ -215,7 +216,7 @@
get_row(map_id, in_buf, i);
write(fe, in_buf, bnd.sz);
}
- G_close_cell(map_id);
+ Rast_close_cell(map_id);
/* fill single-cell holes and take a first stab at flow directions */
G_message(_("Filling sinks..."));
@@ -249,25 +250,25 @@
G_free(bnd.b[1]);
G_free(bnd.b[2]);
- out_buf = G_allocate_c_raster_buf();
+ out_buf = Rast_allocate_c_raster_buf();
bufsz = ncols * sizeof(CELL);
lseek(fe, 0, SEEK_SET);
- new_id = G_open_raster_new(new_map_name, in_type);
+ new_id = Rast_open_raster_new(new_map_name, in_type);
lseek(fd, 0, SEEK_SET);
- dir_id = G_open_raster_new(dir_name, CELL_TYPE);
+ dir_id = Rast_open_raster_new(dir_name, CELL_TYPE);
if (opt5->answer != NULL) {
lseek(fm, 0, SEEK_SET);
- bas_id = G_open_raster_new(bas_name, CELL_TYPE);
+ bas_id = Rast_open_raster_new(bas_name, CELL_TYPE);
for (i = 0; i < nrows; i++) {
read(fm, out_buf, bufsz);
- G_put_raster_row(bas_id, out_buf, CELL_TYPE);
+ Rast_put_raster_row(bas_id, out_buf, CELL_TYPE);
}
- G_close_cell(bas_id);
+ Rast_close_cell(bas_id);
close(fm);
}
@@ -280,14 +281,14 @@
for (j = 0; j < ncols; j += 1)
out_buf[j] = dir_type(type, out_buf[j]);
- G_put_raster_row(dir_id, out_buf, CELL_TYPE);
+ Rast_put_raster_row(dir_id, out_buf, CELL_TYPE);
}
- G_close_cell(new_id);
+ Rast_close_cell(new_id);
close(fe);
- G_close_cell(dir_id);
+ Rast_close_cell(dir_id);
close(fd);
G_free(in_buf);
Modified: grass/trunk/raster/r.fill.dir/ppupdate.c
===================================================================
--- grass/trunk/raster/r.fill.dir/ppupdate.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.fill.dir/ppupdate.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "tinf.h"
struct links
@@ -70,7 +71,7 @@
/* check to see if the cell is non-null and in a basin */
here = (CELL *) basins->b[1] + j;
- if (G_is_c_null_value(here) || *here < 0)
+ if (Rast_is_c_null_value(here) || *here < 0)
continue;
ii = *here;
Modified: grass/trunk/raster/r.fill.dir/resolve.c
===================================================================
--- grass/trunk/raster/r.fill.dir/resolve.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.fill.dir/resolve.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "tinf.h"
@@ -39,7 +40,7 @@
int k;
cwork = p2[j];
- if (G_is_c_null_value(p2 + j) || cwork >= 0 || cwork == -256)
+ if (Rast_is_c_null_value(p2 + j) || cwork >= 0 || cwork == -256)
return;
cwork = -cwork;
@@ -111,7 +112,7 @@
read(fd, bnd->b[0], bnd->sz);
for (j = 1; j < bnd->ns - 1; j += 1) {
offset = j * isz;
- if (G_is_c_null_value((CELL *) (bnd->b[0] + offset)))
+ if (Rast_is_c_null_value((CELL *) (bnd->b[0] + offset)))
continue;
memcpy(&cvalue, bnd->b[0] + offset, isz);
if (cvalue > 0)
Modified: grass/trunk/raster/r.fill.dir/tinf.c
===================================================================
--- grass/trunk/raster/r.fill.dir/tinf.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.fill.dir/tinf.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <float.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "tinf.h"
/* To add a new multitype function, use the function below to initialize
@@ -87,15 +88,15 @@
/* check for null values */
int is_null_c(void *value)
{
- return G_is_c_null_value((CELL *) value);
+ return Rast_is_c_null_value((CELL *) value);
}
int is_null_f(void *value)
{
- return G_is_f_null_value((FCELL *) value);
+ return Rast_is_f_null_value((FCELL *) value);
}
int is_null_d(void *value)
{
- return G_is_d_null_value((DCELL *) value);
+ return Rast_is_d_null_value((DCELL *) value);
}
/* return the size of the current type */
@@ -179,49 +180,49 @@
/* Read one line from a raster map */
int get_row_c(int fd, void *row, int n)
{
- return G_get_c_raster_row(fd, (CELL *) row, n);
+ return Rast_get_c_raster_row(fd, (CELL *) row, n);
}
int get_row_f(int fd, void *row, int n)
{
- return G_get_f_raster_row(fd, (FCELL *) row, n);
+ return Rast_get_f_raster_row(fd, (FCELL *) row, n);
}
int get_row_d(int fd, void *row, int n)
{
- return G_get_d_raster_row(fd, (DCELL *) row, n);
+ return Rast_get_d_raster_row(fd, (DCELL *) row, n);
}
/* Write one row to a raster map */
int put_row_c(int fd, void *row)
{
- return G_put_c_raster_row(fd, (CELL *) row);
+ return Rast_put_c_raster_row(fd, (CELL *) row);
}
int put_row_f(int fd, void *row)
{
- return G_put_f_raster_row(fd, (FCELL *) row);
+ return Rast_put_f_raster_row(fd, (FCELL *) row);
}
int put_row_d(int fd, void *row)
{
- return G_put_d_raster_row(fd, (DCELL *) row);
+ return Rast_put_d_raster_row(fd, (DCELL *) row);
}
/* Allocate memory for one line of data */
void *get_buf_c()
{
- return (void *)G_allocate_c_raster_buf();
+ return (void *)Rast_allocate_c_raster_buf();
}
void *get_buf_f()
{
- return (void *)G_allocate_f_raster_buf();
+ return (void *)Rast_allocate_f_raster_buf();
}
void *get_buf_d()
{
- return (void *)G_allocate_d_raster_buf();
+ return (void *)Rast_allocate_d_raster_buf();
}
/* initialize memory to a minimum value */
@@ -317,7 +318,7 @@
rc = -HUGE_VAL;
pedge = (CELL *) line2;
- if (!G_is_c_null_value(pedge)) {
+ if (!Rast_is_c_null_value(pedge)) {
rc = (*(CELL *) line1 - *pedge) / cnst;
}
return rc;
@@ -330,7 +331,7 @@
rc = -HUGE_VAL;
pedge = (FCELL *) line2;
- if (!G_is_f_null_value(pedge)) {
+ if (!Rast_is_f_null_value(pedge)) {
rc = (*(FCELL *) line1 - *pedge) / cnst;
}
return rc;
@@ -343,7 +344,7 @@
rc = -HUGE_VAL;
pedge = (DCELL *) line2;
- if (!G_is_d_null_value(pedge)) {
+ if (!Rast_is_d_null_value(pedge)) {
rc = (*(DCELL *) line1 - *pedge) / cnst;
}
return rc;
Modified: grass/trunk/raster/r.fill.dir/wtrshed.c
===================================================================
--- grass/trunk/raster/r.fill.dir/wtrshed.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.fill.dir/wtrshed.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <sys/types.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct whereandwhat
@@ -26,37 +27,37 @@
if (i > 0) {
edge = dir[i - 1].p[j - 1];
- if (bas[i - 1].p[j - 1] == -1 && !G_is_c_null_value(&edge) &&
+ if (bas[i - 1].p[j - 1] == -1 && !Rast_is_c_null_value(&edge) &&
edge == 4)
rc += recurse_cell(flag, i - 1, j - 1, nl, ns, bas, dir);
edge = dir[i - 1].p[j];
- if (bas[i - 1].p[j] == -1 && !G_is_c_null_value(&edge) && edge == 8)
+ if (bas[i - 1].p[j] == -1 && !Rast_is_c_null_value(&edge) && edge == 8)
rc += recurse_cell(flag, i - 1, j, nl, ns, bas, dir);
edge = dir[i - 1].p[j + 1];
- if (bas[i - 1].p[j + 1] == -1 && !G_is_c_null_value(&edge) &&
+ if (bas[i - 1].p[j + 1] == -1 && !Rast_is_c_null_value(&edge) &&
edge == 16)
rc += recurse_cell(flag, i - 1, j + 1, nl, ns, bas, dir);
}
edge = dir[i].p[j - 1];
- if (bas[i].p[j - 1] == -1 && !G_is_c_null_value(&edge) && edge == 2)
+ if (bas[i].p[j - 1] == -1 && !Rast_is_c_null_value(&edge) && edge == 2)
rc += recurse_cell(flag, i, j - 1, nl, ns, bas, dir);
edge = dir[i].p[j + 1];
- if (bas[i].p[j + 1] == -1 && !G_is_c_null_value(&edge) && edge == 32)
+ if (bas[i].p[j + 1] == -1 && !Rast_is_c_null_value(&edge) && edge == 32)
rc += recurse_cell(flag, i, j + 1, nl, ns, bas, dir);
if (i < nl - 1) {
edge = dir[i + 1].p[j - 1];
- if (bas[i + 1].p[j - 1] == -1 && !G_is_c_null_value(&edge) &&
+ if (bas[i + 1].p[j - 1] == -1 && !Rast_is_c_null_value(&edge) &&
edge == 1)
rc += recurse_cell(flag, i + 1, j - 1, nl, ns, bas, dir);
edge = dir[i + 1].p[j];
- if (bas[i + 1].p[j] == -1 && !G_is_c_null_value(&edge) && edge == 128)
+ if (bas[i + 1].p[j] == -1 && !Rast_is_c_null_value(&edge) && edge == 128)
rc += recurse_cell(flag, i + 1, j, nl, ns, bas, dir);
edge = dir[i + 1].p[j + 1];
- if (bas[i + 1].p[j + 1] == -1 && !G_is_c_null_value(&edge) &&
+ if (bas[i + 1].p[j + 1] == -1 && !Rast_is_c_null_value(&edge) &&
edge == 64)
rc += recurse_cell(flag, i + 1, j + 1, nl, ns, bas, dir);
}
Modified: grass/trunk/raster/r.flow/aspect.c
===================================================================
--- grass/trunk/raster/r.flow/aspect.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/aspect.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,6 +26,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "r.flow.h"
Modified: grass/trunk/raster/r.flow/aspect.h
===================================================================
--- grass/trunk/raster/r.flow/aspect.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/aspect.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/*
* aspect_fly: calculates aspect on the fly based on elevation map in z
Modified: grass/trunk/raster/r.flow/io.c
===================================================================
--- grass/trunk/raster/r.flow/io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -62,10 +62,10 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), fname);
- if (chd && (G_get_cellhd(fname, mapset, chd) < 0))
+ if (chd && (Rast_get_cellhd(fname, mapset, chd) < 0))
G_fatal_error(_("Unable to get header for %s"), fname);
- return G_open_cell_old(fname, mapset);
+ return Rast_open_cell_old(fname, mapset);
}
void read_input_files(void)
@@ -82,13 +82,13 @@
G_fatal_error(_("Elevation file's resolution differs from current region resolution"));
for (row = 0; row < region.rows; row++) {
- G_get_d_raster_row(fd, el.buf[row], row);
+ Rast_get_d_raster_row(fd, el.buf[row], row);
if (parm.seg)
put_row_seg(el, row);
}
if (parm.seg)
segment_flush(el.seg);
- G_close_cell(fd);
+ Rast_close_cell(fd);
if (parm.aspin) {
G_message(_("Reading input files: aspect"));
@@ -99,29 +99,29 @@
"current region resolution"));
for (row = 0; row < region.rows; row++) {
- G_get_d_raster_row(fd, as.buf[row], row);
+ Rast_get_d_raster_row(fd, as.buf[row], row);
if (parm.seg)
put_row_seg(as, row);
}
if (parm.seg)
segment_flush(as.seg);
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
if (parm.barin) {
G_message(_("Reading input files: barrier"));
- barc = G_allocate_d_raster_buf();
+ barc = Rast_allocate_d_raster_buf();
fd = open_existing_cell_file(parm.barin, &hd);
for (row = 0; row < region.rows; row++) {
- G_get_d_raster_row(fd, barc, row);
+ Rast_get_d_raster_row(fd, barc, row);
for (col = 0; col < region.cols; col++) {
BM_set(bitbar, col, row, (barc[col] != 0));
if (parm.dsout && barc[col] != 0)
put(ds, row, col, -1);
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
}
@@ -163,7 +163,7 @@
}
if (parm.lgout &&
- ((lgfd = G_open_raster_new(parm.lgout, FCELL_TYPE)) < 0))
+ ((lgfd = Rast_open_raster_new(parm.lgout, FCELL_TYPE)) < 0))
G_fatal_error(_("Unable to create raster map <%s>"), parm.lgout);
if (parm.flout && (Vect_open_new(&fl, parm.flout, 0) < 0))
@@ -179,7 +179,7 @@
close(ds.sfd);
}
/* if (parm.lgout)
- G_close_cell(lgfd); */
+ Rast_close_cell(lgfd); */
if (parm.flout) {
Vect_build(&fl);
Vect_close(&fl);
@@ -197,30 +197,30 @@
G_fatal_error(_("Cannot reset current region"));
G_message(_("Writing density file"));
- dsfd = G_open_raster_new(parm.dsout, DCELL_TYPE);
+ dsfd = Rast_open_raster_new(parm.dsout, DCELL_TYPE);
if (dsfd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), parm.dsout);
for (row = 0; row < region.rows; row++) {
- G_put_raster_row(dsfd, get_row(ds, row), DCELL_TYPE);
+ Rast_put_raster_row(dsfd, get_row(ds, row), DCELL_TYPE);
for (col = 0; col < region.cols; col++)
if (ds.buf[row][col] > dsmax)
dsmax = ds.buf[row][col];
}
- G_close_cell(dsfd);
+ Rast_close_cell(dsfd);
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
- G_add_color_rule(-1, 0, 0, 0, -1, 0, 0, 0, &colors);
- G_add_color_rule(0, 255, 255, 255, 5, 255, 255, 0, &colors);
- G_add_color_rule(5, 255, 255, 0, 30, 0, 255, 255, &colors);
- G_add_color_rule(30, 0, 255, 255, 100, 0, 127, 255, &colors);
- G_add_color_rule(100, 0, 127, 255, 1000, 0, 0, 255, &colors);
- G_add_color_rule(1000, 0, 0, 255, (CELL) dsmax, 0, 0, 0, &colors);
+ Rast_add_color_rule(-1, 0, 0, 0, -1, 0, 0, 0, &colors);
+ Rast_add_color_rule(0, 255, 255, 255, 5, 255, 255, 0, &colors);
+ Rast_add_color_rule(5, 255, 255, 0, 30, 0, 255, 255, &colors);
+ Rast_add_color_rule(30, 0, 255, 255, 100, 0, 127, 255, &colors);
+ Rast_add_color_rule(100, 0, 127, 255, 1000, 0, 0, 255, &colors);
+ Rast_add_color_rule(1000, 0, 0, 255, (CELL) dsmax, 0, 0, 0, &colors);
if ((mapset = G_find_file("cell", parm.dsout, "")) == NULL)
G_fatal_error(_("Unable to find file %s"), parm.dsout);
- G_write_colors(parm.dsout, mapset, &colors);
- G_free_colors(&colors);
+ Rast_write_colors(parm.dsout, mapset, &colors);
+ Rast_free_colors(&colors);
}
Modified: grass/trunk/raster/r.flow/io.h
===================================================================
--- grass/trunk/raster/r.flow/io.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/io.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/********************************* I/O **********************************/
Modified: grass/trunk/raster/r.flow/main.c
===================================================================
--- grass/trunk/raster/r.flow/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -29,6 +29,7 @@
#include <stdlib.h> /* for the random number generation */
#include <time.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "r.flow.h"
#include "mem.h"
@@ -117,8 +118,8 @@
}
if (!(a1 == UNDEF || a2 == UNDEF) &&
- !(G_is_d_null_value(&a1) || G_is_d_null_value(&a2)))
- /* if (!(G_is_d_null_value(&a1) || G_is_d_null_value(&a2))) */
+ !(Rast_is_d_null_value(&a1) || Rast_is_d_null_value(&a2)))
+ /* if (!(Rast_is_d_null_value(&a1) || Rast_is_d_null_value(&a2))) */
{
if ((d = a1 - a2) >= D_PI || d <= -D_PI) {
if (a2 > D_PI)
@@ -307,7 +308,7 @@
/* double x, y, length, xstep, ystep, roffset, coffset; */
double x, y, length, xstep, ystep;
- FCELL *lg = G_allocate_f_raster_buf();
+ FCELL *lg = Rast_allocate_f_raster_buf();
struct line_pnts *points = Vect_new_line_struct();
struct line_cats *cats = Vect_new_cats_struct();
int loopstep = (!parm.dsout && !parm.lgout && parm.flout) ? parm.skip : 1;
@@ -367,7 +368,7 @@
while (fls.index <= parm.bound &&
(pts.z != UNDEFZ && pts.theta >= 0 && pts.theta <= 360)
&&
- /* (!G_is_d_null_value(&pts.z) && pts.theta != UNDEF) && */
+ /* (!Rast_is_d_null_value(&pts.z) && pts.theta != UNDEF) && */
next_point(&pts, &ads, bbs, &length));
}
@@ -384,7 +385,7 @@
}
if (parm.lgout)
- G_put_f_raster_row(lgfd, lg);
+ Rast_put_f_raster_row(lgfd, lg);
}
G_free(fls.px);
@@ -395,7 +396,7 @@
Vect_destroy_cats_struct(cats);
if (parm.lgout)
- G_close_cell(lgfd);
+ Rast_close_cell(lgfd);
}
int main(int argc, char *argv[])
@@ -578,14 +579,14 @@
}
if (parm.dsout) {
- G_short_history(parm.dsout, "raster", &history);
- G_command_history(&history);
- G_write_history(parm.dsout, &history);
+ Rast_short_history(parm.dsout, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(parm.dsout, &history);
}
if (parm.lgout) {
- G_short_history(parm.lgout, "raster", &history);
- G_command_history(&history);
- G_write_history(parm.lgout, &history);
+ Rast_short_history(parm.lgout, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(parm.lgout, &history);
}
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.flow/mem.c
===================================================================
--- grass/trunk/raster/r.flow/mem.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/mem.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "r.flow.h"
#include "io.h"
@@ -75,10 +76,10 @@
if (!parm.mem) {
G_debug(1, "Allocating memory: aspect");
as.buf = (DCELL **) G_calloc(region.rows, sizeof(DCELL *));
- as.buf[0] = (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ as.buf[0] = (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
for (row = 0; row < region.rows; row++)
as.buf[row] = parm.seg ?
- as.buf[0] : (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ as.buf[0] : (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
}
if (parm.barin) {
@@ -89,10 +90,10 @@
if (parm.dsout) {
G_debug(1, "Allocating memory: density");
ds.buf = (DCELL **) G_calloc(region.rows, sizeof(DCELL *));
- ds.buf[0] = (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ ds.buf[0] = (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
for (row = 0; row < region.rows; row++)
ds.buf[row] = parm.seg ?
- ds.buf[0] : (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ ds.buf[0] : (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
}
if (parm.flout) {
Modified: grass/trunk/raster/r.flow/mem.h
===================================================================
--- grass/trunk/raster/r.flow/mem.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/mem.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
/************************** MEMORY MANAGEMENT ***************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#define KB 1024
#define MB (KB * KB)
#define SEGSINMEM 9
Modified: grass/trunk/raster/r.flow/precomp.c
===================================================================
--- grass/trunk/raster/r.flow/precomp.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/precomp.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "r.flow.h"
#include "io.h"
@@ -177,7 +178,7 @@
for (col = 0; col < region.cols; col++) {
if (aspect(row, col) == 0)
/* put(as, row, col, (int) UNDEF); */
- G_set_d_null_value(&(as.buf[row][col]), 1);
+ Rast_set_d_null_value(&(as.buf[row][col]), 1);
else if (aspect(row, col) < 90)
put(as, row, col, 90 - aspect(row, col));
else
@@ -201,7 +202,7 @@
for (col = 0; col < region.cols; col++) {
temp = aspect_fly(n++, c++, s++, d);
if (temp == UNDEF)
- G_set_d_null_value(&(as.buf[row][col]), 1);
+ Rast_set_d_null_value(&(as.buf[row][col]), 1);
else
put(as, row, col, temp);
}
Modified: grass/trunk/raster/r.flow/r.flow.h
===================================================================
--- grass/trunk/raster/r.flow/r.flow.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.flow/r.flow.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -32,6 +32,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include <grass/Vect.h>
#include <grass/bitmap.h>
Modified: grass/trunk/raster/r.grow/main.c
===================================================================
--- grass/trunk/raster/r.grow/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.grow/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -182,22 +182,22 @@
else
G_fatal_error(_("Unknown metric: [%s]."), opt.met->answer);
- in_fd = G_open_cell_old(in_name, "");
+ in_fd = Rast_open_cell_old(in_name, "");
if (in_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), in_name);
- type = G_get_raster_map_type(in_fd);
+ type = Rast_get_raster_map_type(in_fd);
- out_fd = G_open_raster_new(out_name, type);
+ out_fd = Rast_open_raster_new(out_name, type);
if (out_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), out_name);
- if (G_read_cats(in_name, "", &cats) == -1) {
+ if (Rast_read_cats(in_name, "", &cats) == -1) {
G_warning(_("Error reading category file for <%s>"), in_name);
- G_init_cats(0, "", &cats);
+ Rast_init_cats(0, "", &cats);
}
- if (G_read_colors(in_name, "", &colr) == -1) {
+ if (Rast_read_colors(in_name, "", &colr) == -1) {
G_warning(_("Error in reading color file for <%s>"), in_name);
colrfile = 0;
}
@@ -205,35 +205,35 @@
colrfile = 1;
if (opt.old->answer && oldval >= 0)
- G_set_cat(oldval, "original cells", &cats);
+ Rast_set_cat(oldval, "original cells", &cats);
if (opt.new->answer)
- G_set_cat(newval, "grown cells", &cats);
+ Rast_set_cat(newval, "grown cells", &cats);
in_rows = G_malloc((size * 2 + 1) * sizeof(DCELL *));
for (row = 0; row <= size * 2; row++)
- in_rows[row] = G_allocate_d_raster_buf();
+ in_rows[row] = Rast_allocate_d_raster_buf();
- out_row = G_allocate_d_raster_buf();
+ out_row = Rast_allocate_d_raster_buf();
for (row = 0; row < size; row++)
- G_get_d_raster_row(in_fd, in_rows[size + row], row);
+ Rast_get_d_raster_row(in_fd, in_rows[size + row], row);
for (row = 0; row < nrows; row++) {
DCELL *tmp;
int i;
if (row + size < nrows)
- G_get_d_raster_row(in_fd, in_rows[size * 2], row + size);
+ Rast_get_d_raster_row(in_fd, in_rows[size * 2], row + size);
for (col = 0; col < ncols; col++) {
DCELL *c = &in_rows[size][col];
- if (!G_is_d_null_value(c)) {
+ if (!Rast_is_d_null_value(c)) {
if (opt.old->answer) {
if (oldval < 0)
- G_set_d_null_value(&out_row[col], 1);
+ Rast_set_d_null_value(&out_row[col], 1);
else
out_row[col] = oldval;
}
@@ -254,17 +254,17 @@
c = &in_rows[size + dy][x];
- if (!G_is_d_null_value(c)) {
+ if (!Rast_is_d_null_value(c)) {
out_row[col] = opt.new->answer ? newval : *c;
break;
}
}
if (i == count)
- G_set_d_null_value(&out_row[col], 1);
+ Rast_set_d_null_value(&out_row[col], 1);
}
- G_put_d_raster_row(out_fd, out_row);
+ Rast_put_d_raster_row(out_fd, out_row);
G_percent(row, nrows, 2);
@@ -276,19 +276,19 @@
G_percent(row, nrows, 2);
- G_close_cell(in_fd);
- G_close_cell(out_fd);
+ Rast_close_cell(in_fd);
+ Rast_close_cell(out_fd);
- if (G_write_cats(out_name, &cats) == -1)
+ if (Rast_write_cats(out_name, &cats) == -1)
G_warning(_("Error writing category file for <%s>"), out_name);
if (colrfile)
- if (G_write_colors(out_name, G_mapset(), &colr) == -1)
+ if (Rast_write_colors(out_name, G_mapset(), &colr) == -1)
G_warning(_("Error writing color file for <%s>"), out_name);
- G_short_history(out_name, "raster", &history);
- G_command_history(&history);
- G_write_history(out_name, &history);
+ Rast_short_history(out_name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out_name, &history);
return EXIT_SUCCESS;
}
Modified: grass/trunk/raster/r.grow.distance/main.c
===================================================================
--- grass/trunk/raster/r.grow.distance/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.grow.distance/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
static struct Cell_head window;
@@ -98,7 +99,7 @@
if (col + dx >= ncols)
return;
- if (G_is_c_null_value(&xrow[col + dx]))
+ if (Rast_is_c_null_value(&xrow[col + dx]))
return;
x = xrow[col + dx] + dx;
@@ -108,7 +109,7 @@
? (*distance) (xres * x, yres * y)
: geodesic_distance(col, row, col + x, row + y);
- if (!G_is_d_null_value(&dist_row[col]) && dist_row[col] < d)
+ if (!Rast_is_d_null_value(&dist_row[col]) && dist_row[col] < d)
return;
dist_row[col] = d;
@@ -207,18 +208,18 @@
if (flag.m->answer)
scale = G_database_units_to_meters_factor();
- in_fd = G_open_cell_old(in_name, "");
+ in_fd = Rast_open_cell_old(in_name, "");
if (in_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), in_name);
if (dist_name) {
- dist_fd = G_open_raster_new(dist_name, DCELL_TYPE);
+ dist_fd = Rast_open_raster_new(dist_name, DCELL_TYPE);
if (dist_fd < 0)
G_fatal_error(_("Unable to create distance map <%s>"), dist_name);
}
if (val_name) {
- val_fd = G_open_raster_new(val_name, DCELL_TYPE);
+ val_fd = Rast_open_raster_new(val_name, DCELL_TYPE);
if (val_fd < 0)
G_fatal_error(_("Unable to create value map <%s>"), val_name);
}
@@ -233,40 +234,40 @@
xres = window.ew_res;
yres = window.ns_res;
- in_row = G_allocate_d_raster_buf();
+ in_row = Rast_allocate_d_raster_buf();
- old_val_row = G_allocate_d_raster_buf();
- new_val_row = G_allocate_d_raster_buf();
+ old_val_row = Rast_allocate_d_raster_buf();
+ new_val_row = Rast_allocate_d_raster_buf();
- old_x_row = G_allocate_c_raster_buf();
- old_y_row = G_allocate_c_raster_buf();
- new_x_row = G_allocate_c_raster_buf();
- new_y_row = G_allocate_c_raster_buf();
+ old_x_row = Rast_allocate_c_raster_buf();
+ old_y_row = Rast_allocate_c_raster_buf();
+ new_x_row = Rast_allocate_c_raster_buf();
+ new_y_row = Rast_allocate_c_raster_buf();
- dist_row = G_allocate_d_raster_buf();
+ dist_row = Rast_allocate_d_raster_buf();
if (dist_name && strcmp(opt.met->answer, "euclidean") == 0)
- out_row = G_allocate_d_raster_buf();
+ out_row = Rast_allocate_d_raster_buf();
else
out_row = dist_row;
- G_set_c_null_value(old_x_row, ncols);
- G_set_c_null_value(old_y_row, ncols);
+ Rast_set_c_null_value(old_x_row, ncols);
+ Rast_set_c_null_value(old_y_row, ncols);
for (row = 0; row < nrows; row++) {
int irow = nrows - 1 - row;
G_percent(row, nrows, 2);
- G_set_c_null_value(new_x_row, ncols);
- G_set_c_null_value(new_y_row, ncols);
+ Rast_set_c_null_value(new_x_row, ncols);
+ Rast_set_c_null_value(new_y_row, ncols);
- G_set_d_null_value(dist_row, ncols);
+ Rast_set_d_null_value(dist_row, ncols);
- G_get_d_raster_row(in_fd, in_row, irow);
+ Rast_get_d_raster_row(in_fd, in_row, irow);
for (col = 0; col < ncols; col++)
- if (!G_is_d_null_value(&in_row[col])) {
+ if (!Rast_is_d_null_value(&in_row[col])) {
new_x_row[col] = 0;
new_y_row[col] = 0;
dist_row[col] = 0;
@@ -295,10 +296,10 @@
G_percent(row, nrows, 2);
- G_close_cell(in_fd);
+ Rast_close_cell(in_fd);
- G_set_c_null_value(old_x_row, ncols);
- G_set_c_null_value(old_y_row, ncols);
+ Rast_set_c_null_value(old_x_row, ncols);
+ Rast_set_c_null_value(old_y_row, ncols);
for (row = 0; row < nrows; row++) {
int irow = nrows - 1 - row;
@@ -335,11 +336,11 @@
for (col = 0; col < ncols; col++)
out_row[col] *= scale;
- G_put_d_raster_row(dist_fd, out_row);
+ Rast_put_d_raster_row(dist_fd, out_row);
}
if (val_name)
- G_put_d_raster_row(val_fd, new_val_row);
+ Rast_put_d_raster_row(val_fd, new_val_row);
swap_rows();
}
@@ -350,22 +351,22 @@
remove(temp_name);
if (dist_name)
- G_close_cell(dist_fd);
+ Rast_close_cell(dist_fd);
if (val_name)
- G_close_cell(val_fd);
+ Rast_close_cell(val_fd);
if (val_name) {
- if (G_read_colors(in_name, "", &colors) < 0)
+ if (Rast_read_colors(in_name, "", &colors) < 0)
G_fatal_error(_("Unable to read color table for raster map <%s>"), in_name);
- G_write_colors(val_name, G_mapset(), &colors);
+ Rast_write_colors(val_name, G_mapset(), &colors);
}
if (dist_name) {
- G_init_colors(&colors);
- G_read_fp_range(dist_name, G_mapset(), &range);
- G_get_fp_range_min_max(&range, &min, &max);
- G_make_fp_colors(&colors, "rainbow", min, max);
- G_write_colors(dist_name, G_mapset(), &colors);
+ Rast_init_colors(&colors);
+ Rast_read_fp_range(dist_name, G_mapset(), &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
+ Rast_make_fp_colors(&colors, "rainbow", min, max);
+ Rast_write_colors(dist_name, G_mapset(), &colors);
}
return EXIT_SUCCESS;
Modified: grass/trunk/raster/r.gwflow/main.c
===================================================================
--- grass/trunk/raster/r.gwflow/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.gwflow/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/N_pde.h>
#include <grass/N_gwflow.h>
@@ -501,7 +502,7 @@
count++;
}
else {
- G_set_null_value(&val, 1, DCELL_TYPE);
+ Rast_set_null_value(&val, 1, DCELL_TYPE);
}
N_put_array_2d_d_value(target, x, y, val);
}
Modified: grass/trunk/raster/r.his/his.c
===================================================================
--- grass/trunk/raster/r.his/his.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.his/his.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "his.h"
/****************************************************************************
@@ -65,10 +66,10 @@
{
int i;
- G_init_colors(gray);
+ Rast_init_colors(gray);
for (i = 0; i < 256; i++)
- G_set_color((CELL) i, i, i, i, gray);
+ Rast_set_color((CELL) i, i, i, i, gray);
return 0;
}
Modified: grass/trunk/raster/r.his/main.c
===================================================================
--- grass/trunk/raster/r.his/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.his/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include "his.h"
@@ -122,7 +123,7 @@
name_h = opt_h->answer;
/* Make sure map is available */
- if ((hue_file = G_open_cell_old(name_h, "")) == -1)
+ if ((hue_file = Rast_open_cell_old(name_h, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name_h);
hue_r = G_malloc(window.cols);
@@ -133,7 +134,7 @@
dummy = G_malloc(window.cols);
/* Reading color lookup table */
- if (G_read_colors(name_h, "", &hue_colors) == -1)
+ if (Rast_read_colors(name_h, "", &hue_colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name_h);
int_used = 0;
@@ -143,14 +144,14 @@
name_i = opt_i->answer;
int_used = 1;
/* Make sure map is available */
- if ((int_file = G_open_cell_old(name_i, "")) == -1)
+ if ((int_file = Rast_open_cell_old(name_i, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name_i);
int_r = G_malloc(window.cols);
int_n = G_malloc(window.cols);
/* Reading color lookup table */
- if (G_read_colors(name_i, "", &int_colors) == -1)
+ if (Rast_read_colors(name_i, "", &int_colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name_i);
}
@@ -162,14 +163,14 @@
sat_used = 1;
/* Make sure map is available */
- if ((sat_file = G_open_cell_old(name_s, "")) == -1)
+ if ((sat_file = Rast_open_cell_old(name_s, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name_s);
sat_r = G_malloc(window.cols);
sat_n = G_malloc(window.cols);
/* Reading color lookup table */
- if (G_read_colors(name_s, "", &sat_colors) == -1)
+ if (Rast_read_colors(name_s, "", &sat_colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name_s);
}
@@ -178,7 +179,7 @@
if (opt_r->answer != NULL) {
name_r = opt_r->answer;
- if ((r_file = G_open_cell_new(name_r)) < 0)
+ if ((r_file = Rast_open_cell_new(name_r)) < 0)
r_used = 0;
else
r_used = 1;
@@ -189,7 +190,7 @@
if (opt_g->answer != NULL) {
name_g = opt_g->answer;
- if ((g_file = G_open_cell_new(name_g)) < 0)
+ if ((g_file = Rast_open_cell_new(name_g)) < 0)
g_used = 0;
else
g_used = 1;
@@ -200,15 +201,15 @@
if (opt_b->answer != NULL) {
name_b = opt_b->answer;
- if ((b_file = G_open_cell_new(name_b)) < 0)
+ if ((b_file = Rast_open_cell_new(name_b)) < 0)
b_used = 0;
else
b_used = 1;
}
- r_array = G_allocate_cell_buf();
- g_array = G_allocate_cell_buf();
- b_array = G_allocate_cell_buf();
+ r_array = Rast_allocate_cell_buf();
+ g_array = Rast_allocate_cell_buf();
+ b_array = Rast_allocate_cell_buf();
/* Make color table */
make_gray_scale(&gray_colors);
@@ -221,15 +222,15 @@
for (atrow = 0; atrow < window.rows; atrow++) {
G_percent(atrow, window.rows, 2);
- if (G_get_raster_row_colors
+ if (Rast_get_raster_row_colors
(hue_file, atrow, &hue_colors, hue_r, hue_g, hue_b, hue_n) < 0)
G_fatal_error(_("Error reading 'hue' map"));
if (int_used &&
- (G_get_raster_row_colors
+ (Rast_get_raster_row_colors
(int_file, atrow, &int_colors, int_r, dummy, dummy, int_n) < 0))
G_fatal_error(_("Error reading 'intensity' map"));
if (sat_used &&
- (G_get_raster_row_colors
+ (Rast_get_raster_row_colors
(sat_file, atrow, &sat_colors, sat_r, dummy, dummy, sat_n) < 0))
G_fatal_error(_("Error reading 'saturation' map"));
@@ -238,9 +239,9 @@
if (hue_n[atcol]
|| (int_used && int_n[atcol])
|| (sat_used && sat_n[atcol])) {
- G_set_c_null_value(&r_array[atcol], 1);
- G_set_c_null_value(&g_array[atcol], 1);
- G_set_c_null_value(&b_array[atcol], 1);
+ Rast_set_c_null_value(&r_array[atcol], 1);
+ Rast_set_c_null_value(&g_array[atcol], 1);
+ Rast_set_c_null_value(&b_array[atcol], 1);
continue;
}
}
@@ -257,49 +258,49 @@
}
if (r_used)
- if (G_put_raster_row(r_file, r_array, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(r_file, r_array, CELL_TYPE) < 0)
r_used = 0;
if (g_used)
- if (G_put_raster_row(g_file, g_array, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(g_file, g_array, CELL_TYPE) < 0)
g_used = 0;
if (b_used)
- if (G_put_raster_row(b_file, b_array, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(b_file, b_array, CELL_TYPE) < 0)
b_used = 0;
}
G_percent(window.rows, window.rows, 5);
/* Close the cell files */
- G_close_cell(hue_file);
+ Rast_close_cell(hue_file);
if (int_used)
- G_close_cell(int_file);
+ Rast_close_cell(int_file);
if (sat_used)
- G_close_cell(sat_file);
+ Rast_close_cell(sat_file);
if (r_used) {
- G_close_cell(r_file);
- G_write_colors(name_r, G_mapset(), &gray_colors);
- G_short_history(name_r, "raster", &history);
- G_command_history(&history);
- G_write_history(name_r, &history);
- G_put_cell_title(name_r, "Red extracted from HIS");
+ Rast_close_cell(r_file);
+ Rast_write_colors(name_r, G_mapset(), &gray_colors);
+ Rast_short_history(name_r, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(name_r, &history);
+ Rast_put_cell_title(name_r, "Red extracted from HIS");
}
if (g_used) {
- G_close_cell(g_file);
- G_write_colors(name_g, G_mapset(), &gray_colors);
- G_short_history(name_g, "raster", &history);
- G_command_history(&history);
- G_write_history(name_g, &history);
- G_put_cell_title(name_g, "Green extracted from HIS");
+ Rast_close_cell(g_file);
+ Rast_write_colors(name_g, G_mapset(), &gray_colors);
+ Rast_short_history(name_g, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(name_g, &history);
+ Rast_put_cell_title(name_g, "Green extracted from HIS");
}
if (b_used) {
- G_close_cell(b_file);
- G_write_colors(name_b, G_mapset(), &gray_colors);
- G_short_history(name_b, "raster", &history);
- G_command_history(&history);
- G_write_history(name_b, &history);
- G_put_cell_title(name_b, "Blue extracted from HIS");
+ Rast_close_cell(b_file);
+ Rast_write_colors(name_b, G_mapset(), &gray_colors);
+ Rast_short_history(name_b, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(name_b, &history);
+ Rast_put_cell_title(name_b, "Blue extracted from HIS");
}
return EXIT_SUCCESS;
Modified: grass/trunk/raster/r.horizon/main.c
===================================================================
--- grass/trunk/raster/r.horizon/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.horizon/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -35,6 +35,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
@@ -536,7 +537,7 @@
int l, i, j, k;
int lmax, kmax;
- cell1 = G_allocate_f_raster_buf();
+ cell1 = Rast_allocate_f_raster_buf();
z = (float **)G_malloc(sizeof(float *) * (m));
z100 = (float **)G_malloc(sizeof(float *) * (m100));
@@ -552,22 +553,22 @@
if ((mapset = G_find_cell2(elevin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), elevin);
- fd1 = G_open_cell_old(elevin, mapset);
+ fd1 = Rast_open_cell_old(elevin, mapset);
for (row = 0; row < m; row++) {
- G_get_f_raster_row(fd1, cell1, row);
+ Rast_get_f_raster_row(fd1, cell1, row);
for (j = 0; j < n; j++) {
row_rev = m - row - 1;
- if (!G_is_f_null_value(cell1 + j))
+ if (!Rast_is_f_null_value(cell1 + j))
z[row_rev][j] = (float)cell1[j];
else
z[row_rev][j] = UNDEFZ;
}
}
- G_close_cell(fd1);
+ Rast_close_cell(fd1);
/*create low resolution array 100 */
for (i = 0; i < m100; i++) {
@@ -616,8 +617,8 @@
exit(EXIT_FAILURE);
if (horizon != NULL) {
- cell1 = G_allocate_f_raster_buf();
- fd1 = G_open_fp_cell_new(shad_filename);
+ cell1 = Rast_allocate_f_raster_buf();
+ fd1 = Rast_open_fp_cell_new(shad_filename);
if (fd1 < 0)
G_fatal_error(_("Unable to create raster map %s"), shad_filename);
}
@@ -637,16 +638,16 @@
if (horizon != NULL) {
for (j = 0; j < numcols; j++) {
if (horizon_raster[i][j] == UNDEFZ)
- G_set_f_null_value(cell1 + j, 1);
+ Rast_set_f_null_value(cell1 + j, 1);
else
cell1[j] = (FCELL) horizon_raster[i][j];
}
- G_put_f_raster_row(fd1, cell1);
+ Rast_put_f_raster_row(fd1, cell1);
}
} /* End loop over rows. */
- G_close_cell(fd1);
+ Rast_close_cell(fd1);
@@ -1264,9 +1265,9 @@
exit(0);
}
- G_short_history(shad_filename, "raster", &history);
- G_command_history(&history);
- G_write_history(shad_filename, &history);
+ Rast_short_history(shad_filename, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(shad_filename, &history);
}
Modified: grass/trunk/raster/r.in.arc/gethead.c
===================================================================
--- grass/trunk/raster/r.in.arc/gethead.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.arc/gethead.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <string.h>
#include <ctype.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
@@ -97,7 +98,7 @@
return 0;
}
- if (err = G_adjust_Cell_head(cellhd, 1, 1)) {
+ if (err = Rast_adjust_Cell_head(cellhd, 1, 1)) {
G_warning(err);
return 0;
}
Modified: grass/trunk/raster/r.in.arc/main.c
===================================================================
--- grass/trunk/raster/r.in.arc/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.arc/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <unistd.h>
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -140,16 +141,16 @@
switch (rtype) {
case CELL_TYPE:
- cell = G_allocate_c_raster_buf();
+ cell = Rast_allocate_c_raster_buf();
break;
case FCELL_TYPE:
- fcell = G_allocate_f_raster_buf();
+ fcell = Rast_allocate_f_raster_buf();
break;
case DCELL_TYPE:
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
break;
}
- cf = G_open_raster_new(output, rtype);
+ cf = Rast_open_raster_new(output, rtype);
if (cf < 0)
G_fatal_error(_("Unable to create raster map <%s>"), output);
@@ -157,28 +158,28 @@
G_percent(row, nrows, 5);
for (col = 0; col < ncols; col++) {
if (fscanf(fd, "%lf", &x) != 1) {
- G_unopen_cell(cf);
+ Rast_unopen_cell(cf);
G_fatal_error(_("Data conversion failed at row %d, col %d"),
row + 1, col + 1);
}
switch (rtype) {
case CELL_TYPE:
if ((int)x == missingval)
- G_set_c_null_value(cell + col, 1);
+ Rast_set_c_null_value(cell + col, 1);
else
cell[col] = (CELL) x *mult_fact;
break;
case FCELL_TYPE:
if ((int)x == missingval)
- G_set_f_null_value(fcell + col, 1);
+ Rast_set_f_null_value(fcell + col, 1);
else
fcell[col] = (FCELL) x *mult_fact;
break;
case DCELL_TYPE:
if ((int)x == missingval)
- G_set_d_null_value(dcell + col, 1);
+ Rast_set_d_null_value(dcell + col, 1);
else
dcell[col] = (DCELL) x *mult_fact;
@@ -187,23 +188,23 @@
}
switch (rtype) {
case CELL_TYPE:
- G_put_c_raster_row(cf, cell);
+ Rast_put_c_raster_row(cf, cell);
break;
case FCELL_TYPE:
- G_put_f_raster_row(cf, fcell);
+ Rast_put_f_raster_row(cf, fcell);
break;
case DCELL_TYPE:
- G_put_d_raster_row(cf, dcell);
+ Rast_put_d_raster_row(cf, dcell);
break;
}
}
/* G_message(_("CREATING SUPPORT FILES FOR %s"), output); */
- G_close_cell(cf);
+ Rast_close_cell(cf);
if (title)
- G_put_cell_title(output, title);
- G_short_history(output, "raster", &history);
- G_command_history(&history);
- G_write_history(output, &history);
+ Rast_put_cell_title(output, title);
+ Rast_short_history(output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(output, &history);
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.in.ascii/gethead.c
===================================================================
--- grass/trunk/raster/r.in.ascii/gethead.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.ascii/gethead.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -171,7 +172,7 @@
}
if (strcmp(label, "multiplier") == 0) {
- if (G_is_d_null_value(mult)) { /* if mult not set on commant line */
+ if (Rast_is_d_null_value(mult)) { /* if mult not set on commant line */
if (sscanf(value, "%lf", mult) != 1) {
G_warning(_("illegal multiplier field: using 1.0"));
*mult = 1.0;
@@ -205,7 +206,7 @@
if (!(*nval))
*nval = G_store("*");
- if (G_is_d_null_value(mult))
+ if (Rast_is_d_null_value(mult))
*mult = 1.0;
/* if data type is not set, then scan data to find out data type */
if (*d_type < 0) {
@@ -220,7 +221,7 @@
}
}
- if ((err = G_adjust_Cell_head(cellhd, 1, 1))) {
+ if ((err = Rast_adjust_Cell_head(cellhd, 1, 1))) {
G_warning(err);
return 0;
}
Modified: grass/trunk/raster/r.in.ascii/main.c
===================================================================
--- grass/trunk/raster/r.in.ascii/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.ascii/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -130,7 +131,7 @@
if ((title = parm.title->answer))
G_strip(title);
if (strcmp(parm.mult->answer, "1.0 or read from header") == 0)
- G_set_d_null_value(&mult, 1);
+ Rast_set_d_null_value(&mult, 1);
else if ((sscanf(parm.mult->answer, "%lf", &mult)) != 1)
G_fatal_error(_("Wrong entry for multiplier: %s"), parm.mult->answer);
if (strcmp(parm.nv->answer, "* or read from header") == 0)
@@ -197,35 +198,35 @@
G_window_cols());
- rast_ptr = G_allocate_raster_buf(data_type);
+ rast_ptr = Rast_allocate_raster_buf(data_type);
rast = rast_ptr;
- cf = G_open_raster_new(output, data_type);
+ cf = Rast_open_raster_new(output, data_type);
if (cf < 0)
G_fatal_error(_("Unable to create raster map <%s>"), output);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
for (col = 0; col < ncols; col++) {
if (fscanf(fd, "%s", y) != 1) {
- G_unopen_cell(cf);
+ Rast_unopen_cell(cf);
G_fatal_error(_("Data conversion failed at row %d, col %d"),
row + 1, col + 1);
}
if (strcmp(y, null_val_str)) {
x = atof(y);
if ((float)x == GS_BLANK) {
- G_set_null_value(rast_ptr, 1, data_type);
+ Rast_set_null_value(rast_ptr, 1, data_type);
}
else {
- G_set_raster_value_d(rast_ptr,
+ Rast_set_raster_value_d(rast_ptr,
(DCELL) (x * mult), data_type);
}
}
else {
- G_set_null_value(rast_ptr, 1, data_type);
+ Rast_set_null_value(rast_ptr, 1, data_type);
}
- rast_ptr = G_incr_void_ptr(rast_ptr, G_raster_size(data_type));
+ rast_ptr = Rast_incr_void_ptr(rast_ptr, Rast_raster_size(data_type));
}
- fwrite(rast, G_raster_size(data_type), ncols, ft);
+ fwrite(rast, Rast_raster_size(data_type), ncols, ft);
rast_ptr = rast;
}
G_percent(nrows, nrows, 2);
@@ -233,7 +234,7 @@
sz = 0;
if (direction < 0) {
- sz = -ncols * G_raster_size(data_type);
+ sz = -ncols * Rast_raster_size(data_type);
fseek(ft, sz, SEEK_END);
sz *= 2;
}
@@ -242,21 +243,21 @@
}
for (row = 0; row < nrows; row += 1) {
- fread(rast, G_raster_size(data_type), ncols, ft);
- G_put_raster_row(cf, rast, data_type);
+ fread(rast, Rast_raster_size(data_type), ncols, ft);
+ Rast_put_raster_row(cf, rast, data_type);
fseek(ft, sz, SEEK_CUR);
}
fclose(ft);
unlink(temp);
- G_close_cell(cf);
+ Rast_close_cell(cf);
if (title)
- G_put_cell_title(output, title);
+ Rast_put_cell_title(output, title);
- G_short_history(output, "raster", &history);
- G_command_history(&history);
- G_write_history(output, &history);
+ Rast_short_history(output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(output, &history);
G_done_msg(" ");
Modified: grass/trunk/raster/r.in.bin/main.c
===================================================================
--- grass/trunk/raster/r.in.bin/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.bin/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -14,6 +14,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "gmt_grd.h"
#include <grass/glocale.h>
@@ -405,7 +406,7 @@
}
/* Adjust Cell Header to match resolution */
- if (err = G_adjust_Cell_head(&cellhd, 0, 0)) {
+ if (err = Rast_adjust_Cell_head(&cellhd, 0, 0)) {
G_fatal_error("%s", err);
exit(EXIT_FAILURE);
}
@@ -417,7 +418,7 @@
if (!flag.gmt_hd->answer) {
/* Adjust Cell Header to New Values */
- if (err = G_adjust_Cell_head(&cellhd, 1, 1)) {
+ if (err = Rast_adjust_Cell_head(&cellhd, 1, 1)) {
G_fatal_error("%s", err);
exit(EXIT_FAILURE);
}
@@ -480,18 +481,18 @@
if (flag.f->answer) {
map_type = FCELL_TYPE;
- fcell = G_allocate_f_raster_buf();
+ fcell = Rast_allocate_f_raster_buf();
}
else if (flag.d->answer) {
map_type = DCELL_TYPE;
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
}
else {
- cell = G_allocate_c_raster_buf();
+ cell = Rast_allocate_c_raster_buf();
map_type = CELL_TYPE;
}
- cf = G_open_raster_new(output, map_type);
+ cf = Rast_open_raster_new(output, map_type);
if (cf < 0) {
G_fatal_error(_("Unable to create raster map <%s>"), output);
exit(EXIT_FAILURE);
@@ -513,7 +514,7 @@
for (row = 0; row < grass_nrows; row++) {
if (fread(x_v, bytes * ncols, 1, fd) != 1) {
- G_unopen_cell(cf);
+ Rast_unopen_cell(cf);
G_fatal_error(_("Conversion failed at row %d"), row);
exit(EXIT_FAILURE);
}
@@ -559,34 +560,34 @@
if (parm.anull->answer) {
if (flag.f->answer) {
if (fcell[col] == (float)nul_val)
- G_set_f_null_value(&fcell[col], 1);
+ Rast_set_f_null_value(&fcell[col], 1);
}
else {
if (cell[col] == (int)nul_val)
- G_set_c_null_value(&cell[col], 1);
+ Rast_set_c_null_value(&cell[col], 1);
}
}
}
if (flag.f->answer)
- G_put_f_raster_row(cf, fcell);
+ Rast_put_f_raster_row(cf, fcell);
else if (flag.d->answer)
- G_put_d_raster_row(cf, dcell);
+ Rast_put_d_raster_row(cf, dcell);
else
- G_put_c_raster_row(cf, cell);
+ Rast_put_c_raster_row(cf, cell);
G_percent(row + 1, nrows, 2);
}
G_debug(1, "Creating support files for %s", output);
- G_close_cell(cf);
+ Rast_close_cell(cf);
if (title)
- G_put_cell_title(output, title);
+ Rast_put_cell_title(output, title);
- G_short_history(output, "raster", &history);
- G_command_history(&history);
- G_write_history(output, &history);
+ Rast_short_history(output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(output, &history);
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.in.gdal/main.c
===================================================================
--- grass/trunk/raster/r.in.gdal/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.gdal/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <math.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
@@ -460,7 +461,7 @@
ImportBand(hBand, output, NULL);
if (title)
- G_put_cell_title(output, title);
+ Rast_put_cell_title(output, title);
}
/* -------------------------------------------------------------------- */
@@ -505,7 +506,7 @@
ImportBand(hBand, szBandName, &ref);
if (title)
- G_put_cell_title(szBandName, title);
+ Rast_put_cell_title(szBandName, title);
}
I_put_group_ref(output, &ref);
@@ -678,7 +679,7 @@
char outputReal[GNAME_MAX], outputImg[GNAME_MAX];
char *nullFlags = NULL;
int (*raster_open_new_func) (const char *, RASTER_MAP_TYPE) =
- G_open_raster_new;
+ Rast_open_raster_new;
struct History history;
/* -------------------------------------------------------------------- */
@@ -698,8 +699,8 @@
data_type = CELL_TYPE;
eGDT = GDT_Int32;
complex = FALSE;
- G_set_cell_format(0);
- /* raster_open_new_func = G_open_raster_new_uncompressed; *//* ?? */
+ Rast_set_cell_format(0);
+ /* raster_open_new_func = Rast_open_raster_new_uncompressed; *//* ?? */
break;
case GDT_Int16:
@@ -707,15 +708,15 @@
data_type = CELL_TYPE;
eGDT = GDT_Int32;
complex = FALSE;
- G_set_cell_format(1);
- /* raster_open_new_func = G_open_raster_new_uncompressed; *//* ?? */
+ Rast_set_cell_format(1);
+ /* raster_open_new_func = Rast_open_raster_new_uncompressed; *//* ?? */
break;
default:
data_type = CELL_TYPE;
eGDT = GDT_Int32;
complex = FALSE;
- G_set_cell_format(3);
+ Rast_set_cell_format(3);
break;
}
@@ -736,8 +737,8 @@
if (cfI < 0)
G_fatal_error(_("Unable to create raster map <%s>"), outputImg);
- cellReal = G_allocate_raster_buf(data_type);
- cellImg = G_allocate_raster_buf(data_type);
+ cellReal = Rast_allocate_raster_buf(data_type);
+ cellImg = Rast_allocate_raster_buf(data_type);
bufComplex = (float *)G_malloc(sizeof(float) * ncols * 2);
if (group_ref != NULL) {
@@ -753,7 +754,7 @@
if (group_ref != NULL)
I_add_file_to_group_ref((char *)output, G_mapset(), group_ref);
- cell = G_allocate_raster_buf(data_type);
+ cell = Rast_allocate_raster_buf(data_type);
}
/* -------------------------------------------------------------------- */
@@ -790,8 +791,8 @@
bufComplex[indx * 2 + 1];
}
}
- G_put_raster_row(cfR, cellReal, data_type);
- G_put_raster_row(cfI, cellImg, data_type);
+ Rast_put_raster_row(cfR, cellReal, data_type);
+ Rast_put_raster_row(cfI, cellImg, data_type);
} /* end of complex */
else { /* single band */
GDALRasterIO(hBand, GF_Read, 0, row - 1, ncols, 1,
@@ -815,10 +816,10 @@
}
}
- G_insert_null_values(cell, nullFlags, ncols, data_type);
+ Rast_insert_null_values(cell, nullFlags, ncols, data_type);
}
- G_put_raster_row(cf, cell, data_type);
+ Rast_put_raster_row(cf, cell, data_type);
} /* end of not complex */
G_percent(row, nrows, 2);
@@ -848,10 +849,10 @@
}
}
- G_insert_null_values(cell, nullFlags, ncols, data_type);
+ Rast_insert_null_values(cell, nullFlags, ncols, data_type);
}
- G_put_raster_row(cf, cell, data_type);
+ Rast_put_raster_row(cf, cell, data_type);
}
G_percent(row, nrows, 2);
@@ -861,25 +862,25 @@
/* -------------------------------------------------------------------- */
if (complex) {
G_debug(1, "Creating support files for %s", outputReal);
- G_close_cell(cfR);
- G_short_history((char *)outputReal, "raster", &history);
- G_command_history(&history);
- G_write_history((char *)outputReal, &history);
+ Rast_close_cell(cfR);
+ Rast_short_history((char *)outputReal, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history((char *)outputReal, &history);
G_debug(1, "Creating support files for %s", outputImg);
- G_close_cell(cfI);
- G_short_history((char *)outputImg, "raster", &history);
- G_command_history(&history);
- G_write_history((char *)outputImg, &history);
+ Rast_close_cell(cfI);
+ Rast_short_history((char *)outputImg, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history((char *)outputImg, &history);
G_free(bufComplex);
}
else {
G_debug(1, "Creating support files for %s", output);
- G_close_cell(cf);
- G_short_history((char *)output, "raster", &history);
- G_command_history(&history);
- G_write_history((char *)output, &history);
+ Rast_close_cell(cf);
+ Rast_short_history((char *)output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history((char *)output, &history);
}
if (nullFlags != NULL)
@@ -897,7 +898,7 @@
hCT = GDALGetRasterColorTable(hBand);
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
for (iColor = 0; iColor < GDALGetColorEntryCount(hCT); iColor++) {
GDALColorEntry sEntry;
@@ -905,10 +906,10 @@
if (sEntry.c4 == 0)
continue;
- G_set_color(iColor, sEntry.c1, sEntry.c2, sEntry.c3, &colors);
+ Rast_set_color(iColor, sEntry.c1, sEntry.c2, sEntry.c3, &colors);
}
- G_write_colors((char *)output, G_mapset(), &colors);
+ Rast_write_colors((char *)output, G_mapset(), &colors);
}
else { /* no color table present */
@@ -920,9 +921,9 @@
G_verbose_message(_("Setting grey color table for <%s> (8bit, full range)"),
output);
- G_init_colors(&colors);
- G_make_grey_scale_colors(&colors, 0, 255); /* full range */
- G_write_colors((char *)output, G_mapset(), &colors);
+ Rast_init_colors(&colors);
+ Rast_make_grey_scale_colors(&colors, 0, 255); /* full range */
+ Rast_write_colors((char *)output, G_mapset(), &colors);
}
if ((GDALGetRasterDataType(hBand) == GDT_UInt16)) {
/* found 0..65535 data: we set to grey scale: */
@@ -932,12 +933,12 @@
G_verbose_message(_("Setting grey color table for <%s> (16bit, image range)"),
output);
- G_read_range((char *)output, G_mapset(), &range);
- G_get_range_min_max(&range, &min, &max);
+ Rast_read_range((char *)output, G_mapset(), &range);
+ Rast_get_range_min_max(&range, &min, &max);
- G_init_colors(&colors);
- G_make_grey_scale_colors(&colors, min, max); /* image range */
- G_write_colors((char *)output, G_mapset(), &colors);
+ Rast_init_colors(&colors);
+ Rast_make_grey_scale_colors(&colors, min, max); /* image range */
+ Rast_write_colors((char *)output, G_mapset(), &colors);
}
}
Modified: grass/trunk/raster/r.in.gridatb/file_io.c
===================================================================
--- grass/trunk/raster/r.in.gridatb/file_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.gridatb/file_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -42,7 +43,7 @@
}
}
- fd = G_open_raster_new(oname, FCELL_TYPE);
+ fd = Rast_open_raster_new(oname, FCELL_TYPE);
cell = (FCELL *) G_malloc(sizeof(FCELL) * cellhd.cols);
@@ -53,20 +54,20 @@
idx = 9999.0;
fscanf(fp, "%f", &idx);
if (idx >= 9999.0) {
- G_set_f_null_value(&(cell[j]), 1);
+ Rast_set_f_null_value(&(cell[j]), 1);
}
else {
cell[j] = idx;
}
}
- G_put_f_raster_row(fd, cell);
+ Rast_put_f_raster_row(fd, cell);
}
G_percent(i, cellhd.rows, 2);
fclose(fp);
- G_close_cell(fd);
+ Rast_close_cell(fd);
- G_put_cell_title(oname, buf);
- G_put_cellhd(oname, &cellhd);
+ Rast_put_cell_title(oname, buf);
+ Rast_put_cellhd(oname, &cellhd);
return;
}
Modified: grass/trunk/raster/r.in.gridatb/local_proto.h
===================================================================
--- grass/trunk/raster/r.in.gridatb/local_proto.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.gridatb/local_proto.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
int check_ready(void);
int adjcellhd(struct Cell_head *cellhd);
Modified: grass/trunk/raster/r.in.gridatb/main.c
===================================================================
--- grass/trunk/raster/r.in.gridatb/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.gridatb/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include "local_proto.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct Cell_head cellhd;
Modified: grass/trunk/raster/r.in.mat/main.c
===================================================================
--- grass/trunk/raster/r.in.mat/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.mat/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
/* typedef unsigned short uint16;
@@ -294,21 +295,21 @@
G_debug(1, " double map");
map_type = DCELL_TYPE;
array_data =
- G_calloc(mrows * (ncols + 1), G_raster_size(map_type));
+ G_calloc(mrows * (ncols + 1), Rast_raster_size(map_type));
fread(array_data, sizeof(double), mrows * ncols, fp1);
break;
case 1:
G_debug(1, " float map");
map_type = FCELL_TYPE;
array_data =
- G_calloc(mrows * (ncols + 1), G_raster_size(map_type));
+ G_calloc(mrows * (ncols + 1), Rast_raster_size(map_type));
fread(array_data, sizeof(float), mrows * ncols, fp1);
break;
case 2:
G_debug(1, " int map");
map_type = CELL_TYPE;
array_data =
- G_calloc(mrows * (ncols + 1), G_raster_size(map_type));
+ G_calloc(mrows * (ncols + 1), Rast_raster_size(map_type));
fread(array_data, sizeof(int), mrows * ncols, fp1);
break;
default:
@@ -388,7 +389,7 @@
region.proj = G_projection();
region.zone = G_zone();
- err = G_adjust_Cell_head(®ion, 1, 1);
+ err = Rast_adjust_Cell_head(®ion, 1, 1);
if (err)
G_fatal_error(err);
G_set_window(®ion);
@@ -406,9 +407,9 @@
G_verbose_message("");
/* prep memory */
- raster = G_allocate_raster_buf(map_type);
+ raster = Rast_allocate_raster_buf(map_type);
- cf = G_open_raster_new(map_name, map_type);
+ cf = Rast_open_raster_new(map_name, map_type);
if (cf < 0)
G_fatal_error(_("Unable to create raster map <%s>"), outfile);
@@ -423,54 +424,54 @@
for (col = 0; col < ncols; col++) {
array_ptr = array_data;
array_ptr =
- G_incr_void_ptr(array_ptr,
+ Rast_incr_void_ptr(array_ptr,
(row +
- col * mrows) * G_raster_size(map_type));
+ col * mrows) * Rast_raster_size(map_type));
if (is_nan(array_ptr, map_type))
- G_set_null_value(rastline_ptr, 1, map_type);
+ Rast_set_null_value(rastline_ptr, 1, map_type);
else {
switch (map_type) {
case CELL_TYPE:
pval_i = (int *)array_ptr;
- G_set_raster_value_c(rastline_ptr, (CELL) pval_i[0],
+ Rast_set_raster_value_c(rastline_ptr, (CELL) pval_i[0],
map_type);
break;
case FCELL_TYPE:
pval_f = (float *)array_ptr;
- G_set_raster_value_f(rastline_ptr, (FCELL) pval_f[0],
+ Rast_set_raster_value_f(rastline_ptr, (FCELL) pval_f[0],
map_type);
break;
case DCELL_TYPE:
pval_d = (double *)array_ptr;
- G_set_raster_value_d(rastline_ptr, (DCELL) pval_d[0],
+ Rast_set_raster_value_d(rastline_ptr, (DCELL) pval_d[0],
map_type);
break;
default:
- G_close_cell(cf);
+ Rast_close_cell(cf);
G_fatal_error(_("Please contact the GRASS development team"));
}
}
rastline_ptr =
- G_incr_void_ptr(rastline_ptr, G_raster_size(map_type));
+ Rast_incr_void_ptr(rastline_ptr, Rast_raster_size(map_type));
}
#ifdef DEBUG
fprintf(stderr, "row[%d]=[", row);
rastline_ptr = raster;
for (col = 0; col < ncols; col++) {
- if (G_is_null_value(rastline_ptr, map_type))
+ if (Rast_is_null_value(rastline_ptr, map_type))
fprintf(stderr, "_");
else
fprintf(stderr, "+");
rastline_ptr =
- G_incr_void_ptr(rastline_ptr, G_raster_size(map_type));
+ Rast_incr_void_ptr(rastline_ptr, Rast_raster_size(map_type));
}
fprintf(stderr, "]\n");
#endif
- if (1 != G_put_raster_row(cf, raster, map_type)) {
- G_close_cell(cf);
+ if (1 != Rast_put_raster_row(cf, raster, map_type)) {
+ Rast_close_cell(cf);
G_fatal_error(_("Writing raster map, row %d"), row);
}
@@ -479,7 +480,7 @@
G_percent(row, mrows, 5); /* finish it off */
- G_close_cell(cf);
+ Rast_close_cell(cf);
G_free(array_data);
G_free(raster);
@@ -488,11 +489,11 @@
if (!have_title)
strncpy(map_title, infile, 1023);
- G_put_cell_title(map_name, map_title);
+ Rast_put_cell_title(map_name, map_title);
- G_short_history(map_name, "raster", &history);
- G_command_history(&history);
- G_write_history(map_name, &history);
+ Rast_short_history(map_name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(map_name, &history);
G_done_msg("");
@@ -516,7 +517,7 @@
switch (dtype) {
case CELL_TYPE: /* int doesn't have a IEEE NaN value, but we'll accept GRASS's version */
- if (G_is_null_value(p, dtype))
+ if (Rast_is_null_value(p, dtype))
return 1;
break;
case FCELL_TYPE:
Modified: grass/trunk/raster/r.in.poly/get_item.c
===================================================================
--- grass/trunk/raster/r.in.poly/get_item.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.poly/get_item.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
int get_item(FILE * fd, int *type, long *cat, double **x, double **y,
int *count, struct Categories *labels)
{
@@ -65,7 +66,7 @@
/* probably change this as G_getl2() doesn't store the new line (?) */
if (sscanf(buf + 1, "%ld%[^\n]", cat, lbl) == 2) {
G_strip(lbl);
- G_set_cat((CELL) * cat, lbl, labels);
+ Rast_set_cat((CELL) * cat, lbl, labels);
}
continue;
}
Modified: grass/trunk/raster/r.in.poly/getformat.c
===================================================================
--- grass/trunk/raster/r.in.poly/getformat.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.poly/getformat.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "format.h"
int getformat(FILE * fd)
Modified: grass/trunk/raster/r.in.poly/main.c
===================================================================
--- grass/trunk/raster/r.in.poly/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.poly/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
*****************************************************************************/
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.in.poly/poly2rast.c
===================================================================
--- grass/trunk/raster/r.in.poly/poly2rast.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.poly/poly2rast.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "format.h"
#include "local_proto.h"
@@ -31,7 +32,7 @@
exit(EXIT_FAILURE);
}
- rfd = G_open_cell_new(raster_map);
+ rfd = Rast_open_cell_new(raster_map);
if (rfd < 0)
G_fatal_error(_("Can't create raster map <%s>"), raster_map);
@@ -39,7 +40,7 @@
title = "";
G_strip(title);
- G_init_cats((CELL) 0, title, &labels);
+ Rast_init_cats((CELL) 0, title, &labels);
format = getformat(ifd);
npasses = begin_rasterization(nrows, format);
@@ -80,15 +81,15 @@
*/
if (stat < 0) {
- G_unopen_cell(rfd);
+ Rast_unopen_cell(rfd);
return 1;
}
- G_close_cell(rfd);
- G_write_cats(raster_map, &labels);
- G_short_history(raster_map, "raster", &history);
- G_command_history(&history);
- G_write_history(raster_map, &history);
+ Rast_close_cell(rfd);
+ Rast_write_cats(raster_map, &labels);
+ Rast_short_history(raster_map, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(raster_map, &history);
return 0;
}
Modified: grass/trunk/raster/r.in.poly/raster.c
===================================================================
--- grass/trunk/raster/r.in.poly/raster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.poly/raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "format.h"
#include "local_proto.h"
@@ -81,7 +82,7 @@
break;
}
if (format != USE_CELL)
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
at_row = 0;
configure_plot();
@@ -157,7 +158,7 @@
for (j = 0; j < page.cols; j++) {
cell[j] = (CELL) raster.c[i][j];
if (cell[j] == 0)
- G_set_null_value(&cell[j], 1, CELL_TYPE);
+ Rast_set_null_value(&cell[j], 1, CELL_TYPE);
}
break;
@@ -165,7 +166,7 @@
for (j = 0; j < page.cols; j++) {
cell[j] = (CELL) raster.u[i][j];
if (cell[j] == 0)
- G_set_null_value(&cell[j], 1, CELL_TYPE);
+ Rast_set_null_value(&cell[j], 1, CELL_TYPE);
}
break;
@@ -173,19 +174,19 @@
for (j = 0; j < page.cols; j++) {
cell[j] = (CELL) raster.s[i][j];
if (cell[j] == 0)
- G_set_null_value(&cell[j], 1, CELL_TYPE);
+ Rast_set_null_value(&cell[j], 1, CELL_TYPE);
}
break;
case USE_CELL:
cell = raster.cell[i];
if (cell == 0)
- G_set_null_value(&cell, 1, CELL_TYPE);
+ Rast_set_null_value(&cell, 1, CELL_TYPE);
break;
}
G_percent(i, page.rows, 2);
- if (G_put_raster_row(fd, cell, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(fd, cell, CELL_TYPE) < 0)
return ERROR;
}
G_percent(i, page.rows, 2);
Modified: grass/trunk/raster/r.in.xyz/local_proto.h
===================================================================
--- grass/trunk/raster/r.in.xyz/local_proto.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.xyz/local_proto.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#define BUFFSIZE 256
Modified: grass/trunk/raster/r.in.xyz/main.c
===================================================================
--- grass/trunk/raster/r.in.xyz/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.xyz/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <math.h>
#include <sys/types.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -427,18 +428,18 @@
if (!scan_flag->answer) {
/* allocate memory (test for enough before we start) */
if (bin_n)
- n_array = G_calloc(rows * (cols + 1), G_raster_size(CELL_TYPE));
+ n_array = G_calloc(rows * (cols + 1), Rast_raster_size(CELL_TYPE));
if (bin_min)
- min_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ min_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
if (bin_max)
- max_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ max_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
if (bin_sum)
- sum_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ sum_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
if (bin_sumsq)
- sumsq_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ sumsq_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
if (bin_index)
index_array =
- G_calloc(rows * (cols + 1), G_raster_size(CELL_TYPE));
+ G_calloc(rows * (cols + 1), Rast_raster_size(CELL_TYPE));
/* and then free it again */
if (bin_n)
@@ -492,7 +493,7 @@
/* open output map */
- out_fd = G_open_raster_new(outmap, rtype);
+ out_fd = Rast_open_raster_new(outmap, rtype);
if (out_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), outmap);
@@ -515,7 +516,7 @@
estimated_lines = -1;
/* allocate memory for a single row of output data */
- raster_row = G_allocate_raster_buf(rtype);
+ raster_row = Rast_allocate_raster_buf(rtype);
G_message(_("Scanning data ..."));
@@ -541,33 +542,33 @@
if (bin_n) {
G_debug(2, "allocating n_array");
- n_array = G_calloc(rows * (cols + 1), G_raster_size(CELL_TYPE));
+ n_array = G_calloc(rows * (cols + 1), Rast_raster_size(CELL_TYPE));
blank_array(n_array, rows, cols, CELL_TYPE, 0);
}
if (bin_min) {
G_debug(2, "allocating min_array");
- min_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ min_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
blank_array(min_array, rows, cols, rtype, -1); /* fill with NULLs */
}
if (bin_max) {
G_debug(2, "allocating max_array");
- max_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ max_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
blank_array(max_array, rows, cols, rtype, -1); /* fill with NULLs */
}
if (bin_sum) {
G_debug(2, "allocating sum_array");
- sum_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ sum_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
blank_array(sum_array, rows, cols, rtype, 0);
}
if (bin_sumsq) {
G_debug(2, "allocating sumsq_array");
- sumsq_array = G_calloc(rows * (cols + 1), G_raster_size(rtype));
+ sumsq_array = G_calloc(rows * (cols + 1), Rast_raster_size(rtype));
blank_array(sumsq_array, rows, cols, rtype, 0);
}
if (bin_index) {
G_debug(2, "allocating index_array");
index_array =
- G_calloc(rows * (cols + 1), G_raster_size(CELL_TYPE));
+ G_calloc(rows * (cols + 1), Rast_raster_size(CELL_TYPE));
blank_array(index_array, rows, cols, CELL_TYPE, -1); /* fill with NULLs */
}
@@ -688,22 +689,22 @@
if (bin_index) {
ptr = index_array;
ptr =
- G_incr_void_ptr(ptr,
+ Rast_incr_void_ptr(ptr,
((arr_row * cols) +
- arr_col) * G_raster_size(CELL_TYPE));
+ arr_col) * Rast_raster_size(CELL_TYPE));
- if (G_is_null_value(ptr, CELL_TYPE)) { /* first node */
+ if (Rast_is_null_value(ptr, CELL_TYPE)) { /* first node */
head_id = new_node();
nodes[head_id].next = -1;
nodes[head_id].z = z;
- G_set_raster_value_c(ptr, head_id, CELL_TYPE); /* store index to head */
+ Rast_set_raster_value_c(ptr, head_id, CELL_TYPE); /* store index to head */
}
else { /* head is already there */
- head_id = G_get_raster_value_c(ptr, CELL_TYPE); /* get index to head */
+ head_id = Rast_get_raster_value_c(ptr, CELL_TYPE); /* get index to head */
head_id = add_node(head_id, z);
if (head_id != -1)
- G_set_raster_value_c(ptr, head_id, CELL_TYPE); /* store index to head */
+ Rast_set_raster_value_c(ptr, head_id, CELL_TYPE); /* store index to head */
}
}
} /* while !EOF */
@@ -719,55 +720,55 @@
switch (method) {
case METHOD_N: /* n is a straight copy */
- G_raster_cpy(raster_row,
+ Rast_raster_cpy(raster_row,
n_array +
- (row * cols * G_raster_size(CELL_TYPE)), cols,
+ (row * cols * Rast_raster_size(CELL_TYPE)), cols,
CELL_TYPE);
break;
case METHOD_MIN:
- G_raster_cpy(raster_row,
- min_array + (row * cols * G_raster_size(rtype)),
+ Rast_raster_cpy(raster_row,
+ min_array + (row * cols * Rast_raster_size(rtype)),
cols, rtype);
break;
case METHOD_MAX:
- G_raster_cpy(raster_row,
- max_array + (row * cols * G_raster_size(rtype)),
+ Rast_raster_cpy(raster_row,
+ max_array + (row * cols * Rast_raster_size(rtype)),
cols, rtype);
break;
case METHOD_SUM:
- G_raster_cpy(raster_row,
- sum_array + (row * cols * G_raster_size(rtype)),
+ Rast_raster_cpy(raster_row,
+ sum_array + (row * cols * Rast_raster_size(rtype)),
cols, rtype);
break;
case METHOD_RANGE: /* (max-min) */
ptr = raster_row;
for (col = 0; col < cols; col++) {
- offset = (row * cols + col) * G_raster_size(rtype);
- min = G_get_raster_value_d(min_array + offset, rtype);
- max = G_get_raster_value_d(max_array + offset, rtype);
- G_set_raster_value_d(ptr, max - min, rtype);
- ptr = G_incr_void_ptr(ptr, G_raster_size(rtype));
+ offset = (row * cols + col) * Rast_raster_size(rtype);
+ min = Rast_get_raster_value_d(min_array + offset, rtype);
+ max = Rast_get_raster_value_d(max_array + offset, rtype);
+ Rast_set_raster_value_d(ptr, max - min, rtype);
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(rtype));
}
break;
case METHOD_MEAN: /* (sum / n) */
ptr = raster_row;
for (col = 0; col < cols; col++) {
- offset = (row * cols + col) * G_raster_size(rtype);
- n_offset = (row * cols + col) * G_raster_size(CELL_TYPE);
- n = G_get_raster_value_c(n_array + n_offset, CELL_TYPE);
- sum = G_get_raster_value_d(sum_array + offset, rtype);
+ offset = (row * cols + col) * Rast_raster_size(rtype);
+ n_offset = (row * cols + col) * Rast_raster_size(CELL_TYPE);
+ n = Rast_get_raster_value_c(n_array + n_offset, CELL_TYPE);
+ sum = Rast_get_raster_value_d(sum_array + offset, rtype);
if (n == 0)
- G_set_null_value(ptr, 1, rtype);
+ Rast_set_null_value(ptr, 1, rtype);
else
- G_set_raster_value_d(ptr, (sum / n), rtype);
+ Rast_set_raster_value_d(ptr, (sum / n), rtype);
- ptr = G_incr_void_ptr(ptr, G_raster_size(rtype));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(rtype));
}
break;
@@ -776,45 +777,45 @@
case METHOD_COEFF_VAR: /* 100 * stdev / mean */
ptr = raster_row;
for (col = 0; col < cols; col++) {
- offset = (row * cols + col) * G_raster_size(rtype);
- n_offset = (row * cols + col) * G_raster_size(CELL_TYPE);
- n = G_get_raster_value_c(n_array + n_offset, CELL_TYPE);
- sum = G_get_raster_value_d(sum_array + offset, rtype);
- sumsq = G_get_raster_value_d(sumsq_array + offset, rtype);
+ offset = (row * cols + col) * Rast_raster_size(rtype);
+ n_offset = (row * cols + col) * Rast_raster_size(CELL_TYPE);
+ n = Rast_get_raster_value_c(n_array + n_offset, CELL_TYPE);
+ sum = Rast_get_raster_value_d(sum_array + offset, rtype);
+ sumsq = Rast_get_raster_value_d(sumsq_array + offset, rtype);
if (n == 0)
- G_set_null_value(ptr, 1, rtype);
+ Rast_set_null_value(ptr, 1, rtype);
else {
variance = (sumsq - sum * sum / n) / n;
if (variance < GRASS_EPSILON)
variance = 0.0;
if (method == METHOD_STDDEV)
- G_set_raster_value_d(ptr, sqrt(variance), rtype);
+ Rast_set_raster_value_d(ptr, sqrt(variance), rtype);
else if (method == METHOD_VARIANCE)
- G_set_raster_value_d(ptr, variance, rtype);
+ Rast_set_raster_value_d(ptr, variance, rtype);
else if (method == METHOD_COEFF_VAR)
- G_set_raster_value_d(ptr,
+ Rast_set_raster_value_d(ptr,
100 * sqrt(variance) / (sum /
n),
rtype);
}
- ptr = G_incr_void_ptr(ptr, G_raster_size(rtype));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(rtype));
}
break;
case METHOD_MEDIAN: /* median, if only one point in cell we will use that */
ptr = raster_row;
for (col = 0; col < cols; col++) {
- n_offset = (row * cols + col) * G_raster_size(CELL_TYPE);
- if (G_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
- G_set_null_value(ptr, 1, rtype);
+ n_offset = (row * cols + col) * Rast_raster_size(CELL_TYPE);
+ if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
+ Rast_set_null_value(ptr, 1, rtype);
else { /* one or more points in cell */
head_id =
- G_get_raster_value_c(index_array + n_offset,
+ Rast_get_raster_value_c(index_array + n_offset,
CELL_TYPE);
node_id = head_id;
@@ -826,7 +827,7 @@
}
if (n == 1) /* only one point, use that */
- G_set_raster_value_d(ptr, nodes[head_id].z,
+ Rast_set_raster_value_d(ptr, nodes[head_id].z,
rtype);
else if (n % 2 != 0) { /* odd number of points: median_i = (n + 1) / 2 */
n = (n + 1) / 2;
@@ -834,7 +835,7 @@
for (j = 1; j < n; j++) /* get "median element" */
node_id = nodes[node_id].next;
- G_set_raster_value_d(ptr, nodes[node_id].z,
+ Rast_set_raster_value_d(ptr, nodes[node_id].z,
rtype);
}
else { /* even number of points: median = (val_below + val_above) / 2 */
@@ -847,21 +848,21 @@
z = (nodes[node_id].z +
nodes[nodes[node_id].next].z) / 2;
- G_set_raster_value_d(ptr, z, rtype);
+ Rast_set_raster_value_d(ptr, z, rtype);
}
}
- ptr = G_incr_void_ptr(ptr, G_raster_size(rtype));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(rtype));
}
break;
case METHOD_PERCENTILE: /* rank = (pth*(n+1))/100; interpolate linearly */
ptr = raster_row;
for (col = 0; col < cols; col++) {
- n_offset = (row * cols + col) * G_raster_size(CELL_TYPE);
- if (G_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
- G_set_null_value(ptr, 1, rtype);
+ n_offset = (row * cols + col) * Rast_raster_size(CELL_TYPE);
+ if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
+ Rast_set_null_value(ptr, 1, rtype);
else {
head_id =
- G_get_raster_value_c(index_array + n_offset,
+ Rast_get_raster_value_c(index_array + n_offset,
CELL_TYPE);
node_id = head_id;
n = 0;
@@ -892,20 +893,20 @@
node_id = nodes[node_id].next;
z = (z + nodes[node_id].z) / 2;
- G_set_raster_value_d(ptr, z, rtype);
+ Rast_set_raster_value_d(ptr, z, rtype);
}
- ptr = G_incr_void_ptr(ptr, G_raster_size(rtype));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(rtype));
}
break;
case METHOD_SKEWNESS: /* skewness = sum(xi-mean)^3/(N-1)*s^3 */
ptr = raster_row;
for (col = 0; col < cols; col++) {
- n_offset = (row * cols + col) * G_raster_size(CELL_TYPE);
- if (G_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
- G_set_null_value(ptr, 1, rtype);
+ n_offset = (row * cols + col) * Rast_raster_size(CELL_TYPE);
+ if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
+ Rast_set_null_value(ptr, 1, rtype);
else {
head_id =
- G_get_raster_value_c(index_array + n_offset,
+ Rast_get_raster_value_c(index_array + n_offset,
CELL_TYPE);
node_id = head_id;
@@ -940,20 +941,20 @@
sumdev / ((n - 1) *
pow(sqrt(variance), 3));
}
- G_set_raster_value_d(ptr, skew, rtype);
+ Rast_set_raster_value_d(ptr, skew, rtype);
}
- ptr = G_incr_void_ptr(ptr, G_raster_size(rtype));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(rtype));
}
break;
case METHOD_TRIMMEAN:
ptr = raster_row;
for (col = 0; col < cols; col++) {
- n_offset = (row * cols + col) * G_raster_size(CELL_TYPE);
- if (G_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
- G_set_null_value(ptr, 1, rtype);
+ n_offset = (row * cols + col) * Rast_raster_size(CELL_TYPE);
+ if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */
+ Rast_set_null_value(ptr, 1, rtype);
else {
head_id =
- G_get_raster_value_c(index_array + n_offset,
+ Rast_get_raster_value_c(index_array + n_offset,
CELL_TYPE);
node_id = head_id;
@@ -997,9 +998,9 @@
}
mean = sum / n;
}
- G_set_raster_value_d(ptr, mean, rtype);
+ Rast_set_raster_value_d(ptr, mean, rtype);
}
- ptr = G_incr_void_ptr(ptr, G_raster_size(rtype));
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(rtype));
}
break;
@@ -1008,8 +1009,8 @@
}
/* write out line of raster data */
- if (1 != G_put_raster_row(out_fd, raster_row, rtype)) {
- G_close_cell(out_fd);
+ if (1 != Rast_put_raster_row(out_fd, raster_row, rtype)) {
+ Rast_close_cell(out_fd);
G_fatal_error(_("Writing map, row %d"),
((pass - 1) * rows) + row);
}
@@ -1044,17 +1045,17 @@
fclose(in_fp);
/* close raster file & write history */
- G_close_cell(out_fd);
+ Rast_close_cell(out_fd);
sprintf(title, "Raw x,y,z data binned into a raster grid by cell %s",
method_opt->answer);
- G_put_cell_title(outmap, title);
+ Rast_put_cell_title(outmap, title);
- G_short_history(outmap, "raster", &history);
- G_command_history(&history);
+ Rast_short_history(outmap, "raster", &history);
+ Rast_command_history(&history);
strncpy(history.datsrc_1, infile, RECORD_LEN);
history.datsrc_1[RECORD_LEN - 1] = '\0'; /* strncpy() doesn't null terminate if maxfill */
- G_write_history(outmap, &history);
+ Rast_write_history(outmap, &history);
sprintf(buff, _("%lu points found in region."), count_total);
Modified: grass/trunk/raster/r.in.xyz/support.c
===================================================================
--- grass/trunk/raster/r.in.xyz/support.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.in.xyz/support.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,14 +9,15 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
static void *get_cell_ptr(void *array, int cols, int row, int col,
RASTER_MAP_TYPE map_type)
{
- return G_incr_void_ptr(array,
+ return Rast_incr_void_ptr(array,
((row * (size_t) cols) +
- col) * G_raster_size(map_type));
+ col) * Rast_raster_size(map_type));
}
int blank_array(void *array, int nrows, int ncols, RASTER_MAP_TYPE map_type,
@@ -32,12 +33,12 @@
switch (value) {
case 0:
/* fill with 0 */
- /* simpler to use G_raster_cpy() or similar ?? */
+ /* simpler to use Rast_raster_cpy() or similar ?? */
for (row = 0; row < nrows; row++) {
for (col = 0; col < ncols; col++) {
- G_set_raster_value_c(ptr, 0, map_type);
- ptr = G_incr_void_ptr(ptr, G_raster_size(map_type));
+ Rast_set_raster_value_c(ptr, 0, map_type);
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(map_type));
}
}
break;
@@ -45,7 +46,7 @@
case -1:
/* fill with NULL */
/* alloc for col+1, do we come up (nrows) short? no. */
- G_set_null_value(array, nrows * ncols, map_type);
+ Rast_set_null_value(array, nrows * ncols, map_type);
break;
default:
@@ -61,8 +62,8 @@
void *ptr = get_cell_ptr(array, cols, row, col, CELL_TYPE);
CELL old_n;
- old_n = G_get_raster_value_c(ptr, CELL_TYPE);
- G_set_raster_value_c(ptr, (1 + old_n), CELL_TYPE);
+ old_n = Rast_get_raster_value_c(ptr, CELL_TYPE);
+ Rast_set_raster_value_c(ptr, (1 + old_n), CELL_TYPE);
return 0;
}
@@ -74,12 +75,12 @@
void *ptr = get_cell_ptr(array, cols, row, col, map_type);
DCELL old_val;
- if (G_is_null_value(ptr, map_type))
- G_set_raster_value_d(ptr, (DCELL) value, map_type);
+ if (Rast_is_null_value(ptr, map_type))
+ Rast_set_raster_value_d(ptr, (DCELL) value, map_type);
else {
- old_val = G_get_raster_value_d(ptr, map_type);
+ old_val = Rast_get_raster_value_d(ptr, map_type);
if (value < old_val)
- G_set_raster_value_d(ptr, (DCELL) value, map_type);
+ Rast_set_raster_value_d(ptr, (DCELL) value, map_type);
}
return 0;
}
@@ -91,12 +92,12 @@
void *ptr = get_cell_ptr(array, cols, row, col, map_type);
DCELL old_val;
- if (G_is_null_value(ptr, map_type))
- G_set_raster_value_d(ptr, (DCELL) value, map_type);
+ if (Rast_is_null_value(ptr, map_type))
+ Rast_set_raster_value_d(ptr, (DCELL) value, map_type);
else {
- old_val = G_get_raster_value_d(ptr, map_type);
+ old_val = Rast_get_raster_value_d(ptr, map_type);
if (value > old_val)
- G_set_raster_value_d(ptr, (DCELL) value, map_type);
+ Rast_set_raster_value_d(ptr, (DCELL) value, map_type);
}
return 0;
@@ -109,8 +110,8 @@
void *ptr = get_cell_ptr(array, cols, row, col, map_type);
DCELL old_val;
- old_val = G_get_raster_value_d(ptr, map_type);
- G_set_raster_value_d(ptr, value + old_val, map_type);
+ old_val = Rast_get_raster_value_d(ptr, map_type);
+ Rast_set_raster_value_d(ptr, value + old_val, map_type);
return 0;
}
@@ -122,8 +123,8 @@
void *ptr = get_cell_ptr(array, cols, row, col, map_type);
DCELL old_val;
- old_val = G_get_raster_value_d(ptr, map_type);
- G_set_raster_value_d(ptr, (value * value) + old_val, map_type);
+ old_val = Rast_get_raster_value_d(ptr, map_type);
+ Rast_set_raster_value_d(ptr, (value * value) + old_val, map_type);
return 0;
}
Modified: grass/trunk/raster/r.info/main.c
===================================================================
--- grass/trunk/raster/r.info/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.info/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <string.h>
#include <stdarg.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -117,15 +118,15 @@
if ((mapset = G_find_cell2(name, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
- head_ok = G_get_cellhd(name, "", &cellhd) >= 0;
- cats_ok = G_read_cats(name, "", &cats) >= 0;
- hist_ok = G_read_history(name, "", &hist) >= 0;
- is_reclass = G_get_reclass(name, "", &reclass);
- data_type = G_raster_map_type(name, "");
+ head_ok = Rast_get_cellhd(name, "", &cellhd) >= 0;
+ cats_ok = Rast_read_cats(name, "", &cats) >= 0;
+ hist_ok = Rast_read_history(name, "", &hist) >= 0;
+ is_reclass = Rast_get_reclass(name, "", &reclass);
+ data_type = Rast_raster_map_type(name, "");
- if (G_read_raster_units(name, "", units) != 0)
+ if (Rast_read_raster_units(name, "", units) != 0)
units[0] = '\0';
- if (G_read_raster_vdatum(name, "", vdatum) != 0)
+ if (Rast_read_raster_vdatum(name, "", vdatum) != 0)
vdatum[0] = '\0';
/*Check the Timestamp */
@@ -138,9 +139,9 @@
second_time_ok = 1;
}
- if (G_read_fp_range(name, "", &range) < 0)
+ if (Rast_read_fp_range(name, "", &range) < 0)
G_fatal_error(_("Unable to read range file"));
- G_get_fp_range_min_max(&range, &zmin, &zmax);
+ Rast_get_fp_range_min_max(&range, &zmin, &zmax);
out = stdout;
@@ -228,7 +229,7 @@
tmp1, tmp2, tmp3);
if (data_type == CELL_TYPE) {
- if (2 == G_read_range(name, "", &crange))
+ if (2 == Rast_read_range(name, "", &crange))
compose_line(out,
" Range of data: min = NULL max = NULL");
else
@@ -282,7 +283,7 @@
for (i = 0; i < reclass.num; i++) {
CELL x = reclass.table[i];
- if (G_is_c_null_value(&x))
+ if (Rast_is_c_null_value(&x))
continue;
if (first || x < mincat)
mincat = x;
@@ -320,7 +321,7 @@
if (rflag->answer) {
if (data_type == CELL_TYPE) {
- if (2 == G_read_range(name, "", &crange)) {
+ if (2 == Rast_read_range(name, "", &crange)) {
fprintf(out, "min=NULL\n");
fprintf(out, "max=NULL\n");
}
Modified: grass/trunk/raster/r.info/reclas_txt.c
===================================================================
--- grass/trunk/raster/r.info/reclas_txt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.info/reclas_txt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.kappa/calc_kappa.c
===================================================================
--- grass/trunk/raster/r.kappa/calc_kappa.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/calc_kappa.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "kappa.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.kappa/kappa.h
===================================================================
--- grass/trunk/raster/r.kappa/kappa.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/kappa.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <math.h>
struct _gstats_
Modified: grass/trunk/raster/r.kappa/main.c
===================================================================
--- grass/trunk/raster/r.kappa/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
#include "kappa.h"
@@ -145,5 +146,5 @@
layers = (LAYER *) G_realloc(layers, 2 * sizeof(LAYER));
layers[n].name = G_store(name);
layers[n].mapset = mapset;
- G_read_cats(name, mapset, &layers[n].labels);
+ Rast_read_cats(name, mapset, &layers[n].labels);
}
Modified: grass/trunk/raster/r.kappa/mask.c
===================================================================
--- grass/trunk/raster/r.kappa/mask.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/mask.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,7 +19,7 @@
results = NULL;
if (G_find_cell("MASK", G_mapset()) == NULL)
return "none";
- if (G_get_reclass("MASK", G_mapset(), &reclass) <= 0) {
+ if (Rast_get_reclass("MASK", G_mapset(), &reclass) <= 0) {
sprintf(text, "MASK in %s", G_mapset());
return append(results, text);
}
@@ -39,7 +39,7 @@
results = append(results, " ");
results = append(results, text);
} while (next >= 0);
- G_free_reclass(&reclass);
+ Rast_free_reclass(&reclass);
return results;
}
Modified: grass/trunk/raster/r.kappa/prt_hdr.c
===================================================================
--- grass/trunk/raster/r.kappa/prt_hdr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/prt_hdr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,7 +31,7 @@
len = strlen(label);
for (i = 0; i < nlayers; i++) {
- titles = G_get_cats_title(&(layers[i].labels));
+ titles = Rast_get_cats_title(&(layers[i].labels));
if (titles)
G_strip(titles);
if (titles == NULL || *titles == 0)
Modified: grass/trunk/raster/r.kappa/prt_label.c
===================================================================
--- grass/trunk/raster/r.kappa/prt_label.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/prt_label.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,7 +23,7 @@
fprintf(fd, "MAP%-d Category Description\n", i + 1);
for (j = 0; j < ncat; j++) {
cats = rlst;
- cl = G_get_cat((CELL) cats[j], &(layers[i].labels));
+ cl = Rast_get_cat((CELL) cats[j], &(layers[i].labels));
if (cl)
G_strip(cl);
if (cl == NULL || *cl == 0)
Modified: grass/trunk/raster/r.kappa/prt_mat.c
===================================================================
--- grass/trunk/raster/r.kappa/prt_mat.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/prt_mat.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "kappa.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.kappa/stats.c
===================================================================
--- grass/trunk/raster/r.kappa/stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.kappa/stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <string.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "kappa.h"
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.lake/main.c
===================================================================
--- grass/trunk/raster/r.lake/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.lake/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
/* Saves map file from 2d array. NULL must be 0. Also meanwhile calculates area and volume. */
@@ -60,7 +61,7 @@
if (flag == 1) /* Create negative map */
out[row][col] = 0 - out[row][col];
if (out[row][col] == 0) {
- G_set_f_null_value(&out[row][col], 1);
+ Rast_set_f_null_value(&out[row][col], 1);
}
if (out[row][col] > 0 || out[row][col] < 0) {
G_debug(5, "volume %f += cellsize %f * value %f [%d,%d]",
@@ -75,7 +76,7 @@
if (out[row][col] < *min_depth)
*min_depth = out[row][col];
}
- if (G_put_f_raster_row(out_fd, out[row]) == -1)
+ if (Rast_put_f_raster_row(out_fd, out[row]) == -1)
G_fatal_error(_("Failed writing output raster map row %d"), row);
G_percent(row + 1, rows, 5);
}
@@ -212,7 +213,7 @@
/* If lakemap is set, write to it, else is set overwrite flag and we should write to seedmap. */
if (lakemap) {
- lake_fd = G_open_raster_new(lakemap, 1);
+ lake_fd = Rast_open_raster_new(lakemap, 1);
if (lake_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), lakemap);
}
@@ -237,13 +238,13 @@
}
/* Open terran map */
- in_terran_fd = G_open_cell_old(terrainmap, "");
+ in_terran_fd = Rast_open_cell_old(terrainmap, "");
if (in_terran_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), terrainmap);
/* Open seed map */
if (smap_opt->answer) {
- out_fd = G_open_cell_old(seedmap, "");
+ out_fd = Rast_open_cell_old(seedmap, "");
if (out_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), seedmap);
}
@@ -262,12 +263,12 @@
out_water[row] = (FCELL *) G_calloc(cols, sizeof(FCELL));
/* In newly created space load data from file. */
- if (G_get_f_raster_row(in_terran_fd, in_terran[row], row) != 1)
+ if (Rast_get_f_raster_row(in_terran_fd, in_terran[row], row) != 1)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
terrainmap, row);
if (smap_opt->answer)
- if (G_get_f_raster_row(out_fd, out_water[row], row) != 1)
+ if (Rast_get_f_raster_row(out_fd, out_water[row], row) != 1)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
seedmap, row);
@@ -284,14 +285,14 @@
/* Close seed map for reading. */
if (smap_opt->answer)
- G_close_cell(out_fd);
+ Rast_close_cell(out_fd);
/* Open output map for writing. */
if (lakemap) {
out_fd = lake_fd;
}
else {
- out_fd = G_open_raster_new(seedmap, 1);
+ out_fd = Rast_open_raster_new(seedmap, 1);
if (out_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), seedmap);
}
@@ -367,27 +368,27 @@
G_warning(_("Volume is correct only if lake depth (terrain raster map) is in meters"));
/* Close all files. Lake map gets written only now. */
- G_close_cell(in_terran_fd);
- G_close_cell(out_fd);
+ Rast_close_cell(in_terran_fd);
+ Rast_close_cell(out_fd);
/* Add blue color gradient from light bank to dark depth */
- G_init_colors(&colr);
+ Rast_init_colors(&colr);
if (negative_flag->answer == 1) {
- G_add_f_raster_color_rule(&max_depth, 0, 240, 255,
+ Rast_add_f_raster_color_rule(&max_depth, 0, 240, 255,
&min_depth, 0, 50, 170, &colr);
}
else {
- G_add_f_raster_color_rule(&min_depth, 0, 240, 255,
+ Rast_add_f_raster_color_rule(&min_depth, 0, 240, 255,
&max_depth, 0, 50, 170, &colr);
}
- if (G_write_colors(lakemap, G_mapset(), &colr) != 1)
+ if (Rast_write_colors(lakemap, G_mapset(), &colr) != 1)
G_fatal_error(_("Unable to read color file of raster map <%s>"),
lakemap);
- G_short_history(lakemap, "raster", &history);
- G_command_history(&history);
- G_write_history(lakemap, &history);
+ Rast_short_history(lakemap, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(lakemap, &history);
return EXIT_SUCCESS;
}
Modified: grass/trunk/raster/r.le/r.le.patch/driver.c
===================================================================
--- grass/trunk/raster/r.le/r.le.patch/driver.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.patch/driver.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -72,7 +72,7 @@
map remains open on finput while all the programs
run, so it is globally available */
- if (0 > (finput = G_open_cell_old(choice->fn, G_mapset()))) {
+ if (0 > (finput = Rast_open_cell_old(choice->fn, G_mapset()))) {
fprintf(stderr, "\n");
fprintf(stderr,
" ******* *************************************************\n");
@@ -90,7 +90,7 @@
double (DCELL_TYPE) and make globally available */
else
- data_type = G_raster_map_type(choice->fn, G_mapset());
+ data_type = Rast_raster_map_type(choice->fn, G_mapset());
/* if using a moving window, get the parameters,
@@ -122,7 +122,7 @@
/* when everything is done, close the raster map
and print a completion message */
- G_close_cell(finput);
+ Rast_close_cell(finput);
fputs("\nR.LE.PATCH IS DONE; ", stderr);
if (choice->wrum != 'm')
fputs("OUTPUT FILES IN SUBDIRECTORY \"r.le.out\"\n", stderr);
@@ -551,49 +551,49 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a1,a1bak");
system(cmdbuf);
}
- a1 = G_open_raster_new("a1", DCELL_TYPE);
+ a1 = Rast_open_raster_new("a1", DCELL_TYPE);
}
if (choice->att[2]) {
if (G_find_cell("a2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a2,a2bak");
system(cmdbuf);
}
- a2 = G_open_raster_new("a2", DCELL_TYPE);
+ a2 = Rast_open_raster_new("a2", DCELL_TYPE);
}
if (choice->att[3]) {
if (G_find_cell("a3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a3,a3bak");
system(cmdbuf);
}
- a3 = G_open_raster_new("a3", DCELL_TYPE);
+ a3 = Rast_open_raster_new("a3", DCELL_TYPE);
}
if (choice->att[4]) {
if (G_find_cell("a4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a4,a4bak");
system(cmdbuf);
}
- a4 = G_open_raster_new("a4", DCELL_TYPE);
+ a4 = Rast_open_raster_new("a4", DCELL_TYPE);
}
if (choice->att[5]) {
if (G_find_cell("a5", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a5,a5bak");
system(cmdbuf);
}
- a5 = G_open_raster_new("a5", DCELL_TYPE);
+ a5 = Rast_open_raster_new("a5", DCELL_TYPE);
}
if (choice->att[6]) {
if (G_find_cell("a6", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a6,a6bak");
system(cmdbuf);
}
- a6 = G_open_raster_new("a6", DCELL_TYPE);
+ a6 = Rast_open_raster_new("a6", DCELL_TYPE);
}
if (choice->att[7]) {
if (G_find_cell("a7", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a7,a7bak");
system(cmdbuf);
}
- a7 = G_open_raster_new("a7", DCELL_TYPE);
+ a7 = Rast_open_raster_new("a7", DCELL_TYPE);
}
if (choice->att[8]) {
@@ -601,7 +601,7 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=a8,a8bak");
system(cmdbuf);
}
- a8 = G_open_raster_new("a8", DCELL_TYPE);
+ a8 = Rast_open_raster_new("a8", DCELL_TYPE);
}
if (choice->size[1]) {
@@ -609,42 +609,42 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s1,s1bak");
system(cmdbuf);
}
- s1 = G_open_raster_new("s1", DCELL_TYPE);
+ s1 = Rast_open_raster_new("s1", DCELL_TYPE);
}
if (choice->size[2]) {
if (G_find_cell("s2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s2,s2bak");
system(cmdbuf);
}
- s2 = G_open_raster_new("s2", DCELL_TYPE);
+ s2 = Rast_open_raster_new("s2", DCELL_TYPE);
}
if (choice->size[3]) {
if (G_find_cell("s3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s3,s3bak");
system(cmdbuf);
}
- s3 = G_open_raster_new("s3", DCELL_TYPE);
+ s3 = Rast_open_raster_new("s3", DCELL_TYPE);
}
if (choice->size[4]) {
if (G_find_cell("s4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s4,s4bak");
system(cmdbuf);
}
- s4 = G_open_raster_new("s4", DCELL_TYPE);
+ s4 = Rast_open_raster_new("s4", DCELL_TYPE);
}
if (choice->size[5]) {
if (G_find_cell("s5", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s5,s5bak");
system(cmdbuf);
}
- s5 = G_open_raster_new("s5", DCELL_TYPE);
+ s5 = Rast_open_raster_new("s5", DCELL_TYPE);
}
if (choice->size[6]) {
if (G_find_cell("s6", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s6,s6bak");
system(cmdbuf);
}
- s6 = G_open_raster_new("s6", DCELL_TYPE);
+ s6 = Rast_open_raster_new("s6", DCELL_TYPE);
}
if (choice->size[7]) {
@@ -652,7 +652,7 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s7,s7bak");
system(cmdbuf);
}
- s7 = G_open_raster_new("s7", DCELL_TYPE);
+ s7 = Rast_open_raster_new("s7", DCELL_TYPE);
}
if (choice->size[8]) {
@@ -660,7 +660,7 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=s8,s8bak");
system(cmdbuf);
}
- s8 = G_open_raster_new("s8", DCELL_TYPE);
+ s8 = Rast_open_raster_new("s8", DCELL_TYPE);
}
if (choice->core[1]) {
@@ -668,70 +668,70 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c1,c1bak");
system(cmdbuf);
}
- c1 = G_open_raster_new("c1", DCELL_TYPE);
+ c1 = Rast_open_raster_new("c1", DCELL_TYPE);
}
if (choice->core[2]) {
if (G_find_cell("c2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c2,c2bak");
system(cmdbuf);
}
- c2 = G_open_raster_new("c2", DCELL_TYPE);
+ c2 = Rast_open_raster_new("c2", DCELL_TYPE);
}
if (choice->core[3]) {
if (G_find_cell("c3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c3,c3bak");
system(cmdbuf);
}
- c3 = G_open_raster_new("c3", DCELL_TYPE);
+ c3 = Rast_open_raster_new("c3", DCELL_TYPE);
}
if (choice->core[4]) {
if (G_find_cell("c4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c4,c4bak");
system(cmdbuf);
}
- c4 = G_open_raster_new("c4", DCELL_TYPE);
+ c4 = Rast_open_raster_new("c4", DCELL_TYPE);
}
if (choice->core[5]) {
if (G_find_cell("c5", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c5,c5bak");
system(cmdbuf);
}
- c5 = G_open_raster_new("c5", DCELL_TYPE);
+ c5 = Rast_open_raster_new("c5", DCELL_TYPE);
}
if (choice->core[6]) {
if (G_find_cell("c6", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c6,c6bak");
system(cmdbuf);
}
- c6 = G_open_raster_new("c6", DCELL_TYPE);
+ c6 = Rast_open_raster_new("c6", DCELL_TYPE);
}
if (choice->core[7]) {
if (G_find_cell("c7", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c7,c7bak");
system(cmdbuf);
}
- c7 = G_open_raster_new("c7", DCELL_TYPE);
+ c7 = Rast_open_raster_new("c7", DCELL_TYPE);
}
if (choice->core[8]) {
if (G_find_cell("c8", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c8,c8bak");
system(cmdbuf);
}
- c8 = G_open_raster_new("c8", DCELL_TYPE);
+ c8 = Rast_open_raster_new("c8", DCELL_TYPE);
}
if (choice->core[9]) {
if (G_find_cell("c9", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c9,c9bak");
system(cmdbuf);
}
- c9 = G_open_raster_new("c9", DCELL_TYPE);
+ c9 = Rast_open_raster_new("c9", DCELL_TYPE);
}
if (choice->core[10]) {
if (G_find_cell("c10", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=c10,c10bak");
system(cmdbuf);
}
- c10 = G_open_raster_new("c10", DCELL_TYPE);
+ c10 = Rast_open_raster_new("c10", DCELL_TYPE);
}
if (choice->shape[1]) {
@@ -739,42 +739,42 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=h1,h1bak");
system(cmdbuf);
}
- h1 = G_open_raster_new("h1", DCELL_TYPE);
+ h1 = Rast_open_raster_new("h1", DCELL_TYPE);
}
if (choice->shape[2]) {
if (G_find_cell("h2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=h2,h2bak");
system(cmdbuf);
}
- h2 = G_open_raster_new("h2", DCELL_TYPE);
+ h2 = Rast_open_raster_new("h2", DCELL_TYPE);
}
if (choice->shape[3]) {
if (G_find_cell("h3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=h3,h3bak");
system(cmdbuf);
}
- h3 = G_open_raster_new("h3", DCELL_TYPE);
+ h3 = Rast_open_raster_new("h3", DCELL_TYPE);
}
if (choice->shape[4]) {
if (G_find_cell("h4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=h4,h4bak");
system(cmdbuf);
}
- h4 = G_open_raster_new("h4", DCELL_TYPE);
+ h4 = Rast_open_raster_new("h4", DCELL_TYPE);
}
if (choice->shape[5]) {
if (G_find_cell("h5", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=h5,h5bak");
system(cmdbuf);
}
- h5 = G_open_raster_new("h5", DCELL_TYPE);
+ h5 = Rast_open_raster_new("h5", DCELL_TYPE);
}
if (choice->shape[6]) {
if (G_find_cell("h6", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=h6,h6bak");
system(cmdbuf);
}
- h6 = G_open_raster_new("h6", DCELL_TYPE);
+ h6 = Rast_open_raster_new("h6", DCELL_TYPE);
}
if (choice->boundary[1]) {
@@ -782,7 +782,7 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=n1,n1bak");
system(cmdbuf);
}
- n1 = G_open_raster_new("n1", DCELL_TYPE);
+ n1 = Rast_open_raster_new("n1", DCELL_TYPE);
}
if (choice->boundary[2]) {
@@ -790,7 +790,7 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=n2,n2bak");
system(cmdbuf);
}
- n2 = G_open_raster_new("n2", DCELL_TYPE);
+ n2 = Rast_open_raster_new("n2", DCELL_TYPE);
}
if (choice->boundary[3]) {
@@ -798,7 +798,7 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=n3,n3bak");
system(cmdbuf);
}
- n3 = G_open_raster_new("n3", DCELL_TYPE);
+ n3 = Rast_open_raster_new("n3", DCELL_TYPE);
}
if (choice->boundary[4]) {
@@ -806,7 +806,7 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=n4,n4bak");
system(cmdbuf);
}
- n4 = G_open_raster_new("n4", DCELL_TYPE);
+ n4 = Rast_open_raster_new("n4", DCELL_TYPE);
}
if (choice->perim[1]) {
@@ -814,42 +814,42 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=p1,p1bak");
system(cmdbuf);
}
- p1 = G_open_raster_new("p1", DCELL_TYPE);
+ p1 = Rast_open_raster_new("p1", DCELL_TYPE);
}
if (choice->perim[2]) {
if (G_find_cell("p2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=p2,p2bak");
system(cmdbuf);
}
- p2 = G_open_raster_new("p2", DCELL_TYPE);
+ p2 = Rast_open_raster_new("p2", DCELL_TYPE);
}
if (choice->perim[3]) {
if (G_find_cell("p3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=p3,p3bak");
system(cmdbuf);
}
- p3 = G_open_raster_new("p3", DCELL_TYPE);
+ p3 = Rast_open_raster_new("p3", DCELL_TYPE);
}
if (choice->perim[4]) {
if (G_find_cell("p4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=p4,p4bak");
system(cmdbuf);
}
- p4 = G_open_raster_new("p4", DCELL_TYPE);
+ p4 = Rast_open_raster_new("p4", DCELL_TYPE);
}
if (choice->perim[5]) {
if (G_find_cell("p5", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=p5,p5bak");
system(cmdbuf);
}
- p5 = G_open_raster_new("p5", DCELL_TYPE);
+ p5 = Rast_open_raster_new("p5", DCELL_TYPE);
}
if (choice->perim[6]) {
if (G_find_cell("p6", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=p6,p6bak");
system(cmdbuf);
}
- p6 = G_open_raster_new("p6", DCELL_TYPE);
+ p6 = Rast_open_raster_new("p6", DCELL_TYPE);
}
/* get the moving window parameters */
@@ -915,7 +915,7 @@
fprintf(stderr,
" warning may be printed or appear in a window; ignore this warning.\n");
fprintf(stderr, "If a MASK is present there will be no warning.\n");
- fmask = G_open_cell_old("MASK", G_mapset());
+ fmask = Rast_open_cell_old("MASK", G_mapset());
fprintf(stderr, "\n");
/* allocate memory for the buffer that
@@ -933,7 +933,7 @@
a row of the MASK, if there is a MASK */
if (fmask > 0)
- row_buf = G_allocate_raster_buf(CELL_TYPE);
+ row_buf = Rast_allocate_raster_buf(CELL_TYPE);
/* main loop for clipping & measuring
using the moving-window */
@@ -955,8 +955,8 @@
process */
if (fmask > 0) {
- G_zero_raster_buf(row_buf, CELL_TYPE);
- G_get_raster_row_nomask(fmask, row_buf, y0 + i + u_l / 2,
+ Rast_zero_raster_buf(row_buf, CELL_TYPE);
+ Rast_get_raster_row_nomask(fmask, row_buf, y0 + i + u_l / 2,
CELL_TYPE);
/* for each cell whose value is "1"
@@ -1006,937 +1006,937 @@
maps; the map location is adjusted to the center
of the moving window */
- tmp_buf = G_allocate_raster_buf(DCELL_TYPE);
- nulltmp = G_allocate_null_buf();
+ tmp_buf = Rast_allocate_raster_buf(DCELL_TYPE);
+ nulltmp = Rast_allocate_null_buf();
if (choice->att[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a1, tmp_buf);
+ Rast_put_d_raster_row(a1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 0) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 0);
}
- G_put_d_raster_row(a1, tmp_buf);
+ Rast_put_d_raster_row(a1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a1, tmp_buf2);
+ Rast_put_d_raster_row(a1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a2, tmp_buf);
+ Rast_put_d_raster_row(a2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 1) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 1);
}
- G_put_d_raster_row(a2, tmp_buf);
+ Rast_put_d_raster_row(a2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a2, tmp_buf2);
+ Rast_put_d_raster_row(a2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a3, tmp_buf);
+ Rast_put_d_raster_row(a3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 2) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 2);
}
- G_put_d_raster_row(a3, tmp_buf);
+ Rast_put_d_raster_row(a3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a3, tmp_buf2);
+ Rast_put_d_raster_row(a3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a4, tmp_buf);
+ Rast_put_d_raster_row(a4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 3) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 3);
}
- G_put_d_raster_row(a4, tmp_buf);
+ Rast_put_d_raster_row(a4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a4, tmp_buf2);
+ Rast_put_d_raster_row(a4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[5]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a5, tmp_buf);
+ Rast_put_d_raster_row(a5, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 4) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 4);
}
- G_put_d_raster_row(a5, tmp_buf);
+ Rast_put_d_raster_row(a5, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a5, tmp_buf2);
+ Rast_put_d_raster_row(a5, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[6]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a6, tmp_buf);
+ Rast_put_d_raster_row(a6, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 5) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 5);
}
- G_put_d_raster_row(a6, tmp_buf);
+ Rast_put_d_raster_row(a6, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a6, tmp_buf2);
+ Rast_put_d_raster_row(a6, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[7]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a7, tmp_buf);
+ Rast_put_d_raster_row(a7, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 6) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 6);
}
- G_put_d_raster_row(a7, tmp_buf);
+ Rast_put_d_raster_row(a7, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a7, tmp_buf2);
+ Rast_put_d_raster_row(a7, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s1, tmp_buf);
+ Rast_put_d_raster_row(s1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 7) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 7);
}
- G_put_d_raster_row(s1, tmp_buf);
+ Rast_put_d_raster_row(s1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s1, tmp_buf2);
+ Rast_put_d_raster_row(s1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s2, tmp_buf);
+ Rast_put_d_raster_row(s2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 8) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 8);
}
- G_put_d_raster_row(s2, tmp_buf);
+ Rast_put_d_raster_row(s2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s2, tmp_buf2);
+ Rast_put_d_raster_row(s2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s3, tmp_buf);
+ Rast_put_d_raster_row(s3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 9) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 9);
}
- G_put_d_raster_row(s3, tmp_buf);
+ Rast_put_d_raster_row(s3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s3, tmp_buf2);
+ Rast_put_d_raster_row(s3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s4, tmp_buf);
+ Rast_put_d_raster_row(s4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 10) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 10);
}
- G_put_d_raster_row(s4, tmp_buf);
+ Rast_put_d_raster_row(s4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s4, tmp_buf2);
+ Rast_put_d_raster_row(s4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[5]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s5, tmp_buf);
+ Rast_put_d_raster_row(s5, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 11) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 11);
}
- G_put_d_raster_row(s5, tmp_buf);
+ Rast_put_d_raster_row(s5, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s5, tmp_buf2);
+ Rast_put_d_raster_row(s5, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[6]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s6, tmp_buf);
+ Rast_put_d_raster_row(s6, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 12) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 12);
}
- G_put_d_raster_row(s6, tmp_buf);
+ Rast_put_d_raster_row(s6, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s6, tmp_buf2);
+ Rast_put_d_raster_row(s6, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c1, tmp_buf);
+ Rast_put_d_raster_row(c1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 13) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 13);
}
- G_put_d_raster_row(c1, tmp_buf);
+ Rast_put_d_raster_row(c1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c1, tmp_buf2);
+ Rast_put_d_raster_row(c1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c2, tmp_buf);
+ Rast_put_d_raster_row(c2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 14) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 14);
}
- G_put_d_raster_row(c2, tmp_buf);
+ Rast_put_d_raster_row(c2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c2, tmp_buf2);
+ Rast_put_d_raster_row(c2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c3, tmp_buf);
+ Rast_put_d_raster_row(c3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 15) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 15);
}
- G_put_d_raster_row(c3, tmp_buf);
+ Rast_put_d_raster_row(c3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c3, tmp_buf2);
+ Rast_put_d_raster_row(c3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c4, tmp_buf);
+ Rast_put_d_raster_row(c4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 16) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 16);
}
- G_put_d_raster_row(c4, tmp_buf);
+ Rast_put_d_raster_row(c4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c4, tmp_buf2);
+ Rast_put_d_raster_row(c4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[5]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c5, tmp_buf);
+ Rast_put_d_raster_row(c5, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 17) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 17);
}
- G_put_d_raster_row(c5, tmp_buf);
+ Rast_put_d_raster_row(c5, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c5, tmp_buf2);
+ Rast_put_d_raster_row(c5, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[6]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c6, tmp_buf);
+ Rast_put_d_raster_row(c6, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 18) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 18);
}
- G_put_d_raster_row(c6, tmp_buf);
+ Rast_put_d_raster_row(c6, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c6, tmp_buf2);
+ Rast_put_d_raster_row(c6, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[7]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c7, tmp_buf);
+ Rast_put_d_raster_row(c7, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 19) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 19);
}
- G_put_d_raster_row(c7, tmp_buf);
+ Rast_put_d_raster_row(c7, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c7, tmp_buf2);
+ Rast_put_d_raster_row(c7, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[8]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c8, tmp_buf);
+ Rast_put_d_raster_row(c8, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 20) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 20);
}
- G_put_d_raster_row(c8, tmp_buf);
+ Rast_put_d_raster_row(c8, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c8, tmp_buf2);
+ Rast_put_d_raster_row(c8, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[9]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c9, tmp_buf);
+ Rast_put_d_raster_row(c9, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 21) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 21);
}
- G_put_d_raster_row(c9, tmp_buf);
+ Rast_put_d_raster_row(c9, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c9, tmp_buf2);
+ Rast_put_d_raster_row(c9, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->core[10]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c10, tmp_buf);
+ Rast_put_d_raster_row(c10, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 22) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 22);
}
- G_put_d_raster_row(c10, tmp_buf);
+ Rast_put_d_raster_row(c10, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(c10, tmp_buf2);
+ Rast_put_d_raster_row(c10, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->shape[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h1, tmp_buf);
+ Rast_put_d_raster_row(h1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 23) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 23);
}
- G_put_d_raster_row(h1, tmp_buf);
+ Rast_put_d_raster_row(h1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h1, tmp_buf2);
+ Rast_put_d_raster_row(h1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->shape[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h2, tmp_buf);
+ Rast_put_d_raster_row(h2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 24) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 24);
}
- G_put_d_raster_row(h2, tmp_buf);
+ Rast_put_d_raster_row(h2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h2, tmp_buf2);
+ Rast_put_d_raster_row(h2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->shape[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h3, tmp_buf);
+ Rast_put_d_raster_row(h3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 25) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 25);
}
- G_put_d_raster_row(h3, tmp_buf);
+ Rast_put_d_raster_row(h3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h3, tmp_buf2);
+ Rast_put_d_raster_row(h3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->shape[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h4, tmp_buf);
+ Rast_put_d_raster_row(h4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 26) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 26);
}
- G_put_d_raster_row(h4, tmp_buf);
+ Rast_put_d_raster_row(h4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h4, tmp_buf2);
+ Rast_put_d_raster_row(h4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->shape[5]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h5, tmp_buf);
+ Rast_put_d_raster_row(h5, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 27) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 27);
}
- G_put_d_raster_row(h5, tmp_buf);
+ Rast_put_d_raster_row(h5, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h5, tmp_buf2);
+ Rast_put_d_raster_row(h5, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->shape[6]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h6, tmp_buf);
+ Rast_put_d_raster_row(h6, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 28) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 28);
}
- G_put_d_raster_row(h6, tmp_buf);
+ Rast_put_d_raster_row(h6, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(h6, tmp_buf2);
+ Rast_put_d_raster_row(h6, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->boundary[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n1, tmp_buf);
+ Rast_put_d_raster_row(n1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 29) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 29);
}
- G_put_d_raster_row(n1, tmp_buf);
+ Rast_put_d_raster_row(n1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n1, tmp_buf2);
+ Rast_put_d_raster_row(n1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->perim[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p1, tmp_buf);
+ Rast_put_d_raster_row(p1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 30) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 30);
}
- G_put_d_raster_row(p1, tmp_buf);
+ Rast_put_d_raster_row(p1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p1, tmp_buf2);
+ Rast_put_d_raster_row(p1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->perim[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p2, tmp_buf);
+ Rast_put_d_raster_row(p2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 31) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 31);
}
- G_put_d_raster_row(p2, tmp_buf);
+ Rast_put_d_raster_row(p2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p2, tmp_buf2);
+ Rast_put_d_raster_row(p2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->perim[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p3, tmp_buf);
+ Rast_put_d_raster_row(p3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 32) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 32);
}
- G_put_d_raster_row(p3, tmp_buf);
+ Rast_put_d_raster_row(p3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p3, tmp_buf2);
+ Rast_put_d_raster_row(p3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->perim[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p4, tmp_buf);
+ Rast_put_d_raster_row(p4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 33) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 33);
}
- G_put_d_raster_row(p4, tmp_buf);
+ Rast_put_d_raster_row(p4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p4, tmp_buf2);
+ Rast_put_d_raster_row(p4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->perim[5]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p5, tmp_buf);
+ Rast_put_d_raster_row(p5, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 34) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 34);
}
- G_put_d_raster_row(p5, tmp_buf);
+ Rast_put_d_raster_row(p5, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p5, tmp_buf2);
+ Rast_put_d_raster_row(p5, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->perim[6]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p6, tmp_buf);
+ Rast_put_d_raster_row(p6, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 35) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 35);
}
- G_put_d_raster_row(p6, tmp_buf);
+ Rast_put_d_raster_row(p6, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(p6, tmp_buf2);
+ Rast_put_d_raster_row(p6, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[8]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a8, tmp_buf);
+ Rast_put_d_raster_row(a8, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 36) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 36);
}
- G_put_d_raster_row(a8, tmp_buf);
+ Rast_put_d_raster_row(a8, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(a8, tmp_buf2);
+ Rast_put_d_raster_row(a8, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[7]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s7, tmp_buf);
+ Rast_put_d_raster_row(s7, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 37) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 37);
}
- G_put_d_raster_row(s7, tmp_buf);
+ Rast_put_d_raster_row(s7, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s7, tmp_buf2);
+ Rast_put_d_raster_row(s7, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->size[8]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s8, tmp_buf);
+ Rast_put_d_raster_row(s8, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 38) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 38);
}
- G_put_d_raster_row(s8, tmp_buf);
+ Rast_put_d_raster_row(s8, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(s8, tmp_buf2);
+ Rast_put_d_raster_row(s8, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->boundary[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n2, tmp_buf);
+ Rast_put_d_raster_row(n2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 39) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 39);
}
- G_put_d_raster_row(n2, tmp_buf);
+ Rast_put_d_raster_row(n2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n2, tmp_buf2);
+ Rast_put_d_raster_row(n2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->boundary[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n3, tmp_buf);
+ Rast_put_d_raster_row(n3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 40) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 40);
}
- G_put_d_raster_row(n3, tmp_buf);
+ Rast_put_d_raster_row(n3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n3, tmp_buf2);
+ Rast_put_d_raster_row(n3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->boundary[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n4, tmp_buf);
+ Rast_put_d_raster_row(n4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 41) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 41);
}
- G_put_d_raster_row(n4, tmp_buf);
+ Rast_put_d_raster_row(n4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(n4, tmp_buf2);
+ Rast_put_d_raster_row(n4, tmp_buf2);
G_free(tmp_buf2);
}
}
@@ -1964,259 +1964,259 @@
if (choice->att[1]) {
- G_close_cell(a1);
+ Rast_close_cell(a1);
set_colors("a1");
sprintf(cmdbuf, "%s %s", "r.compress", "a1");
system(cmdbuf);
}
if (choice->att[2]) {
- G_close_cell(a2);
+ Rast_close_cell(a2);
set_colors("a2");
sprintf(cmdbuf, "%s %s", "r.compress", "a2");
system(cmdbuf);
}
if (choice->att[3]) {
- G_close_cell(a3);
+ Rast_close_cell(a3);
set_colors("a3");
sprintf(cmdbuf, "%s %s", "r.compress", "a3");
system(cmdbuf);
}
if (choice->att[4]) {
- G_close_cell(a4);
+ Rast_close_cell(a4);
set_colors("a4");
sprintf(cmdbuf, "%s %s", "r.compress", "a4");
system(cmdbuf);
}
if (choice->att[5]) {
- G_close_cell(a5);
+ Rast_close_cell(a5);
set_colors("a5");
sprintf(cmdbuf, "%s %s", "r.compress", "a5");
system(cmdbuf);
}
if (choice->att[6]) {
- G_close_cell(a6);
+ Rast_close_cell(a6);
set_colors("a6");
sprintf(cmdbuf, "%s %s", "r.compress", "a6");
system(cmdbuf);
}
if (choice->att[7]) {
- G_close_cell(a7);
+ Rast_close_cell(a7);
set_colors("a7");
sprintf(cmdbuf, "%s %s", "r.compress", "a7");
system(cmdbuf);
}
if (choice->att[8]) {
- G_close_cell(a8);
+ Rast_close_cell(a8);
set_colors("a8");
sprintf(cmdbuf, "%s %s", "r.compress", "a8");
system(cmdbuf);
}
if (choice->size[1]) {
- G_close_cell(s1);
+ Rast_close_cell(s1);
set_colors("s1");
sprintf(cmdbuf, "%s %s", "r.compress", "s1");
system(cmdbuf);
}
if (choice->size[2]) {
- G_close_cell(s2);
+ Rast_close_cell(s2);
set_colors("s2");
sprintf(cmdbuf, "%s %s", "r.compress", "s2");
system(cmdbuf);
}
if (choice->size[3]) {
- G_close_cell(s3);
+ Rast_close_cell(s3);
set_colors("s3");
sprintf(cmdbuf, "%s %s", "r.compress", "s3");
system(cmdbuf);
}
if (choice->size[4]) {
- G_close_cell(s4);
+ Rast_close_cell(s4);
set_colors("s4");
sprintf(cmdbuf, "%s %s", "r.compress", "s4");
system(cmdbuf);
}
if (choice->size[5]) {
- G_close_cell(s5);
+ Rast_close_cell(s5);
set_colors("s5");
sprintf(cmdbuf, "%s %s", "r.compress", "s5");
system(cmdbuf);
}
if (choice->size[6]) {
- G_close_cell(s6);
+ Rast_close_cell(s6);
set_colors("s6");
sprintf(cmdbuf, "%s %s", "r.compress", "s6");
system(cmdbuf);
}
if (choice->size[7]) {
- G_close_cell(s7);
+ Rast_close_cell(s7);
set_colors("s7");
sprintf(cmdbuf, "%s %s", "r.compress", "s7");
system(cmdbuf);
}
if (choice->size[8]) {
- G_close_cell(s8);
+ Rast_close_cell(s8);
set_colors("s8");
sprintf(cmdbuf, "%s %s", "r.compress", "s8");
system(cmdbuf);
}
if (choice->core[1]) {
- G_close_cell(c1);
+ Rast_close_cell(c1);
set_colors("c1");
sprintf(cmdbuf, "%s %s", "r.compress", "c1");
system(cmdbuf);
}
if (choice->core[2]) {
- G_close_cell(c2);
+ Rast_close_cell(c2);
set_colors("c2");
sprintf(cmdbuf, "%s %s", "r.compress", "c2");
system(cmdbuf);
}
if (choice->core[3]) {
- G_close_cell(c3);
+ Rast_close_cell(c3);
set_colors("c3");
sprintf(cmdbuf, "%s %s", "r.compress", "c3");
system(cmdbuf);
}
if (choice->core[4]) {
- G_close_cell(c4);
+ Rast_close_cell(c4);
set_colors("c4");
sprintf(cmdbuf, "%s %s", "r.compress", "c4");
system(cmdbuf);
}
if (choice->core[5]) {
- G_close_cell(c5);
+ Rast_close_cell(c5);
set_colors("c5");
sprintf(cmdbuf, "%s %s", "r.compress", "c5");
system(cmdbuf);
}
if (choice->core[6]) {
- G_close_cell(c6);
+ Rast_close_cell(c6);
set_colors("c6");
sprintf(cmdbuf, "%s %s", "r.compress", "c6");
system(cmdbuf);
}
if (choice->core[7]) {
- G_close_cell(c7);
+ Rast_close_cell(c7);
set_colors("c7");
sprintf(cmdbuf, "%s %s", "r.compress", "c7");
system(cmdbuf);
}
if (choice->core[8]) {
- G_close_cell(c8);
+ Rast_close_cell(c8);
set_colors("c8");
sprintf(cmdbuf, "%s %s", "r.compress", "c8");
system(cmdbuf);
}
if (choice->core[9]) {
- G_close_cell(c9);
+ Rast_close_cell(c9);
set_colors("c9");
sprintf(cmdbuf, "%s %s", "r.compress", "c9");
system(cmdbuf);
}
if (choice->core[10]) {
- G_close_cell(c10);
+ Rast_close_cell(c10);
set_colors("c10");
sprintf(cmdbuf, "%s %s", "r.compress", "c10");
system(cmdbuf);
}
if (choice->shape[1]) {
- G_close_cell(h1);
+ Rast_close_cell(h1);
set_colors("h1");
sprintf(cmdbuf, "%s %s", "r.compress", "h1");
system(cmdbuf);
}
if (choice->shape[2]) {
- G_close_cell(h2);
+ Rast_close_cell(h2);
set_colors("h2");
sprintf(cmdbuf, "%s %s", "r.compress", "h2");
system(cmdbuf);
}
if (choice->shape[3]) {
- G_close_cell(h3);
+ Rast_close_cell(h3);
set_colors("h3");
sprintf(cmdbuf, "%s %s", "r.compress", "h3");
system(cmdbuf);
}
if (choice->shape[4]) {
- G_close_cell(h4);
+ Rast_close_cell(h4);
set_colors("h4");
sprintf(cmdbuf, "%s %s", "r.compress", "h4");
system(cmdbuf);
}
if (choice->shape[5]) {
- G_close_cell(h5);
+ Rast_close_cell(h5);
set_colors("h5");
sprintf(cmdbuf, "%s %s", "r.compress", "h5");
system(cmdbuf);
}
if (choice->shape[6]) {
- G_close_cell(h6);
+ Rast_close_cell(h6);
set_colors("h6");
sprintf(cmdbuf, "%s %s", "r.compress", "h6");
system(cmdbuf);
}
if (choice->boundary[1]) {
- G_close_cell(n1);
+ Rast_close_cell(n1);
set_colors("n1");
sprintf(cmdbuf, "%s %s", "r.compress", "n1");
system(cmdbuf);
}
if (choice->boundary[2]) {
- G_close_cell(n2);
+ Rast_close_cell(n2);
set_colors("n2");
sprintf(cmdbuf, "%s %s", "r.compress", "n2");
system(cmdbuf);
}
if (choice->boundary[3]) {
- G_close_cell(n3);
+ Rast_close_cell(n3);
set_colors("n3");
sprintf(cmdbuf, "%s %s", "r.compress", "n3");
system(cmdbuf);
}
if (choice->boundary[4]) {
- G_close_cell(n4);
+ Rast_close_cell(n4);
set_colors("n4");
sprintf(cmdbuf, "%s %s", "r.compress", "n4");
system(cmdbuf);
}
if (choice->perim[1]) {
- G_close_cell(p1);
+ Rast_close_cell(p1);
set_colors("p1");
sprintf(cmdbuf, "%s %s", "r.compress", "p1");
system(cmdbuf);
}
if (choice->perim[2]) {
- G_close_cell(p2);
+ Rast_close_cell(p2);
set_colors("p2");
sprintf(cmdbuf, "%s %s", "r.compress", "p2");
system(cmdbuf);
}
if (choice->perim[3]) {
- G_close_cell(p3);
+ Rast_close_cell(p3);
set_colors("p3");
sprintf(cmdbuf, "%s %s", "r.compress", "p3");
system(cmdbuf);
}
if (choice->perim[4]) {
- G_close_cell(p4);
+ Rast_close_cell(p4);
set_colors("p4");
sprintf(cmdbuf, "%s %s", "r.compress", "p4");
system(cmdbuf);
}
if (choice->perim[5]) {
- G_close_cell(p5);
+ Rast_close_cell(p5);
set_colors("p5");
sprintf(cmdbuf, "%s %s", "r.compress", "p5");
system(cmdbuf);
}
if (choice->perim[6]) {
- G_close_cell(p6);
+ Rast_close_cell(p6);
set_colors("p6");
sprintf(cmdbuf, "%s %s", "r.compress", "p6");
system(cmdbuf);
}
- G_close_cell(fmask);
+ Rast_close_cell(fmask);
return;
}
@@ -2234,9 +2234,9 @@
struct Colors colors;
struct FPRange fprange;
- G_read_fp_range(name, G_mapset(), &fprange);
- G_make_gyr_fp_colors(&colors, fprange.min, fprange.max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_read_fp_range(name, G_mapset(), &fprange);
+ Rast_make_gyr_fp_colors(&colors, fprange.min, fprange.max);
+ Rast_write_colors(name, G_mapset(), &colors);
return;
}
@@ -2702,18 +2702,18 @@
if (choice->units) {
strcpy(unitname, "units_");
strcat(unitname, istr);
- fd = G_open_raster_new(unitname, CELL_TYPE);
- unit_buf = G_allocate_raster_buf(CELL_TYPE);
+ fd = Rast_open_raster_new(unitname, CELL_TYPE);
+ unit_buf = Rast_allocate_raster_buf(CELL_TYPE);
for (k = 1; k < wind.rows + 1; k++) {
- G_zero_raster_buf(unit_buf, CELL_TYPE);
- G_set_null_value(unit_buf, wind.cols + 1, CELL_TYPE);
+ Rast_zero_raster_buf(unit_buf, CELL_TYPE);
+ Rast_set_null_value(unit_buf, wind.cols + 1, CELL_TYPE);
for (m = 1; m < wind.cols + 1; m++) {
if (*(*(units + k) + m))
*(unit_buf + m - 1) = *(*(units + k) + m);
}
- G_put_raster_row(fd, unit_buf, CELL_TYPE);
+ Rast_put_raster_row(fd, unit_buf, CELL_TYPE);
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(unit_buf);
}
}
@@ -2817,11 +2817,11 @@
}
else {
regcnt = 0;
- fr = G_open_cell_old(choice->reg, G_mapset());
- row_buf = G_allocate_raster_buf(CELL_TYPE);
+ fr = Rast_open_cell_old(choice->reg, G_mapset());
+ row_buf = Rast_allocate_raster_buf(CELL_TYPE);
for (i = 0; i < nrows; i++) {
- G_zero_raster_buf(row_buf, CELL_TYPE);
- G_get_raster_row(fr, row_buf, i, CELL_TYPE);
+ Rast_zero_raster_buf(row_buf, CELL_TYPE);
+ Rast_get_raster_row(fr, row_buf, i, CELL_TYPE);
for (j = 0; j < ncols; j++) {
if (*(row_buf + j) > 0) {
if (regcnt == 0)
@@ -2872,7 +2872,7 @@
0.0);
ptrthis = ptrthis->next;
}
- G_close_cell(fr);
+ Rast_close_cell(fr);
G_free(row_buf);
G_free(ptrnew);
}
Modified: grass/trunk/raster/r.le/r.le.patch/patch.h
===================================================================
--- grass/trunk/raster/r.le/r.le.patch/patch.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.patch/patch.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#define SML 0.5
#define MIN 2
Modified: grass/trunk/raster/r.le/r.le.patch/trace.c
===================================================================
--- grass/trunk/raster/r.le/r.le.patch/trace.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.patch/trace.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -105,7 +105,7 @@
name = choice->fn;
mapset = G_mapset();
- data_type = G_raster_map_type(name, mapset);
+ data_type = Rast_raster_map_type(name, mapset);
/* dynamically allocate storage for the
buffer that will hold the contents of
@@ -113,7 +113,7 @@
buf = (DCELL **) G_calloc(nrows + 3, sizeof(DCELL *));
for (i = 0; i < nrows + 3; i++) {
- buf[i] = (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ buf[i] = (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
}
@@ -123,7 +123,7 @@
null_buf = (DCELL **) G_calloc(nrows + 3, sizeof(DCELL *));
for (i = 0; i < nrows + 3; i++)
- null_buf[i] = (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ null_buf[i] = (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
/* if a map of patch cores was requested,
@@ -134,10 +134,10 @@
if (choice->coremap) {
cor = (DCELL **) G_calloc(nrows + 3, sizeof(DCELL *));
for (i = 0; i < nrows + 3; i++) {
- cor[i] = (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ cor[i] = (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
}
for (i = 0; i < nrows + 3; i++) {
- G_set_null_value(cor[i], ncols + 3, DCELL_TYPE);
+ Rast_set_null_value(cor[i], ncols + 3, DCELL_TYPE);
}
}
@@ -148,7 +148,7 @@
if (choice->patchmap) {
pat = (CELL **) G_calloc(nrows + 3, sizeof(CELL *));
for (i = 0; i < nrows + 3; i++)
- pat[i] = (CELL *) G_allocate_raster_buf(CELL_TYPE);
+ pat[i] = (CELL *) Rast_allocate_raster_buf(CELL_TYPE);
}
/* clip out the sampling area */
@@ -178,11 +178,11 @@
categories, history, quant) into the
corresponding data structures */
- infd = G_open_cell_old(name, mapset);
- colr_ok = G_read_colors(name, mapset, &colr) > 0;
- cats_ok = G_read_raster_cats(name, mapset, &cats) >= 0;
- hist_ok = G_read_history(name, mapset, &hist) >= 0;
- range_ok = G_read_range(name, mapset, &range) >= 0;
+ infd = Rast_open_cell_old(name, mapset);
+ colr_ok = Rast_read_colors(name, mapset, &colr) > 0;
+ cats_ok = Rast_read_raster_cats(name, mapset, &cats) >= 0;
+ hist_ok = Rast_read_history(name, mapset, &hist) >= 0;
+ range_ok = Rast_read_range(name, mapset, &range) >= 0;
/* 2. if map is floating point, then read
the rules for quantization into the quant
@@ -190,17 +190,17 @@
them by rounding floating point values */
if (data_type != CELL_TYPE) {
- G_quant_init(&quant);
- if (G_read_quant(name, mapset, &quant) <= 0)
- G_quant_round(&quant);
+ Rast_quant_init(&quant);
+ if (Rast_read_quant(name, mapset, &quant) <= 0)
+ Rast_quant_round(&quant);
}
/* 3. initialize appropriate data structures */
if (cats_ok)
- G_init_raster_cats(G_get_raster_cats_title(&cats), &newcats);
+ Rast_init_raster_cats(Rast_get_raster_cats_title(&cats), &newcats);
if (data_type == CELL_TYPE)
- G_init_cell_stats(&stats);
+ Rast_init_cell_stats(&stats);
/* 4. open an output map called "interior" and
@@ -209,41 +209,41 @@
switch (data_type) {
case CELL_TYPE:
- cor_cell_buf = G_allocate_raster_buf(CELL_TYPE);
- fe = G_open_raster_new("interior", CELL_TYPE);
+ cor_cell_buf = Rast_allocate_raster_buf(CELL_TYPE);
+ fe = Rast_open_raster_new("interior", CELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- G_zero_raster_buf(cor_cell_buf, CELL_TYPE);
+ Rast_zero_raster_buf(cor_cell_buf, CELL_TYPE);
for (j = 1; j < ncols + 1; j++)
*(cor_cell_buf + j - 1) = (int)(*(*(cor + i) + j));
- if (G_put_raster_row(fe, cor_cell_buf, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(fe, cor_cell_buf, CELL_TYPE) < 0)
exit(EXIT_FAILURE);
- G_update_cell_stats(cor_cell_buf, ncols + 1, &stats);
+ Rast_update_cell_stats(cor_cell_buf, ncols + 1, &stats);
}
break;
case FCELL_TYPE:
- cor_fcell_buf = G_allocate_raster_buf(FCELL_TYPE);
- fe = G_open_raster_new("interior", FCELL_TYPE);
+ cor_fcell_buf = Rast_allocate_raster_buf(FCELL_TYPE);
+ fe = Rast_open_raster_new("interior", FCELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- G_zero_raster_buf(cor_fcell_buf, FCELL_TYPE);
+ Rast_zero_raster_buf(cor_fcell_buf, FCELL_TYPE);
for (j = 1; j < ncols + 1; j++) {
*(cor_fcell_buf + j - 1) = (float)(*(*(cor + i) + j));
}
- if (G_put_raster_row(fe, cor_fcell_buf, FCELL_TYPE) < 0)
+ if (Rast_put_raster_row(fe, cor_fcell_buf, FCELL_TYPE) < 0)
exit(EXIT_FAILURE);
}
break;
case DCELL_TYPE:
- cor_dcell_buf = G_allocate_raster_buf(DCELL_TYPE);
- fe = G_open_raster_new("interior", DCELL_TYPE);
+ cor_dcell_buf = Rast_allocate_raster_buf(DCELL_TYPE);
+ fe = Rast_open_raster_new("interior", DCELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- G_zero_raster_buf(cor_dcell_buf, DCELL_TYPE);
+ Rast_zero_raster_buf(cor_dcell_buf, DCELL_TYPE);
for (j = 1; j < ncols + 1; j++)
*(cor_dcell_buf + j - 1) = (double)(*(*(cor + i) + j));
- if (G_put_raster_row(fe, cor_dcell_buf, DCELL_TYPE) < 0)
+ if (Rast_put_raster_row(fe, cor_dcell_buf, DCELL_TYPE) < 0)
exit(EXIT_FAILURE);
}
break;
@@ -255,14 +255,14 @@
complete the details of map creation */
if (choice->patchmap) {
- fd = G_open_raster_new("num", CELL_TYPE);
+ fd = Rast_open_raster_new("num", CELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- pat_buf = G_allocate_raster_buf(CELL_TYPE);
- G_zero_raster_buf(pat_buf, CELL_TYPE);
+ pat_buf = Rast_allocate_raster_buf(CELL_TYPE);
+ Rast_zero_raster_buf(pat_buf, CELL_TYPE);
for (j = 1; j < ncols + 1; j++)
*(pat_buf + j - 1) = *(*(pat + i) + j);
- if (G_put_raster_row(fd, pat_buf, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(fd, pat_buf, CELL_TYPE) < 0)
exit(EXIT_FAILURE);
}
}
@@ -356,7 +356,7 @@
memory allocated for it */
if (choice->patchmap) {
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(pat_buf);
}
@@ -367,67 +367,67 @@
memory allocated for the cor_buf */
if (choice->coremap) {
- G_close_cell(fe);
- G_rewind_cell_stats(&stats);
- G_rewind_raster_cats(&cats);
+ Rast_close_cell(fe);
+ Rast_rewind_cell_stats(&stats);
+ Rast_rewind_raster_cats(&cats);
if (cats_ok && data_type == CELL_TYPE) {
long count;
void *rast1, *rast2;
rast1 = cor_cell_buf;
- rast2 = G_incr_void_ptr(rast1, G_raster_size(CELL_TYPE));
- while (G_next_cell_stat(rast1, &count, &stats))
- G_set_raster_cat(rast1, rast2, G_get_raster_cat(rast1, &cats,
+ rast2 = Rast_incr_void_ptr(rast1, Rast_raster_size(CELL_TYPE));
+ while (Rast_next_cell_stat(rast1, &count, &stats))
+ Rast_set_raster_cat(rast1, rast2, Rast_get_raster_cat(rast1, &cats,
CELL_TYPE),
&newcats, CELL_TYPE);
- G_write_raster_cats("interior", &newcats);
- G_free_raster_cats(&cats);
- G_free_raster_cats(&newcats);
- G_free_cell_stats(&stats);
+ Rast_write_raster_cats("interior", &newcats);
+ Rast_free_raster_cats(&cats);
+ Rast_free_raster_cats(&newcats);
+ Rast_free_cell_stats(&stats);
}
if (colr_ok) {
if (data_type == CELL_TYPE) {
CELL min, max, cmin, cmax;
- G_read_range("interior", mapset, &range);
- G_get_range_min_max(&range, &min, &max);
- G_get_color_range(&cmin, &cmax, &colr);
+ Rast_read_range("interior", mapset, &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_get_color_range(&cmin, &cmax, &colr);
if (min > cmin)
cmin = min;
if (max < cmax)
cmax = max;
- G_set_color_range(cmin, cmax, &colr);
+ Rast_set_color_range(cmin, cmax, &colr);
}
else {
DCELL dmin, dmax;
CELL cmin, cmax;
- G_read_fp_range("interior", mapset, &fprange);
- G_get_fp_range_min_max(&fprange, &dmin, &dmax);
- G_get_color_range(&cmin, &cmax, &colr);
+ Rast_read_fp_range("interior", mapset, &fprange);
+ Rast_get_fp_range_min_max(&fprange, &dmin, &dmax);
+ Rast_get_color_range(&cmin, &cmax, &colr);
if (dmin > cmin)
cmin = dmin;
if (dmax < cmax)
cmax = dmax;
- G_set_color_range(cmin, cmax, &colr);
+ Rast_set_color_range(cmin, cmax, &colr);
}
- G_write_colors("interior", mapset, &colr);
+ Rast_write_colors("interior", mapset, &colr);
}
if (range_ok) {
if (data_type == CELL_TYPE)
- G_write_range("interior", &range);
+ Rast_write_range("interior", &range);
else
- G_write_fp_range("interior", &fprange);
+ Rast_write_fp_range("interior", &fprange);
}
if (hist_ok)
- G_write_history("interior", &hist);
+ Rast_write_history("interior", &hist);
- G_free_cats(&cats);
- G_free_colors(&colr);
+ Rast_free_cats(&cats);
+ Rast_free_colors(&colr);
switch (data_type) {
case CELL_TYPE:
G_free(cor_cell_buf);
@@ -510,7 +510,7 @@
an integer (CELL_TYPE) map */
if (choice->wrum == 'r') {
- if (0 > (fr = G_open_cell_old(choice->reg, G_mapset()))) {
+ if (0 > (fr = Rast_open_cell_old(choice->reg, G_mapset()))) {
fprintf(stderr, "\n");
fprintf(stderr,
" *******************************************************\n");
@@ -524,7 +524,7 @@
" *******************************************************\n");
exit(EXIT_FAILURE);
}
- if (G_raster_map_type(choice->reg, G_mapset()) > 0) {
+ if (Rast_raster_map_type(choice->reg, G_mapset()) > 0) {
fprintf(stderr, "\n");
fprintf(stderr,
" *******************************************************\n");
@@ -540,12 +540,12 @@
" *******************************************************\n");
exit(EXIT_FAILURE);
}
- tmp1 = G_allocate_raster_buf(CELL_TYPE);
- G_zero_raster_buf(tmp1, CELL_TYPE);
+ tmp1 = Rast_allocate_raster_buf(CELL_TYPE);
+ Rast_zero_raster_buf(tmp1, CELL_TYPE);
fprintf(stderr, "Analyzing region number %d...\n", index);
}
- data_type = G_raster_map_type(choice->fn, G_mapset());
+ data_type = Rast_raster_map_type(choice->fn, G_mapset());
/* allocate memory to store a row of the
@@ -555,15 +555,15 @@
switch (data_type) {
case CELL_TYPE:
- tmp = G_allocate_raster_buf(CELL_TYPE);
+ tmp = Rast_allocate_raster_buf(CELL_TYPE);
tmpname = "tmp";
break;
case FCELL_TYPE:
- ftmp = G_allocate_raster_buf(FCELL_TYPE);
+ ftmp = Rast_allocate_raster_buf(FCELL_TYPE);
tmpname = "ftmp";
break;
case DCELL_TYPE:
- dtmp = G_allocate_raster_buf(DCELL_TYPE);
+ dtmp = Rast_allocate_raster_buf(DCELL_TYPE);
tmpname = "dtmp";
break;
}
@@ -596,7 +596,7 @@
map row in the region file */
if (choice->wrum == 'r')
- G_get_raster_row_nomask(fr, tmp1, i, CELL_TYPE);
+ Rast_get_raster_row_nomask(fr, tmp1, i, CELL_TYPE);
/* initialize each element of the
row buffer to 0; this row buffer
@@ -606,16 +606,16 @@
switch (data_type) {
case CELL_TYPE:
- G_zero_raster_buf(tmp, data_type);
- G_get_raster_row(finput, tmp, i, data_type);
+ Rast_zero_raster_buf(tmp, data_type);
+ Rast_get_raster_row(finput, tmp, i, data_type);
break;
case FCELL_TYPE:
- G_zero_raster_buf(ftmp, data_type);
- G_get_raster_row(finput, ftmp, i, data_type);
+ Rast_zero_raster_buf(ftmp, data_type);
+ Rast_get_raster_row(finput, ftmp, i, data_type);
break;
case DCELL_TYPE:
- G_zero_raster_buf(dtmp, data_type);
- G_get_raster_row(finput, dtmp, i, data_type);
+ Rast_zero_raster_buf(dtmp, data_type);
+ Rast_get_raster_row(finput, dtmp, i, data_type);
break;
}
@@ -629,17 +629,17 @@
case CELL_TYPE:
rastptr = tmp;
for (x = 0; x < col0; x++)
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(CELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(CELL_TYPE));
break;
case FCELL_TYPE:
rastptr = ftmp;
for (x = 0; x < col0; x++)
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(FCELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(FCELL_TYPE));
break;
case DCELL_TYPE:
rastptr = dtmp;
for (x = 0; x < col0; x++)
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(DCELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(DCELL_TYPE));
break;
}
@@ -655,7 +655,7 @@
switch (data_type) {
case CELL_TYPE:
- if (G_is_null_value(rastptr, CELL_TYPE)) {
+ if (Rast_is_null_value(rastptr, CELL_TYPE)) {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
if (i == row0 + nrows / 2 && j == col0 + ncols / 2)
*centernull = 1;
@@ -667,11 +667,11 @@
else
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
}
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(CELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(CELL_TYPE));
break;
case FCELL_TYPE:
- if (G_is_null_value(rastptr, FCELL_TYPE)) {
+ if (Rast_is_null_value(rastptr, FCELL_TYPE)) {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
if (i == row0 + nrows / 2 && j == col0 + ncols / 2)
*centernull = 1;
@@ -683,11 +683,11 @@
else
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
}
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(FCELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(FCELL_TYPE));
break;
case DCELL_TYPE:
- if (G_is_null_value(rastptr, DCELL_TYPE)) {
+ if (Rast_is_null_value(rastptr, DCELL_TYPE)) {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
if (i == row0 + nrows / 2 && j == col0 + ncols / 2)
*centernull = 1;
@@ -699,7 +699,7 @@
else
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
}
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(CELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(CELL_TYPE));
break;
}
@@ -773,7 +773,7 @@
}
if (choice->wrum == 'r') {
G_free(tmp1);
- G_close_cell(fr);
+ Rast_close_cell(fr);
}
return;
}
@@ -996,7 +996,7 @@
patchmap = (CELL **) G_calloc(nrows + 3, sizeof(CELL *));
for (m = 0; m < nrows + 3; m++)
- patchmap[m] = (CELL *) G_allocate_raster_buf(CELL_TYPE);
+ patchmap[m] = (CELL *) Rast_allocate_raster_buf(CELL_TYPE);
/* print on the screen a message indicating
that tracing has reached a certain patch */
Modified: grass/trunk/raster/r.le/r.le.pixel/cellclip.c
===================================================================
--- grass/trunk/raster/r.le/r.le.pixel/cellclip.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.pixel/cellclip.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -58,7 +58,7 @@
name = choice->fn;
mapset = G_mapset();
- data_type = G_raster_map_type(name, mapset);
+ data_type = Rast_raster_map_type(name, mapset);
/* dynamically allocate storage for the
buffer that will hold the contents of
@@ -253,14 +253,14 @@
i, j = indices to rows and cols of the arrays
*/
- data_type = G_raster_map_type(choice->fn, G_mapset());
+ data_type = Rast_raster_map_type(choice->fn, G_mapset());
/* if sampling by region was chosen, check
for the region map and make sure it is
an integer (CELL_TYPE) map */
if (choice->wrum == 'r') {
- if (0 > (fr = G_open_cell_old(choice->reg, G_mapset()))) {
+ if (0 > (fr = Rast_open_cell_old(choice->reg, G_mapset()))) {
fprintf(stderr, "\n");
fprintf(stderr,
" *******************************************************\n");
@@ -274,7 +274,7 @@
" *******************************************************\n");
exit(1);
}
- if (G_raster_map_type(choice->reg, G_mapset()) > 0) {
+ if (Rast_raster_map_type(choice->reg, G_mapset()) > 0) {
fprintf(stderr, "\n");
fprintf(stderr,
" *******************************************************\n");
@@ -290,8 +290,8 @@
" *******************************************************\n");
exit(1);
}
- tmp1 = G_allocate_raster_buf(CELL_TYPE);
- G_zero_raster_buf(tmp1, CELL_TYPE);
+ tmp1 = Rast_allocate_raster_buf(CELL_TYPE);
+ Rast_zero_raster_buf(tmp1, CELL_TYPE);
fprintf(stderr, "Analyzing region number %d...\n", index);
}
@@ -302,15 +302,15 @@
switch (data_type) {
case CELL_TYPE:
- tmp = G_allocate_raster_buf(CELL_TYPE);
+ tmp = Rast_allocate_raster_buf(CELL_TYPE);
tmpname = "tmp";
break;
case FCELL_TYPE:
- ftmp = G_allocate_raster_buf(FCELL_TYPE);
+ ftmp = Rast_allocate_raster_buf(FCELL_TYPE);
tmpname = "ftmp";
break;
case DCELL_TYPE:
- dtmp = G_allocate_raster_buf(DCELL_TYPE);
+ dtmp = Rast_allocate_raster_buf(DCELL_TYPE);
tmpname = "dtmp";
break;
}
@@ -319,7 +319,7 @@
null values corresponding to the raster
map */
- nulltmp = G_allocate_null_buf();
+ nulltmp = Rast_allocate_null_buf();
/* if circles are used for sampling, then
calculate the center of the area to be
@@ -338,7 +338,7 @@
map row in the region file */
if (choice->wrum == 'r')
- G_get_raster_row_nomask(fr, tmp1, i, CELL_TYPE);
+ Rast_get_raster_row_nomask(fr, tmp1, i, CELL_TYPE);
/* initialize each element of the
row buffer to 0; this row buffer
@@ -349,20 +349,20 @@
switch (data_type) {
case CELL_TYPE:
- G_zero_raster_buf(tmp, data_type);
- G_get_raster_row(finput, tmp, i, CELL_TYPE);
+ Rast_zero_raster_buf(tmp, data_type);
+ Rast_get_raster_row(finput, tmp, i, CELL_TYPE);
break;
case FCELL_TYPE:
- G_zero_raster_buf(ftmp, data_type);
- G_get_raster_row(finput, ftmp, i, FCELL_TYPE);
+ Rast_zero_raster_buf(ftmp, data_type);
+ Rast_get_raster_row(finput, ftmp, i, FCELL_TYPE);
break;
case DCELL_TYPE:
- G_zero_raster_buf(dtmp, data_type);
- G_get_raster_row(finput, dtmp, i, DCELL_TYPE);
+ Rast_zero_raster_buf(dtmp, data_type);
+ Rast_get_raster_row(finput, dtmp, i, DCELL_TYPE);
break;
}
- G_get_null_value_row(finput, nulltmp, i);
+ Rast_get_null_value_row(finput, nulltmp, i);
/* for all the columns one by one */
@@ -436,7 +436,7 @@
}
if (choice->wrum == 'r') {
G_free(tmp1);
- G_close_cell(fr);
+ Rast_close_cell(fr);
}
G_free(nulltmp);
return;
Modified: grass/trunk/raster/r.le/r.le.pixel/driver.c
===================================================================
--- grass/trunk/raster/r.le/r.le.pixel/driver.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.pixel/driver.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -51,7 +51,7 @@
/* check for input raster map */
- if (0 > (finput = G_open_cell_old(choice->fn, G_mapset()))) {
+ if (0 > (finput = Rast_open_cell_old(choice->fn, G_mapset()))) {
fprintf(stdout, "\n");
fprintf(stdout,
" ********************************************************\n");
@@ -69,7 +69,7 @@
double (DCELL_TYPE) and make globally available */
else
- data_type = G_raster_map_type(choice->fn, G_mapset());
+ data_type = Rast_raster_map_type(choice->fn, G_mapset());
/* if using a moving window, get the parameters,
and start the moving window driver */
@@ -138,7 +138,7 @@
unit_driver();
}
- G_close_cell(finput);
+ Rast_close_cell(finput);
fputs("R.LE.PIXEL IS DONE; ", stderr);
@@ -198,28 +198,28 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=b1,b1bak");
system(cmdbuf);
}
- b1 = G_open_raster_new("b1", DCELL_TYPE);
+ b1 = Rast_open_raster_new("b1", DCELL_TYPE);
}
if (choice->att[2]) {
if (G_find_cell("b2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=b2,b2bak");
system(cmdbuf);
}
- b2 = G_open_raster_new("b2", DCELL_TYPE);
+ b2 = Rast_open_raster_new("b2", DCELL_TYPE);
}
if (choice->att[3]) {
if (G_find_cell("b3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=b3,b3bak");
system(cmdbuf);
}
- b3 = G_open_raster_new("b3", DCELL_TYPE);
+ b3 = Rast_open_raster_new("b3", DCELL_TYPE);
}
if (choice->att[4]) {
if (G_find_cell("b4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=b4,b4bak");
system(cmdbuf);
}
- b4 = G_open_raster_new("b4", DCELL_TYPE);
+ b4 = Rast_open_raster_new("b4", DCELL_TYPE);
}
if (choice->div[1]) {
@@ -227,28 +227,28 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=d1,d1bak");
system(cmdbuf);
}
- d1 = G_open_raster_new("d1", DCELL_TYPE);
+ d1 = Rast_open_raster_new("d1", DCELL_TYPE);
}
if (choice->div[2]) {
if (G_find_cell("d2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=d2,d2bak");
system(cmdbuf);
}
- d2 = G_open_raster_new("d2", DCELL_TYPE);
+ d2 = Rast_open_raster_new("d2", DCELL_TYPE);
}
if (choice->div[3]) {
if (G_find_cell("d3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=d3,d3bak");
system(cmdbuf);
}
- d3 = G_open_raster_new("d3", DCELL_TYPE);
+ d3 = Rast_open_raster_new("d3", DCELL_TYPE);
}
if (choice->div[4]) {
if (G_find_cell("d4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=d4,d4bak");
system(cmdbuf);
}
- d4 = G_open_raster_new("d4", DCELL_TYPE);
+ d4 = Rast_open_raster_new("d4", DCELL_TYPE);
}
if (choice->te2[1]) {
@@ -256,35 +256,35 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=t1,t1bak");
system(cmdbuf);
}
- t1 = G_open_raster_new("t1", DCELL_TYPE);
+ t1 = Rast_open_raster_new("t1", DCELL_TYPE);
}
if (choice->te2[2]) {
if (G_find_cell("t2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=t2,t2bak");
system(cmdbuf);
}
- t2 = G_open_raster_new("t2", DCELL_TYPE);
+ t2 = Rast_open_raster_new("t2", DCELL_TYPE);
}
if (choice->te2[3]) {
if (G_find_cell("t3", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=t3,t3bak");
system(cmdbuf);
}
- t3 = G_open_raster_new("t3", DCELL_TYPE);
+ t3 = Rast_open_raster_new("t3", DCELL_TYPE);
}
if (choice->te2[4]) {
if (G_find_cell("t4", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=t4,t4bak");
system(cmdbuf);
}
- t4 = G_open_raster_new("t4", DCELL_TYPE);
+ t4 = Rast_open_raster_new("t4", DCELL_TYPE);
}
if (choice->te2[5]) {
if (G_find_cell("t5", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=t5,t5bak");
system(cmdbuf);
}
- t5 = G_open_raster_new("t5", DCELL_TYPE);
+ t5 = Rast_open_raster_new("t5", DCELL_TYPE);
}
if (choice->jux[1]) {
@@ -292,28 +292,28 @@
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=j1,j1bak");
system(cmdbuf);
}
- j1 = G_open_raster_new("j1", DCELL_TYPE);
+ j1 = Rast_open_raster_new("j1", DCELL_TYPE);
}
if (choice->jux[2]) {
if (G_find_cell("j2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=j2,j2bak");
system(cmdbuf);
}
- j2 = G_open_raster_new("j2", DCELL_TYPE);
+ j2 = Rast_open_raster_new("j2", DCELL_TYPE);
}
if (choice->edg[1]) {
if (G_find_cell("e1", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=e1,e1bak");
system(cmdbuf);
}
- e1 = G_open_raster_new("e1", DCELL_TYPE);
+ e1 = Rast_open_raster_new("e1", DCELL_TYPE);
}
if (choice->edg[2]) {
if (G_find_cell("e2", G_mapset()) != NULL) {
sprintf(cmdbuf, "%s %s", "g.rename -o", "rast=e2,e2bak");
system(cmdbuf);
}
- e2 = G_open_raster_new("e2", DCELL_TYPE);
+ e2 = Rast_open_raster_new("e2", DCELL_TYPE);
}
@@ -383,7 +383,7 @@
fprintf(stdout,
" warning may be printed or appear in a window; ignore this warning.\n");
fprintf(stdout, "If a MASK is present there will be no warning.\n");
- fmask = G_open_cell_old("MASK", G_mapset());
+ fmask = Rast_open_cell_old("MASK", G_mapset());
fprintf(stdout, "\n");
/* allocate memory for the buffer */
@@ -400,7 +400,7 @@
there is a mask */
if (fmask > 0)
- row_buf = G_allocate_raster_buf(CELL_TYPE);
+ row_buf = Rast_allocate_raster_buf(CELL_TYPE);
if (choice->edg[2] || choice->jux[0]) {
@@ -423,17 +423,17 @@
switch (data_type) {
case CELL_TYPE:
- tmp = G_allocate_raster_buf(CELL_TYPE);
+ tmp = Rast_allocate_raster_buf(CELL_TYPE);
break;
case FCELL_TYPE:
- ftmp = G_allocate_raster_buf(FCELL_TYPE);
+ ftmp = Rast_allocate_raster_buf(FCELL_TYPE);
break;
case DCELL_TYPE:
- dtmp = G_allocate_raster_buf(DCELL_TYPE);
+ dtmp = Rast_allocate_raster_buf(DCELL_TYPE);
break;
}
- nul_buf = G_allocate_null_buf();
+ nul_buf = Rast_allocate_null_buf();
/* go through the search area
pixel by pixel */
@@ -442,20 +442,20 @@
switch (data_type) {
case (CELL_TYPE):
- G_zero_raster_buf(tmp, CELL_TYPE);
- G_get_raster_row(finput, tmp, i, CELL_TYPE);
+ Rast_zero_raster_buf(tmp, CELL_TYPE);
+ Rast_get_raster_row(finput, tmp, i, CELL_TYPE);
break;
case (FCELL_TYPE):
- G_zero_raster_buf(ftmp, FCELL_TYPE);
- G_get_raster_row(finput, ftmp, i, FCELL_TYPE);
+ Rast_zero_raster_buf(ftmp, FCELL_TYPE);
+ Rast_get_raster_row(finput, ftmp, i, FCELL_TYPE);
break;
case (DCELL_TYPE):
- G_zero_raster_buf(dtmp, DCELL_TYPE);
- G_get_raster_row(finput, dtmp, i, DCELL_TYPE);
+ Rast_zero_raster_buf(dtmp, DCELL_TYPE);
+ Rast_get_raster_row(finput, dtmp, i, DCELL_TYPE);
break;
}
- G_get_null_value_row(finput, nul_buf, i);
+ Rast_get_null_value_row(finput, nul_buf, i);
for (j = 0; j < nc; j++) {
@@ -524,8 +524,8 @@
process */
if (fmask > 0) {
- G_zero_raster_buf(row_buf, CELL_TYPE);
- G_get_raster_row_nomask(fmask, row_buf, y0 + i + u_l / 2,
+ Rast_zero_raster_buf(row_buf, CELL_TYPE);
+ Rast_get_raster_row_nomask(fmask, row_buf, y0 + i + u_l / 2,
CELL_TYPE);
/* for each cell whose value is "1"
@@ -578,380 +578,380 @@
maps; the map location is adjusted to the center
of the moving window */
- tmp_buf = G_allocate_raster_buf(DCELL_TYPE);
- nulltmp = G_allocate_null_buf();
+ tmp_buf = Rast_allocate_raster_buf(DCELL_TYPE);
+ nulltmp = Rast_allocate_null_buf();
if (choice->att[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b1, tmp_buf);
+ Rast_put_d_raster_row(b1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 0) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 0);
}
- G_put_d_raster_row(b1, tmp_buf);
+ Rast_put_d_raster_row(b1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b1, tmp_buf2);
+ Rast_put_d_raster_row(b1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b2, tmp_buf);
+ Rast_put_d_raster_row(b2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 1) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 1);
}
- G_put_d_raster_row(b2, tmp_buf);
+ Rast_put_d_raster_row(b2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b2, tmp_buf2);
+ Rast_put_d_raster_row(b2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b3, tmp_buf);
+ Rast_put_d_raster_row(b3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 2) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 2);
}
- G_put_d_raster_row(b3, tmp_buf);
+ Rast_put_d_raster_row(b3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b3, tmp_buf2);
+ Rast_put_d_raster_row(b3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->att[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b4, tmp_buf);
+ Rast_put_d_raster_row(b4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 3) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 3);
}
- G_put_d_raster_row(b4, tmp_buf);
+ Rast_put_d_raster_row(b4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(b4, tmp_buf2);
+ Rast_put_d_raster_row(b4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->div[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d1, tmp_buf);
+ Rast_put_d_raster_row(d1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 4) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 4);
}
- G_put_d_raster_row(d1, tmp_buf);
+ Rast_put_d_raster_row(d1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d1, tmp_buf2);
+ Rast_put_d_raster_row(d1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->div[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d2, tmp_buf);
+ Rast_put_d_raster_row(d2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 5) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 5);
}
- G_put_d_raster_row(d2, tmp_buf);
+ Rast_put_d_raster_row(d2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d2, tmp_buf2);
+ Rast_put_d_raster_row(d2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->div[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d3, tmp_buf);
+ Rast_put_d_raster_row(d3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 6) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 6);
}
- G_put_d_raster_row(d3, tmp_buf);
+ Rast_put_d_raster_row(d3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d3, tmp_buf2);
+ Rast_put_d_raster_row(d3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->div[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d4, tmp_buf);
+ Rast_put_d_raster_row(d4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 7) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 7);
}
- G_put_d_raster_row(d4, tmp_buf);
+ Rast_put_d_raster_row(d4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(d4, tmp_buf2);
+ Rast_put_d_raster_row(d4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->te2[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t1, tmp_buf);
+ Rast_put_d_raster_row(t1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 8) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 8);
}
- G_put_d_raster_row(t1, tmp_buf);
+ Rast_put_d_raster_row(t1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t1, tmp_buf2);
+ Rast_put_d_raster_row(t1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->te2[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t2, tmp_buf);
+ Rast_put_d_raster_row(t2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 9) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 9);
}
- G_put_d_raster_row(t2, tmp_buf);
+ Rast_put_d_raster_row(t2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t2, tmp_buf2);
+ Rast_put_d_raster_row(t2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->te2[3]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t3, tmp_buf);
+ Rast_put_d_raster_row(t3, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 10) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 10);
}
- G_put_d_raster_row(t3, tmp_buf);
+ Rast_put_d_raster_row(t3, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t3, tmp_buf2);
+ Rast_put_d_raster_row(t3, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->te2[4]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t4, tmp_buf);
+ Rast_put_d_raster_row(t4, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 11) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 11);
}
- G_put_d_raster_row(t4, tmp_buf);
+ Rast_put_d_raster_row(t4, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t4, tmp_buf2);
+ Rast_put_d_raster_row(t4, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->te2[5]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t5, tmp_buf);
+ Rast_put_d_raster_row(t5, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 12) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 12);
}
- G_put_d_raster_row(t5, tmp_buf);
+ Rast_put_d_raster_row(t5, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(t5, tmp_buf2);
+ Rast_put_d_raster_row(t5, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->jux[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(j1, tmp_buf);
+ Rast_put_d_raster_row(j1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 13) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 13);
}
- G_put_d_raster_row(j1, tmp_buf);
+ Rast_put_d_raster_row(j1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(j1, tmp_buf2);
+ Rast_put_d_raster_row(j1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->jux[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(j2, tmp_buf);
+ Rast_put_d_raster_row(j2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 14) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 14);
}
- G_put_d_raster_row(j2, tmp_buf);
+ Rast_put_d_raster_row(j2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(j2, tmp_buf2);
+ Rast_put_d_raster_row(j2, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->edg[1]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(e1, tmp_buf);
+ Rast_put_d_raster_row(e1, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 15) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 15);
}
- G_put_d_raster_row(e1, tmp_buf);
+ Rast_put_d_raster_row(e1, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(e1, tmp_buf2);
+ Rast_put_d_raster_row(e1, tmp_buf2);
G_free(tmp_buf2);
}
}
if (choice->edg[2]) {
- G_zero_raster_buf(tmp_buf, DCELL_TYPE);
- G_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
+ Rast_zero_raster_buf(tmp_buf, DCELL_TYPE);
+ Rast_set_null_value(tmp_buf, x0 + nc + u_w, DCELL_TYPE);
if (i == 0) {
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(e2, tmp_buf);
+ Rast_put_d_raster_row(e2, tmp_buf);
}
if (i < nr) {
for (m = 0; m < nc; m++) {
if (*(*(buff + m) + 16) > -BIG)
*(tmp_buf + (x0 + m + u_w / 2)) = *(*(buff + m) + 16);
}
- G_put_d_raster_row(e2, tmp_buf);
+ Rast_put_d_raster_row(e2, tmp_buf);
}
if (i == nr - 1) {
- tmp_buf2 = G_allocate_raster_buf(DCELL_TYPE);
- G_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
+ tmp_buf2 = Rast_allocate_raster_buf(DCELL_TYPE);
+ Rast_set_null_value(tmp_buf2, x0 + nc + u_w, DCELL_TYPE);
for (b = 0; b < u_l / 2; b++)
- G_put_d_raster_row(e2, tmp_buf2);
+ Rast_put_d_raster_row(e2, tmp_buf2);
G_free(tmp_buf2);
}
}
@@ -980,109 +980,109 @@
if (choice->att[1]) {
- G_close_cell(b1);
+ Rast_close_cell(b1);
set_colors("b1");
sprintf(cmdbuf, "%s %s", "r.compress", "b1");
system(cmdbuf);
}
if (choice->att[2]) {
- G_close_cell(b2);
+ Rast_close_cell(b2);
set_colors("b2");
sprintf(cmdbuf, "%s %s", "r.compress", "b2");
system(cmdbuf);
}
if (choice->att[3]) {
- G_close_cell(b3);
+ Rast_close_cell(b3);
set_colors("b3");
sprintf(cmdbuf, "%s %s", "r.compress", "b3");
system(cmdbuf);
}
if (choice->att[4]) {
- G_close_cell(b4);
+ Rast_close_cell(b4);
set_colors("b4");
sprintf(cmdbuf, "%s %s", "r.compress", "b4");
system(cmdbuf);
}
if (choice->div[1]) {
- G_close_cell(d1);
+ Rast_close_cell(d1);
set_colors("d1");
sprintf(cmdbuf, "%s %s", "r.compress", "d1");
system(cmdbuf);
}
if (choice->div[2]) {
- G_close_cell(d2);
+ Rast_close_cell(d2);
set_colors("d2");
sprintf(cmdbuf, "%s %s", "r.compress", "d2");
system(cmdbuf);
}
if (choice->div[3]) {
- G_close_cell(d3);
+ Rast_close_cell(d3);
set_colors("d3");
sprintf(cmdbuf, "%s %s", "r.compress", "d3");
system(cmdbuf);
}
if (choice->div[4]) {
- G_close_cell(d4);
+ Rast_close_cell(d4);
set_colors("d4");
sprintf(cmdbuf, "%s %s", "r.compress", "d4");
system(cmdbuf);
}
if (choice->te2[1]) {
- G_close_cell(t1);
+ Rast_close_cell(t1);
set_colors("t1");
sprintf(cmdbuf, "%s %s", "r.compress", "t1");
system(cmdbuf);
}
if (choice->te2[2]) {
- G_close_cell(t2);
+ Rast_close_cell(t2);
set_colors("t2");
sprintf(cmdbuf, "%s %s", "r.compress", "t2");
system(cmdbuf);
}
if (choice->te2[3]) {
- G_close_cell(t3);
+ Rast_close_cell(t3);
set_colors("t3");
sprintf(cmdbuf, "%s %s", "r.compress", "t3");
system(cmdbuf);
}
if (choice->te2[4]) {
- G_close_cell(t4);
+ Rast_close_cell(t4);
set_colors("t4");
sprintf(cmdbuf, "%s %s", "r.compress", "t4");
system(cmdbuf);
}
if (choice->te2[5]) {
- G_close_cell(t5);
+ Rast_close_cell(t5);
set_colors("t5");
sprintf(cmdbuf, "%s %s", "r.compress", "t5");
system(cmdbuf);
}
if (choice->jux[1]) {
- G_close_cell(j1);
+ Rast_close_cell(j1);
set_colors("j1");
sprintf(cmdbuf, "%s %s", "r.compress", "j1");
system(cmdbuf);
}
if (choice->jux[2]) {
- G_close_cell(j2);
+ Rast_close_cell(j2);
set_colors("j2");
sprintf(cmdbuf, "%s %s", "r.compress", "j2");
system(cmdbuf);
}
if (choice->edg[1]) {
- G_close_cell(e1);
+ Rast_close_cell(e1);
set_colors("e1");
sprintf(cmdbuf, "%s %s", "r.compress", "e1");
system(cmdbuf);
}
if (choice->edg[2]) {
- G_close_cell(e2);
+ Rast_close_cell(e2);
set_colors("e2");
sprintf(cmdbuf, "%s %s", "r.compress", "e2");
system(cmdbuf);
}
- G_close_cell(fmask);
+ Rast_close_cell(fmask);
return;
}
@@ -1101,9 +1101,9 @@
struct Colors colors;
struct FPRange fprange;
- G_read_fp_range(name, G_mapset(), &fprange);
- G_make_gyr_fp_colors(&colors, fprange.min, fprange.max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_read_fp_range(name, G_mapset(), &fprange);
+ Rast_make_gyr_fp_colors(&colors, fprange.min, fprange.max);
+ Rast_write_colors(name, G_mapset(), &colors);
return;
}
@@ -1346,17 +1346,17 @@
switch (data_type) {
case CELL_TYPE:
- tmp = G_allocate_raster_buf(CELL_TYPE);
+ tmp = Rast_allocate_raster_buf(CELL_TYPE);
break;
case FCELL_TYPE:
- ftmp = G_allocate_raster_buf(FCELL_TYPE);
+ ftmp = Rast_allocate_raster_buf(FCELL_TYPE);
break;
case DCELL_TYPE:
- dtmp = G_allocate_raster_buf(DCELL_TYPE);
+ dtmp = Rast_allocate_raster_buf(DCELL_TYPE);
break;
}
- nul_buf = G_allocate_null_buf();
+ nul_buf = Rast_allocate_null_buf();
/* go through the search area
pixel by pixel */
@@ -1365,20 +1365,20 @@
switch (data_type) {
case (CELL_TYPE):
- G_zero_raster_buf(tmp, CELL_TYPE);
- G_get_raster_row(finput, tmp, i, CELL_TYPE);
+ Rast_zero_raster_buf(tmp, CELL_TYPE);
+ Rast_get_raster_row(finput, tmp, i, CELL_TYPE);
break;
case (FCELL_TYPE):
- G_zero_raster_buf(ftmp, FCELL_TYPE);
- G_get_raster_row(finput, ftmp, i, FCELL_TYPE);
+ Rast_zero_raster_buf(ftmp, FCELL_TYPE);
+ Rast_get_raster_row(finput, ftmp, i, FCELL_TYPE);
break;
case (DCELL_TYPE):
- G_zero_raster_buf(dtmp, DCELL_TYPE);
- G_get_raster_row(finput, dtmp, i, DCELL_TYPE);
+ Rast_zero_raster_buf(dtmp, DCELL_TYPE);
+ Rast_get_raster_row(finput, dtmp, i, DCELL_TYPE);
break;
}
- G_get_null_value_row(finput, nul_buf, i);
+ Rast_get_null_value_row(finput, nul_buf, i);
for (j = 0; j < wind.cols; j++) {
@@ -1524,18 +1524,18 @@
if (choice->units) {
strcpy(unitname, "units_");
strcat(unitname, istr);
- fd = G_open_raster_new(unitname, CELL_TYPE);
- unit_buf = G_allocate_raster_buf(CELL_TYPE);
+ fd = Rast_open_raster_new(unitname, CELL_TYPE);
+ unit_buf = Rast_allocate_raster_buf(CELL_TYPE);
for (k = 1; k < wind.rows + 1; k++) {
- G_zero_raster_buf(unit_buf, CELL_TYPE);
- G_set_null_value(unit_buf, wind.cols + 1, CELL_TYPE);
+ Rast_zero_raster_buf(unit_buf, CELL_TYPE);
+ Rast_set_null_value(unit_buf, wind.cols + 1, CELL_TYPE);
for (m = 1; m < wind.cols + 3; m++) {
if (*(*(units + k) + m))
*(unit_buf + m - 1) = *(*(units + k) + m);
}
- G_put_raster_row(fd, unit_buf, CELL_TYPE);
+ Rast_put_raster_row(fd, unit_buf, CELL_TYPE);
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(unit_buf);
}
}
@@ -1638,7 +1638,7 @@
REGLIST *ptrfirst, *ptrthis, *ptrnew;
RASTER_MAP_TYPE data_type;
- data_type = G_raster_map_type(choice->fn, G_mapset());
+ data_type = Rast_raster_map_type(choice->fn, G_mapset());
nrows = G_window_rows();
ncols = G_window_cols();
@@ -1665,17 +1665,17 @@
switch (data_type) {
case CELL_TYPE:
- tmp = G_allocate_raster_buf(CELL_TYPE);
+ tmp = Rast_allocate_raster_buf(CELL_TYPE);
break;
case FCELL_TYPE:
- ftmp = G_allocate_raster_buf(FCELL_TYPE);
+ ftmp = Rast_allocate_raster_buf(FCELL_TYPE);
break;
case DCELL_TYPE:
- dtmp = G_allocate_raster_buf(DCELL_TYPE);
+ dtmp = Rast_allocate_raster_buf(DCELL_TYPE);
break;
}
- nul_buf = G_allocate_null_buf();
+ nul_buf = Rast_allocate_null_buf();
/* go through the search area
pixel by pixel */
@@ -1684,20 +1684,20 @@
switch (data_type) {
case (CELL_TYPE):
- G_zero_raster_buf(tmp, CELL_TYPE);
- G_get_raster_row(finput, tmp, i, CELL_TYPE);
+ Rast_zero_raster_buf(tmp, CELL_TYPE);
+ Rast_get_raster_row(finput, tmp, i, CELL_TYPE);
break;
case (FCELL_TYPE):
- G_zero_raster_buf(ftmp, FCELL_TYPE);
- G_get_raster_row(finput, ftmp, i, FCELL_TYPE);
+ Rast_zero_raster_buf(ftmp, FCELL_TYPE);
+ Rast_get_raster_row(finput, ftmp, i, FCELL_TYPE);
break;
case (DCELL_TYPE):
- G_zero_raster_buf(dtmp, DCELL_TYPE);
- G_get_raster_row(finput, dtmp, i, DCELL_TYPE);
+ Rast_zero_raster_buf(dtmp, DCELL_TYPE);
+ Rast_get_raster_row(finput, dtmp, i, DCELL_TYPE);
break;
}
- G_get_null_value_row(finput, nul_buf, i);
+ Rast_get_null_value_row(finput, nul_buf, i);
for (j = 0; j < ncols; j++) {
@@ -1750,11 +1750,11 @@
}
else {
regcnt = 0;
- fr = G_open_cell_old(choice->reg, G_mapset());
- row_buf = G_allocate_raster_buf(CELL_TYPE);
+ fr = Rast_open_cell_old(choice->reg, G_mapset());
+ row_buf = Rast_allocate_raster_buf(CELL_TYPE);
for (i = 0; i < nrows; i++) {
- G_zero_raster_buf(row_buf, CELL_TYPE);
- G_get_raster_row(fr, row_buf, i, CELL_TYPE);
+ Rast_zero_raster_buf(row_buf, CELL_TYPE);
+ Rast_get_raster_row(fr, row_buf, i, CELL_TYPE);
for (j = 0; j < ncols; j++) {
if (*(row_buf + j)) {
if (regcnt == 0)
@@ -1805,7 +1805,7 @@
cntwhole, 0.0);
ptrthis = ptrthis->next;
}
- G_close_cell(fr);
+ Rast_close_cell(fr);
G_free(row_buf);
G_free(ptrnew);
}
Modified: grass/trunk/raster/r.le/r.le.pixel/pixel.h
===================================================================
--- grass/trunk/raster/r.le/r.le.pixel/pixel.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.pixel/pixel.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#define BIG 1000000000.0
#define MAX 800
Modified: grass/trunk/raster/r.le/r.le.pixel/texture.c
===================================================================
--- grass/trunk/raster/r.le/r.le.pixel/texture.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.pixel/texture.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -37,7 +37,7 @@
struct Categories cats;
-char *G_get_cat();
+char *Rast_get_cat();
/* declare a counter for the number
of pixels with non-null values
@@ -259,7 +259,7 @@
DCELL **edgemap_d, *edge_buf_d, *zscor_buf;
RASTER_MAP_TYPE data_type;
- data_type = G_raster_map_type(choice->fn, G_mapset());
+ data_type = Rast_raster_map_type(choice->fn, G_mapset());
/* set the contents of the arrays
used to stored the results of the
@@ -464,42 +464,42 @@
/* if the edge map was requested */
if (choice->edgemap) {
- fc = G_open_raster_new("edge", data_type);
+ fc = Rast_open_raster_new("edge", data_type);
switch (data_type) {
case (CELL_TYPE):
- edge_buf_c = G_allocate_raster_buf(CELL_TYPE);
+ edge_buf_c = Rast_allocate_raster_buf(CELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- G_zero_raster_buf(edge_buf_c, CELL_TYPE);
- G_set_null_value(edge_buf_c, ncols + 1, CELL_TYPE);
+ Rast_zero_raster_buf(edge_buf_c, CELL_TYPE);
+ Rast_set_null_value(edge_buf_c, ncols + 1, CELL_TYPE);
for (j = 1; j < ncols + 1; j++) {
if (*(*(edgenull + i) + j) == 0)
*(edge_buf_c + j - 1) = edgemap_c[i][j];
}
- G_put_raster_row(fc, edge_buf_c, CELL_TYPE);
+ Rast_put_raster_row(fc, edge_buf_c, CELL_TYPE);
}
break;
case (FCELL_TYPE):
- edge_buf_f = G_allocate_raster_buf(FCELL_TYPE);
+ edge_buf_f = Rast_allocate_raster_buf(FCELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- G_zero_raster_buf(edge_buf_f, FCELL_TYPE);
- G_set_null_value(edge_buf_f, ncols + 1, FCELL_TYPE);
+ Rast_zero_raster_buf(edge_buf_f, FCELL_TYPE);
+ Rast_set_null_value(edge_buf_f, ncols + 1, FCELL_TYPE);
for (j = 1; j < ncols + 1; j++) {
if (*(*(edgenull + i) + j) == 0)
*(edge_buf_f + j - 1) = edgemap_f[i][j];
}
- G_put_raster_row(fc, edge_buf_f, FCELL_TYPE);
+ Rast_put_raster_row(fc, edge_buf_f, FCELL_TYPE);
}
break;
case (DCELL_TYPE):
- edge_buf_d = G_allocate_raster_buf(DCELL_TYPE);
+ edge_buf_d = Rast_allocate_raster_buf(DCELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- G_zero_raster_buf(edge_buf_d, DCELL_TYPE);
- G_set_null_value(edge_buf_d, ncols + 1, DCELL_TYPE);
+ Rast_zero_raster_buf(edge_buf_d, DCELL_TYPE);
+ Rast_set_null_value(edge_buf_d, ncols + 1, DCELL_TYPE);
for (j = 1; j < ncols + 1; j++) {
if (*(*(edgenull + i) + j) == 0)
*(edge_buf_d + j - 1) = edgemap_d[i][j];
}
- G_put_raster_row(fc, edge_buf_d, DCELL_TYPE);
+ Rast_put_raster_row(fc, edge_buf_d, DCELL_TYPE);
}
break;
}
@@ -526,17 +526,17 @@
for (i = 0; i < nrows + 3; i++)
G_free(edgenull[i]);
G_free(edgenull);
- G_close_cell(fc);
+ Rast_close_cell(fc);
}
/* if the zscore map was requested */
if (choice->z) {
- fd = G_open_raster_new("zscores", DCELL_TYPE);
- zscor_buf = G_allocate_raster_buf(DCELL_TYPE);
+ fd = Rast_open_raster_new("zscores", DCELL_TYPE);
+ zscor_buf = Rast_allocate_raster_buf(DCELL_TYPE);
for (i = 1; i < nrows + 1; i++) {
- G_zero_raster_buf(zscor_buf, DCELL_TYPE);
- G_set_null_value(zscor_buf, ncols + 1, DCELL_TYPE);
+ Rast_zero_raster_buf(zscor_buf, DCELL_TYPE);
+ Rast_set_null_value(zscor_buf, ncols + 1, DCELL_TYPE);
for (j = 1; j < ncols + 1; j++) {
if (attr[1] > 0.0)
if ((buf[i][j] || buf[i][j] == 0) &&
@@ -544,10 +544,10 @@
*(zscor_buf + j - 1) =
(buf[i][j] - attr[0]) / attr[1];
}
- G_put_raster_row(fd, zscor_buf, DCELL_TYPE);
+ Rast_put_raster_row(fd, zscor_buf, DCELL_TYPE);
}
G_free(zscor_buf);
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
/* open the output files and
Modified: grass/trunk/raster/r.le/r.le.setup/mv_wind.c
===================================================================
--- grass/trunk/raster/r.le/r.le.setup/mv_wind.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.setup/mv_wind.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -103,7 +103,7 @@
fprintf(stderr,
" If a MASK is present there will be no warning.\n");
- fmask = G_open_cell_old("MASK", G_mapset());
+ fmask = Rast_open_cell_old("MASK", G_mapset());
fprintf(stderr, "\n");
@@ -338,7 +338,7 @@
t = t0;
}
- G_close_cell(fmask);
+ Rast_close_cell(fmask);
}
/* if neither, then exit */
Modified: grass/trunk/raster/r.le/r.le.setup/polytocell/bmf_to_cll.c
===================================================================
--- grass/trunk/raster/r.le/r.le.setup/polytocell/bmf_to_cll.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.setup/polytocell/bmf_to_cll.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -48,7 +48,7 @@
num_rows = col_b;
num_cols = col_e;
- if (G_get_cellhd(argv[1], mapset = G_mapset(), &wind)) {
+ if (Rast_get_cellhd(argv[1], mapset = G_mapset(), &wind)) {
fprintf(stderr, "ERROR bmif_to_cell: can't read cellhd file for %s\n",
argv[1]);
quit();
@@ -66,9 +66,9 @@
G_set_window(&wind);
- record = G_allocate_cell_buf();
+ record = Rast_allocate_cell_buf();
- if ((newmap = G_open_cell_new(argv[1])) == -1) {
+ if ((newmap = Rast_open_cell_new(argv[1])) == -1) {
fprintf(stderr, "ERROR bmif_to_cell: can't open raster map %s\n",
argv[1]);
quit();
@@ -91,17 +91,17 @@
if (cur_row > num_rows) {
while (atrow < num_rows) {
- G_put_map_row(newmap, record);
+ Rast_put_map_row(newmap, record);
atrow++;
}
- G_close_cell(newmap);
+ Rast_close_cell(newmap);
goto finish;
}
/* write out enough rows to get to current row */
while (atrow < cur_row + ROW_SHIFT) {
- G_put_map_row(newmap, record);
+ Rast_put_map_row(newmap, record);
atrow++;
}
@@ -114,17 +114,17 @@
}
while (cur_row == (atrow - ROW_SHIFT));
- G_put_map_row(newmap, record);
+ Rast_put_map_row(newmap, record);
}
- fprintf(stderr, "Close: %d\n", G_close_cell(newmap));
+ fprintf(stderr, "Close: %d\n", Rast_close_cell(newmap));
finish:
G_suppress_warnings(1);
- stat = G_read_vector_cats(argv[1], mapset, &cats);
+ stat = Rast_read_vector_cats(argv[1], mapset, &cats);
G_suppress_warnings(0);
if (stat >= 0) { /* if cats file existed */
printf("Copying vector category file\n");
- stat = G_write_cats(argv[1], &cats);
+ stat = Rast_write_cats(argv[1], &cats);
}
exit(0);
}
Modified: grass/trunk/raster/r.le/r.le.setup/sample.c
===================================================================
--- grass/trunk/raster/r.le/r.le.setup/sample.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.setup/sample.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -102,7 +102,7 @@
" and a WARNING may be printed that can be ignored.\n");
fprintf(stderr,
" If a MASK is present there will be no warning.\n");
- fmask = G_open_cell_old("MASK", G_mapset());
+ fmask = Rast_open_cell_old("MASK", G_mapset());
fprintf(stderr, "\n");
@@ -118,7 +118,7 @@
else if (d == 2)
graph_unit(t0, b0, l0, r0, name, name1, name2, msc, fmask);
- G_close_cell(fmask);
+ Rast_close_cell(fmask);
}
/* if neither, then exit */
else
@@ -353,18 +353,18 @@
if (fmask > 0) {
count = 0;
- row_buf = G_allocate_raster_buf(CELL_TYPE);
- fr = G_open_cell_old(n1, G_mapset());
+ row_buf = Rast_allocate_raster_buf(CELL_TYPE);
+ fr = Rast_open_cell_old(n1, G_mapset());
for (j = t; j < b; j++) {
- G_zero_raster_buf(row_buf, CELL_TYPE);
- G_get_raster_row(fr, row_buf, j, CELL_TYPE);
+ Rast_zero_raster_buf(row_buf, CELL_TYPE);
+ Rast_get_raster_row(fr, row_buf, j, CELL_TYPE);
for (k = l; k < r; k++) {
if (*(row_buf + k))
count++;
}
}
G_free(row_buf);
- G_close_cell(fr);
+ Rast_close_cell(fr);
cnt = (double)(count);
if (cnt)
cnt = sqrt(cnt);
@@ -410,18 +410,18 @@
if (fmask > 0) {
count = 0;
- row_buf = G_allocate_raster_buf(CELL_TYPE);
- fr = G_open_cell_old(n1, G_mapset());
+ row_buf = Rast_allocate_raster_buf(CELL_TYPE);
+ fr = Rast_open_cell_old(n1, G_mapset());
for (j = t; j < b; j++) {
- G_zero_raster_buf(row_buf, CELL_TYPE);
- G_get_raster_row(fr, row_buf, j, CELL_TYPE);
+ Rast_zero_raster_buf(row_buf, CELL_TYPE);
+ Rast_get_raster_row(fr, row_buf, j, CELL_TYPE);
for (k = l; k < r; k++) {
if (*(row_buf + k))
count++;
}
}
G_free(row_buf);
- G_close_cell(fr);
+ Rast_close_cell(fr);
cnt = (double)(count);
if (cnt)
cnt = sqrt(cnt);
@@ -956,14 +956,14 @@
the unit will be within the mask area */
if (fmask > 0) {
- row_buf = G_allocate_cell_buf();
- G_get_map_row_nomask(fmask, row_buf, t + top1);
+ row_buf = Rast_allocate_cell_buf();
+ Rast_get_map_row_nomask(fmask, row_buf, t + top1);
if (!
(*(row_buf + l + left1) &&
*(row_buf + l + left1 + u_w - 1)))
goto back;
- G_zero_cell_buf(row_buf);
- G_get_map_row_nomask(fmask, row_buf, t + top1 + u_l - 1);
+ Rast_zero_cell_buf(row_buf);
+ Rast_get_map_row_nomask(fmask, row_buf, t + top1 + u_l - 1);
if (!
(*(row_buf + l + left1) &&
*(row_buf + l + left1 + u_w - 1)))
@@ -1407,8 +1407,8 @@
corners of the unit are in the mask */
if (fmask > 0) {
- row_buf = G_allocate_cell_buf();
- G_get_map_row_nomask(fmask, row_buf, at);
+ row_buf = Rast_allocate_cell_buf();
+ Rast_get_map_row_nomask(fmask, row_buf, at);
if (!(*(row_buf + al) && *(row_buf + ar - 1))) {
fprintf(stderr,
"\n The unit would be outside the mask; ");
@@ -1417,8 +1417,8 @@
G_free(row_buf);
goto back1;
}
- G_zero_cell_buf(row_buf);
- G_get_map_row_nomask(fmask, row_buf, ab - 1);
+ Rast_zero_cell_buf(row_buf);
+ Rast_get_map_row_nomask(fmask, row_buf, ab - 1);
if (!(*(row_buf + al) && *(row_buf + ar - 1))) {
fprintf(stderr,
"\n The unit would be outside the mask; ");
@@ -1529,8 +1529,8 @@
the unit will be within the mask area */
if (fmask > 0) {
- row_buf = G_allocate_cell_buf();
- G_get_map_row_nomask(fmask, row_buf, at);
+ row_buf = Rast_allocate_cell_buf();
+ Rast_get_map_row_nomask(fmask, row_buf, at);
if (!(*(row_buf + al) && *(row_buf + ar - 1))) {
fprintf(stderr,
"\n The unit would be outside the mask; ");
@@ -1539,8 +1539,8 @@
G_free(row_buf);
goto back2;
}
- G_zero_cell_buf(row_buf);
- G_get_map_row_nomask(fmask, row_buf, ab - 1);
+ Rast_zero_cell_buf(row_buf);
+ Rast_get_map_row_nomask(fmask, row_buf, ab - 1);
if (!(*(row_buf + al) && *(row_buf + ar - 1))) {
fprintf(stderr,
"\n The unit would be outside the mask; ");
Modified: grass/trunk/raster/r.le/r.le.setup/setup.c
===================================================================
--- grass/trunk/raster/r.le/r.le.setup/setup.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.setup/setup.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -122,8 +122,8 @@
*/
colors_old = (struct Colors *)G_malloc(1 * sizeof(struct Colors));
- G_init_colors(colors_old);
- G_read_colors(name, G_mapset(), colors_old);
+ Rast_init_colors(colors_old);
+ Rast_read_colors(name, G_mapset(), colors_old);
G_system("clear");
paint_map(name, name1, name2);
@@ -238,8 +238,8 @@
/* reset the colortable and exit */
else if (method == 7) {
- G_write_colors(name, G_mapset(), colors_old);
- G_free_colors(colors_old);
+ Rast_write_colors(name, G_mapset(), colors_old);
+ Rast_free_colors(colors_old);
/* R_close_driver(); */
G_system("d.frame -e");
exit(0);
@@ -624,7 +624,7 @@
fprintf(tmp, "E\n");
fclose(tmp);
G_get_set_window(&wind);
- G_put_cellhd(name, &wind);
+ Rast_put_cellhd(name, &wind);
/* make a GRASS raster map from the
region boundary pts, using the
@@ -642,9 +642,9 @@
/* set the color table for the regions
file to color wave */
- G_init_colors(&colors);
- G_make_wave_colors(&colors, 1, class);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_init_colors(&colors);
+ Rast_make_wave_colors(&colors, 1, class);
+ Rast_write_colors(name, G_mapset(), &colors);
/* overlay the region file on the
screen */
@@ -711,8 +711,8 @@
double etmp;
- G_read_range(name, G_mapset(), &range);
- G_get_range_min_max(&range, &min, &max);
+ Rast_read_range(name, G_mapset(), &range);
+ Rast_get_range_min_max(&range, &min, &max);
G_system("clear");
again:
@@ -738,39 +738,39 @@
while (d > 10 || d < 1);
if (d == 1) {
- G_make_aspect_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_aspect_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 2) {
- G_make_ramp_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_ramp_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 3) {
- G_make_wave_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_wave_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 4) {
- G_make_grey_scale_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_grey_scale_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 5) {
- G_make_rainbow_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_rainbow_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 6) {
- G_make_random_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_random_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 7) {
- G_make_ryg_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_ryg_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 8) {
- G_make_gyr_colors(&colors, min, max);
- G_write_colors(name, G_mapset(), &colors);
+ Rast_make_gyr_colors(&colors, min, max);
+ Rast_write_colors(name, G_mapset(), &colors);
}
else if (d == 9) {
- G_write_colors(name, G_mapset(), colors_old);
+ Rast_write_colors(name, G_mapset(), colors_old);
}
else if (d == 10) {
return;
@@ -802,8 +802,8 @@
else if (d == 2)
return;
else if (d == 3) {
- G_write_colors(name, G_mapset(), colors_old);
- G_free_colors(colors_old);
+ Rast_write_colors(name, G_mapset(), colors_old);
+ Rast_free_colors(colors_old);
}
else if (d == 4)
*colors_old = colors;
Modified: grass/trunk/raster/r.le/r.le.setup/setup.h
===================================================================
--- grass/trunk/raster/r.le/r.le.setup/setup.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.setup/setup.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -28,6 +28,7 @@
#include "stdlib.h"
#include "string.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "sys/types.h"
Modified: grass/trunk/raster/r.le/r.le.trace/main.c
===================================================================
--- grass/trunk/raster/r.le/r.le.trace/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.trace/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -435,7 +435,7 @@
name = choice->fn;
mapset = G_mapset();
- data_type = G_raster_map_type(name, mapset);
+ data_type = Rast_raster_map_type(name, mapset);
/* dynamically allocate storage for the
buffer that will hold the contents of
@@ -443,7 +443,7 @@
buf = (DCELL **) G_calloc(nrows + 3, sizeof(DCELL *));
for (i = 0; i < nrows + 3; i++) {
- buf[i] = (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ buf[i] = (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
}
@@ -453,7 +453,7 @@
null_buf = (DCELL **) G_calloc(nrows + 3, sizeof(DCELL *));
for (i = 0; i < nrows + 3; i++)
- null_buf[i] = (DCELL *) G_allocate_raster_buf(DCELL_TYPE);
+ null_buf[i] = (DCELL *) Rast_allocate_raster_buf(DCELL_TYPE);
/* clip out the sampling area */
@@ -553,7 +553,7 @@
map remains open on finput while all the programs
run, so it is globally available */
- if (0 > (finput = G_open_cell_old(choice->fn, G_mapset()))) {
+ if (0 > (finput = Rast_open_cell_old(choice->fn, G_mapset()))) {
fprintf(stderr, "\n");
fprintf(stderr,
" ********************************************************\n");
@@ -567,7 +567,7 @@
}
else
- data_type = G_raster_map_type(choice->fn, G_mapset());
+ data_type = Rast_raster_map_type(choice->fn, G_mapset());
/* allocate memory to store a row of the
raster map, depending on the type of
@@ -576,15 +576,15 @@
switch (data_type) {
case CELL_TYPE:
- tmp = G_allocate_raster_buf(CELL_TYPE);
+ tmp = Rast_allocate_raster_buf(CELL_TYPE);
tmpname = "tmp";
break;
case FCELL_TYPE:
- ftmp = G_allocate_raster_buf(FCELL_TYPE);
+ ftmp = Rast_allocate_raster_buf(FCELL_TYPE);
tmpname = "ftmp";
break;
case DCELL_TYPE:
- dtmp = G_allocate_raster_buf(DCELL_TYPE);
+ dtmp = Rast_allocate_raster_buf(DCELL_TYPE);
tmpname = "dtmp";
break;
}
@@ -609,16 +609,16 @@
switch (data_type) {
case CELL_TYPE:
- G_zero_raster_buf(tmp, data_type);
- G_get_raster_row(finput, tmp, i, data_type);
+ Rast_zero_raster_buf(tmp, data_type);
+ Rast_get_raster_row(finput, tmp, i, data_type);
break;
case FCELL_TYPE:
- G_zero_raster_buf(ftmp, data_type);
- G_get_raster_row(finput, ftmp, i, data_type);
+ Rast_zero_raster_buf(ftmp, data_type);
+ Rast_get_raster_row(finput, ftmp, i, data_type);
break;
case DCELL_TYPE:
- G_zero_raster_buf(dtmp, data_type);
- G_get_raster_row(finput, dtmp, i, data_type);
+ Rast_zero_raster_buf(dtmp, data_type);
+ Rast_get_raster_row(finput, dtmp, i, data_type);
break;
}
@@ -632,17 +632,17 @@
case CELL_TYPE:
rastptr = tmp;
for (x = 0; x < col0; x++)
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(CELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(CELL_TYPE));
break;
case FCELL_TYPE:
rastptr = ftmp;
for (x = 0; x < col0; x++)
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(FCELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(FCELL_TYPE));
break;
case DCELL_TYPE:
rastptr = dtmp;
for (x = 0; x < col0; x++)
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(DCELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(DCELL_TYPE));
break;
}
@@ -657,7 +657,7 @@
switch (data_type) {
case CELL_TYPE:
- if (G_is_null_value(rastptr, CELL_TYPE)) {
+ if (Rast_is_null_value(rastptr, CELL_TYPE)) {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
if (i == row0 + nrows / 2 && j == col0 + ncols / 2)
*centernull = 1;
@@ -665,11 +665,11 @@
else {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 0.0;
}
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(CELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(CELL_TYPE));
break;
case FCELL_TYPE:
- if (G_is_null_value(rastptr, FCELL_TYPE)) {
+ if (Rast_is_null_value(rastptr, FCELL_TYPE)) {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
if (i == row0 + nrows / 2 && j == col0 + ncols / 2)
*centernull = 1;
@@ -677,11 +677,11 @@
else {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 0.0;
}
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(FCELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(FCELL_TYPE));
break;
case DCELL_TYPE:
- if (G_is_null_value(rastptr, DCELL_TYPE)) {
+ if (Rast_is_null_value(rastptr, DCELL_TYPE)) {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 1.0;
if (i == row0 + nrows / 2 && j == col0 + ncols / 2)
*centernull = 1;
@@ -689,7 +689,7 @@
else {
*(*(null_buf + i + 1 - row0) + j + 1 - col0) = 0.0;
}
- rastptr = G_incr_void_ptr(rastptr, G_raster_size(CELL_TYPE));
+ rastptr = Rast_incr_void_ptr(rastptr, Rast_raster_size(CELL_TYPE));
break;
}
@@ -932,7 +932,7 @@
patchmap = (CELL **) G_calloc(nrows + 3, sizeof(CELL *));
for (m = 0; m < nrows + 3; m++)
- patchmap[m] = (CELL *) G_allocate_raster_buf(CELL_TYPE);
+ patchmap[m] = (CELL *) Rast_allocate_raster_buf(CELL_TYPE);
/* if this is the first patch to be traced,
then set the next patch on the patch list
Modified: grass/trunk/raster/r.le/r.le.trace/r.le.trace.h
===================================================================
--- grass/trunk/raster/r.le/r.le.trace/r.le.trace.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.le/r.le.trace/r.le.trace.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,6 +26,7 @@
#include "stdlib.h"
#include "string.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#define EQ(a, b) (a-b < 0.01 && a-b > -0.01 )
#define BIG 500000000.0
Modified: grass/trunk/raster/r.li/r.li.cwed/cwed.c
===================================================================
--- grass/trunk/raster/r.li/r.li.cwed/cwed.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.cwed/cwed.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <fcntl.h> /* for O_RDONLY usage */
@@ -159,7 +160,7 @@
return RLI_ERRORE;
}
- if (G_get_cellhd(ad->raster, "", &hd) == -1) {
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1) {
G_fatal_error("can't read raster header");
return RLI_ERRORE;
}
@@ -340,7 +341,7 @@
}
- buf_sup = G_allocate_cell_buf();
+ buf_sup = Rast_allocate_cell_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
@@ -349,13 +350,13 @@
c1.t = CELL_TYPE;
c2.t = CELL_TYPE;
- buf_corr = G_allocate_cell_buf();
+ buf_corr = Rast_allocate_cell_buf();
if (buf_corr == NULL) {
G_fatal_error("error malloc buf_corr");
return RLI_ERRORE;
}
- G_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (j = 0; j < ad->rl; j++) { /* for each row */
buf_corr = RLI_get_cell_raster_row(fd, j + ad->y, ad); /* read row of raster */
if (j > 0) { /* not first row */
@@ -369,20 +370,20 @@
}
}
- G_set_c_null_value(&prevCell, 1);
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&prevCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
area++;
corrCell = buf_corr[i + ad->x];
if (masked && mask_corr[i + ad->x] == 0) {
area--;
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, CELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, CELL_TYPE))) {
supCell = buf_sup[i + ad->x];
/* calculate how many edge the cell has */
- if (((!G_is_null_value(&prevCell, CELL_TYPE))) &&
+ if (((!Rast_is_null_value(&prevCell, CELL_TYPE))) &&
(corrCell != prevCell)) {
int r = 0;
@@ -395,7 +396,7 @@
}
- if ((!(G_is_null_value(&supCell, CELL_TYPE))) &&
+ if ((!(Rast_is_null_value(&supCell, CELL_TYPE))) &&
(corrCell != supCell)) {
int r = 0;
@@ -481,7 +482,7 @@
}
- buf_sup = G_allocate_d_raster_buf();
+ buf_sup = Rast_allocate_d_raster_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
@@ -490,9 +491,9 @@
c1.t = DCELL_TYPE;
c2.t = DCELL_TYPE;
- buf_corr = G_allocate_d_raster_buf();
+ buf_corr = Rast_allocate_d_raster_buf();
- G_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (j = 0; j < ad->rl; j++) { /* for each row */
buf_corr = RLI_get_dcell_raster_row(fd, j + ad->y, ad); /* read row of raster */
@@ -506,19 +507,19 @@
return RLI_ERRORE;
}
}
- G_set_d_null_value(&prevCell, 1);
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&prevCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
area++;
corrCell = buf_corr[i + ad->x];
if (masked && mask_corr[i + ad->x] == 0) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, DCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, DCELL_TYPE))) {
supCell = buf_sup[i + ad->x];
/* calculate how many edge the cell has */
- if (((!G_is_null_value(&prevCell, DCELL_TYPE))) &&
+ if (((!Rast_is_null_value(&prevCell, DCELL_TYPE))) &&
(corrCell != prevCell)) {
int r = 0;
@@ -530,7 +531,7 @@
}
- if ((!(G_is_null_value(&supCell, DCELL_TYPE))) &&
+ if ((!(Rast_is_null_value(&supCell, DCELL_TYPE))) &&
(corrCell != supCell)) {
int r = 0;
@@ -617,14 +618,14 @@
}
/* allocate and inizialize buffers */
- buf_sup = G_allocate_f_raster_buf();
+ buf_sup = Rast_allocate_f_raster_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- G_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
- buf_corr = G_allocate_f_raster_buf();
+ buf_corr = Rast_allocate_f_raster_buf();
if (buf_corr == NULL) {
G_fatal_error("malloc buf_corr failed");
return RLI_ERRORE;
@@ -646,19 +647,19 @@
return RLI_ERRORE;
}
}
- G_set_f_null_value(&prevCell, 1);
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&prevCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
area++;
corrCell = buf_corr[i + ad->x];
if (masked && mask_corr[i + ad->x] == 0) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, FCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, FCELL_TYPE))) {
supCell = buf_sup[i + ad->x];
- if (((!G_is_null_value(&prevCell, FCELL_TYPE))) &&
+ if (((!Rast_is_null_value(&prevCell, FCELL_TYPE))) &&
(corrCell != prevCell)) {
int r = 0;
@@ -670,7 +671,7 @@
}
- if ((!(G_is_null_value(&supCell, FCELL_TYPE))) &&
+ if ((!(Rast_is_null_value(&supCell, FCELL_TYPE))) &&
(corrCell != supCell)) {
int r = 0;
@@ -737,22 +738,22 @@
switch (ce1.t) {
case CELL_TYPE:
{
- if ((G_is_null_value(&ce1.val.c, CELL_TYPE)) ||
- (G_is_null_value(&ce2.val.c, CELL_TYPE)))
+ if ((Rast_is_null_value(&ce1.val.c, CELL_TYPE)) ||
+ (Rast_is_null_value(&ce2.val.c, CELL_TYPE)))
return _ERR;
break;
}
case DCELL_TYPE:
{
- if ((G_is_null_value(&ce1.val.dc, DCELL_TYPE)) ||
- (G_is_null_value(&ce2.val.dc, DCELL_TYPE)))
+ if ((Rast_is_null_value(&ce1.val.dc, DCELL_TYPE)) ||
+ (Rast_is_null_value(&ce2.val.dc, DCELL_TYPE)))
return _ERR;
break;
}
case FCELL_TYPE:
{
- if ((G_is_null_value(&ce1.val.fc, FCELL_TYPE)) ||
- (G_is_null_value(&ce2.val.fc, FCELL_TYPE)))
+ if ((Rast_is_null_value(&ce1.val.fc, FCELL_TYPE)) ||
+ (Rast_is_null_value(&ce2.val.fc, FCELL_TYPE)))
return _ERR;
break;
}
@@ -824,22 +825,22 @@
switch (c1.t) {
case CELL_TYPE:
{
- if ((G_is_null_value(&(c1.val.c), CELL_TYPE)) ||
- (G_is_null_value(&(c2.val.c), CELL_TYPE)))
+ if ((Rast_is_null_value(&(c1.val.c), CELL_TYPE)) ||
+ (Rast_is_null_value(&(c2.val.c), CELL_TYPE)))
return RLI_ERRORE;
break;
}
case DCELL_TYPE:
{
- if ((G_is_null_value(&(c1.val.dc), DCELL_TYPE)) ||
- (G_is_null_value(&(c2.val.dc), DCELL_TYPE)))
+ if ((Rast_is_null_value(&(c1.val.dc), DCELL_TYPE)) ||
+ (Rast_is_null_value(&(c2.val.dc), DCELL_TYPE)))
return RLI_ERRORE;
break;
}
case FCELL_TYPE:
{
- if ((G_is_null_value(&(c1.val.fc), FCELL_TYPE)) ||
- (G_is_null_value(&(c2.val.fc), FCELL_TYPE)))
+ if ((Rast_is_null_value(&(c1.val.fc), FCELL_TYPE)) ||
+ (Rast_is_null_value(&(c2.val.fc), FCELL_TYPE)))
return RLI_ERRORE;
break;
}
Modified: grass/trunk/raster/r.li/r.li.cwed/utility.c
===================================================================
--- grass/trunk/raster/r.li/r.li.cwed/utility.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.cwed/utility.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -10,6 +10,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <string.h>
Modified: grass/trunk/raster/r.li/r.li.daemon/GenericCell.h
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/GenericCell.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/GenericCell.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,6 +9,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#ifndef GENERICCELL_H
Modified: grass/trunk/raster/r.li/r.li.daemon/avl.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/avl.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/avl.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
* \BUGS: please send bugs reports to pallecch at cli.di.unipi.it
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <string.h>
Modified: grass/trunk/raster/r.li/r.li.daemon/avlID.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/avlID.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/avlID.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "daemon.h"
@@ -112,7 +113,7 @@
/* struct Cell_head cellhd_r, cellhd_new;
char *mapset; */
/*creating new raster file */
- mv_fd = G_open_raster_new(output, DCELL_TYPE);
+ mv_fd = Rast_open_raster_new(output, DCELL_TYPE);
if (mv_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), output);
@@ -267,10 +268,10 @@
write_raster(mv_fd, random_access, g);
close(random_access);
unlink(random_access_name);
- G_close_cell(mv_fd);
- G_short_history(output, "raster", &history);
- G_command_history(&history);
- G_write_history(output, &history);
+ Rast_close_cell(mv_fd);
+ Rast_short_history(output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(output, &history);
}
@@ -315,7 +316,7 @@
rel_cl = atof(strtok(NULL, "\n"));
/*finding raster map */
- if (G_get_cellhd(raster, "", &cellhd) == -1)
+ if (Rast_get_cellhd(raster, "", &cellhd) == -1)
G_fatal_error(_("Cannot read raster header file"));
/*calculating absolute sampling frame definition */
sf_x = (int)rint(cellhd.cols * rel_x);
@@ -686,10 +687,10 @@
file_buf = malloc(cols * sizeof(double));
lseek(random_access, 0, SEEK_SET);
- cell_buf = G_allocate_d_raster_buf();
- G_set_d_null_value(cell_buf, G_window_cols() + 1);
+ cell_buf = Rast_allocate_d_raster_buf();
+ Rast_set_d_null_value(cell_buf, G_window_cols() + 1);
for (i = 0; i < g->sf_y + ((int)g->rl / 2); i++) {
- G_put_raster_row(mv_fd, cell_buf, DCELL_TYPE);
+ Rast_put_raster_row(mv_fd, cell_buf, DCELL_TYPE);
}
for (i = 0; i < rows; i++) {
letti = read(random_access, file_buf, (cols * sizeof(double)));
@@ -698,10 +699,10 @@
for (j = 0; j < cols; j++) {
cell_buf[j + center] = file_buf[j];
}
- G_put_raster_row(mv_fd, cell_buf, DCELL_TYPE);
+ Rast_put_raster_row(mv_fd, cell_buf, DCELL_TYPE);
}
- G_set_d_null_value(cell_buf, G_window_cols() + 1);
+ Rast_set_d_null_value(cell_buf, G_window_cols() + 1);
for (i = 0; i < G_window_rows() - g->sf_y - g->rows; i++)
- G_put_raster_row(mv_fd, cell_buf, DCELL_TYPE);
+ Rast_put_raster_row(mv_fd, cell_buf, DCELL_TYPE);
return 1;
}
Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.h
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "list.h"
Modified: grass/trunk/raster/r.li/r.li.daemon/ipc.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/ipc.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/ipc.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ipc.h"
Modified: grass/trunk/raster/r.li/r.li.daemon/list.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/list.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/list.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "daemon.h"
Modified: grass/trunk/raster/r.li/r.li.daemon/worker.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/worker.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.daemon/worker.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -30,6 +30,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "daemon.h"
#include "defs.h"
@@ -58,13 +59,13 @@
pid = getpid();
ad = malloc(sizeof(struct area_entry));
/* open raster map */
- fd = G_open_cell_old(raster, "");
- if (G_get_cellhd(raster, "", &hd) == -1) {
+ fd = Rast_open_cell_old(raster, "");
+ if (Rast_get_cellhd(raster, "", &hd) == -1) {
G_message(_("CHILD[pid = %i] cannot open raster map"), pid);
exit(EXIT_FAILURE);
}
/* read data type to allocate cache */
- data_type = G_raster_map_type(raster, "");
+ data_type = Rast_raster_map_type(raster, "");
/* calculate rows in cache */
switch (data_type) {
case CELL_TYPE:{
@@ -160,19 +161,19 @@
switch (data_type) {
case CELL_TYPE:{
for (i = 0; i < (ad->rl - used); i++) {
- cm->cache[used + i] = G_allocate_cell_buf();
+ cm->cache[used + i] = Rast_allocate_cell_buf();
}
}
break;
case DCELL_TYPE:{
for (i = 0; i < ad->rl - used; i++) {
- dm->cache[used + i] = G_allocate_d_raster_buf();
+ dm->cache[used + i] = Rast_allocate_d_raster_buf();
}
}
break;
case FCELL_TYPE:{
for (i = 0; i < ad->rl - used; i++) {
- fm->cache[used + i] = G_allocate_f_raster_buf();
+ fm->cache[used + i] = Rast_allocate_f_raster_buf();
}
}
break;
@@ -209,7 +210,7 @@
receive(rec_ch, &toReceive);
}
/* close raster map */
- G_close_cell(fd);
+ Rast_close_cell(fd);
/* close channels */
close(rec_ch);
@@ -228,24 +229,24 @@
buf = malloc(cl * sizeof(int));
/* open raster */
- if (G_get_cellhd(raster, "", &cell) == -1)
+ if (Rast_get_cellhd(raster, "", &cell) == -1)
return NULL;
/* open raster */
- if (G_get_cellhd(mask, "", &oldcell) == -1)
+ if (Rast_get_cellhd(mask, "", &oldcell) == -1)
return NULL;
add_row = 1.0 * oldcell.rows / rl;
add_col = 1.0 * oldcell.cols / cl;
tmp_file = G_tempfile();
mask_fd = open(tmp_file, O_RDWR | O_CREAT, 0755);
- old_fd = G_open_cell_old(mask, "");
- old = G_allocate_cell_buf();
+ old_fd = Rast_open_cell_old(mask, "");
+ old = Rast_allocate_cell_buf();
for (i = 0; i < rl; i++) {
int riga;
riga = (int)rint(i * add_row);
- G_get_map_row_nomask(old_fd, old, riga);
+ Rast_get_map_row_nomask(old_fd, old, riga);
for (j = 0; j < cl; j++) {
int colonna;
@@ -267,7 +268,7 @@
if (ad->cm->contents[hash] == row)
return ad->cm->cache[hash];
else {
- G_get_raster_row(fd, ad->cm->cache[hash], row, CELL_TYPE);
+ Rast_get_raster_row(fd, ad->cm->cache[hash], row, CELL_TYPE);
ad->cm->contents[hash] = row;
return ad->cm->cache[hash];
}
@@ -282,7 +283,7 @@
if (ad->dm->contents[hash] == row)
return ad->dm->cache[hash];
else {
- G_get_raster_row(fd, ad->dm->cache[hash], row, DCELL_TYPE);
+ Rast_get_raster_row(fd, ad->dm->cache[hash], row, DCELL_TYPE);
ad->dm->contents[hash] = row;
return ad->dm->cache[hash];
}
@@ -297,7 +298,7 @@
if (ad->fm->contents[hash] == row)
return ad->fm->cache[hash];
else {
- G_get_raster_row(fd, ad->fm->cache[hash], row, FCELL_TYPE);
+ Rast_get_raster_row(fd, ad->fm->cache[hash], row, FCELL_TYPE);
ad->fm->contents[hash] = row;
return ad->fm->cache[hash];
}
Modified: grass/trunk/raster/r.li/r.li.dominance/dominance.c
===================================================================
--- grass/trunk/raster/r.li/r.li.dominance/dominance.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.dominance/dominance.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -72,7 +73,7 @@
struct Cell_head hd;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
@@ -157,7 +158,7 @@
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
/*for each row */
@@ -178,13 +179,13 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, CELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, CELL_TYPE))) {
a = 1;
- if (G_is_null_value(&precCell, cc.t)) {
+ if (Rast_is_null_value(&precCell, cc.t)) {
precCell = corrCell;
}
@@ -368,7 +369,7 @@
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
/*for each row */
for (j = 0; j < ad->rl; j++) {
@@ -388,13 +389,13 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, DCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, DCELL_TYPE))) {
a = 1;
- if (G_is_null_value(&precCell, DCELL_TYPE)) {
+ if (Rast_is_null_value(&precCell, DCELL_TYPE)) {
precCell = corrCell;
}
if (corrCell != precCell) {
@@ -572,7 +573,7 @@
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
/*for each row */
@@ -592,13 +593,13 @@
area++;
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, FCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, FCELL_TYPE))) {
a = 1;
- if (G_is_null_value(&precCell, FCELL_TYPE)) {
+ if (Rast_is_null_value(&precCell, FCELL_TYPE)) {
precCell = corrCell;
}
if (corrCell != precCell) {
Modified: grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c
===================================================================
--- grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -11,6 +11,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -81,7 +82,7 @@
int ris = -1;
double indice = 0;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
@@ -167,13 +168,13 @@
masked = TRUE;
}
- buf_sup = G_allocate_cell_buf();
+ buf_sup = Rast_allocate_cell_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- G_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (j = 0; j < ad->rl; j++) { /* for each raster row */
@@ -188,12 +189,12 @@
buf_inf = RLI_get_cell_raster_row(fd, 1 + j + ad->y, ad);
}
else {
- buf_inf = G_allocate_cell_buf();
+ buf_inf = Rast_allocate_cell_buf();
if (buf_inf == NULL) {
G_fatal_error("malloc buf_inf failed");
return RLI_ERRORE;
}
- G_set_c_null_value(buf_inf + ad->x, ad->cl);
+ Rast_set_c_null_value(buf_inf + ad->x, ad->cl);
}
/*read mask if needed */
@@ -219,9 +220,9 @@
}
- G_set_c_null_value(&nextCell, 1);
- G_set_c_null_value(&prevCell, 1);
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&nextCell, 1);
+ Rast_set_c_null_value(&prevCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
area++;
@@ -229,15 +230,15 @@
if (masked && mask_corr[i + ad->x] == 0) {
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, CELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, CELL_TYPE))) {
if ((i + 1) == ad->cl) /*last cell of the row */
- G_set_c_null_value(&nextCell, 1);
+ Rast_set_c_null_value(&nextCell, 1);
else if (masked && mask_corr[i + 1 + ad->x] == 0)
- G_set_c_null_value(&nextCell, 1);
+ Rast_set_c_null_value(&nextCell, 1);
else
nextCell = buf_corr[i + 1 + ad->x];
@@ -245,30 +246,30 @@
if (masked && mask_inf[i + ad->x] == 0)
- G_set_c_null_value(&infCell, 1);
+ Rast_set_c_null_value(&infCell, 1);
else
infCell = buf_inf[i + ad->x];
/* calculate how many edge the cell has */
- if ((G_is_null_value(&prevCell, CELL_TYPE)) ||
+ if ((Rast_is_null_value(&prevCell, CELL_TYPE)) ||
(corrCell != prevCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&supCell, CELL_TYPE)) ||
+ if ((Rast_is_null_value(&supCell, CELL_TYPE)) ||
(corrCell != supCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&infCell, CELL_TYPE)) ||
+ if ((Rast_is_null_value(&infCell, CELL_TYPE)) ||
(corrCell != infCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&nextCell, CELL_TYPE)) ||
+ if ((Rast_is_null_value(&nextCell, CELL_TYPE)) ||
(corrCell != nextCell)) {
bordoCorr++;
}
@@ -428,13 +429,13 @@
masked = TRUE;
}
- buf_sup = G_allocate_d_raster_buf();
+ buf_sup = Rast_allocate_d_raster_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- G_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (j = 0; j < ad->rl; j++) { /* for each raster row */
@@ -450,13 +451,13 @@
buf_inf = RLI_get_dcell_raster_row(fd, 1 + j + ad->y, ad);
}
else {
- buf_inf = G_allocate_d_raster_buf();
+ buf_inf = Rast_allocate_d_raster_buf();
if (buf_inf == NULL) {
G_fatal_error("malloc buf_inf failed");
return RLI_ERRORE;
}
- G_set_d_null_value(buf_inf + ad->x, ad->cl);
+ Rast_set_d_null_value(buf_inf + ad->x, ad->cl);
}
/*read mask if needed */
@@ -483,9 +484,9 @@
}
- G_set_d_null_value(&nextCell, 1);
- G_set_d_null_value(&prevCell, 1);
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&nextCell, 1);
+ Rast_set_d_null_value(&prevCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
@@ -494,18 +495,18 @@
if (masked && mask_corr[i + ad->x] == 0) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, DCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, DCELL_TYPE))) {
if ((i + 1) == ad->cl) /*last cell of the row */
- G_set_d_null_value(&nextCell, 1);
+ Rast_set_d_null_value(&nextCell, 1);
else if (masked && mask_corr[i + 1 + ad->x] == 0)
- G_set_d_null_value(&nextCell, 1);
+ Rast_set_d_null_value(&nextCell, 1);
else
nextCell = buf_corr[i + 1 + ad->x];
@@ -513,30 +514,30 @@
if (masked && mask_inf[i + ad->x] == 0)
- G_set_d_null_value(&infCell, 1);
+ Rast_set_d_null_value(&infCell, 1);
else
infCell = buf_inf[i + ad->x];
/* calculate how many edge the cell has */
- if ((G_is_null_value(&prevCell, DCELL_TYPE)) ||
+ if ((Rast_is_null_value(&prevCell, DCELL_TYPE)) ||
(corrCell != prevCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&supCell, DCELL_TYPE)) ||
+ if ((Rast_is_null_value(&supCell, DCELL_TYPE)) ||
(corrCell != supCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&infCell, DCELL_TYPE)) ||
+ if ((Rast_is_null_value(&infCell, DCELL_TYPE)) ||
(corrCell != infCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&nextCell, DCELL_TYPE)) ||
+ if ((Rast_is_null_value(&nextCell, DCELL_TYPE)) ||
(corrCell != nextCell)) {
bordoCorr++;
}
@@ -693,13 +694,13 @@
masked = TRUE;
}
- buf_sup = G_allocate_f_raster_buf();
+ buf_sup = Rast_allocate_f_raster_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- G_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (j = 0; j < ad->rl; j++) { /* for each raster row */
@@ -715,13 +716,13 @@
buf_inf = RLI_get_fcell_raster_row(fd, 1 + j + ad->y, ad);
}
else {
- buf_inf = G_allocate_f_raster_buf();
+ buf_inf = Rast_allocate_f_raster_buf();
if (mask_inf == NULL) {
G_fatal_error("malloc mask_inf failed");
return RLI_ERRORE;
}
- G_set_f_null_value(buf_inf + ad->x, ad->cl);
+ Rast_set_f_null_value(buf_inf + ad->x, ad->cl);
}
/*read mask if needed */
@@ -748,9 +749,9 @@
}
- G_set_f_null_value(&nextCell, 1);
- G_set_f_null_value(&prevCell, 1);
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&nextCell, 1);
+ Rast_set_f_null_value(&prevCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
for (i = 0; i < ad->cl; i++) { /* for each cell in the row */
area++;
@@ -758,16 +759,16 @@
if (masked && mask_corr[i + ad->x] == 0) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, FCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, FCELL_TYPE))) {
if ((i + 1) == ad->cl) /*last cell of the row */
- G_set_f_null_value(&nextCell, 1);
+ Rast_set_f_null_value(&nextCell, 1);
else if (masked && mask_corr[i + 1 + ad->x] == 0)
- G_set_f_null_value(&nextCell, 1);
+ Rast_set_f_null_value(&nextCell, 1);
else
nextCell = buf_corr[i + 1 + ad->x];
@@ -775,30 +776,30 @@
if (masked && mask_inf[i + ad->x] == 0)
- G_set_f_null_value(&infCell, 1);
+ Rast_set_f_null_value(&infCell, 1);
else
infCell = buf_inf[i + ad->x];
/* calculate how many edge the cell has */
- if ((G_is_null_value(&prevCell, FCELL_TYPE)) ||
+ if ((Rast_is_null_value(&prevCell, FCELL_TYPE)) ||
(corrCell != prevCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&supCell, FCELL_TYPE)) ||
+ if ((Rast_is_null_value(&supCell, FCELL_TYPE)) ||
(corrCell != supCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&infCell, FCELL_TYPE)) ||
+ if ((Rast_is_null_value(&infCell, FCELL_TYPE)) ||
(corrCell != infCell)) {
bordoCorr++;
}
- if ((G_is_null_value(&nextCell, FCELL_TYPE)) ||
+ if ((Rast_is_null_value(&nextCell, FCELL_TYPE)) ||
(corrCell != nextCell)) {
bordoCorr++;
}
Modified: grass/trunk/raster/r.li/r.li.mpa/mpa.c
===================================================================
--- grass/trunk/raster/r.li/r.li.mpa/mpa.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.mpa/mpa.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -68,7 +69,7 @@
double indice = 0;
struct Cell_head hd;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
@@ -149,10 +150,10 @@
for (i = 0; i < ad->cl; i++) { /*for each cell in the row */
area++;
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_c_null_value(&buf[i + ad->x], 1);
+ Rast_set_c_null_value(&buf[i + ad->x], 1);
area--;
}
- if (!(G_is_null_value(&buf[i + ad->x], CELL_TYPE))) { /*if it's a cell to consider */
+ if (!(Rast_is_null_value(&buf[i + ad->x], CELL_TYPE))) { /*if it's a cell to consider */
somma = somma + buf[i + ad->x];
}
}
@@ -214,9 +215,9 @@
area++;
if ((masked) && (mask_buf[i + ad->x] == 0)) {
area--;
- G_set_d_null_value(&buf[i + ad->x], 1);
+ Rast_set_d_null_value(&buf[i + ad->x], 1);
}
- if (!(G_is_null_value(&buf[i + ad->x], DCELL_TYPE))) {
+ if (!(Rast_is_null_value(&buf[i + ad->x], DCELL_TYPE))) {
somma = somma + buf[i + ad->x];
}
}
@@ -280,9 +281,9 @@
if ((masked) && (mask_buf[i + ad->x] == 0)) {
area--;
- G_set_f_null_value(&buf[i + ad->x], 1);
+ Rast_set_f_null_value(&buf[i + ad->x], 1);
}
- if (!(G_is_null_value(&buf[i + ad->x], FCELL_TYPE))) {
+ if (!(Rast_is_null_value(&buf[i + ad->x], FCELL_TYPE))) {
somma = somma + buf[i + ad->x];
}
}
Modified: grass/trunk/raster/r.li/r.li.mps/mps.c
===================================================================
--- grass/trunk/raster/r.li/r.li.mps/mps.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.mps/mps.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -69,7 +70,7 @@
double indice = 0;
struct Cell_head hd;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
switch (ad->data_type) {
@@ -164,19 +165,19 @@
return RLI_ERRORE;
}
- buf_sup = G_allocate_cell_buf();
+ buf_sup = Rast_allocate_cell_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
@@ -196,23 +197,23 @@
return RLI_ERRORE;
}
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++) { /*for each cell in the row */
corrCell = buf[i + ad->x];
if ((masked) && (mask_buf[i + ad->x] == 0)) {
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
}
/*valid cell */
- if (!(G_is_null_value(&corrCell, CELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, CELL_TYPE))) {
area++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_c_null_value(&supCell, 1);
+ Rast_set_c_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -534,19 +535,19 @@
return RLI_ERRORE;
}
- buf_sup = G_allocate_d_raster_buf();
+ buf_sup = Rast_allocate_d_raster_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_d_raster_buf();
+ buf = Rast_allocate_d_raster_buf();
if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
@@ -565,22 +566,22 @@
return RLI_ERRORE;
}
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++) { /*for each cell in the row */
corrCell = buf[i + ad->x];
if ((masked) && (mask_buf[i + ad->x] == 0)) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, DCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, DCELL_TYPE))) {
area++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_d_null_value(&supCell, 1);
+ Rast_set_d_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -904,20 +905,20 @@
return RLI_ERRORE;
}
- buf_sup = G_allocate_f_raster_buf();
+ buf_sup = Rast_allocate_f_raster_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_f_raster_buf();
+ buf = Rast_allocate_f_raster_buf();
if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
@@ -936,20 +937,20 @@
return RLI_ERRORE;
}
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++) { /*for each cell in the row */
corrCell = buf[i + ad->x];
if (((masked) && (mask_buf[i + ad->x] == 0))) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, FCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, FCELL_TYPE))) {
area++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_f_null_value(&supCell, 1);
+ Rast_set_f_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
Modified: grass/trunk/raster/r.li/r.li.padcv/padcv.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padcv/padcv.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.padcv/padcv.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -57,7 +58,7 @@
struct Cell_head hd;
int ris = RLI_OK;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
switch (ad->data_type)
{
@@ -153,19 +154,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_cell_buf();
+ buf_sup = Rast_allocate_cell_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++)
{
mask_patch_sup[i] = 0;
@@ -188,7 +189,7 @@
return RLI_ERRORE;
}
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++)
/* for each cell in the row */
{
@@ -196,16 +197,16 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0)
{
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, gc.t)))
+ if (!(Rast_is_null_value(&corrCell, gc.t)))
{
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_c_null_value(&supCell, 1);
+ Rast_set_c_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -575,19 +576,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_d_raster_buf();
+ buf_sup = Rast_allocate_d_raster_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_d_raster_buf();
+ buf = Rast_allocate_d_raster_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++)
{
mask_patch_sup[i] = 0;
@@ -610,7 +611,7 @@
return RLI_ERRORE;
}
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++)
{
/* for each dcell in the row */
@@ -618,16 +619,16 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0)
{
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, gc.t)))
+ if (!(Rast_is_null_value(&corrCell, gc.t)))
{
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_d_null_value(&supCell, 1);
+ Rast_set_d_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -996,19 +997,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_f_raster_buf();
+ buf_sup = Rast_allocate_f_raster_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_f_raster_buf();
+ buf = Rast_allocate_f_raster_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++)
{
mask_patch_sup[i] = 0;
@@ -1031,7 +1032,7 @@
return RLI_ERRORE;
}
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++)
{
/* for each fcell in the row */
@@ -1039,16 +1040,16 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0)
{
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, gc.t)))
+ if (!(Rast_is_null_value(&corrCell, gc.t)))
{
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_f_null_value(&supCell, 1);
+ Rast_set_f_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
Modified: grass/trunk/raster/r.li/r.li.padrange/padrange.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padrange/padrange.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.padrange/padrange.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -60,7 +61,7 @@
struct Cell_head hd;
int ris = RLI_OK;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
switch (ad->data_type)
{
@@ -161,19 +162,19 @@
return RLI_ERRORE;
}
- buf_sup = G_allocate_cell_buf();
+ buf_sup = Rast_allocate_cell_buf();
if (buf_sup == NULL) {
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
if (buf == NULL) {
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
@@ -196,23 +197,23 @@
}
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++)
/* for each cell in the row */
{
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, gc.t))) {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_c_null_value(&supCell, 1);
+ Rast_set_c_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -561,19 +562,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_d_raster_buf();
+ buf_sup = Rast_allocate_d_raster_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_d_raster_buf();
+ buf = Rast_allocate_d_raster_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++)
{
mask_patch_sup[i] = 0;
@@ -594,21 +595,21 @@
return RLI_ERRORE;
}
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++) {
/* for each dcell in the row */
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, gc.t))) {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_d_null_value(&supCell, 1);
+ Rast_set_d_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -953,19 +954,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_f_raster_buf();
+ buf_sup = Rast_allocate_f_raster_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_f_raster_buf();
+ buf = Rast_allocate_f_raster_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++) {
mask_patch_sup[i] = 0;
mask_patch_corr[i] = 0;
@@ -988,22 +989,22 @@
return RLI_ERRORE;
}
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++) {
/* for each fcell in the row */
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, gc.t))) {
+ if (!(Rast_is_null_value(&corrCell, gc.t))) {
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_f_null_value(&supCell, 1);
+ Rast_set_f_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
Modified: grass/trunk/raster/r.li/r.li.padsd/padsd.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padsd/padsd.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.padsd/padsd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -57,7 +58,7 @@
struct Cell_head hd;
int ris = RLI_OK;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
switch (ad->data_type)
{
@@ -152,19 +153,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_cell_buf();
+ buf_sup = Rast_allocate_cell_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_c_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++)
{
mask_patch_sup[i] = 0;
@@ -187,7 +188,7 @@
return RLI_ERRORE;
}
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++)
/* for each cell in the row */
{
@@ -195,16 +196,16 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0)
{
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, gc.t)))
+ if (!(Rast_is_null_value(&corrCell, gc.t)))
{
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_c_null_value(&supCell, 1);
+ Rast_set_c_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -574,19 +575,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_d_raster_buf();
+ buf_sup = Rast_allocate_d_raster_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_d_raster_buf();
+ buf = Rast_allocate_d_raster_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_d_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++)
{
mask_patch_sup[i] = 0;
@@ -609,7 +610,7 @@
return RLI_ERRORE;
}
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++)
/* for each dcell in the row */
{
@@ -617,16 +618,16 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0)
{
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, gc.t)))
+ if (!(Rast_is_null_value(&corrCell, gc.t)))
{
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_d_null_value(&supCell, 1);
+ Rast_set_d_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
@@ -992,19 +993,19 @@
G_fatal_error("malloc mask_patch_corr failed");
return RLI_ERRORE;
}
- buf_sup = G_allocate_f_raster_buf();
+ buf_sup = Rast_allocate_f_raster_buf();
if (buf_sup == NULL)
{
G_fatal_error("malloc buf_sup failed");
return RLI_ERRORE;
}
- buf = G_allocate_f_raster_buf();
+ buf = Rast_allocate_f_raster_buf();
if (buf == NULL)
{
G_fatal_error("malloc buf failed");
return RLI_ERRORE;
}
- G_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
+ Rast_set_f_null_value(buf_sup + ad->x, ad->cl); /*the first time buf_sup is all null */
for (i = 0; i < ad->cl; i++)
{
mask_patch_sup[i] = 0;
@@ -1027,7 +1028,7 @@
return RLI_ERRORE;
}
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
for (i = 0; i < ad->cl; i++)
{
/* for each fcell in the row */
@@ -1035,16 +1036,16 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0)
{
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, gc.t)))
+ if (!(Rast_is_null_value(&corrCell, gc.t)))
{
areaPatch++;
if (i > 0)
precCell = buf[i - 1 + ad->x];
if (j == 0)
- G_set_f_null_value(&supCell, 1);
+ Rast_set_f_null_value(&supCell, 1);
else
supCell = buf_sup[i + ad->x];
Modified: grass/trunk/raster/r.li/r.li.patchdensity/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.patchdensity/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.patchdensity/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "../r.li.daemon/daemon.h"
@@ -66,10 +67,10 @@
double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
int mask_fd = -1, *mask_buf, *mask_sup, null_count = 0;
- G_set_c_null_value(&complete_value, 1);
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ Rast_set_c_null_value(&complete_value, 1);
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return 0;
- sup = G_allocate_cell_buf();
+ sup = Rast_allocate_cell_buf();
/* open mask if needed */
if (ad->mask == 1) {
@@ -114,7 +115,7 @@
return 0;
for (k = 0; k < ad->cl; k++) {
if (mask_buf[k] == 0) {
- G_set_c_null_value(mask_buf + k, 1);
+ Rast_set_c_null_value(mask_buf + k, 1);
null_count++;
}
}
@@ -123,7 +124,7 @@
if (complete_line) {
- if (!G_is_null_value(&(buf[ad->x]), CELL_TYPE) &&
+ if (!Rast_is_null_value(&(buf[ad->x]), CELL_TYPE) &&
buf[ad->x] != complete_value)
count++;
@@ -131,7 +132,7 @@
if (buf[j + ad->x] != buf[j + 1 + ad->x]) {
complete_line = 0;
- if (!G_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE) &&
+ if (!Rast_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE) &&
buf[j + 1 + ad->x] != complete_value)
count++;
}
@@ -155,13 +156,13 @@
}
else {
if (connected &&
- !G_is_null_value(&(buf[j + ad->x]), CELL_TYPE))
+ !Rast_is_null_value(&(buf[j + ad->x]), CELL_TYPE))
other_above = 1;
}
if (j < ad->cl - 1 && buf[j + ad->x] != buf[j + 1 + ad->x]) {
complete_line = 0;
if (!connected &&
- !G_is_null_value(&(buf[j + ad->x]), CELL_TYPE)) {
+ !Rast_is_null_value(&(buf[j + ad->x]), CELL_TYPE)) {
count++;
connected = 0;
@@ -175,7 +176,7 @@
}
if (!connected &&
sup[ad->cl - 1 + ad->x] != buf[ad->cl - 1 + ad->x]) {
- if (!G_is_null_value(&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
+ if (!Rast_is_null_value(&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
count++;
complete_line = 0;
}
Modified: grass/trunk/raster/r.li/r.li.patchnum/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.patchnum/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.patchnum/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "../r.li.daemon/daemon.h"
@@ -63,10 +64,10 @@
CELL complete_value;
int mask_fd = -1, *mask_buf, *mask_sup, null_count = 0;
- G_set_c_null_value(&complete_value, 1);
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ Rast_set_c_null_value(&complete_value, 1);
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return 0;
- sup = G_allocate_cell_buf();
+ sup = Rast_allocate_cell_buf();
/* open mask if needed */
if (ad->mask == 1) {
@@ -97,7 +98,7 @@
return 0;
for (k = 0; k < ad->cl; k++) {
if (mask_buf[k] == 0) {
- G_set_c_null_value(mask_buf + k, 1);
+ Rast_set_c_null_value(mask_buf + k, 1);
null_count++;
}
}
@@ -106,7 +107,7 @@
if (complete_line) {
- if (!G_is_null_value(&(buf[ad->x]), CELL_TYPE) &&
+ if (!Rast_is_null_value(&(buf[ad->x]), CELL_TYPE) &&
buf[ad->x] != complete_value)
count++;
@@ -114,7 +115,7 @@
if (buf[j + ad->x] != buf[j + 1 + ad->x]) {
complete_line = 0;
- if (!G_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE) &&
+ if (!Rast_is_null_value(&(buf[j + 1 + ad->x]), CELL_TYPE) &&
buf[j + 1 + ad->x] != complete_value)
count++;
}
@@ -138,13 +139,13 @@
}
else {
if (connected &&
- !G_is_null_value(&(buf[j + ad->x]), CELL_TYPE))
+ !Rast_is_null_value(&(buf[j + ad->x]), CELL_TYPE))
other_above = 1;
}
if (j < ad->cl - 1 && buf[j + ad->x] != buf[j + 1 + ad->x]) {
complete_line = 0;
if (!connected &&
- !G_is_null_value(&(buf[j + ad->x]), CELL_TYPE)) {
+ !Rast_is_null_value(&(buf[j + ad->x]), CELL_TYPE)) {
count++;
connected = 0;
@@ -158,7 +159,7 @@
}
if (!connected &&
sup[ad->cl - 1 + ad->x] != buf[ad->cl - 1 + ad->x]) {
- if (!G_is_null_value(&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
+ if (!Rast_is_null_value(&(buf[ad->cl - 1 + ad->x]), CELL_TYPE)) {
count++;
complete_line = 0;
}
Modified: grass/trunk/raster/r.li/r.li.richness/richness.c
===================================================================
--- grass/trunk/raster/r.li/r.li.richness/richness.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.richness/richness.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -67,7 +68,7 @@
double indice = 0;
struct Cell_head hd;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
switch (ad->data_type) {
@@ -140,7 +141,7 @@
masked = TRUE;
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
for (j = 0; j < ad->rl; j++) { /* for each row */
@@ -156,12 +157,12 @@
corrCell = buf[i + ad->x];
if ((masked) && (mask_buf[i + ad->x] == 0)) {
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, uc.t))) {
+ if (!(Rast_is_null_value(&corrCell, uc.t))) {
a = 1;
- if (G_is_null_value(&precCell, uc.t)) {
+ if (Rast_is_null_value(&precCell, uc.t)) {
precCell = corrCell;
}
if (corrCell != precCell) {
@@ -298,7 +299,7 @@
masked = TRUE;
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
for (j = 0; j < ad->rl; j++) { /* for each row */
if (masked) {
@@ -314,13 +315,13 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, uc.t))) {
+ if (!(Rast_is_null_value(&corrCell, uc.t))) {
a = 1;
- if (G_is_null_value(&precCell, uc.t)) {
+ if (Rast_is_null_value(&precCell, uc.t)) {
precCell = corrCell;
}
if (corrCell != precCell) {
@@ -460,7 +461,7 @@
masked = TRUE;
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
for (j = 0; j < ad->rl; j++) { /* for each row */
@@ -479,12 +480,12 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
}
- if (!(G_is_null_value(&corrCell, uc.t))) {
+ if (!(Rast_is_null_value(&corrCell, uc.t))) {
a = 1;
- if (G_is_null_value(&precCell, uc.t)) {
+ if (Rast_is_null_value(&precCell, uc.t)) {
precCell = corrCell;
}
if (corrCell != precCell) {
Modified: grass/trunk/raster/r.li/r.li.shannon/shannon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.shannon/shannon.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.shannon/shannon.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -68,7 +69,7 @@
double indice = 0;
struct Cell_head hd;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
@@ -153,7 +154,7 @@
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
/*for each row */
@@ -174,13 +175,13 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, CELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, CELL_TYPE))) {
a = 1;
- if (G_is_null_value(&precCell, cc.t)) {
+ if (Rast_is_null_value(&precCell, cc.t)) {
precCell = corrCell;
}
@@ -360,7 +361,7 @@
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
/*for each row */
for (j = 0; j < ad->rl; j++) {
@@ -380,13 +381,13 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, DCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, DCELL_TYPE))) {
a = 1;
- if (G_is_null_value(&precCell, DCELL_TYPE)) {
+ if (Rast_is_null_value(&precCell, DCELL_TYPE)) {
precCell = corrCell;
}
if (corrCell != precCell) {
@@ -563,7 +564,7 @@
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
/*for each row */
@@ -583,13 +584,13 @@
area++;
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, FCELL_TYPE))) {
+ if (!(Rast_is_null_value(&corrCell, FCELL_TYPE))) {
a = 1;
- if (G_is_null_value(&precCell, FCELL_TYPE)) {
+ if (Rast_is_null_value(&precCell, FCELL_TYPE)) {
precCell = corrCell;
}
if (corrCell != precCell) {
Modified: grass/trunk/raster/r.li/r.li.shape/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.shape/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.shape/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "../r.li.daemon/daemon.h"
@@ -68,8 +69,8 @@
int i = 0, k = 0;
int *mask_buf;
- G_set_c_null_value(&complete_value, 1);
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ Rast_set_c_null_value(&complete_value, 1);
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return 0;
Modified: grass/trunk/raster/r.li/r.li.simpson/simpson.c
===================================================================
--- grass/trunk/raster/r.li/r.li.simpson/simpson.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.li/r.li.simpson/simpson.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <stdlib.h>
@@ -67,7 +68,7 @@
double indice = 0;
struct Cell_head hd;
- if (G_get_cellhd(ad->raster, "", &hd) == -1)
+ if (Rast_get_cellhd(ad->raster, "", &hd) == -1)
return RLI_ERRORE;
switch (ad->data_type) {
@@ -149,7 +150,7 @@
masked = TRUE;
}
- G_set_c_null_value(&precCell, 1);
+ Rast_set_c_null_value(&precCell, 1);
for (j = 0; j < ad->rl; j++) { /* for each row */
@@ -166,13 +167,13 @@
corrCell = buf[i + ad->x];
if ((masked) && (mask_buf[i + ad->x] == 0)) {
- G_set_c_null_value(&corrCell, 1);
+ Rast_set_c_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, uc.t))) {
+ if (!(Rast_is_null_value(&corrCell, uc.t))) {
a = 1;
- if (G_is_null_value(&precCell, uc.t)) {
+ if (Rast_is_null_value(&precCell, uc.t)) {
precCell = corrCell;
}
if (corrCell != precCell) {
@@ -338,7 +339,7 @@
masked = TRUE;
}
- G_set_d_null_value(&precCell, 1);
+ Rast_set_d_null_value(&precCell, 1);
for (j = 0; j < ad->rl; j++) { /* for each row */
if (masked) {
@@ -355,14 +356,14 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_d_null_value(&corrCell, 1);
+ Rast_set_d_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, uc.t))) {
+ if (!(Rast_is_null_value(&corrCell, uc.t))) {
a = 1;
- if (G_is_null_value(&precCell, uc.t)) {
+ if (Rast_is_null_value(&precCell, uc.t)) {
precCell = corrCell;
}
if (corrCell != precCell) {
@@ -527,7 +528,7 @@
masked = TRUE;
}
- G_set_f_null_value(&precCell, 1);
+ Rast_set_f_null_value(&precCell, 1);
for (j = 0; j < ad->rl; j++) { /* for each row */
@@ -547,13 +548,13 @@
corrCell = buf[i + ad->x];
if (masked && mask_buf[i + ad->x] == 0) {
- G_set_f_null_value(&corrCell, 1);
+ Rast_set_f_null_value(&corrCell, 1);
area--;
}
- if (!(G_is_null_value(&corrCell, uc.t))) {
+ if (!(Rast_is_null_value(&corrCell, uc.t))) {
a = 1;
- if (G_is_null_value(&precCell, uc.t)) {
+ if (Rast_is_null_value(&precCell, uc.t)) {
precCell = corrCell;
}
if (corrCell != precCell) {
Modified: grass/trunk/raster/r.los/delete.c
===================================================================
--- grass/trunk/raster/r.los/delete.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.los/delete.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "point.h"
Modified: grass/trunk/raster/r.los/main.c
===================================================================
--- grass/trunk/raster/r.los/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.los/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -34,6 +34,7 @@
#include <math.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include <grass/gprojects.h>
@@ -179,41 +180,41 @@
}
/* read header info for elevation layer */
- if (G_get_cellhd(elev_layer, old_mapset, &cellhd_elev) < 0)
+ if (Rast_get_cellhd(elev_layer, old_mapset, &cellhd_elev) < 0)
G_fatal_error(_("[%s]: Cannot read map header"), elev_layer);
/* if pattern layer present, read in its header info */
if (patt_flag == TRUE) {
- if (G_get_cellhd(patt_layer, patt_mapset, &cellhd_patt) < 0)
+ if (Rast_get_cellhd(patt_layer, patt_mapset, &cellhd_patt) < 0)
G_fatal_error(_("[%s]: Cannot read map header"), patt_layer);
/* allocate buffer space for row-io to layer */
- cell = G_allocate_raster_buf(CELL_TYPE);
+ cell = Rast_allocate_raster_buf(CELL_TYPE);
}
/* allocate buffer space for row-io to layer */
- fcell = G_allocate_raster_buf(FCELL_TYPE);
+ fcell = Rast_allocate_raster_buf(FCELL_TYPE);
/* find number of rows and columns in elevation map */
nrows = G_window_rows();
ncols = G_window_cols();
/* open elevation overlay file for reading */
- old = G_open_cell_old(elev_layer, old_mapset);
+ old = Rast_open_cell_old(elev_layer, old_mapset);
if (old < 0)
G_fatal_error(_("Unable to open raster map <%s>"), elev_layer);
/* open cell layer for writing output */
- new = G_open_raster_new(out_layer, FCELL_TYPE);
+ new = Rast_open_raster_new(out_layer, FCELL_TYPE);
if (new < 0)
G_fatal_error(_("Unable to create raster map <%s>"), out_layer);
/* if pattern layer specified, open it for reading */
if (patt_flag == TRUE) {
- patt = G_open_cell_old(patt_layer, patt_mapset);
+ patt = Rast_open_cell_old(patt_layer, patt_mapset);
if (patt < 0)
G_fatal_error(_("Unable to open raster map <%s>"), patt_layer);
- if (G_get_raster_map_type(patt) != CELL_TYPE)
+ if (Rast_get_raster_map_type(patt) != CELL_TYPE)
G_fatal_error(_("Pattern map should be a binary 0/1 CELL map"));
}
@@ -266,7 +267,7 @@
patt_fd = open(patt_name, 2);
segment_init(&seg_patt, patt_fd, 4);
for (row = 0; row < nrows; row++) {
- if (G_get_raster_row(patt, cell, row, CELL_TYPE) < 0)
+ if (Rast_get_raster_row(patt, cell, row, CELL_TYPE) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
patt_layer, row);
segment_put_row(&seg_patt, cell, row);
@@ -274,7 +275,7 @@
}
for (row = 0; row < nrows; row++) {
- if (G_get_raster_row(old, fcell, row, FCELL_TYPE) < 0)
+ if (Rast_get_raster_row(old, fcell, row, FCELL_TYPE) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
elev_layer, row);
segment_put_row(&seg_in, fcell, row);
@@ -381,8 +382,8 @@
for (col = 0; col < ncols; col++)
/* set to NULL if beyond max_dist (0) or blocked view (1) */
if (fcell[col] == 0 || fcell[col] == 1)
- G_set_null_value(&fcell[col], 1, FCELL_TYPE);
- if (G_put_raster_row(new, fcell, FCELL_TYPE) < 0)
+ Rast_set_null_value(&fcell[col], 1, FCELL_TYPE);
+ if (Rast_put_raster_row(new, fcell, FCELL_TYPE) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
out_layer, row);
}
@@ -397,26 +398,26 @@
close(out_fd);
unlink(in_name); /* remove temp files as well */
unlink(out_name);
- G_close_cell(old);
- G_close_cell(new);
+ Rast_close_cell(old);
+ Rast_close_cell(new);
if (patt_flag == TRUE) {
close(patt_fd);
- G_close_cell(patt);
+ Rast_close_cell(patt);
}
/* create category file for output map */
- G_read_cats(out_layer, current_mapset, &cats);
- G_set_cats_fmt("$1 degree$?s", 1.0, 0.0, 0.0, 0.0, &cats);
- G_write_cats(out_layer, &cats);
+ Rast_read_cats(out_layer, current_mapset, &cats);
+ Rast_set_cats_fmt("$1 degree$?s", 1.0, 0.0, 0.0, 0.0, &cats);
+ Rast_write_cats(out_layer, &cats);
sprintf(title, "Line of sight %.2fm above %s", obs_elev, opt3->answer);
- G_put_cell_title(out_layer, title);
- G_write_raster_units(out_layer, "degrees");
+ Rast_put_cell_title(out_layer, title);
+ Rast_write_raster_units(out_layer, "degrees");
- G_short_history(out_layer, "raster", &history);
- G_command_history(&history);
- G_write_history(out_layer, &history);
+ Rast_short_history(out_layer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out_layer, &history);
/* release that last tiny bit of memory ... */
if ( DELAYED_DELETE != NULL ) {
Modified: grass/trunk/raster/r.los/make_list.c
===================================================================
--- grass/trunk/raster/r.los/make_list.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.los/make_list.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <math.h>
#include <grass/segment.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "point.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.los/make_point.c
===================================================================
--- grass/trunk/raster/r.los/make_point.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.los/make_point.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
/****************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "point.h"
/* #define NULL 0 should be (char *0), or just let the compiler fix it. */
Modified: grass/trunk/raster/r.los/mark_pts.c
===================================================================
--- grass/trunk/raster/r.los/mark_pts.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.los/mark_pts.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <grass/segment.h>
#include "point.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#define PT_TO_MARK_X PT_TO_MARK->x
#define PT_TO_MARK_Y PT_TO_MARK->y
Modified: grass/trunk/raster/r.los/pts_elim.c
===================================================================
--- grass/trunk/raster/r.los/pts_elim.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.los/pts_elim.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include <grass/glocale.h>
#include "point.h"
@@ -113,7 +114,7 @@
row_viewpt - CHECKED_PT_Y,
col_viewpt + CHECKED_PT_X);
- if (mask == 0 || G_is_null_value(&mask, CELL_TYPE)) {
+ if (mask == 0 || Rast_is_null_value(&mask, CELL_TYPE)) {
head = delete(CHECKED_PT, head, seg_out_p,
row_viewpt, col_viewpt);
goto next_iter;
@@ -200,7 +201,7 @@
if (patt_flag == 1) {
segment_get(seg_patt_p, &mask, row_viewpt - BLOCKING_PT_Y,
col_viewpt + BLOCKING_PT_X);
- if (mask == 0 || G_is_null_value(&mask, CELL_TYPE)) {
+ if (mask == 0 || Rast_is_null_value(&mask, CELL_TYPE)) {
/* Commenting out the following fixes a bug in r.los.
In that program the 8 cells around the viewpoint
Modified: grass/trunk/raster/r.los/radians.h
===================================================================
--- grass/trunk/raster/r.los/radians.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.los/radians.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -10,6 +10,7 @@
/****************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#define PI M_PI
#define PIBYFOUR M_PI_4
Modified: grass/trunk/raster/r.mapcalc/column_shift.c
===================================================================
--- grass/trunk/raster/r.mapcalc/column_shift.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/column_shift.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "expression.h"
#include "globals.h"
Modified: grass/trunk/raster/r.mapcalc/evaluate.c
===================================================================
--- grass/trunk/raster/r.mapcalc/evaluate.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/evaluate.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "mapcalc.h"
@@ -23,7 +24,7 @@
static void allocate_buf(expression * e)
{
- e->buf = G_malloc(columns * G_raster_size(e->res_type));
+ e->buf = G_malloc(columns * Rast_raster_size(e->res_type));
}
static void set_buf(expression * e, void *buf)
Modified: grass/trunk/raster/r.mapcalc/expression.c
===================================================================
--- grass/trunk/raster/r.mapcalc/expression.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/expression.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "mapcalc.h"
Modified: grass/trunk/raster/r.mapcalc/expression.h
===================================================================
--- grass/trunk/raster/r.mapcalc/expression.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/expression.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -112,12 +112,12 @@
extern func_desc func_descs[];
-#define IS_NULL_C(x) (G_is_c_null_value((x)))
-#define IS_NULL_F(x) (G_is_f_null_value((x)))
-#define IS_NULL_D(x) (G_is_d_null_value((x)))
+#define IS_NULL_C(x) (Rast_is_c_null_value((x)))
+#define IS_NULL_F(x) (Rast_is_f_null_value((x)))
+#define IS_NULL_D(x) (Rast_is_d_null_value((x)))
-#define SET_NULL_C(x) (G_set_c_null_value((x),1))
-#define SET_NULL_F(x) (G_set_f_null_value((x),1))
-#define SET_NULL_D(x) (G_set_d_null_value((x),1))
+#define SET_NULL_C(x) (Rast_set_c_null_value((x),1))
+#define SET_NULL_F(x) (Rast_set_f_null_value((x),1))
+#define SET_NULL_D(x) (Rast_set_d_null_value((x),1))
#endif /* __EXPRESSION_H_ */
Modified: grass/trunk/raster/r.mapcalc/map.c
===================================================================
--- grass/trunk/raster/r.mapcalc/map.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/map.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -10,6 +10,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/btree.h>
#include <grass/glocale.h>
@@ -92,7 +93,7 @@
sub->valid = G_calloc(cache->nrows, 1);
sub->buf = G_malloc(cache->nrows * sizeof(void *));
for (i = 0; i < cache->nrows; i++)
- sub->buf[i] = G_allocate_raster_buf(data_type);
+ sub->buf[i] = Rast_allocate_raster_buf(data_type);
cache->sub[data_type] = sub;
}
@@ -143,7 +144,7 @@
if (i >= 0 && i < cache->nrows) {
if (!sub->valid[i]) {
- G_get_raster_row(cache->fd, sub->buf[i], row + i, data_type);
+ Rast_get_raster_row(cache->fd, sub->buf[i], row + i, data_type);
sub->valid[i] = 1;
}
return sub->buf[i];
@@ -152,7 +153,7 @@
if (i <= -cache->nrows || i >= cache->nrows * 2 - 1) {
memset(sub->valid, 0, cache->nrows);
sub->row = i;
- G_get_raster_row(cache->fd, sub->buf[0], row, data_type);
+ Rast_get_raster_row(cache->fd, sub->buf[0], row, data_type);
sub->valid[0] = 1;
return sub->buf[0];
}
@@ -180,7 +181,7 @@
G__freea(tmp);
G__freea(vtmp);
- G_get_raster_row(cache->fd, sub->buf[i], row, data_type);
+ Rast_get_raster_row(cache->fd, sub->buf[i], row, data_type);
sub->valid[i] = 1;
return sub->buf[i];
@@ -189,7 +190,7 @@
static void cache_get(struct row_cache *cache, void *buf, int row, int res_type)
{
void *p = cache_get_raw(cache, row, res_type);
- memcpy(buf, p, columns * G_raster_size(res_type));
+ memcpy(buf, p, columns * Rast_raster_size(res_type));
};
/****************************************************************************/
@@ -201,7 +202,7 @@
static void init_colors(struct map *m)
{
- if (G_read_colors((char *)m->name, (char *)m->mapset, &m->colors) < 0)
+ if (Rast_read_colors((char *)m->name, (char *)m->mapset, &m->colors) < 0)
G_fatal_error(_("Unable to read color file for raster map <%s@%s>"),
m->name, m->mapset);
@@ -210,7 +211,7 @@
static void init_cats(struct map *m)
{
- if (G_read_cats((char *)m->name, (char *)m->mapset, &m->cats) < 0)
+ if (Rast_read_cats((char *)m->name, (char *)m->mapset, &m->cats) < 0)
G_fatal_error(_("Unable to read category file of raster map <%s@%s>"),
m->name, m->mapset);
@@ -230,7 +231,7 @@
unsigned char *set = G__alloca(columns);
int i;
- G_lookup_d_raster_colors(rast, red, grn, blu, set, ncols, &m->colors);
+ Rast_lookup_d_raster_colors(rast, red, grn, blu, set, ncols, &m->colors);
switch (mod) {
case 'r':
@@ -338,7 +339,7 @@
if (!btree_find(btree, &key, &ptr)) {
values = vbuf;
for (i = 0; i < NCATS; i++) {
- if ((label = G_get_cat((CELL) (i + key), pcats)) == NULL
+ if ((label = Rast_get_cat((CELL) (i + key), pcats)) == NULL
|| sscanf(label, "%lf", values) != 1)
SET_NULL_D(values);
values++;
@@ -364,7 +365,7 @@
static void read_row(int fd, void *buf, int row, int res_type)
{
- if (G_get_raster_row(fd, buf, row, res_type) < 0)
+ if (Rast_get_raster_row(fd, buf, row, res_type) < 0)
G_fatal_error(_("Unable to read raster map row %d"), row);
}
@@ -428,7 +429,7 @@
if (m->fd < 0)
return;
- if (G_close_cell(m->fd) < 0)
+ if (Rast_close_cell(m->fd) < 0)
G_fatal_error(_("Unable to close raster map <%s@%s>"),
m->name, m->mapset);
@@ -438,12 +439,12 @@
if (m->have_cats) {
btree_free(&m->btree);
- G_free_cats(&m->cats);
+ Rast_free_cats(&m->cats);
m->have_cats = 0;
}
if (m->have_colors) {
- G_free_colors(&m->colors);
+ Rast_free_colors(&m->colors);
m->have_colors = 0;
}
@@ -465,7 +466,7 @@
case 'M':
tmpname = G_store((char *)name);
mapset = G_find_cell2(tmpname, "");
- result = mapset ? G_raster_map_type(tmpname, mapset) : -1;
+ result = mapset ? Rast_raster_map_type(tmpname, mapset) : -1;
G_free(tmpname);
return result;
case '@':
@@ -505,7 +506,7 @@
if (!mapset)
G_fatal_error(_("Raster map <%s> not found"), name);
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s@%s>"), name, mapset);
@@ -570,7 +571,7 @@
if (use_colors)
init_colors(m);
- m->fd = G_open_cell_old(name, mapset);
+ m->fd = Rast_open_cell_old(name, mapset);
if (m->fd < 0)
G_fatal_error(_("Unable to open raster map <%s@%s>"), name, mapset);
@@ -657,7 +658,7 @@
{
int fd;
- fd = G_open_raster_new((char *)name, res_type);
+ fd = Rast_open_raster_new((char *)name, res_type);
if (fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), name);
@@ -666,19 +667,19 @@
void put_map_row(int fd, void *buf, int res_type)
{
- if (G_put_raster_row(fd, buf, res_type) < 0)
+ if (Rast_put_raster_row(fd, buf, res_type) < 0)
G_fatal_error(_("Failed writing raster map row"));
}
void close_output_map(int fd)
{
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_fatal_error(_("Unable to close raster map"));
}
void unopen_output_map(int fd)
{
- G_unopen_cell(fd);
+ Rast_unopen_cell(fd);
}
/****************************************************************************/
@@ -688,11 +689,11 @@
const struct map *m = &maps[idx];
struct Categories cats;
- if (G_read_cats((char *)m->name, (char *)m->mapset, &cats) < 0)
+ if (Rast_read_cats((char *)m->name, (char *)m->mapset, &cats) < 0)
return;
- G_write_cats((char *)dst, &cats);
- G_free_cats(&cats);
+ Rast_write_cats((char *)dst, &cats);
+ Rast_free_cats(&cats);
}
void copy_colors(const char *dst, int idx)
@@ -700,11 +701,11 @@
const struct map *m = &maps[idx];
struct Colors colr;
- if (G_read_colors((char *)m->name, (char *)m->mapset, &colr) <= 0)
+ if (Rast_read_colors((char *)m->name, (char *)m->mapset, &colr) <= 0)
return;
- G_write_colors((char *)dst, G_mapset(), &colr);
- G_free_colors(&colr);
+ Rast_write_colors((char *)dst, G_mapset(), &colr);
+ Rast_free_colors(&colr);
}
void copy_history(const char *dst, int idx)
@@ -712,10 +713,10 @@
const struct map *m = &maps[idx];
struct History hist;
- if (G_read_history((char *)m->name, (char *)m->mapset, &hist) < 0)
+ if (Rast_read_history((char *)m->name, (char *)m->mapset, &hist) < 0)
return;
- G_write_history((char *)dst, &hist);
+ Rast_write_history((char *)dst, &hist);
}
void create_history(const char *dst, expression * e)
@@ -727,7 +728,7 @@
int len = strlen(expr);
int i;
- G_short_history((char *)dst, "raster", &hist);
+ Rast_short_history((char *)dst, "raster", &hist);
for (i = 0; i < MAXEDLINES; i++) {
int n;
@@ -755,7 +756,7 @@
hist.edlinecnt = i;
- G_write_history((char *)dst, &hist);
+ Rast_write_history((char *)dst, &hist);
G_free(expr);
}
Modified: grass/trunk/raster/r.mapcalc/map3.c
===================================================================
--- grass/trunk/raster/r.mapcalc/map3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/map3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/btree.h>
#include <grass/glocale.h>
@@ -198,7 +199,7 @@
{
int i;
- G_lookup_d_raster_colors(rast, red, grn, blu, set, ncols, &m->colors);
+ Rast_lookup_d_raster_colors(rast, red, grn, blu, set, ncols, &m->colors);
switch (mod) {
case 'r':
@@ -297,7 +298,7 @@
if (!btree_find(btree, &key, &ptr)) {
values = vbuf;
for (i = 0; i < NCATS; i++) {
- if ((label = G_get_cat((CELL) (i + key), pcats)) == NULL
+ if ((label = Rast_get_cat((CELL) (i + key), pcats)) == NULL
|| sscanf(label, "%lf", values) != 1)
SET_NULL_D(values);
values++;
@@ -369,12 +370,12 @@
if (m->have_cats) {
btree_free(&m->btree);
- G_free_cats(&m->cats);
+ Rast_free_cats(&m->cats);
m->have_cats = 0;
}
if (m->have_colors) {
- G_free_colors(&m->colors);
+ Rast_free_colors(&m->colors);
m->have_colors = 0;
}
}
@@ -626,7 +627,7 @@
return;
G3d_writeCats((char *)dst, &cats);
- G_free_cats(&cats);
+ Rast_free_cats(&cats);
}
void copy_colors(const char *dst, int idx)
@@ -638,7 +639,7 @@
return;
G3d_writeColors((char *)dst, G_mapset(), &colr);
- G_free_colors(&colr);
+ Rast_free_colors(&colr);
}
void copy_history(const char *dst, int idx)
Modified: grass/trunk/raster/r.mapcalc/mapcalc.h
===================================================================
--- grass/trunk/raster/r.mapcalc/mapcalc.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/mapcalc.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
#include <grass/config.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "expression.h"
Modified: grass/trunk/raster/r.mapcalc/xabs.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xabs.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xabs.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xacos.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xacos.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xacos.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xadd.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xadd.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xadd.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xand.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xand.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xand.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xand2.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xand2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xand2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xasin.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xasin.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xasin.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xatan.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xatan.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xatan.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xbitand.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xbitand.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xbitand.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xbitnot.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xbitnot.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xbitnot.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xbitor.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xbitor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xbitor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xbitxor.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xbitxor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xbitxor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xcoor.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xcoor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xcoor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "globals2.h"
#include "expression.h"
Modified: grass/trunk/raster/r.mapcalc/xcoor3.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xcoor3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xcoor3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include "globals.h"
#include "globals3.h"
Modified: grass/trunk/raster/r.mapcalc/xcos.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xcos.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xcos.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xdiv.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xdiv.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xdiv.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xdouble.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xdouble.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xdouble.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xeq.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xeq.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xeq.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xeval.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xeval.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xeval.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xexp.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xexp.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xexp.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xfloat.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xfloat.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xfloat.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xge.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xge.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xge.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xgraph.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xgraph.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xgraph.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xgt.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xgt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xgt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xif.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xif.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xif.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xint.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xint.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xint.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xisnull.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xisnull.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xisnull.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xle.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xle.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xle.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xlog.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xlog.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xlog.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xlt.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xlt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xlt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xmax.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xmax.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xmax.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xmedian.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xmedian.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xmedian.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
@@ -47,7 +48,7 @@
{
static void *array;
static int alloc;
- int size = argc * G_raster_size(argt[0]);
+ int size = argc * Rast_raster_size(argt[0]);
int i, j;
if (argc < 1)
Modified: grass/trunk/raster/r.mapcalc/xmin.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xmin.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xmin.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xmod.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xmod.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xmod.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xmode.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xmode.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xmode.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xmul.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xmul.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xmul.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xne.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xne.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xne.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xneg.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xneg.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xneg.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xnot.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xnot.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xnot.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xnull.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xnull.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xnull.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xor.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xor2.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xor2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xor2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xpow.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xpow.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xpow.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xrand.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xrand.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xrand.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <grass/config.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xres.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xres.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xres.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "globals2.h"
#include "expression.h"
Modified: grass/trunk/raster/r.mapcalc/xres3.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xres3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xres3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include "globals.h"
#include "globals3.h"
Modified: grass/trunk/raster/r.mapcalc/xround.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xround.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xround.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <limits.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xrowcol.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xrowcol.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xrowcol.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xshiftl.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xshiftl.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xshiftl.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xshiftr.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xshiftr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xshiftr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xshiftru.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xshiftru.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xshiftru.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xsin.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xsin.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xsin.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xsqrt.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xsqrt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xsqrt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xsub.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xsub.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xsub.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mapcalc/xtan.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xtan.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mapcalc/xtan.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "globals.h"
#include "expression.h"
#include "func_proto.h"
Modified: grass/trunk/raster/r.mfilter/apply.c
===================================================================
--- grass/trunk/raster/r.mfilter/apply.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mfilter/apply.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,7 +21,7 @@
for (r = 0; r < size; r++)
for (c = 0; c < size; c++) {
- if (G_is_d_null_value(&input[r][c]))
+ if (Rast_is_d_null_value(&input[r][c]))
continue;
v += input[r][c] * matrix[r][c];
divisor += filter->dmatrix[r][c];
@@ -31,13 +31,13 @@
if (have_result)
v /= divisor;
else
- G_set_d_null_value(&v, 1);
+ Rast_set_d_null_value(&v, 1);
}
else {
for (r = 0; r < size; r++)
for (c = 0; c < size; c++) {
- if (G_is_d_null_value(&input[r][c])) {
- G_set_d_null_value(&v, 1);
+ if (Rast_is_d_null_value(&input[r][c])) {
+ Rast_set_d_null_value(&v, 1);
return v;
}
v += input[r][c] * matrix[r][c];
Modified: grass/trunk/raster/r.mfilter/execute.c
===================================================================
--- grass/trunk/raster/r.mfilter/execute.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mfilter/execute.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -87,7 +87,7 @@
col = ccount;
while (col--) {
if (null_only) {
- if (G_is_d_null_value(&box[mid][mid]))
+ if (Rast_is_d_null_value(&box[mid][mid]))
*cp++ = apply_filter(filter, box);
else
*cp++ = box[mid][mid];
Modified: grass/trunk/raster/r.mfilter/filter.h
===================================================================
--- grass/trunk/raster/r.mfilter/filter.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mfilter/filter.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/rowio.h>
typedef struct
{
Modified: grass/trunk/raster/r.mfilter/getrow.c
===================================================================
--- grass/trunk/raster/r.mfilter/getrow.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mfilter/getrow.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,13 +2,14 @@
#include <unistd.h>
#include <sys/types.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "glob.h"
#include "local_proto.h"
int getmaprow(int fd, void *buf, int row, int len)
{
- if (G_get_d_raster_row(fd, (DCELL *) buf, row) < 0)
+ if (Rast_get_d_raster_row(fd, (DCELL *) buf, row) < 0)
G_fatal_error(_("Cannot read raster row %d"), row);
return 1;
}
Modified: grass/trunk/raster/r.mfilter/main.c
===================================================================
--- grass/trunk/raster/r.mfilter/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mfilter/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "filter.h"
@@ -131,7 +132,7 @@
perform_filter(in_name, out_name, filter, nfilters, repeat);
- G_put_cell_title(out_name, title);
+ Rast_put_cell_title(out_name, title);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.mfilter/perform.c
===================================================================
--- grass/trunk/raster/r.mfilter/perform.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mfilter/perform.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,7 +20,7 @@
DCELL *cell;
- cell = G_allocate_d_raster_buf();
+ cell = Rast_allocate_d_raster_buf();
count = 0;
for (pass = 0; pass < repeat; pass++) {
@@ -29,7 +29,7 @@
G_debug(1, "Filter %d", n + 1);
if (count == 0) {
- in = G_open_cell_old(in_name, "");
+ in = Rast_open_cell_old(in_name, "");
G_debug(1, "Open raster map %s = %d", in_name, in);
@@ -45,7 +45,7 @@
G_debug(1, "Closing raster map");
- G_close_cell(in);
+ Rast_close_cell(in);
in = out;
close(creat(tmp2 = G_tempfile(), 0666));
out = open(tmp2, 2);
@@ -72,13 +72,13 @@
}
if (count == 1)
- G_close_cell(in);
+ Rast_close_cell(in);
else if (count > 1)
close(in);
/* copy final result to output raster map */
in = out;
- out = G_open_fp_cell_new(out_name);
+ out = Rast_open_fp_cell_new(out_name);
if (out < 0) {
G_fatal_error(_("Cannot create raster map <%s>"), out_name);
}
@@ -86,17 +86,17 @@
G_message(_("Writing raster map <%s>"), out_name);
for (row = 0; row < nrows; row++) {
getrow(in, cell, row, buflen);
- G_put_d_raster_row(out, cell);
+ Rast_put_d_raster_row(out, cell);
}
- /* remove the temporary files before closing so that the G_close_cell()
+ /* remove the temporary files before closing so that the Rast_close_cell()
has more disk to work with
*/
if (count > 0)
unlink(tmp1);
if (count > 1)
unlink(tmp2);
- G_close_cell(out);
+ Rast_close_cell(out);
return 0;
}
Modified: grass/trunk/raster/r.mode/main.c
===================================================================
--- grass/trunk/raster/r.mode/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mode/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
@@ -81,7 +82,7 @@
covermap = parm.cover->answer;
outmap = parm.output->answer;
- if (G_read_cats(covermap, "", &cover_cats) < 0) {
+ if (Rast_read_cats(covermap, "", &cover_cats) < 0) {
G_fatal_error(_("%s: Unable to read category labels"), covermap);
}
@@ -104,7 +105,7 @@
max = value;
}
if (basecat != catb) {
- write_reclass(reclass, catb, catc, G_get_cat(catc, &cover_cats));
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, &cover_cats));
catb = basecat;
catc = covercat;
max = value;
@@ -117,7 +118,7 @@
if (first) {
catb = catc = 0;
}
- write_reclass(reclass, catb, catc, G_get_cat(catc, &cover_cats));
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, &cover_cats));
pclose(stats);
pclose(reclass);
Modified: grass/trunk/raster/r.mode/read_stats.c
===================================================================
--- grass/trunk/raster/r.mode/read_stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.mode/read_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int read_stats(FILE * fd, long *cat1, long *cat2, double *value)
Modified: grass/trunk/raster/r.neighbors/bufs.c
===================================================================
--- grass/trunk/raster/r.neighbors/bufs.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/bufs.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ncb.h"
/*
@@ -19,7 +20,7 @@
ncb.buf = (DCELL **) G_malloc(ncb.nsize * sizeof(DCELL *));
for (i = 0; i < ncb.nsize; i++) {
ncb.buf[i] = (DCELL *) G_malloc(bufsize);
- G_set_d_null_value(ncb.buf[i], G_window_cols() + 2 * ncb.nsize);
+ Rast_set_d_null_value(ncb.buf[i], G_window_cols() + 2 * ncb.nsize);
}
return 0;
Modified: grass/trunk/raster/r.neighbors/divr_cats.c
===================================================================
--- grass/trunk/raster/r.neighbors/divr_cats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/divr_cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,8 +1,9 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ncb.h"
int divr_cats(void)
{
- G_set_cats_fmt("$1 $?different categories$category$", 1.0, 0.0, 0.0, 0.0,
+ Rast_set_cats_fmt("$1 $?different categories$category$", 1.0, 0.0, 0.0, 0.0,
&ncb.cats);
return 0;
Modified: grass/trunk/raster/r.neighbors/gather.c
===================================================================
--- grass/trunk/raster/r.neighbors/gather.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/gather.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ncb.h"
/*
@@ -58,8 +59,8 @@
if (ncb.mask && !ncb.mask[row][col])
continue;
- if (G_is_d_null_value(c))
- G_set_d_null_value(&values[n], 1);
+ if (Rast_is_d_null_value(c))
+ Rast_set_d_null_value(&values[n], 1);
else
values[n] = *c;
@@ -81,8 +82,8 @@
for (col = 0; col < ncb.nsize; col++) {
DCELL *c = &ncb.buf[row][offset + col];
- if (G_is_d_null_value(c))
- G_set_d_null_value(&values[n][0], 1);
+ if (Rast_is_d_null_value(c))
+ Rast_set_d_null_value(&values[n][0], 1);
else
values[n][0] = *c;
Modified: grass/trunk/raster/r.neighbors/intr_cats.c
===================================================================
--- grass/trunk/raster/r.neighbors/intr_cats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/intr_cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,9 +1,10 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ncb.h"
int intr_cats(void)
{
- G_set_cats_fmt("$1% dispersion", 1.0, -1.0, 0.0, 0.0, &ncb.cats);
+ Rast_set_cats_fmt("$1% dispersion", 1.0, -1.0, 0.0, 0.0, &ncb.cats);
return 0;
}
Modified: grass/trunk/raster/r.neighbors/main.c
===================================================================
--- grass/trunk/raster/r.neighbors/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/stats.h>
#include "ncb.h"
@@ -203,7 +204,7 @@
ncb.newcell = parm.output->answer;
if (!flag.align->answer) {
- if (G_get_cellhd(ncb.oldcell, "", &cellhd) < 0)
+ if (Rast_get_cellhd(ncb.oldcell, "", &cellhd) < 0)
exit(EXIT_FAILURE);
G_get_window(&window);
G_align_window(&window, &cellhd);
@@ -214,11 +215,11 @@
ncols = G_window_cols();
/* open raster maps */
- if ((in_fd = G_open_cell_old(ncb.oldcell, "")) < 0)
+ if ((in_fd = Rast_open_cell_old(ncb.oldcell, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
ncb.oldcell);
- map_type = G_get_raster_map_type(in_fd);
+ map_type = Rast_get_raster_map_type(in_fd);
/* get the method */
for (method = 0; (p = menu[method].name); method++)
@@ -247,7 +248,7 @@
if (copycolr) {
G_suppress_warnings(1);
copycolr =
- (G_read_colors(ncb.oldcell, "", &colr) > 0);
+ (Rast_read_colors(ncb.oldcell, "", &colr) > 0);
G_suppress_warnings(0);
}
@@ -267,7 +268,7 @@
/* allocate the cell buffers */
allocate_bufs();
- result = G_allocate_d_raster_buf();
+ result = Rast_allocate_d_raster_buf();
/* get title, initialize the category and stat info */
if (parm.title->answer)
@@ -284,12 +285,12 @@
readcell(in_fd, readrow++, nrows, ncols);
/* open raster map */
- in_fd = G_open_cell_old(ncb.oldcell, "");
+ in_fd = Rast_open_cell_old(ncb.oldcell, "");
if (in_fd < 0)
exit(EXIT_FAILURE);
/*open the new raster map */
- out_fd = G_open_raster_new(ncb.newcell, map_type);
+ out_fd = Rast_open_raster_new(ncb.newcell, map_type);
if (out_fd < 0)
exit(EXIT_FAILURE);
@@ -314,37 +315,37 @@
n = gather(values, col);
if (n < 0)
- G_set_d_null_value(rp, 1);
+ Rast_set_d_null_value(rp, 1);
else {
if (newvalue_w)
newvalue_w(rp, values_w, n, closure);
else
newvalue(rp, values, n, closure);
- if (half && !G_is_d_null_value(rp))
+ if (half && !Rast_is_d_null_value(rp))
*rp += 0.5;
}
}
- G_put_d_raster_row(out_fd, result);
+ Rast_put_d_raster_row(out_fd, result);
}
G_percent(row, nrows, 2);
- G_close_cell(out_fd);
- G_close_cell(in_fd);
+ Rast_close_cell(out_fd);
+ Rast_close_cell(in_fd);
/* put out category info */
null_cats();
if ((cat_names = menu[method].cat_names))
cat_names();
- G_write_cats(ncb.newcell, &ncb.cats);
+ Rast_write_cats(ncb.newcell, &ncb.cats);
if (copycolr)
- G_write_colors(ncb.newcell, G_mapset(), &colr);
+ Rast_write_colors(ncb.newcell, G_mapset(), &colr);
- G_short_history(ncb.newcell, "raster", &history);
- G_command_history(&history);
- G_write_history(ncb.newcell, &history);
+ Rast_short_history(ncb.newcell, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(ncb.newcell, &history);
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.neighbors/null_cats.c
===================================================================
--- grass/trunk/raster/r.neighbors/null_cats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/null_cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,12 +1,13 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ncb.h"
int null_cats(void)
{
int ncats;
- ncats = G_number_of_cats(ncb.newcell, G_mapset());
- G_init_cats(ncats, ncb.title, &ncb.cats);
+ ncats = Rast_number_of_cats(ncb.newcell, G_mapset());
+ Rast_init_cats(ncats, ncb.title, &ncb.cats);
return 0;
}
Modified: grass/trunk/raster/r.neighbors/readcell.c
===================================================================
--- grass/trunk/raster/r.neighbors/readcell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/readcell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ncb.h"
#include "local_proto.h"
@@ -8,9 +9,9 @@
rotate_bufs();
if (row < nrows)
- G_get_d_raster_row(fd, ncb.buf[ncb.nsize - 1] + ncb.dist, row);
+ Rast_get_d_raster_row(fd, ncb.buf[ncb.nsize - 1] + ncb.dist, row);
else
- G_set_d_null_value(ncb.buf[ncb.nsize - 1] + ncb.dist, ncols);
+ Rast_set_d_null_value(ncb.buf[ncb.nsize - 1] + ncb.dist, ncols);
return 0;
}
Modified: grass/trunk/raster/r.neighbors/readweights.c
===================================================================
--- grass/trunk/raster/r.neighbors/readweights.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.neighbors/readweights.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ncb.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.null/main.c
===================================================================
--- grass/trunk/raster/r.null/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.null/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,6 +15,7 @@
#include <string.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "mask.h"
#include "local_proto.h"
@@ -112,7 +113,7 @@
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
- is_reclass = (G_is_reclass(name, mapset, rname, rmapset) > 0);
+ is_reclass = (Rast_is_reclass(name, mapset, rname, rmapset) > 0);
if (is_reclass)
G_fatal_error(_("Raster map <%s> is a reclass of map <%s@%s>. "
"Consider to generate a copy with r.mapcalc. Exiting."),
@@ -131,7 +132,7 @@
parms.null->answer);
}
- map_type = G_raster_map_type(name, mapset);
+ map_type = Rast_raster_map_type(name, mapset);
if (only_null && G_find_file2_misc("cell_misc", "null", name, mapset))
G_fatal_error(_("Raster map <%s> already has a null bitmap file"), name);
@@ -153,15 +154,15 @@
parse_vallist(parms.setnull->answers, &d_mask);
- if (G_get_cellhd(name, mapset, &cellhd) < 0)
+ if (Rast_get_cellhd(name, mapset, &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"),
G_fully_qualified_name(name, mapset));
if (create) {
/* write a file of no-nulls */
- null_bits = (unsigned char *)G__allocate_null_bits(cellhd.cols);
+ null_bits = (unsigned char *)Rast__allocate_null_bits(cellhd.cols);
/* init all cells to 0's */
- for (col = 0; col < G__null_bitstream_size(cellhd.cols); col++)
+ for (col = 0; col < Rast__null_bitstream_size(cellhd.cols); col++)
null_bits[col] = 0;
null_fd = G_open_new_misc("cell_misc", "null", name);
@@ -171,7 +172,7 @@
for (row = 0; row < cellhd.rows; row++) {
G_percent(row, cellhd.rows, 1);
- if (G__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0) <
+ if (Rast__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0) <
0)
G_fatal_error(_("Error writing null row %d"), row);
}
@@ -275,13 +276,13 @@
int quant_ok;
G_suppress_warnings(1);
- colr_ok = G_read_colors(name, mapset, &colr) > 0;
- hist_ok = G_read_history(name, mapset, &hist) >= 0;
- cats_ok = G_read_raster_cats(name, mapset, &cats) >= 0;
+ colr_ok = Rast_read_colors(name, mapset, &colr) > 0;
+ hist_ok = Rast_read_history(name, mapset, &hist) >= 0;
+ cats_ok = Rast_read_raster_cats(name, mapset, &cats) >= 0;
if (map_type != CELL_TYPE) {
- G_quant_init(&quant);
- quant_ok = G_read_quant(name, mapset, &quant);
+ Rast_quant_init(&quant);
+ quant_ok = Rast_read_quant(name, mapset, &quant);
G_suppress_warnings(0);
}
@@ -289,18 +290,18 @@
return 1;
if (colr_ok) {
- G_write_colors(name, mapset, &colr);
- G_free_colors(&colr);
+ Rast_write_colors(name, mapset, &colr);
+ Rast_free_colors(&colr);
}
if (hist_ok)
- G_write_history(name, &hist);
+ Rast_write_history(name, &hist);
if (cats_ok) {
- cats.num = G_number_of_cats(name, mapset);
- G_write_raster_cats(name, &cats);
- G_free_cats(&cats);
+ cats.num = Rast_number_of_cats(name, mapset);
+ Rast_write_raster_cats(name, &cats);
+ Rast_free_cats(&cats);
}
if (map_type != CELL_TYPE && quant_ok)
- G_write_quant(name, mapset, &quant);
+ Rast_write_quant(name, mapset, &quant);
return 0;
}
@@ -312,16 +313,16 @@
G_set_window(&cellhd);
- old = G_open_cell_old(name, mapset);
+ old = Rast_open_cell_old(name, mapset);
if (old < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- new = G_open_raster_new(name, map_type);
+ new = Rast_open_raster_new(name, map_type);
if (new < 0)
G_fatal_error(_("Unable to create raster map <%s>"), name);
- rast = G_allocate_raster_buf(map_type);
+ rast = Rast_allocate_raster_buf(map_type);
G_verbose_message(_("Writing new data for raster map <%s>..."), name);
@@ -329,7 +330,7 @@
for (row = 0; row < cellhd.rows; row++) {
G_percent(row, cellhd.rows, 1);
- if (G_get_raster_row_nomask(old, rast, row, map_type) < 0) {
+ if (Rast_get_raster_row_nomask(old, rast, row, map_type) < 0) {
G_warning(_("Unable to read raster map <%s> row %d"),
name, row);
break;
@@ -337,7 +338,7 @@
mask_raster_array(rast, cellhd.cols, change_null, map_type);
- if (G_put_raster_row(new, rast, map_type) < 0) {
+ if (Rast_put_raster_row(new, rast, map_type) < 0) {
G_warning(_("Failed writing raster map <%s> row %d"),
name, row);
break;
@@ -345,12 +346,12 @@
}
G_percent(row, cellhd.rows, 1);
G_free(rast);
- G_close_cell(old);
+ Rast_close_cell(old);
if (row < cellhd.rows) {
- G_unopen_cell(new);
+ Rast_unopen_cell(new);
return 1;
}
- G_close_cell(new);
+ Rast_close_cell(new);
return 0;
}
Modified: grass/trunk/raster/r.null/mask.c
===================================================================
--- grass/trunk/raster/r.null/mask.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.null/mask.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "mask.h"
#include "local_proto.h"
@@ -29,12 +30,12 @@
DCELL x;
while (ncols-- > 0) {
- x = G_get_raster_value_d(rast, data_type);
- if (change_null && G_is_null_value(rast, data_type))
- G_set_raster_value_d(rast, new_null, data_type);
+ x = Rast_get_raster_value_d(rast, data_type);
+ if (change_null && Rast_is_null_value(rast, data_type))
+ Rast_set_raster_value_d(rast, new_null, data_type);
if (mask_d_select(&x, &d_mask))
- G_set_null_value(rast, 1, data_type);
- rast = G_incr_void_ptr(rast, G_raster_size(data_type));
+ Rast_set_null_value(rast, 1, data_type);
+ rast = Rast_incr_void_ptr(rast, Rast_raster_size(data_type));
}
return 0;
@@ -55,7 +56,7 @@
int mask_match_d_interval(DCELL x, d_Interval * I)
{
- if (G_is_d_null_value(&x))
+ if (Rast_is_d_null_value(&x))
return 0;
if (I->inf < 0)
Modified: grass/trunk/raster/r.out.arc/main.c
===================================================================
--- grass/trunk/raster/r.out.arc/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.arc/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <math.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
/*
@@ -115,17 +116,17 @@
sprintf(null_str, "-9999");
- fd = G_open_cell_old(parm.map->answer, "");
+ fd = Rast_open_cell_old(parm.map->answer, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), parm.map->answer);
- map_type = G_get_raster_map_type(fd);
+ map_type = Rast_get_raster_map_type(fd);
out_type = map_type;
/*
- null_row = G_allocate_null_buf();
+ null_row = Rast_allocate_null_buf();
*/
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
nrows = G_window_rows();
ncols = G_window_cols();
@@ -170,15 +171,15 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(fd, raster, row, out_type) < 0)
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0)
exit(EXIT_FAILURE);
/*
- if (G_get_null_value_row(fd, null_row, row) < 0)
+ if (Rast_get_null_value_row(fd, null_row, row) < 0)
exit(EXIT_FAILURE);
*/
for (col = 0, ptr = raster; col < ncols; col++,
- ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
- if (!G_is_null_value(ptr, out_type)) {
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
+ if (!Rast_is_null_value(ptr, out_type)) {
if (out_type == CELL_TYPE)
fprintf(fp, "%d", *((CELL *) ptr));
@@ -215,7 +216,7 @@
/* make sure it got to 100% */
G_percent(1, 1, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
fclose(fp);
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.out.ascii/formspecific.c
===================================================================
--- grass/trunk/raster/r.out.ascii/formspecific.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.ascii/formspecific.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
/* write the GRASS ASCII heading */
int writeGRASSheader(FILE * fp)
@@ -32,17 +33,17 @@
void *ptr, *raster;
char cell_buf[300];
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(fd, raster, row, out_type) < 0)
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0)
return (row);
for (col = 0, ptr = raster; col < ncols; col++,
- ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
- if (!G_is_null_value(ptr, out_type)) {
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
+ if (!Rast_is_null_value(ptr, out_type)) {
if (out_type == CELL_TYPE)
fprintf(fp, "%d", *((CELL *) ptr));
@@ -85,29 +86,29 @@
int row, col, colcnt;
void *ptr, *raster;
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(fd, raster, row, out_type) < 0)
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0)
return (row);
colcnt = 0;
for (col = 0, ptr = raster; col < ncols; col++,
- ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
if (out_type == CELL_TYPE) {
- if (G_is_null_value(ptr, out_type))
+ if (Rast_is_null_value(ptr, out_type))
*((CELL *) ptr) = 0;
fprintf(fp, " %d", *((CELL *) ptr));
}
else if (out_type == FCELL_TYPE) {
- if (G_is_null_value(ptr, out_type))
+ if (Rast_is_null_value(ptr, out_type))
*((FCELL *) ptr) = 0;
fprintf(fp, "%*.*e", dp + 6, dp - 1, *((FCELL *) ptr));
}
else if (out_type == DCELL_TYPE) {
- if (G_is_null_value(ptr, out_type))
+ if (Rast_is_null_value(ptr, out_type))
*((DCELL *) ptr) = 0;
fprintf(fp, "%*.*e", dp + 6, dp - 1, *((DCELL *) ptr));
}
@@ -133,7 +134,7 @@
struct FPRange range;
DCELL Z_MIN, Z_MAX;
- if (G_read_fp_range(name, "", &range) < 0)
+ if (Rast_read_fp_range(name, "", &range) < 0)
return 1;
fprintf(fp, "DSAA \n");
@@ -154,7 +155,7 @@
G_projection() == PROJECTION_LL ? -1 : 0);
fprintf(fp, "%s %s\n", fromc, toc);
- G_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
+ Rast_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
fprintf(fp, "%f %f\n", (double)Z_MIN, (double)Z_MAX);
return 0;
@@ -171,19 +172,19 @@
void *ptr, *raster;
char cell_buf[300];
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
for (row = nrows - 1; row >= 0; row--) {
G_percent((row - nrows) * (-1), nrows, 2);
- if (G_get_raster_row(fd, raster, row, out_type) < 0)
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0)
return (row);
colcnt = 0;
for (col = 0, ptr = raster; col < ncols; col++,
- ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
colcnt += 1;
- if (!G_is_null_value(ptr, out_type)) {
+ if (!Rast_is_null_value(ptr, out_type)) {
if (out_type == CELL_TYPE)
fprintf(fp, "%d", *((CELL *) ptr));
else if (out_type == FCELL_TYPE) {
Modified: grass/trunk/raster/r.out.ascii/main.c
===================================================================
--- grass/trunk/raster/r.out.ascii/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.ascii/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <math.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "localproto.h"
#include <grass/glocale.h>
@@ -141,11 +142,11 @@
name = parm.map->answer;
/* open raster map */
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- map_type = G_get_raster_map_type(fd);
+ map_type = Rast_get_raster_map_type(fd);
if (!flag.int_out->answer)
out_type = map_type;
@@ -193,7 +194,7 @@
}
/* tidy up and go away */
- G_close_cell(fd);
+ Rast_close_cell(fd);
fclose(fp);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.out.bin/main.c
===================================================================
--- grass/trunk/raster/r.out.bin/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.bin/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "./gmt_grd.h"
@@ -122,11 +123,11 @@
G_get_window(®ion);
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- map_type = G_get_raster_map_type(fd);
+ map_type = Rast_get_raster_map_type(fd);
if (!flag.int_out->answer)
out_type = map_type;
else
@@ -153,8 +154,8 @@
/* Set up Parameters for GMT header */
if (flag.gmt_hd->answer) {
- G_read_fp_range(name, "", &range);
- G_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
+ Rast_read_fp_range(name, "", &range);
+ Rast_get_fp_range_min_max(&range, &Z_MIN, &Z_MAX);
header.nx = region.cols;
header.ny = region.rows;
@@ -273,7 +274,7 @@
fclose(fp_2);
}
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
/* Write out GMT Header if required */
if (flag.gmt_hd->answer) {
@@ -331,13 +332,13 @@
G_message(_("c=%d"), region.cols);
for (row = 0; row < nrows; row++) {
- if (G_get_raster_row(fd, raster, row, out_type) < 0)
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0)
G_fatal_error(_("Reading map"));
G_percent(row, nrows, 2);
for (col = 0, ptr = raster; col < ncols; col++,
- ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
- if (!G_is_null_value(ptr, out_type)) {
+ ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
+ if (!Rast_is_null_value(ptr, out_type)) {
if (out_type == CELL_TYPE) {
number_i = *((CELL *) ptr);
if (flag.swap->answer)
@@ -382,7 +383,7 @@
}
G_percent(row, nrows, 2); /* finish it off */
- G_close_cell(fd);
+ Rast_close_cell(fd);
fclose(fp);
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.out.gdal/export_band.c
===================================================================
--- grass/trunk/raster/r.out.gdal/export_band.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.gdal/export_band.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,6 +15,7 @@
*****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "cpl_string.h"
@@ -49,7 +50,7 @@
int ret = 0;
/* Open GRASS raster */
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd < 0) {
G_warning(_("Unable to open raster map <%s>"), name);
return -1;
@@ -64,12 +65,12 @@
}
/* Get min/max values. */
- if (G_read_fp_range(name, mapset, &sRange) == -1) {
+ if (Rast_read_fp_range(name, mapset, &sRange) == -1) {
bHaveMinMax = FALSE;
}
else {
bHaveMinMax = TRUE;
- G_get_fp_range_min_max(&sRange, &dfCellMin, &dfCellMax);
+ Rast_get_fp_range_min_max(&sRange, &dfCellMin, &dfCellMax);
}
/* suppress useless warnings */
@@ -78,13 +79,13 @@
CPLPopErrorHandler();
/* use default color rules if no color rules are given */
- if (G_read_colors(name, mapset, &sGrassColors) >= 0) {
+ if (Rast_read_colors(name, mapset, &sGrassColors) >= 0) {
int maxcolor, i;
CELL min, max;
char key[200], value[200];
int rcount;
- G_get_color_range(&min, &max, &sGrassColors);
+ Rast_get_color_range(&min, &max, &sGrassColors);
if (bHaveMinMax) {
if (max < dfCellMax) {
maxcolor = max;
@@ -109,7 +110,7 @@
}
}
- rcount = G_colors_count(&sGrassColors);
+ rcount = Rast_colors_count(&sGrassColors);
G_debug(3, "dfCellMin: %f, dfCellMax: %f, maxcolor: %d", dfCellMin,
dfCellMax, maxcolor);
@@ -121,7 +122,7 @@
int nRed, nGreen, nBlue;
GDALColorEntry sColor;
- if (G_get_color
+ if (Rast_get_color
(iColor, &nRed, &nGreen, &nBlue, &sGrassColors)) {
sColor.c1 = nRed;
sColor.c2 = nGreen;
@@ -129,7 +130,7 @@
sColor.c4 = 255;
G_debug(3,
- "G_get_color: Y, rcount %d, nRed %d, nGreen %d, nBlue %d",
+ "Rast_get_color: Y, rcount %d, nRed %d, nGreen %d, nBlue %d",
rcount, nRed, nGreen, nBlue);
GDALSetColorEntry(hCT, iColor, &sColor);
}
@@ -140,7 +141,7 @@
sColor.c4 = 0;
G_debug(3,
- "G_get_color: N, rcount %d, nRed %d, nGreen %d, nBlue %d",
+ "Rast_get_color: N, rcount %d, nRed %d, nGreen %d, nBlue %d",
rcount, nRed, nGreen, nBlue);
GDALSetColorEntry(hCT, iColor, &sColor);
}
@@ -163,7 +164,7 @@
DCELL val1, val2;
unsigned char r1, g1, b1, r2, g2, b2;
- G_get_f_color_rule(&val1, &r1, &g1, &b1, &val2, &r2, &g2, &b2,
+ Rast_get_f_color_rule(&val1, &r1, &g1, &b1, &val2, &r2, &g2, &b2,
&sGrassColors, i);
@@ -175,7 +176,7 @@
}
/* Create GRASS raster buffer */
- void *bufer = G_allocate_raster_buf(maptype);
+ void *bufer = Rast_allocate_raster_buf(maptype);
if (bufer == NULL) {
G_warning(_("Unable to allocate buffer for reading raster map"));
@@ -208,12 +209,12 @@
for (row = 0; row < rows; row++) {
- if (G_get_raster_row(fd, bufer, row, maptype) < 0) {
+ if (Rast_get_raster_row(fd, bufer, row, maptype) < 0) {
G_warning(_("Unable to read raster map <%s> row %d"),
name, row);
return -1;
}
- G_get_null_value_row(fd, nulls, row);
+ Rast_get_null_value_row(fd, nulls, row);
for (col = 0; col < cols; col++)
if (nulls[col]) {
((FCELL *) bufer)[col] = fnullval;
@@ -250,12 +251,12 @@
for (row = 0; row < rows; row++) {
- if (G_get_raster_row(fd, bufer, row, maptype) < 0) {
+ if (Rast_get_raster_row(fd, bufer, row, maptype) < 0) {
G_warning(_("Unable to read raster map <%s> row %d"),
name, row);
return -1;
}
- G_get_null_value_row(fd, nulls, row);
+ Rast_get_null_value_row(fd, nulls, row);
for (col = 0; col < cols; col++)
if (nulls[col]) {
((DCELL *) bufer)[col] = dnullval;
@@ -292,12 +293,12 @@
for (row = 0; row < rows; row++) {
- if (G_get_raster_row(fd, bufer, row, maptype) < 0) {
+ if (Rast_get_raster_row(fd, bufer, row, maptype) < 0) {
G_warning(_("Unable to read raster map <%s> row %d"),
name, row);
return -1;
}
- G_get_null_value_row(fd, nulls, row);
+ Rast_get_null_value_row(fd, nulls, row);
for (col = 0; col < cols; col++)
if (nulls[col]) {
((CELL *) bufer)[col] = inullval;
Modified: grass/trunk/raster/r.out.gdal/main.c
===================================================================
--- grass/trunk/raster/r.out.gdal/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.gdal/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <math.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/imagery.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
@@ -346,14 +347,14 @@
export_min = TYPE_FLOAT64_MIN;
export_max = TYPE_FLOAT64_MAX;
for (band = 0; band < ref.nfiles; band++) {
- if (G_read_fp_range
+ if (Rast_read_fp_range
(ref.file[band].name, ref.file[band].mapset, &sRange) == -1) {
bHaveMinMax = FALSE;
G_warning(_("Could not read data range of raster <%s>"),
ref.file[band].name);
}
else {
- G_get_fp_range_min_max(&sRange, &dfCellMin, &dfCellMax);
+ Rast_get_fp_range_min_max(&sRange, &dfCellMin, &dfCellMax);
if (band == 0) {
export_min = dfCellMin;
export_max = dfCellMax;
@@ -379,7 +380,7 @@
/* GDAL datatype not set by user, determine suitable datatype */
if (datatype == GDT_Unknown) {
/* Use raster data type from first GRASS raster in a group */
- maptype = G_raster_map_type(ref.file[0].name, ref.file[0].mapset);
+ maptype = Rast_raster_map_type(ref.file[0].name, ref.file[0].mapset);
if (maptype == FCELL_TYPE) {
datatype = GDT_Float32;
}
@@ -428,7 +429,7 @@
/* Precision tests */
for (band = 0; band < ref.nfiles; band++) {
testmaptype =
- G_raster_map_type(ref.file[band].name, ref.file[band].mapset);
+ Rast_raster_map_type(ref.file[band].name, ref.file[band].mapset);
/* Exporting floating point rasters to some integer type ? */
if ((testmaptype == FCELL_TYPE || testmaptype == DCELL_TYPE) &&
(datatype == GDT_Byte || datatype == GDT_Int16 ||
Modified: grass/trunk/raster/r.out.gridatb/file_io.c
===================================================================
--- grass/trunk/raster/r.out.gridatb/file_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.gridatb/file_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,24 +13,24 @@
FCELL *fcell;
RASTER_MAP_TYPE data_type;
- fd = G_open_cell_old(iname, "");
+ fd = Rast_open_cell_old(iname, "");
if (fd < 0)
G_fatal_error("%s - could not read", iname);
- data_type = G_get_raster_map_type(fd);
+ data_type = Rast_get_raster_map_type(fd);
switch (data_type) {
case CELL_TYPE:
- cell = G_allocate_c_raster_buf();
+ cell = Rast_allocate_c_raster_buf();
break;
case FCELL_TYPE:
- fcell = G_allocate_f_raster_buf();
+ fcell = Rast_allocate_f_raster_buf();
break;
case DCELL_TYPE:
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
break;
}
- G_get_cellhd(iname, "", &cellhd);
+ Rast_get_cellhd(iname, "", &cellhd);
adjcellhdval = adjcellhd(&cellhd);
switch (adjcellhdval) {
@@ -47,20 +47,20 @@
fp = fopen(file, "w");
- fprintf(fp, "%s\n", G_get_cell_title(iname, ""));
+ fprintf(fp, "%s\n", Rast_get_cell_title(iname, ""));
fprintf(fp, "%d %d %lf\n", cellhd.cols, cellhd.rows, cellhd.ns_res);
for (row = 0; row < cellhd.rows; row++) {
G_percent(row, cellhd.rows, 2);
switch (data_type) {
case CELL_TYPE:
- if (G_get_c_raster_row(fd, cell, row) < 0) {
- G_close_cell(fd);
+ if (Rast_get_c_raster_row(fd, cell, row) < 0) {
+ Rast_close_cell(fd);
exit(1);
}
for (col = 0; col < cellhd.cols; col++) {
- if (G_is_c_null_value(&cell[col]))
+ if (Rast_is_c_null_value(&cell[col]))
fprintf(fp, " 9999.00 ");
else
fprintf(fp, "%9.2f ", (float)cell[col]);
@@ -69,13 +69,13 @@
}
break;
case FCELL_TYPE:
- if (G_get_f_raster_row(fd, fcell, row) < 0) {
- G_close_cell(fd);
+ if (Rast_get_f_raster_row(fd, fcell, row) < 0) {
+ Rast_close_cell(fd);
exit(1);
}
for (col = 0; col < cellhd.cols; col++) {
- if (G_is_f_null_value(&fcell[col]))
+ if (Rast_is_f_null_value(&fcell[col]))
fprintf(fp, " 9999.00 ");
else
fprintf(fp, "%9.2f ", (float)fcell[col]);
@@ -84,13 +84,13 @@
}
break;
case DCELL_TYPE:
- if (G_get_d_raster_row(fd, dcell, row) < 0) {
- G_close_cell(fd);
+ if (Rast_get_d_raster_row(fd, dcell, row) < 0) {
+ Rast_close_cell(fd);
exit(1);
}
for (col = 0; col < cellhd.cols; col++) {
- if (G_is_d_null_value(&dcell[col]))
+ if (Rast_is_d_null_value(&dcell[col]))
fprintf(fp, " 9999.00 ");
else
fprintf(fp, "%9.2lf ", (double)dcell[col]);
@@ -100,7 +100,7 @@
break;
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
return;
}
Modified: grass/trunk/raster/r.out.gridatb/local_proto.h
===================================================================
--- grass/trunk/raster/r.out.gridatb/local_proto.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.gridatb/local_proto.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
void check_ready(void);
int adjcellhd(struct Cell_head *cellhd);
Modified: grass/trunk/raster/r.out.gridatb/main.c
===================================================================
--- grass/trunk/raster/r.out.gridatb/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.gridatb/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.out.mat/main.c
===================================================================
--- grass/trunk/raster/r.out.mat/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.mat/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int main(int argc, char *argv[])
@@ -81,11 +82,11 @@
outfile = G_malloc(strlen(basename) + 5);
sprintf(outfile, "%s.mat", basename);
- fd = G_open_cell_old(infile, "");
+ fd = Rast_open_cell_old(infile, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), infile);
- map_type = G_get_raster_map_type(fd);
+ map_type = Rast_get_raster_map_type(fd);
/* open bin file for writing */
fp1 = fopen(outfile, "wb");
@@ -138,7 +139,7 @@
/********** Write title (if there is one) **********/
- maptitle = G_get_cell_title(infile, "");
+ maptitle = Rast_get_cell_title(infile, "");
if (strlen(maptitle) >= 1) {
/** write text element (map title) **/
@@ -294,10 +295,10 @@
/* data array, by increasing column */
raster =
G_calloc((G_window_rows() + 1) * (G_window_cols() + 1),
- G_raster_size(map_type));
+ Rast_raster_size(map_type));
G_debug(1, "mem alloc is %d bytes\n", /* I think _cols()+1 is unneeded? */
- G_raster_size(map_type) * (G_window_rows() +
+ Rast_raster_size(map_type) * (G_window_rows() +
1) * (G_window_cols() + 1));
G_verbose_message(_("Reading in map ... "));
@@ -305,9 +306,9 @@
/* load entire map into memory */
for (row = 0, ptr = raster; row < mrows; row++,
ptr =
- G_incr_void_ptr(ptr,
- (G_window_cols() + 1) * G_raster_size(map_type))) {
- if (G_get_raster_row(fd, ptr, row, map_type) < 0)
+ Rast_incr_void_ptr(ptr,
+ (G_window_cols() + 1) * Rast_raster_size(map_type))) {
+ if (Rast_get_raster_row(fd, ptr, row, map_type) < 0)
G_fatal_error("reading map");
G_percent(row, mrows, 2);
}
@@ -317,18 +318,18 @@
G_verbose_message(_("Writing out map..."));
/* then write it to disk */
- /* NoGood: fwrite(raster, G_raster_size(map_type), mrows*ncols, fp1); */
+ /* NoGood: fwrite(raster, Rast_raster_size(map_type), mrows*ncols, fp1); */
for (col = 0; col < ncols; col++) {
for (row = 0; row < mrows; row++) {
ptr = raster;
ptr =
- G_incr_void_ptr(ptr,
+ Rast_incr_void_ptr(ptr,
(col +
row * (ncols +
- 1)) * G_raster_size(map_type));
+ 1)) * Rast_raster_size(map_type));
- if (!G_is_null_value(ptr, map_type)) {
+ if (!Rast_is_null_value(ptr, map_type)) {
if (map_type == CELL_TYPE) {
val_i = *((CELL *) ptr);
fwrite(&val_i, sizeof(int), 1, fp1);
Modified: grass/trunk/raster/r.out.mpeg/main.c
===================================================================
--- grass/trunk/raster/r.out.mpeg/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.mpeg/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -40,6 +40,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "rom_proto.h"
@@ -281,23 +282,23 @@
if (!quiet)
G_message("\r%s <%s>", _("Reading file"), name);
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Raster map <%s> not found"), name);
- if (G_read_colors(name, "", &colors) < 0)
+ if (Rast_read_colors(name, "", &colors) < 0)
G_fatal_error(_("Unable to read color table for <%s>"), name);
- rtype = G_get_raster_map_type(fd);
- voidc = G_allocate_raster_buf(rtype);
+ rtype = Rast_get_raster_map_type(fd);
+ voidc = Rast_allocate_raster_buf(rtype);
for (row = 0; row < vrows; row++) {
- if (G_get_raster_row(fd, voidc,
+ if (Rast_get_raster_row(fd, voidc,
(int)(row / vscale), rtype) < 0)
G_fatal_error(_("Error reading row <%d>"), row);
rowoff = (vyoff + row) * ncols;
- G_lookup_raster_colors(voidc, tr, tg, tb,
+ Rast_lookup_raster_colors(voidc, tr, tg, tb,
tset, tsiz, &colors, rtype);
for (col = 0; col < vcols; col++) {
@@ -314,7 +315,7 @@
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
yfiles[cnt] = G_tempfile();
Modified: grass/trunk/raster/r.out.mpeg/write.c
===================================================================
--- grass/trunk/raster/r.out.mpeg/write.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.mpeg/write.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <math.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "rom_proto.h"
Modified: grass/trunk/raster/r.out.png/main.c
===================================================================
--- grass/trunk/raster/r.out.png/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.png/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -37,6 +37,7 @@
#endif /* _MYINCLUDE_H */
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define DEF_RED 255
@@ -151,12 +152,12 @@
G_message(_("rows = %d, cols = %d"), w.rows, w.cols);
/* open raster map for reading */
- if ((cellfile = G_open_cell_old(rast->answer, "")) == -1)
+ if ((cellfile = Rast_open_cell_old(rast->answer, "")) == -1)
G_fatal_error(_("Unable to open cellfile for <%s>"), rastermap);
- cell_buf = G_allocate_c_raster_buf();
- fcell_buf = G_allocate_f_raster_buf();
- dcell_buf = G_allocate_d_raster_buf();
+ cell_buf = Rast_allocate_c_raster_buf();
+ fcell_buf = Rast_allocate_f_raster_buf();
+ dcell_buf = Rast_allocate_d_raster_buf();
ored = G_malloc(w.cols);
ogrn = G_malloc(w.cols);
@@ -221,9 +222,9 @@
{
struct Colors colors;
- G_read_colors(rast->answer, "", &colors);
+ Rast_read_colors(rast->answer, "", &colors);
- rtype = G_get_raster_map_type(cellfile);
+ rtype = Rast_get_raster_map_type(cellfile);
if (rtype == CELL_TYPE)
voidc = (CELL *) cell_buf;
else if (rtype == FCELL_TYPE)
@@ -251,9 +252,9 @@
for (row = 0; row < w.rows; row++) {
G_percent(row, w.rows, 5);
- if (G_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
+ if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
exit(EXIT_FAILURE);
- G_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
+ Rast_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
w.cols, &colors, rtype);
pp = line;
@@ -291,7 +292,7 @@
G_warning("don't know how to write grey scale!\n");
}
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
G_free(cell_buf);
@@ -301,7 +302,7 @@
G_free(ogrn);
G_free(oblu);
G_free(set);
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
Modified: grass/trunk/raster/r.out.pov/main.c
===================================================================
--- grass/trunk/raster/r.out.pov/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.pov/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -39,6 +39,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
void writeHeader(FILE * outf);
@@ -161,7 +162,7 @@
name = parm.map->answer;
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
@@ -173,7 +174,7 @@
if (NULL == (outf = fopen(outfilename, "wb")))
G_fatal_error(_("Unable to open output file <%s>"), outfilename);
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
nrows = G_window_rows();
ncols = G_window_cols();
@@ -195,9 +196,9 @@
northMost = region.north;
southMost = region.south;
- G_init_range(&range);
- G_read_range(name, "", &range);
- G_get_range_min_max(&range, &range_min, &range_max);
+ Rast_init_range(&range);
+ Rast_read_range(name, "", &range);
+ Rast_get_range_min_max(&range, &range_min, &range_max);
if (range.min < 0 || range.max < 0)
G_warning(_("Negative elevation values in input"));
@@ -219,7 +220,7 @@
(void)processProfiles(fd, outf);
fclose(outf);
- G_close_cell(fd);
+ Rast_close_cell(fd);
exit(EXIT_SUCCESS);
}
@@ -259,9 +260,9 @@
int c, r;
double tempFloat;
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
for (r = 0; r < rowCount; r++) {
- if (G_get_map_row(inputFile, cell, r) < 0)
+ if (Rast_get_map_row(inputFile, cell, r) < 0)
exit(1);
/* break; */
Modified: grass/trunk/raster/r.out.ppm/main.c
===================================================================
--- grass/trunk/raster/r.out.ppm/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.ppm/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define DEF_RED 255
@@ -95,12 +96,12 @@
G_message(_("rows = %d, cols = %d"), w.rows, w.cols);
/* open raster map for reading */
- if ((cellfile = G_open_cell_old(rast->answer, "")) == -1)
+ if ((cellfile = Rast_open_cell_old(rast->answer, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), rast->answer);
- cell_buf = G_allocate_c_raster_buf();
- fcell_buf = G_allocate_f_raster_buf();
- dcell_buf = G_allocate_d_raster_buf();
+ cell_buf = Rast_allocate_c_raster_buf();
+ fcell_buf = Rast_allocate_f_raster_buf();
+ dcell_buf = Rast_allocate_d_raster_buf();
ored = G_malloc(w.cols);
ogrn = G_malloc(w.cols);
@@ -146,9 +147,9 @@
{
struct Colors colors;
- G_read_colors(rast->answer, "", &colors);
+ Rast_read_colors(rast->answer, "", &colors);
- rtype = G_get_raster_map_type(cellfile);
+ rtype = Rast_get_raster_map_type(cellfile);
if (rtype == CELL_TYPE)
voidc = (CELL *) cell_buf;
else if (rtype == FCELL_TYPE)
@@ -161,10 +162,10 @@
if (!gscale->answer) { /* 24BIT COLOR IMAGE */
for (row = 0; row < w.rows; row++) {
G_percent(row, w.rows, 5);
- if (G_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
+ if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
rast->answer, row);
- G_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
+ Rast_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
w.cols, &colors, rtype);
for (col = 0; col < w.cols; col++) {
@@ -185,9 +186,9 @@
for (row = 0; row < w.rows; row++) {
G_percent(row, w.rows, 5);
- if (G_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
+ if (Rast_get_raster_row(cellfile, (void *)voidc, row, rtype) < 0)
exit(1);
- G_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
+ Rast_lookup_raster_colors((void *)voidc, ored, ogrn, oblu, set,
w.cols, &colors, rtype);
for (col = 0; col < w.cols; col++) {
@@ -205,7 +206,7 @@
}
}
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
G_free(cell_buf);
@@ -215,7 +216,7 @@
G_free(ogrn);
G_free(oblu);
G_free(set);
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
/*
if(!do_stdout)
*/
Modified: grass/trunk/raster/r.out.ppm3/main.c
===================================================================
--- grass/trunk/raster/r.out.ppm3/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.ppm3/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define DEF_RED 255
@@ -99,18 +100,18 @@
char *name = B[i].opt->answer;
/* Open raster map */
- if ((B[i].file = G_open_cell_old(name, "")) == -1)
+ if ((B[i].file = Rast_open_cell_old(name, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), name);
/* Get map type (CELL/FCELL/DCELL) */
- B[i].type = G_get_raster_map_type(B[i].file);
+ B[i].type = Rast_get_raster_map_type(B[i].file);
/* Get color table */
- if (G_read_colors(name, "", &B[i].colors) == -1)
+ if (Rast_read_colors(name, "", &B[i].colors) == -1)
G_fatal_error(_("Color file for <%s> not available"), name);
/* Allocate input buffer */
- B[i].array = G_allocate_raster_buf(B[i].type);
+ B[i].array = Rast_allocate_raster_buf(B[i].type);
/* Allocate output buffers */
B[i].buf = (unsigned char *)G_malloc(w.cols);
@@ -158,10 +159,10 @@
G_percent(row, w.rows, 5);
for (i = 0; i < 3; i++) {
- if (G_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
- G_fatal_error("G_get_raster_row failed");
+ if (Rast_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
+ G_fatal_error("Rast_get_raster_row failed");
- G_lookup_raster_colors(B[i].array,
+ Rast_lookup_raster_colors(B[i].array,
(i == 0) ? B[i].buf : dummy,
(i == 1) ? B[i].buf : dummy,
(i == 2) ? B[i].buf : dummy,
@@ -186,11 +187,11 @@
fclose(fp);
for (i = 0; i < 3; i++) {
- G_free_colors(&B[i].colors);
+ Rast_free_colors(&B[i].colors);
G_free(B[i].array);
G_free(B[i].buf);
G_free(B[i].mask);
- G_close_cell(B[i].file);
+ Rast_close_cell(B[i].file);
}
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.out.tiff/main.c
===================================================================
--- grass/trunk/raster/r.out.tiff/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.tiff/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -50,6 +50,7 @@
#include <sys/types.h>
#include <tiffio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "rasterfile.h"
@@ -138,25 +139,25 @@
palette = pflag->answer;
tfw = tflag->answer;
- if ((G_get_cellhd(inopt->answer, "", &cellhd) < 0))
+ if ((Rast_get_cellhd(inopt->answer, "", &cellhd) < 0))
G_fatal_error(_("Unable to read header of raster map <%s>"),
inopt->answer);
G_get_window(&cellhd);
- G_read_colors(inopt->answer, "", &colors);
- if ((isfp = G_raster_map_is_fp(inopt->answer, "")))
+ Rast_read_colors(inopt->answer, "", &colors);
+ if ((isfp = Rast_raster_map_is_fp(inopt->answer, "")))
G_warning(_("Raster map <%s>> is a floating point "
"map. Fractional values will be rounded to integer"),
inopt->answer);
- G_set_null_value_color(255, 255, 255, &colors);
+ Rast_set_null_value_color(255, 255, 255, &colors);
if (palette && (colors.cmax - colors.cmin > 255))
G_fatal_error(_("Color map for palette must have less "
"than 256 colors for the available range of data"));
- cell = G_allocate_cell_buf();
- if ((in = G_open_cell_old(inopt->answer, "")) < 0)
+ cell = Rast_allocate_cell_buf();
+ if ((in = Rast_open_cell_old(inopt->answer, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), inopt->answer);
basename = G_store(outopt->answer);
@@ -199,7 +200,7 @@
#define SCALE(x) (((x)*((1L<<16)-1))/255)
for (i = colors.cmin; i <= colors.cmax; i++, redp++, grnp++, blup++) {
- G_get_color(i, &red, &grn, &blu, &colors);
+ Rast_get_color(i, &red, &grn, &blu, &colors);
*redp = (unsigned short) (SCALE(red));
*grnp = (unsigned short) (SCALE(grn));
*blup = (unsigned short) (SCALE(blu));
@@ -241,7 +242,7 @@
/* allocate cell buffers */
for (i = 0; i < tilelength; i++)
- cells[i] = G_allocate_cell_buf();
+ cells[i] = Rast_allocate_cell_buf();
/* build tiff tiles from grass buffer */
for (row = 0; row < imagelength; row += tilelength) {
@@ -251,7 +252,7 @@
uint32 colb = 0;
for (i = 0; i < nrow; i++) {
- if (G_get_c_raster_row(in, cells[i], row + i) < 0)
+ if (Rast_get_c_raster_row(in, cells[i], row + i) < 0)
G_fatal_error(_("Reading raster map..."));
}
@@ -288,7 +289,7 @@
}
else {
for (j = 0; j < width; j++) {
- G_get_color(cellptr[col + j], &red, &grn, &blu,
+ Rast_get_color(cellptr[col + j], &red, &grn, &blu,
&colors);
*tptr++ = (unsigned char) red;
*tptr++ = (unsigned char) grn;
@@ -338,7 +339,7 @@
G_percent(row, h.ras_height, 2);
- if (G_get_c_raster_row(in, cell, row) < 0)
+ if (Rast_get_c_raster_row(in, cell, row) < 0)
exit(EXIT_FAILURE);
cellptr = cell;
@@ -348,7 +349,7 @@
}
else {
for (col = 0; col < h.ras_width; col++) {
- G_get_color(cell[col], &red, &grn, &blu, &colors);
+ Rast_get_color(cell[col], &red, &grn, &blu, &colors);
*tmpptr++ = (unsigned char) red;
*tmpptr++ = (unsigned char) grn;
*tmpptr++ = (unsigned char) blu;
Modified: grass/trunk/raster/r.out.vrml/main.c
===================================================================
--- grass/trunk/raster/r.out.vrml/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.vrml/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "pv.h"
@@ -80,7 +81,7 @@
G_get_set_window(&W);
- if ((elevfd = G_open_cell_old(rast_el->answer, "")) == -1)
+ if ((elevfd = Rast_open_cell_old(rast_el->answer, "")) == -1)
G_fatal_error("Unable to open cellfile for <%s>", rast_el->answer);
{
@@ -90,32 +91,32 @@
DCELL dmin, dmax;
struct FPRange fp_range;
- is_fp = G_raster_map_is_fp(rast_el->answer, "");
+ is_fp = Rast_raster_map_is_fp(rast_el->answer, "");
if (is_fp) {
- if (G_read_fp_range(rast_el->answer, "", &fp_range) != 1) {
+ if (Rast_read_fp_range(rast_el->answer, "", &fp_range) != 1) {
G_fatal_error(_("Range info for [%s] not available (run r.support)"),
rast_el->answer);
}
- G_get_fp_range_min_max(&fp_range, &dmin, &dmax);
+ Rast_get_fp_range_min_max(&fp_range, &dmin, &dmax);
min = dmin;
max = dmax;
}
else {
- if (G_read_range(rast_el->answer, "", &range) == -1) {
+ if (Rast_read_range(rast_el->answer, "", &range) == -1) {
G_fatal_error(_("Range info for <%s> not available (run r.support)"),
rast_el->answer);
}
- G_get_range_min_max(&range, &cmin, &cmax);
+ Rast_get_range_min_max(&range, &cmin, &cmax);
min = cmin;
max = cmax;
}
}
if (rast_co->answer) {
- if ((colorfd = G_open_cell_old(rast_co->answer, "")) == -1)
+ if ((colorfd = Rast_open_cell_old(rast_co->answer, "")) == -1)
G_warning(_("Unable to open cellfile for <%s>"), rast_co->answer);
else {
- G_read_colors(rast_co->answer, "", &colr);
+ Rast_read_colors(rast_co->answer, "", &colr);
color_ok = 1;
}
}
@@ -159,9 +160,9 @@
vrml_end(vout);
- G_close_cell(elevfd);
+ Rast_close_cell(elevfd);
if (color_ok)
- G_close_cell(colorfd);
+ Rast_close_cell(colorfd);
return (EXIT_SUCCESS);
Modified: grass/trunk/raster/r.out.vrml/put_grid.c
===================================================================
--- grass/trunk/raster/r.out.vrml/put_grid.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.vrml/put_grid.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -47,7 +47,7 @@
if (!shh)
G_percent(row, rows - 1, 10);
- G_get_f_raster_row(elevfd, tf, row);
+ Rast_get_f_raster_row(elevfd, tf, row);
coordz = G_row_to_northing((double)row, w);
do_coordcnv(&coordz, 'z');
@@ -57,7 +57,7 @@
do_coordcnv(&coordx, 'x');
/* HACK: no nulls in vrml grid */
- if (G_is_f_null_value(tf))
+ if (Rast_is_f_null_value(tf))
*tf = 0.0;
coordy = *tf;
do_coordcnv(&coordy, 'y');
@@ -98,8 +98,8 @@
if (!shh)
G_percent(row, rows - 1, 5);
- G_get_f_raster_row(colorfd, tf, row);
- G_lookup_f_raster_colors(tf, red, green, blue, set, cols, colr);
+ Rast_get_f_raster_row(colorfd, tf, row);
+ Rast_lookup_f_raster_colors(tf, red, green, blue, set, cols, colr);
for (col = 0; col < cols; col++) {
sprintf(str, "%.3f %.3f %.3f,",
Modified: grass/trunk/raster/r.out.vrml/pv.h
===================================================================
--- grass/trunk/raster/r.out.vrml/pv.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.vrml/pv.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/* VRML VERSION - only 1.0 currently supported
#define VRML2
Modified: grass/trunk/raster/r.out.vtk/main.c
===================================================================
--- grass/trunk/raster/r.out.vtk/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.vtk/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/config.h>
#include "writeascii.h"
@@ -122,12 +123,12 @@
G_debug(3, _("Open Raster file %s"), param.elevationmap->answer);
/* open raster map */
- fd = G_open_cell_old(param.elevationmap->answer, "");
+ fd = Rast_open_cell_old(param.elevationmap->answer, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
param.elevationmap->answer);
- out_type = G_get_raster_map_type(fd);
+ out_type = Rast_get_raster_map_type(fd);
/*The write the Coordinates */
if (param.usestruct->answer) {
@@ -150,7 +151,7 @@
region, out_type, null_value,
scale, polytype, digits);
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
else {
/*Should pointdata or celldata be written */
@@ -185,15 +186,15 @@
G_debug(3, _("Open Raster file %s"), param.input->answers[i]);
/* open raster map */
- fd = G_open_cell_old(param.input->answers[i], "");
+ fd = Rast_open_cell_old(param.input->answers[i], "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
param.input->answers[i]);
- out_type = G_get_raster_map_type(fd);
+ out_type = Rast_get_raster_map_type(fd);
/*Now write the data */
write_vtk_data(fd, fp, param.input->answers[i], region, out_type,
null_value, digits);
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
}
@@ -210,11 +211,11 @@
param.rgbmaps->answers[i]);
/* open raster map */
- rgbfd[i] = G_open_cell_old(param.rgbmaps->answers[i], "");
+ rgbfd[i] = Rast_open_cell_old(param.rgbmaps->answers[i], "");
if (rgbfd[i] < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
param.rgbmaps->answers[i]);
- celltype[i] = G_get_raster_map_type(rgbfd[i]);
+ celltype[i] = Rast_get_raster_map_type(rgbfd[i]);
}
/*Maps have to be from the same type */
@@ -235,7 +236,7 @@
/*Close the maps */
for (i = 0; i < 3; i++)
- G_close_cell(rgbfd[i]);
+ Rast_close_cell(rgbfd[i]);
}
}
@@ -253,11 +254,11 @@
/* open raster map */
vectfd[i] =
- G_open_cell_old(param.vectmaps->answers[i], "");
+ Rast_open_cell_old(param.vectmaps->answers[i], "");
if (vectfd[i] < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
param.vectmaps->answers[i]);
- celltype[i] = G_get_raster_map_type(vectfd[i]);
+ celltype[i] = Rast_get_raster_map_type(vectfd[i]);
}
/*Maps have to be from the same type */
@@ -278,7 +279,7 @@
/*Close the maps */
for (i = 0; i < 3; i++)
- G_close_cell(vectfd[i]);
+ Rast_close_cell(vectfd[i]);
}
}
Modified: grass/trunk/raster/r.out.vtk/parameters.c
===================================================================
--- grass/trunk/raster/r.out.vtk/parameters.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.vtk/parameters.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
*
*****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/config.h>
#include "parameters.h"
Modified: grass/trunk/raster/r.out.vtk/writeascii.c
===================================================================
--- grass/trunk/raster/r.out.vtk/writeascii.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.out.vtk/writeascii.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/config.h>
#include "globaldefs.h"
@@ -37,7 +38,7 @@
double val = nullval;
if (MapType == CELL_TYPE) {
- if (G_is_null_value(ptr, MapType)) {
+ if (Rast_is_null_value(ptr, MapType)) {
val = nullval;
}
else {
@@ -45,7 +46,7 @@
}
}
if (MapType == FCELL_TYPE) {
- if (G_is_null_value(ptr, MapType)) {
+ if (Rast_is_null_value(ptr, MapType)) {
val = nullval;
}
else {
@@ -53,7 +54,7 @@
}
}
if (MapType == DCELL_TYPE) {
- if (G_is_null_value(ptr, MapType)) {
+ if (Rast_is_null_value(ptr, MapType)) {
val = nullval;
}
else {
@@ -173,14 +174,14 @@
nullvalue = 0;
}
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
rowcount = 0;
for (row = nrows - 1; row >= 0; row--) {
colcount = 0;
G_percent((row - nrows) * (-1), nrows, 2);
- if (G_get_raster_row(fd, raster, row, out_type) < 0) {
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
@@ -189,7 +190,7 @@
nspos -= y_extent;
for (col = 0, ptr = raster; col < ncols;
- col++, ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
+ col++, ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
ewpos =
region.ew_res / 2 + region.west + colcount * region.ew_res;
ewpos -= x_extent;
@@ -234,14 +235,14 @@
/*First we are writing the coordinate points, the elevation cell is only used for the z coordinate */
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
rowcount = 0;
for (row = nrows - 1; row >= 0; row--) {
colcount = 0;
G_percent((row - nrows) * (-1), nrows, 10);
- if (G_get_raster_row(fd, raster, row, out_type) < 0) {
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
@@ -250,7 +251,7 @@
nspos -= y_extent;
for (col = 0, ptr = raster; col < ncols;
- col++, ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
+ col++, ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
ewpos =
region.ew_res / 2 + region.west + colcount * region.ew_res;
ewpos -= x_extent;
@@ -348,18 +349,18 @@
fprintf(fp, "LOOKUP_TABLE default\n");
- raster = G_allocate_raster_buf(out_type);
+ raster = Rast_allocate_raster_buf(out_type);
for (row = nrows - 1; row >= 0; row--) {
G_percent((row - nrows) * (-1), nrows, 10);
- if (G_get_raster_row(fd, raster, row, out_type) < 0) {
+ if (Rast_get_raster_row(fd, raster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
for (col = 0, ptr = raster; col < ncols;
- col++, ptr = G_incr_void_ptr(ptr, G_raster_size(out_type))) {
+ col++, ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(out_type))) {
value = get_raster_value_as_double(out_type, ptr, nullvalue);
fprintf(fp, "%.*f ", dp, value);
@@ -393,22 +394,22 @@
fprintf(fp, "COLOR_SCALARS %s 3\n", varname);
- redraster = G_allocate_raster_buf(out_type);
- greenraster = G_allocate_raster_buf(out_type);
- blueraster = G_allocate_raster_buf(out_type);
+ redraster = Rast_allocate_raster_buf(out_type);
+ greenraster = Rast_allocate_raster_buf(out_type);
+ blueraster = Rast_allocate_raster_buf(out_type);
for (row = nrows - 1; row >= 0; row--) {
G_percent((row - nrows) * (-1), nrows, 10);
- if (G_get_raster_row(redfd, redraster, row, out_type) < 0) {
+ if (Rast_get_raster_row(redfd, redraster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
- if (G_get_raster_row(greenfd, greenraster, row, out_type) < 0) {
+ if (Rast_get_raster_row(greenfd, greenraster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
- if (G_get_raster_row(bluefd, blueraster, row, out_type) < 0) {
+ if (Rast_get_raster_row(bluefd, blueraster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
@@ -416,9 +417,9 @@
for (col = 0, redptr = redraster, greenptr = greenraster, blueptr =
blueraster; col < ncols;
col++, redptr =
- G_incr_void_ptr(redptr, G_raster_size(out_type)), greenptr =
- G_incr_void_ptr(greenptr, G_raster_size(out_type)), blueptr =
- G_incr_void_ptr(blueptr, G_raster_size(out_type))) {
+ Rast_incr_void_ptr(redptr, Rast_raster_size(out_type)), greenptr =
+ Rast_incr_void_ptr(greenptr, Rast_raster_size(out_type)), blueptr =
+ Rast_incr_void_ptr(blueptr, Rast_raster_size(out_type))) {
r = get_raster_value_as_double(out_type, redptr, 0.0);
g = get_raster_value_as_double(out_type, greenptr, 0.0);
@@ -460,22 +461,22 @@
fprintf(fp, "VECTORS %s float\n", varname);
- xraster = G_allocate_raster_buf(out_type);
- yraster = G_allocate_raster_buf(out_type);
- zraster = G_allocate_raster_buf(out_type);
+ xraster = Rast_allocate_raster_buf(out_type);
+ yraster = Rast_allocate_raster_buf(out_type);
+ zraster = Rast_allocate_raster_buf(out_type);
for (row = nrows - 1; row >= 0; row--) {
G_percent((row - nrows) * (-1), nrows, 10);
- if (G_get_raster_row(xfd, xraster, row, out_type) < 0) {
+ if (Rast_get_raster_row(xfd, xraster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
- if (G_get_raster_row(yfd, yraster, row, out_type) < 0) {
+ if (Rast_get_raster_row(yfd, yraster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
- if (G_get_raster_row(zfd, zraster, row, out_type) < 0) {
+ if (Rast_get_raster_row(zfd, zraster, row, out_type) < 0) {
G_fatal_error(_("Unable to read row %i\n"), row);
return;
}
@@ -483,9 +484,9 @@
for (col = 0, xptr = xraster, yptr = yraster, zptr =
zraster; col < ncols;
col++, xptr =
- G_incr_void_ptr(xptr, G_raster_size(out_type)), yptr =
- G_incr_void_ptr(yptr, G_raster_size(out_type)), zptr =
- G_incr_void_ptr(zptr, G_raster_size(out_type))) {
+ Rast_incr_void_ptr(xptr, Rast_raster_size(out_type)), yptr =
+ Rast_incr_void_ptr(yptr, Rast_raster_size(out_type)), zptr =
+ Rast_incr_void_ptr(zptr, Rast_raster_size(out_type))) {
x = get_raster_value_as_double(out_type, xptr, 0.0);
y = get_raster_value_as_double(out_type, yptr, 0.0);
Modified: grass/trunk/raster/r.param.scale/close_down.c
===================================================================
--- grass/trunk/raster/r.param.scale/close_down.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/close_down.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,13 +17,13 @@
char map_title[RECORD_LEN], map_type[32];
/* Close connection with existing input raster. */
- G_unopen_cell(fd_in);
+ Rast_unopen_cell(fd_in);
/* Write output raster map and close connection. */
- G_close_cell(fd_out);
+ Rast_close_cell(fd_out);
/* write out map metadata */
- G_short_history(rast_out_name, "raster", &history);
+ Rast_short_history(rast_out_name, "raster", &history);
strncpy(history.datsrc_1, rast_in_name, RECORD_LEN-1);
history.datsrc_1[RECORD_LEN-1] = '\0';
@@ -36,7 +36,7 @@
case SLOPE:
strcpy(map_type, "Magnitude of maximum gradient");
- G_write_raster_units(rast_out_name, "degrees");
+ Rast_write_raster_units(rast_out_name, "degrees");
strcpy(history.edhist[0],
"Slope is given for steepest slope angle and measured in degrees.");
@@ -45,7 +45,7 @@
case ASPECT:
strcpy(map_type, "Direction of maximum gradient");
- G_write_raster_units(rast_out_name, "degrees");
+ Rast_write_raster_units(rast_out_name, "degrees");
strcpy(history.edhist[0],
"Flow direction (aspect): W=0, E=180, N=+90, S=-90 degrees");
@@ -117,11 +117,11 @@
break;
}
- G_command_history(&history);
- G_write_history(rast_out_name, &history);
+ Rast_command_history(&history);
+ Rast_write_history(rast_out_name, &history);
sprintf(map_title, "DEM terrain parameter: %s", map_type);
- G_put_cell_title(rast_out_name, map_title);
+ Rast_put_cell_title(rast_out_name, map_title);
return;
}
Modified: grass/trunk/raster/r.param.scale/interface.c
===================================================================
--- grass/trunk/raster/r.param.scale/interface.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/interface.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "param.h"
Modified: grass/trunk/raster/r.param.scale/nrutil.c
===================================================================
--- grass/trunk/raster/r.param.scale/nrutil.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/nrutil.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "nrutil.h"
Modified: grass/trunk/raster/r.param.scale/open_files.c
===================================================================
--- grass/trunk/raster/r.param.scale/open_files.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/open_files.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -14,6 +14,7 @@
/*****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "param.h"
@@ -22,17 +23,17 @@
{
/* Open existing file and set the input file descriptor. */
- if ((fd_in = G_open_cell_old(rast_in_name, "")) < 0)
+ if ((fd_in = Rast_open_cell_old(rast_in_name, "")) < 0)
G_fatal_error(_("Cannot open raster map <%s>"), rast_in_name);
/* Open new file and set the output file descriptor. */
if (mparam != FEATURE) {
- if ((fd_out = G_open_raster_new(rast_out_name, DCELL_TYPE)) < 0)
+ if ((fd_out = Rast_open_raster_new(rast_out_name, DCELL_TYPE)) < 0)
G_fatal_error(_("Cannot create raster map <%s>"), rast_out_name);
}
else {
- if ((fd_out = G_open_raster_new(rast_out_name, CELL_TYPE)) < 0)
+ if ((fd_out = Rast_open_raster_new(rast_out_name, CELL_TYPE)) < 0)
G_fatal_error(_("Cannot create raster map <%s>"), rast_out_name);
}
Modified: grass/trunk/raster/r.param.scale/param.h
===================================================================
--- grass/trunk/raster/r.param.scale/param.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/param.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,6 +9,7 @@
/************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
/* programs. It sets up the necessary */
/* prototypes for GRASS library calls. */
#include <math.h>
Modified: grass/trunk/raster/r.param.scale/process.c
===================================================================
--- grass/trunk/raster/r.param.scale/process.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/process.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/gmath.h>
#include "param.h"
@@ -86,9 +87,9 @@
/* Reserve `wsize' rows of memory. */
if (mparam != FEATURE)
- row_out = G_allocate_raster_buf(DCELL_TYPE); /* Initialise output row buffer. */
+ row_out = Rast_allocate_raster_buf(DCELL_TYPE); /* Initialise output row buffer. */
else
- featrow_out = G_allocate_raster_buf(CELL_TYPE); /* Initialise output row buffer. */
+ featrow_out = Rast_allocate_raster_buf(CELL_TYPE); /* Initialise output row buffer. */
window_ptr = (DCELL *) G_malloc(SQR(wsize) * sizeof(DCELL));
/* Reserve enough memory for local wind. */
@@ -146,13 +147,13 @@
if (mparam != FEATURE)
for (wind_row = 0; wind_row < EDGE; wind_row++)
- G_put_raster_row(fd_out, row_out, DCELL_TYPE); /* Write out the edge cells as NULL. */
+ Rast_put_raster_row(fd_out, row_out, DCELL_TYPE); /* Write out the edge cells as NULL. */
else
for (wind_row = 0; wind_row < EDGE; wind_row++)
- G_put_raster_row(fd_out, featrow_out, CELL_TYPE); /* Write out the edge cells as NULL. */
+ Rast_put_raster_row(fd_out, featrow_out, CELL_TYPE); /* Write out the edge cells as NULL. */
for (wind_row = 0; wind_row < wsize - 1; wind_row++)
- G_get_raster_row(fd_in, row_in + (wind_row * ncols), wind_row,
+ Rast_get_raster_row(fd_in, row_in + (wind_row * ncols), wind_row,
DCELL_TYPE);
/* Read in enough of the first rows to */
/* allow window to be examined. */
@@ -160,7 +161,7 @@
for (row = EDGE; row < (nrows - EDGE); row++) {
G_percent(row + 1, nrows - EDGE, 2);
- G_get_raster_row(fd_in, row_in + ((wsize - 1) * ncols), row + EDGE,
+ Rast_get_raster_row(fd_in, row_in + ((wsize - 1) * ncols), row + EDGE,
DCELL_TYPE);
for (col = EDGE; col < (ncols - EDGE); col++) {
@@ -210,10 +211,10 @@
}
if (mparam != FEATURE)
- G_put_raster_row(fd_out, row_out, DCELL_TYPE); /* Write the row buffer to the output */
+ Rast_put_raster_row(fd_out, row_out, DCELL_TYPE); /* Write the row buffer to the output */
/* raster. */
else /* write FEATURE to CELL */
- G_put_raster_row(fd_out, featrow_out, CELL_TYPE); /* Write the row buffer to the output */
+ Rast_put_raster_row(fd_out, featrow_out, CELL_TYPE); /* Write the row buffer to the output */
/* raster. */
/* 'Shuffle' rows down one, and read in */
@@ -226,9 +227,9 @@
for (wind_row = 0; wind_row < EDGE; wind_row++) {
if (mparam != FEATURE)
- G_put_raster_row(fd_out, row_out, DCELL_TYPE); /* Write out the edge cells as NULL. */
+ Rast_put_raster_row(fd_out, row_out, DCELL_TYPE); /* Write out the edge cells as NULL. */
else
- G_put_raster_row(fd_out, featrow_out, CELL_TYPE); /* Write out the edge cells as NULL. */
+ Rast_put_raster_row(fd_out, featrow_out, CELL_TYPE); /* Write out the edge cells as NULL. */
}
/*--------------------------------------------------------------------------*/
Modified: grass/trunk/raster/r.param.scale/write_cats.c
===================================================================
--- grass/trunk/raster/r.param.scale/write_cats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/write_cats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
/*****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "param.h"
@@ -25,29 +26,29 @@
/* INITIALISE */
/*------------------------------------------------------------------------*/
- G_init_cats((CELL) 0, "", &cats);
- G_set_raster_cats_title("Surface Features", &cats);
+ Rast_init_cats((CELL) 0, "", &cats);
+ Rast_set_raster_cats_title("Surface Features", &cats);
/*------------------------------------------------------------------------*/
/* FILL OUT CATEGORIES STRUCTURE */
/*------------------------------------------------------------------------*/
- G_set_cat(FLAT, " Planar", &cats);
- G_set_cat(PIT, " Pit", &cats);
- G_set_cat(PEAK, " Peak", &cats);
- G_set_cat(RIDGE, " Ridge", &cats);
- G_set_cat(CHANNEL, " Channel", &cats);
- G_set_cat(PASS, " Pass (saddle)", &cats);
+ Rast_set_cat(FLAT, " Planar", &cats);
+ Rast_set_cat(PIT, " Pit", &cats);
+ Rast_set_cat(PEAK, " Peak", &cats);
+ Rast_set_cat(RIDGE, " Ridge", &cats);
+ Rast_set_cat(CHANNEL, " Channel", &cats);
+ Rast_set_cat(PASS, " Pass (saddle)", &cats);
/*------------------------------------------------------------------------*/
/* WRITE OUT CATEGORIES STRUCTURE */
/*------------------------------------------------------------------------*/
- if (G_write_cats(rast_out_name, &cats) <= 0)
+ if (Rast_write_cats(rast_out_name, &cats) <= 0)
G_warning(_("Cannot write category file for raster map <%s>"),
rast_out_name);
- G_free_cats(&cats);
+ Rast_free_cats(&cats);
return;
}
Modified: grass/trunk/raster/r.param.scale/write_cols.c
===================================================================
--- grass/trunk/raster/r.param.scale/write_cols.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.param.scale/write_cols.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,17 +20,17 @@
{
struct Colors colours;
- G_init_colors(&colours);
+ Rast_init_colors(&colours);
- G_add_color_rule(FLAT, 180, 180, 180, /* White */
+ Rast_add_color_rule(FLAT, 180, 180, 180, /* White */
PIT, 0, 0, 0, &colours); /* Black */
- G_add_color_rule(CHANNEL, 0, 0, 255, /* Blue */
+ Rast_add_color_rule(CHANNEL, 0, 0, 255, /* Blue */
PASS, 0, 255, 0, &colours); /* Green */
- G_add_color_rule(RIDGE, 255, 255, 0, /* Yellow */
+ Rast_add_color_rule(RIDGE, 255, 255, 0, /* Yellow */
PEAK, 255, 0, 0, &colours); /* Red */
- G_write_colors(rast_out_name, G_mapset(), &colours);
+ Rast_write_colors(rast_out_name, G_mapset(), &colours);
- G_free_colors(&colours);
+ Rast_free_colors(&colours);
}
Modified: grass/trunk/raster/r.patch/do_patch.c
===================================================================
--- grass/trunk/raster/r.patch/do_patch.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.patch/do_patch.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/*
* patch in non-zero data over zero data
* keep track of the categories which are patched in
@@ -13,8 +14,8 @@
/* insert 0 check here */
- return G_is_null_value(rast, data_type) ||
- G_get_raster_value_d(rast, data_type) != 0.0 ? 0 : 1;
+ return Rast_is_null_value(rast, data_type) ||
+ Rast_get_raster_value_d(rast, data_type) != 0.0 ? 0 : 1;
}
@@ -28,35 +29,35 @@
while (ncols-- > 0) {
if (ZEROFLAG) { /* use 0 for transparency instead of NULL */
if (G_is_zero_value(result, out_type) ||
- G_is_null_value(result, out_type)) {
+ Rast_is_null_value(result, out_type)) {
/* Don't patch hole with a null, just mark as more */
- if (G_is_null_value(patch, out_type))
+ if (Rast_is_null_value(patch, out_type))
more = 1;
else {
/* Mark that there is more to be done if we patch with 0 */
if (G_is_zero_value(patch, out_type))
more = 1;
- G_raster_cpy(result, patch, 1, out_type);
+ Rast_raster_cpy(result, patch, 1, out_type);
if (out_type == CELL_TYPE)
- G_update_cell_stats((CELL *) result, 1, statf);
+ Rast_update_cell_stats((CELL *) result, 1, statf);
}
} /* ZERO support */
}
else { /* use NULL for transparency instead of 0 */
- if (G_is_null_value(result, out_type)) {
- if (G_is_null_value(patch, out_type))
+ if (Rast_is_null_value(result, out_type)) {
+ if (Rast_is_null_value(patch, out_type))
more = 1;
else {
- G_raster_cpy(result, patch, 1, out_type);
+ Rast_raster_cpy(result, patch, 1, out_type);
if (out_type == CELL_TYPE)
- G_update_cell_stats((CELL *) result, 1, statf);
+ Rast_update_cell_stats((CELL *) result, 1, statf);
}
} /* NULL support */
}
- result = G_incr_void_ptr(result, G_raster_size(out_type));
- patch = G_incr_void_ptr(patch, G_raster_size(out_type));
+ result = Rast_incr_void_ptr(result, Rast_raster_size(out_type));
+ patch = Rast_incr_void_ptr(patch, Rast_raster_size(out_type));
}
return more;
}
Modified: grass/trunk/raster/r.patch/main.c
===================================================================
--- grass/trunk/raster/r.patch/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.patch/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "nfiles.h"
#include "local_proto.h"
@@ -98,7 +99,7 @@
if (!ok)
continue;
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0) {
ok = 0;
continue;
@@ -106,25 +107,25 @@
infd[i] = fd;
- map_type = G_get_raster_map_type(fd);
+ map_type = Rast_get_raster_map_type(fd);
if (map_type == FCELL_TYPE && out_type == CELL_TYPE)
out_type = FCELL_TYPE;
else if (map_type == DCELL_TYPE)
out_type = DCELL_TYPE;
- G_init_cell_stats(&statf[i]);
+ Rast_init_cell_stats(&statf[i]);
}
if (!ok)
G_fatal_error(_("One or more input raster maps not found"));
rname = opt2->answer;
- outfd = G_open_raster_new(new_name = rname, out_type);
+ outfd = Rast_open_raster_new(new_name = rname, out_type);
if (outfd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), new_name);
- presult = G_allocate_raster_buf(out_type);
- patch = G_allocate_raster_buf(out_type);
+ presult = Rast_allocate_raster_buf(out_type);
+ patch = Rast_allocate_raster_buf(out_type);
nrows = G_window_rows();
ncols = G_window_cols();
@@ -132,28 +133,28 @@
G_verbose_message(_("Percent complete..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(infd[0], presult, row, out_type) < 0)
+ if (Rast_get_raster_row(infd[0], presult, row, out_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
names[0], row);
if (out_type == CELL_TYPE)
- G_update_cell_stats((CELL *) presult, ncols, &statf[0]);
+ Rast_update_cell_stats((CELL *) presult, ncols, &statf[0]);
for (i = 1; i < nfiles; i++) {
- if (G_get_raster_row(infd[i], patch, row, out_type) < 0)
+ if (Rast_get_raster_row(infd[i], patch, row, out_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
names[i], row);
if (!do_patch
(presult, patch, &statf[i], ncols, out_type, ZEROFLAG))
break;
}
- G_put_raster_row(outfd, presult, out_type);
+ Rast_put_raster_row(outfd, presult, out_type);
}
G_percent(row, nrows, 2);
G_free(patch);
G_free(presult);
for (i = 0; i < nfiles; i++)
- G_close_cell(infd[i]);
+ Rast_close_cell(infd[i]);
/*
* build the new cats and colors. do this before closing the new
* file, in case the new file is one of the patching files as well.
@@ -162,15 +163,15 @@
support(names, statf, nfiles, &cats, &cats_ok, &colr, &colr_ok, out_type);
/* now close (and create) the result */
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
if (cats_ok)
- G_write_cats(new_name, &cats);
+ Rast_write_cats(new_name, &cats);
if (colr_ok)
- G_write_colors(new_name, G_mapset(), &colr);
+ Rast_write_colors(new_name, G_mapset(), &colr);
- G_short_history(new_name, "raster", &history);
- G_command_history(&history);
- G_write_history(new_name, &history);
+ Rast_short_history(new_name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(new_name, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.patch/support.c
===================================================================
--- grass/trunk/raster/r.patch/support.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.patch/support.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
/*
* creates new category and color structures from the patching
* files category and color files
@@ -26,10 +27,10 @@
*cats_ok = 1;
*colr_ok = 1;
- if (G_read_cats(names[0], "", cats) < 0)
+ if (Rast_read_cats(names[0], "", cats) < 0)
*cats_ok = 0;
G_suppress_warnings(1);
- if (G_read_colors(names[0], "", colr) < 0)
+ if (Rast_read_colors(names[0], "", colr) < 0)
*colr_ok = 0;
G_suppress_warnings(0);
@@ -37,33 +38,33 @@
return 0;
for (i = 1; i < nfiles; i++) {
- do_cats = *cats_ok && (G_read_cats(names[i], "", &pcats) >= 0);
+ do_cats = *cats_ok && (Rast_read_cats(names[i], "", &pcats) >= 0);
G_suppress_warnings(1);
- do_colr = *colr_ok && (G_read_colors(names[i], "", &pcolr) >= 0);
+ do_colr = *colr_ok && (Rast_read_colors(names[i], "", &pcolr) >= 0);
G_suppress_warnings(0);
if (!do_cats && !do_colr)
continue;
if (out_type == CELL_TYPE) {
- G_rewind_cell_stats(statf + i);
- while (G_next_cell_stat(&n, &count, statf + i))
- if (n && !G_find_cell_stat(n, &count, statf)) {
+ Rast_rewind_cell_stats(statf + i);
+ while (Rast_next_cell_stat(&n, &count, statf + i))
+ if (n && !Rast_find_cell_stat(n, &count, statf)) {
if (do_cats) {
- G_update_cell_stats(&n, 1, statf);
- G_set_cat(n, G_get_cat(n, &pcats), cats);
+ Rast_update_cell_stats(&n, 1, statf);
+ Rast_set_cat(n, Rast_get_cat(n, &pcats), cats);
}
if (do_colr) {
- G_get_color(n, &red, &grn, &blu, &pcolr);
- G_set_color(n, red, grn, blu, colr);
+ Rast_get_color(n, &red, &grn, &blu, &pcolr);
+ Rast_set_color(n, red, grn, blu, colr);
}
}
}
/* else the color will be the color of the first map */
if (do_cats)
- G_free_cats(&pcats);
+ Rast_free_cats(&pcats);
if (do_colr)
/* otherwise this memory is used in colr pointer */
- G_free_colors(&pcolr);
+ Rast_free_colors(&pcolr);
}
return 1;
}
Modified: grass/trunk/raster/r.profile/local_proto.h
===================================================================
--- grass/trunk/raster/r.profile/local_proto.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.profile/local_proto.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
/* main.c */
Modified: grass/trunk/raster/r.profile/main.c
===================================================================
--- grass/trunk/raster/r.profile/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.profile/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -128,12 +129,12 @@
coords = 1;
/* Open Raster File */
- if ((fd = G_open_cell_old(name, "")) < 0)
+ if ((fd = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
/* initialize color structure */
if (clr)
- G_read_colors(name, "", &colors);
+ Rast_read_colors(name, "", &colors);
/* Open ASCII file for output or stdout */
outfile = parm.output->answer;
@@ -145,7 +146,7 @@
G_fatal_error(_("Unable to open file <%s>"), outfile);
/* Get Raster Type */
- data_type = G_get_raster_map_type(fd);
+ data_type = Rast_get_raster_map_type(fd);
/* Done with file */
/* Show message giving output format */
@@ -212,11 +213,11 @@
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
fclose(fp);
if (clr)
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
exit(EXIT_SUCCESS);
} /* Done with main */
Modified: grass/trunk/raster/r.profile/read_rast.c
===================================================================
--- grass/trunk/raster/r.profile/read_rast.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.profile/read_rast.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -23,8 +24,8 @@
int outofbounds = FALSE;
if (!dcell) {
- G_set_c_null_value(&nullcell, 1);
- dcell = G_allocate_d_raster_buf();
+ Rast_set_c_null_value(&nullcell, 1);
+ dcell = Rast_allocate_d_raster_buf();
G_get_window(&window);
nrows = window.rows;
ncols = window.cols;
@@ -38,7 +39,7 @@
outofbounds = TRUE;
if (!outofbounds) {
- if (row != cur_row && G_get_d_raster_row(fd, dcell, row) < 0)
+ if (row != cur_row && Rast_get_d_raster_row(fd, dcell, row) < 0)
G_fatal_error(_("Unable to read raster map row %d"), row);
cur_row = row;
}
@@ -48,7 +49,7 @@
fprintf(fp, " %f", dist);
- if (outofbounds || G_is_d_null_value(&dcell[col]))
+ if (outofbounds || Rast_is_d_null_value(&dcell[col]))
fprintf(fp, " %s", null_string);
else {
if (data_type == CELL_TYPE)
@@ -61,9 +62,9 @@
int red, green, blue;
if (outofbounds)
- G_get_color(nullcell, &red, &green, &blue, &colors);
+ Rast_get_color(nullcell, &red, &green, &blue, &colors);
else
- G_get_d_raster_color(&dcell[col], &red, &green, &blue,
+ Rast_get_d_raster_color(&dcell[col], &red, &green, &blue,
&colors);
fprintf(fp, " %03d:%03d:%03d", red, green, blue);
Modified: grass/trunk/raster/r.proj/bilinear.c
===================================================================
--- grass/trunk/raster/r.proj/bilinear.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/bilinear.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "r.proj.h"
void p_bilinear(struct cache *ibuffer, /* input buffer */
@@ -39,7 +40,7 @@
/* check for out of bounds - if out of bounds set NULL value and return */
if (row0 < 0 || row1 >= cellhd->rows || col0 < 0 || col1 >= cellhd->cols) {
- G_set_null_value(obufptr, 1, cell_type);
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
@@ -49,10 +50,10 @@
c11 = CPTR(ibuffer, row1, col1);
/* check for NULL values */
- if (G_is_f_null_value(c00) ||
- G_is_f_null_value(c01) ||
- G_is_f_null_value(c10) || G_is_f_null_value(c11)) {
- G_set_null_value(obufptr, 1, cell_type);
+ if (Rast_is_f_null_value(c00) ||
+ Rast_is_f_null_value(c01) ||
+ Rast_is_f_null_value(c10) || Rast_is_f_null_value(c11)) {
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
@@ -61,7 +62,7 @@
u = *row_idx - row0;
tu = t * u;
- result = G_interp_bilinear(t, u, *c00, *c01, *c10, *c11);
+ result = Rast_interp_bilinear(t, u, *c00, *c01, *c10, *c11);
- G_set_raster_value_f(obufptr, result, cell_type);
+ Rast_set_raster_value_f(obufptr, result, cell_type);
}
Modified: grass/trunk/raster/r.proj/bilinear_f.c
===================================================================
--- grass/trunk/raster/r.proj/bilinear_f.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/bilinear_f.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,6 +9,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "r.proj.h"
void p_bilinear_f(struct cache *ibuffer, /* input buffer */
@@ -29,19 +30,19 @@
/* check for out of bounds - if out of bounds set NULL value */
if (row < 0 || row >= cellhd->rows || col < 0 || col >= cellhd->cols) {
- G_set_null_value(obufptr, 1, cell_type);
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
cellp = CPTR(ibuffer, row, col);
/* if nearest is null, all the other interps will be null */
- if (G_is_f_null_value(cellp)) {
- G_set_null_value(obufptr, 1, cell_type);
+ if (Rast_is_f_null_value(cellp)) {
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
p_bilinear(ibuffer, obufptr, cell_type, col_idx, row_idx, cellhd);
/* fallback to nearest if bilinear is null */
- if (G_is_f_null_value(obufptr))
- G_set_raster_value_f(obufptr, *cellp, cell_type);
+ if (Rast_is_f_null_value(obufptr))
+ Rast_set_raster_value_f(obufptr, *cellp, cell_type);
}
Modified: grass/trunk/raster/r.proj/bordwalk.c
===================================================================
--- grass/trunk/raster/r.proj/bordwalk.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/bordwalk.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -28,6 +28,7 @@
#include <math.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.proj/cubic.c
===================================================================
--- grass/trunk/raster/r.proj/cubic.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/cubic.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <math.h>
#include "r.proj.h"
@@ -40,7 +41,7 @@
/* check for out of bounds of map - if out of bounds set NULL value */
if (row - 1 < 0 || row + 2 >= cellhd->rows ||
col - 1 < 0 || col + 2 >= cellhd->cols) {
- G_set_null_value(obufptr, 1, cell_type);
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
@@ -51,8 +52,8 @@
/* check for NULL value */
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++) {
- if (G_is_f_null_value(cellp[i][j])) {
- G_set_null_value(obufptr, 1, cell_type);
+ if (Rast_is_f_null_value(cellp[i][j])) {
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
}
@@ -64,10 +65,10 @@
for (i = 0; i < 4; i++) {
FCELL **tmp = cellp[i];
- val[i] = G_interp_cubic(t, *tmp[0], *tmp[1], *tmp[2], *tmp[3]);
+ val[i] = Rast_interp_cubic(t, *tmp[0], *tmp[1], *tmp[2], *tmp[3]);
}
- result = G_interp_cubic(u, val[0], val[1], val[2], val[3]);
+ result = Rast_interp_cubic(u, val[0], val[1], val[2], val[3]);
- G_set_raster_value_f(obufptr, result, cell_type);
+ Rast_set_raster_value_f(obufptr, result, cell_type);
}
Modified: grass/trunk/raster/r.proj/cubic_f.c
===================================================================
--- grass/trunk/raster/r.proj/cubic_f.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/cubic_f.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -10,6 +10,7 @@
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "r.proj.h"
void p_cubic_f(struct cache *ibuffer, /* input buffer */
@@ -30,23 +31,23 @@
/* check for out of bounds - if out of bounds set NULL value */
if (row < 0 || row >= cellhd->rows || col < 0 || col >= cellhd->cols) {
- G_set_null_value(obufptr, 1, cell_type);
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
cellp = CPTR(ibuffer, row, col);
/* if nearest is null, all the other interps will be null */
- if (G_is_f_null_value(cellp)) {
- G_set_null_value(obufptr, 1, cell_type);
+ if (Rast_is_f_null_value(cellp)) {
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
p_cubic(ibuffer, obufptr, cell_type, col_idx, row_idx, cellhd);
/* fallback to bilinear if cubic is null */
- if (G_is_f_null_value(obufptr)) {
+ if (Rast_is_f_null_value(obufptr)) {
p_bilinear(ibuffer, obufptr, cell_type, col_idx, row_idx, cellhd);
/* fallback to nearest if bilinear is null */
- if (G_is_f_null_value(obufptr))
- G_set_raster_value_f(obufptr, *cellp, cell_type);
+ if (Rast_is_f_null_value(obufptr))
+ Rast_set_raster_value_f(obufptr, *cellp, cell_type);
}
}
Modified: grass/trunk/raster/r.proj/main.c
===================================================================
--- grass/trunk/raster/r.proj/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -58,6 +58,7 @@
#include <string.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
#include "r.proj.h"
@@ -264,7 +265,7 @@
inmap->answer, inlocation->answer, setname);
/* Read input map colour table */
- have_colors = G_read_colors(inmap->answer, setname, &colr);
+ have_colors = Rast_read_colors(inmap->answer, setname, &colr);
/* Get projection info for input mapset */
if ((in_proj_info = G_get_projinfo()) == NULL)
@@ -283,7 +284,7 @@
pj_print_proj_params(&iproj, &oproj);
/* this call causes r.proj to read the entire map into memeory */
- G_get_cellhd(inmap->answer, setname, &incellhd);
+ Rast_get_cellhd(inmap->answer, setname, &incellhd);
G_set_window(&incellhd);
@@ -358,7 +359,7 @@
if (res->answer != NULL) /* set user defined resolution */
outcellhd.ns_res = outcellhd.ew_res = atof(res->answer);
- G_adjust_Cell_head(&outcellhd, 0, 0);
+ Rast_adjust_Cell_head(&outcellhd, 0, 0);
G_set_window(&outcellhd);
G_message("");
@@ -387,25 +388,25 @@
/* open and read the relevant parts of the input map and close it */
G__switch_env();
G_set_window(&incellhd);
- fdi = G_open_cell_old(inmap->answer, setname);
- cell_type = G_get_raster_map_type(fdi);
+ fdi = Rast_open_cell_old(inmap->answer, setname);
+ cell_type = Rast_get_raster_map_type(fdi);
ibuffer = readcell(fdi, memory->answer);
- G_close_cell(fdi);
+ Rast_close_cell(fdi);
G__switch_env();
G_set_window(&outcellhd);
if (strcmp(interpol->answer, "nearest") == 0) {
- fdo = G_open_raster_new(mapname, cell_type);
- obuffer = (CELL *) G_allocate_raster_buf(cell_type);
+ fdo = Rast_open_raster_new(mapname, cell_type);
+ obuffer = (CELL *) Rast_allocate_raster_buf(cell_type);
}
else {
- fdo = G_open_fp_cell_new(mapname);
+ fdo = Rast_open_fp_cell_new(mapname);
cell_type = FCELL_TYPE;
- obuffer = (FCELL *) G_allocate_raster_buf(cell_type);
+ obuffer = (FCELL *) Rast_allocate_raster_buf(cell_type);
}
- cell_size = G_raster_size(cell_type);
+ cell_size = Rast_raster_size(cell_type);
xcoord1 = xcoord2 = outcellhd.west + (outcellhd.ew_res / 2);
/**/ ycoord1 = ycoord2 = outcellhd.north - (outcellhd.ns_res / 2);
@@ -419,7 +420,7 @@
/* project coordinates in output matrix to */
/* coordinates in input matrix */
if (pj_do_proj(&xcoord1, &ycoord1, &oproj, &iproj) < 0)
- G_set_null_value(obufptr, 1, cell_type);
+ Rast_set_null_value(obufptr, 1, cell_type);
else {
/* convert to row/column indices of input matrix */
col_idx = (xcoord1 - incellhd.west) / incellhd.ew_res;
@@ -430,13 +431,13 @@
&col_idx, &row_idx, &incellhd);
}
- obufptr = G_incr_void_ptr(obufptr, cell_size);
+ obufptr = Rast_incr_void_ptr(obufptr, cell_size);
xcoord2 += outcellhd.ew_res;
xcoord1 = xcoord2;
ycoord1 = ycoord2;
}
- if (G_put_raster_row(fdo, obuffer, cell_type) < 0)
+ if (Rast_put_raster_row(fdo, obuffer, cell_type) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"), mapname,
row);
@@ -446,16 +447,16 @@
G_percent(row, outcellhd.rows - 1, 2);
}
- G_close_cell(fdo);
+ Rast_close_cell(fdo);
if (have_colors > 0) {
- G_write_colors(mapname, G_mapset(), &colr);
- G_free_colors(&colr);
+ Rast_write_colors(mapname, G_mapset(), &colr);
+ Rast_free_colors(&colr);
}
- G_short_history(mapname, "raster", &history);
- G_command_history(&history);
- G_write_history(mapname, &history);
+ Rast_short_history(mapname, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(mapname, &history);
G_done_msg("");
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.proj/nearest.c
===================================================================
--- grass/trunk/raster/r.proj/nearest.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/nearest.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -6,6 +6,7 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "r.proj.h"
void p_nearest(struct cache *ibuffer, /* input buffer */
@@ -25,16 +26,16 @@
/* check for out of bounds - if out of bounds set NULL value */
if (row < 0 || row >= cellhd->rows || col < 0 || col >= cellhd->cols) {
- G_set_null_value(obufptr, 1, cell_type);
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
cellp = CPTR(ibuffer, row, col);
- if (G_is_f_null_value(cellp)) {
- G_set_null_value(obufptr, 1, cell_type);
+ if (Rast_is_f_null_value(cellp)) {
+ Rast_set_null_value(obufptr, 1, cell_type);
return;
}
- G_set_raster_value_f(obufptr, *cellp, cell_type);
+ Rast_set_raster_value_f(obufptr, *cellp, cell_type);
}
Modified: grass/trunk/raster/r.proj/readcell.c
===================================================================
--- grass/trunk/raster/r.proj/readcell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.proj/readcell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -11,6 +11,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "r.proj.h"
@@ -77,7 +78,7 @@
if (row + y >= nrows)
break;
- if (G_get_f_raster_row(fdi, &tmpbuf[y * nx * BDIM], row + y) < 0)
+ if (Rast_get_f_raster_row(fdi, &tmpbuf[y * nx * BDIM], row + y) < 0)
G_fatal_error(_("Error reading input"));
}
Modified: grass/trunk/raster/r.quant/global.h
===================================================================
--- grass/trunk/raster/r.quant/global.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.quant/global.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
extern struct Quant quant_struct;
extern CELL old_min, old_max;
Modified: grass/trunk/raster/r.quant/main.c
===================================================================
--- grass/trunk/raster/r.quant/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.quant/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -122,32 +122,32 @@
for (noi = 0; input->answers[noi]; noi++) {
name[noi] = G_store(input->answers[noi]);
- if (G_raster_map_type(name[noi], G_mapset()) == CELL_TYPE)
+ if (Rast_raster_map_type(name[noi], G_mapset()) == CELL_TYPE)
G_fatal_error(_("%s is integer map, it can't be quantized"),
name[noi]);
}
- G_quant_init(&quant_struct);
+ Rast_quant_init(&quant_struct);
/* now figure out what new quant rules to write */
if (truncate) {
G_message(_("Truncating..."));
- G_quant_truncate(&quant_struct);
+ Rast_quant_truncate(&quant_struct);
}
else if (round) {
G_message(_("Rounding..."));
- G_quant_round(&quant_struct);
+ Rast_quant_round(&quant_struct);
}
else if (basename)
/* set the quant to that of basemap */
{
- if (G_raster_map_type(basename, "") == CELL_TYPE)
+ if (Rast_raster_map_type(basename, "") == CELL_TYPE)
G_fatal_error(_("%s is integer map, it can't be used as basemap"),
basename);
- if (G_read_quant(basename, "", &quant_struct) <= 0)
+ if (Rast_read_quant(basename, "", &quant_struct) <= 0)
G_fatal_error(_("unable to read quant rules for basemap <%s>"),
basename);
}
@@ -160,7 +160,7 @@
G_fatal_error(_("invalid value for range= <%s>"), range->answer);
G_message(_("Setting quant rules for input map(s) to (%f,%f) -> (%d,%d)"),
new_dmin, new_dmax, new_min, new_max);
- G_quant_add_rule(&quant_struct, new_dmin, new_dmax, new_min, new_max);
+ Rast_quant_add_rule(&quant_struct, new_dmin, new_dmax, new_min, new_max);
}
else if (rules->answer) {
@@ -178,7 +178,7 @@
} /* use rules */
for (i = 0; i < noi; i++) {
- if (G_write_quant(name[i], G_mapset(), &quant_struct) < 0)
+ if (Rast_write_quant(name[i], G_mapset(), &quant_struct) < 0)
G_message(_("Quant table not changed for %s"), name[i]);
else
G_message(_("New quant table created for %s"), name[i]);
Modified: grass/trunk/raster/r.quant/read_rules.c
===================================================================
--- grass/trunk/raster/r.quant/read_rules.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.quant/read_rules.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,24 +17,24 @@
/* read the fpranges and ranges of all input maps */
for (i = 0; i < noi; i++) {
- if (G_read_fp_range(name[i], G_mapset(), &drange) <= 0) {
+ if (Rast_read_fp_range(name[i], G_mapset(), &drange) <= 0) {
sprintf(buff, "Can't read f_range for map %s", name[i]);
G_fatal_error(buff);
}
- G_get_fp_range_min_max(&drange, &tmp_dmin, &tmp_dmax);
+ Rast_get_fp_range_min_max(&drange, &tmp_dmin, &tmp_dmax);
- if (G_read_range(name[i], G_mapset(), &range) <= 0) {
+ if (Rast_read_range(name[i], G_mapset(), &range) <= 0) {
sprintf(buff, "Can't read range for map %s", name[i]);
G_fatal_error(buff);
}
- G_get_range_min_max(&range, &tmp_min, &tmp_max);
- if (!i || tmp_max > old_max || G_is_c_null_value(&old_max))
+ Rast_get_range_min_max(&range, &tmp_min, &tmp_max);
+ if (!i || tmp_max > old_max || Rast_is_c_null_value(&old_max))
old_max = tmp_max;
- if (!i || tmp_min < old_min || G_is_c_null_value(&old_min))
+ if (!i || tmp_min < old_min || Rast_is_c_null_value(&old_min))
old_min = tmp_min;
- if (!i || tmp_dmax > old_dmax || G_is_d_null_value(&old_dmax))
+ if (!i || tmp_dmax > old_dmax || Rast_is_d_null_value(&old_dmax))
old_dmax = tmp_dmax;
- if (!i || tmp_dmin < old_dmin || G_is_d_null_value(&old_dmin))
+ if (!i || tmp_dmin < old_dmin || Rast_is_d_null_value(&old_dmin))
old_dmin = tmp_dmin;
} /* for loop */
@@ -45,7 +45,7 @@
{
char buff[300], buff2[300];
- if (G_is_d_null_value(&old_dmin) || G_is_d_null_value(&old_dmax))
+ if (Rast_is_d_null_value(&old_dmin) || Rast_is_d_null_value(&old_dmax))
G_message(_("Old data range is empty"));
else {
sprintf(buff, "%.10f", old_dmin);
@@ -54,7 +54,7 @@
G_trim_decimal(buff2);
G_message(_("Old data range is %s to %s"), buff, buff2);
}
- if (G_is_c_null_value(&old_min) || G_is_c_null_value(&old_max))
+ if (Rast_is_c_null_value(&old_min) || Rast_is_c_null_value(&old_max))
G_message(_("Old integer data range is empty"));
else
G_message(_("Old integer data range is %d to %d"),
@@ -86,7 +86,7 @@
report_range();
if (isatty(fileno(fp)))
fprintf(stderr, _("\nEnter the rule or 'help' for the format description or 'end' to exit:\n"));
- G_quant_init(&quant_struct);
+ Rast_quant_init(&quant_struct);
for (line = 1;; line++) {
if (isatty(fileno(fp)))
fprintf(stderr, "> ");
@@ -106,7 +106,7 @@
break; /* if no new rules have been specified */
/* give warning when quant rules do not cover the whole range of map */
- G_quant_get_limits(&quant_struct, &dmin, &dmax, &cmin, &cmax);
+ Rast_quant_get_limits(&quant_struct, &dmin, &dmax, &cmin, &cmax);
if ((dmin > old_dmin || dmax < old_dmax) && !first)
G_warning(_("quant rules do not cover the whole range map"));
break;
@@ -126,26 +126,26 @@
lookup the values in the quant table */
switch (sscanf(buf, "%lf:%lf:%d:%d", &dLow, &dHigh, &iLow, &iHigh)) {
case 3:
- G_quant_add_rule(&quant_struct, dLow, dHigh, iLow, iLow);
+ Rast_quant_add_rule(&quant_struct, dLow, dHigh, iLow, iLow);
nrules++;
first = 0;
break;
case 4:
- G_quant_add_rule(&quant_struct, dLow, dHigh, iLow, iHigh);
+ Rast_quant_add_rule(&quant_struct, dLow, dHigh, iLow, iHigh);
nrules++;
first = 0;
break;
default:
if (sscanf(buf, "%lf:*:%d", &dLow, &iLow) == 2) {
- G_quant_set_pos_infinite_rule(&quant_struct, dLow, iLow);
+ Rast_quant_set_pos_infinite_rule(&quant_struct, dLow, iLow);
nrules++;
first = 0;
}
else if (sscanf(buf, "*:%lf:%d", &dHigh, &iLow) == 2) {
- G_quant_set_neg_infinite_rule(&quant_struct, dHigh, iLow);
+ Rast_quant_set_neg_infinite_rule(&quant_struct, dHigh, iLow);
nrules++;
first = 0;
}
Modified: grass/trunk/raster/r.quantile/main.c
===================================================================
--- grass/trunk/raster/r.quantile/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.quantile/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -14,6 +14,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct bin
@@ -56,7 +57,7 @@
static void get_slot_counts(int infile)
{
- DCELL *inbuf = G_allocate_d_raster_buf();
+ DCELL *inbuf = Rast_allocate_d_raster_buf();
int row, col;
G_message(_("Computing histogram"));
@@ -64,12 +65,12 @@
total = 0;
for (row = 0; row < rows; row++) {
- G_get_d_raster_row(infile, inbuf, row);
+ Rast_get_d_raster_row(infile, inbuf, row);
for (col = 0; col < cols; col++) {
int i;
- if (G_is_d_null_value(&inbuf[col]))
+ if (Rast_is_d_null_value(&inbuf[col]))
continue;
i = get_slot(inbuf[col]);
@@ -127,19 +128,19 @@
static void fill_bins(int infile)
{
- DCELL *inbuf = G_allocate_d_raster_buf();
+ DCELL *inbuf = Rast_allocate_d_raster_buf();
int row, col;
G_message(_("Binning data"));
for (row = 0; row < rows; row++) {
- G_get_d_raster_row(infile, inbuf, row);
+ Rast_get_d_raster_row(infile, inbuf, row);
for (col = 0; col < cols; col++) {
int i, bin;
struct bin *b;
- if (G_is_d_null_value(&inbuf[col]))
+ if (Rast_is_d_null_value(&inbuf[col]))
continue;
i = get_slot(inbuf[col]);
@@ -306,12 +307,12 @@
quants[i] = 1.0 * (i + 1) / (num_quants + 1);
}
- infile = G_open_cell_old(opt.input->answer, "");
+ infile = Rast_open_cell_old(opt.input->answer, "");
if (infile < 0)
G_fatal_error(_("Unable to open raster map <%s>"), opt.input->answer);
- G_read_fp_range(opt.input->answer, "", &range);
- G_get_fp_range_min_max(&range, &min, &max);
+ Rast_read_fp_range(opt.input->answer, "", &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
slots = G_calloc(num_slots, sizeof(unsigned int));
slot_bins = G_calloc(num_slots, sizeof(unsigned char));
@@ -330,7 +331,7 @@
values = G_calloc(num_values, sizeof(DCELL));
fill_bins(infile);
- G_close_cell(infile);
+ Rast_close_cell(infile);
G_free(slot_bins);
sort_bins();
Modified: grass/trunk/raster/r.random/count.c
===================================================================
--- grass/trunk/raster/r.random/count.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random/count.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <math.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -19,43 +20,43 @@
{
int nrows, ncols, row, col;
- theState->fd_old = G_open_cell_old(theState->inraster, "");
+ theState->fd_old = Rast_open_cell_old(theState->inraster, "");
if (theState->fd_old < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
theState->inraster);
if (theState->docover == 1) {
- theState->fd_cold = G_open_cell_old(theState->inrcover, "");
+ theState->fd_cold = Rast_open_cell_old(theState->inrcover, "");
if (theState->fd_cold < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
theState->inrcover);
}
- theState->buf.type = G_get_raster_map_type(theState->fd_old);
- theState->buf.data.v = G_allocate_raster_buf(theState->buf.type);
+ theState->buf.type = Rast_get_raster_map_type(theState->fd_old);
+ theState->buf.data.v = Rast_allocate_raster_buf(theState->buf.type);
if (theState->docover == 1) {
- theState->cover.type = G_get_raster_map_type(theState->fd_cold);
- theState->cover.data.v = G_allocate_raster_buf(theState->cover.type);
+ theState->cover.type = Rast_get_raster_map_type(theState->fd_cold);
+ theState->cover.data.v = Rast_allocate_raster_buf(theState->cover.type);
}
theState->nulls.type = theState->buf.type;
theState->min.type = theState->buf.type;
theState->max.type = theState->buf.type;
theState->nulls.data.v =
- (void *)G_malloc(G_raster_size(theState->nulls.type));
+ (void *)G_malloc(Rast_raster_size(theState->nulls.type));
theState->min.data.v =
- (void *)G_malloc(G_raster_size(theState->min.type));
+ (void *)G_malloc(Rast_raster_size(theState->min.type));
theState->max.data.v =
- (void *)G_malloc(G_raster_size(theState->max.type));
+ (void *)G_malloc(Rast_raster_size(theState->max.type));
if (theState->docover == 1) {
theState->cnulls.type = theState->cover.type;
theState->cmin.type = theState->cover.type;
theState->cmax.type = theState->cover.type;
theState->cnulls.data.v =
- (void *)G_malloc(G_raster_size(theState->cnulls.type));
+ (void *)G_malloc(Rast_raster_size(theState->cnulls.type));
theState->cmin.data.v =
- (void *)G_malloc(G_raster_size(theState->cmin.type));
+ (void *)G_malloc(Rast_raster_size(theState->cmin.type));
theState->cmax.data.v =
- (void *)G_malloc(G_raster_size(theState->cmax.type));
+ (void *)G_malloc(Rast_raster_size(theState->cmax.type));
}
nrows = G_window_rows();
ncols = G_window_cols();
@@ -72,11 +73,11 @@
}
G_message(_("Collecting Stats..."));
for (row = 0; row < nrows; row++) {
- if (G_get_raster_row(theState->fd_old, theState->buf.data.v,
+ if (Rast_get_raster_row(theState->fd_old, theState->buf.data.v,
row, theState->buf.type) < 0)
G_fatal_error(_("Cannot read raster row [%d]"), row);
if (theState->docover == 1) {
- if (G_get_raster_row(theState->fd_cold, theState->cover.data.v,
+ if (Rast_get_raster_row(theState->fd_cold, theState->cover.data.v,
row, theState->cover.type) < 0)
G_fatal_error(_("Cannot read cover raster row [%d]"), row);
}
Modified: grass/trunk/raster/r.random/main.c
===================================================================
--- grass/trunk/raster/r.random/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.random/random.c
===================================================================
--- grass/trunk/raster/r.random/random.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random/random.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -51,7 +52,7 @@
type = theState->cover.type;
else
type = theState->buf.type;
- if ((outfd = G_open_raster_new(theState->outraster, type)) < 0)
+ if ((outfd = Rast_open_raster_new(theState->outraster, type)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
theState->outraster);
theState->fd_new = outfd;
@@ -123,12 +124,12 @@
cat = 1;
/* Execute for loop for every row if nt>1 */
for (row = 0; row < nrows && nt; row++) {
- if (G_get_raster_row
+ if (Rast_get_raster_row
(infd, theState->buf.data.v, row, theState->buf.type) < 0)
G_fatal_error(_("Cannot read raster row [%d] from raster map <%s>"),
row, theState->inraster);
if (theState->docover == 1) {
- if (G_get_raster_row
+ if (Rast_get_raster_row
(cinfd, theState->cover.data.v, row,
theState->cover.type) < 0)
G_fatal_error(_("Cannot read raster row [%d] from cover raster map <%s>"),
@@ -215,10 +216,10 @@
if (theState->outraster) {
if (theState->docover == 1)
- G_put_raster_row(outfd, theState->cover.data.v,
+ Rast_put_raster_row(outfd, theState->cover.data.v,
theState->cover.type);
else
- G_put_raster_row(outfd, theState->buf.data.v,
+ Rast_put_raster_row(outfd, theState->buf.data.v,
theState->buf.type);
}
}
@@ -233,10 +234,10 @@
}
for (; row < nrows; row++) {
if (theState->docover == 1)
- G_put_raster_row(outfd, theState->cover.data.v,
+ Rast_put_raster_row(outfd, theState->cover.data.v,
theState->cover.type);
else
- G_put_raster_row(outfd, theState->buf.data.v,
+ Rast_put_raster_row(outfd, theState->buf.data.v,
theState->buf.type);
}
}
@@ -246,9 +247,9 @@
theState->nRand - nt);
/* close files */
- G_close_cell(infd);
+ Rast_close_cell(infd);
if (theState->docover == 1)
- G_close_cell(cinfd);
+ Rast_close_cell(cinfd);
if (theState->outvector) {
db_commit_transaction(driver);
db_close_database_shutdown_driver(driver);
@@ -257,7 +258,7 @@
Vect_close(&Out);
}
if (theState->outraster)
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
return 0;
} /* execute_random() */
@@ -299,13 +300,13 @@
{
switch (buf->type) {
case CELL_TYPE:
- G_set_c_null_value(&(buf->data.c[col]), 1);
+ Rast_set_c_null_value(&(buf->data.c[col]), 1);
break;
case FCELL_TYPE:
- G_set_f_null_value(&(buf->data.f[col]), 1);
+ Rast_set_f_null_value(&(buf->data.f[col]), 1);
break;
case DCELL_TYPE:
- G_set_d_null_value(&(buf->data.d[col]), 1);
+ Rast_set_d_null_value(&(buf->data.d[col]), 1);
break;
}
}
@@ -315,13 +316,13 @@
{
switch (buf.type) {
case CELL_TYPE:
- return G_is_c_null_value(&buf.data.c[col]);
+ return Rast_is_c_null_value(&buf.data.c[col]);
break;
case FCELL_TYPE:
- return G_is_f_null_value(&buf.data.f[col]);
+ return Rast_is_f_null_value(&buf.data.f[col]);
break;
case DCELL_TYPE:
- return G_is_d_null_value(&buf.data.d[col]);
+ return Rast_is_d_null_value(&buf.data.d[col]);
break;
}
Modified: grass/trunk/raster/r.random/support.c
===================================================================
--- grass/trunk/raster/r.random/support.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random/support.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include "local_proto.h"
@@ -23,20 +24,20 @@
inraster = theState->inraster;
nulls = theState->nulls;
}
- if (G_read_raster_cats(inraster, "", &cats) >= 0) {
+ if (Rast_read_raster_cats(inraster, "", &cats) >= 0) {
sprintf(title, "Random points on <%s>", inraster);
- G_set_cats_title(title, &cats);
+ Rast_set_cats_title(title, &cats);
if (theState->use_nulls)
- G_set_raster_cat(nulls.data.v,
+ Rast_set_raster_cat(nulls.data.v,
nulls.data.v,
"Points with NULL values in original",
&cats, nulls.type);
- G_write_raster_cats(theState->outraster, &cats);
+ Rast_write_raster_cats(theState->outraster, &cats);
}
/* write history for output raster */
- if (G_read_history(theState->outraster, G_mapset(), &hist) >= 0) {
- G_short_history(theState->outraster, "raster", &hist);
+ if (Rast_read_history(theState->outraster, G_mapset(), &hist) >= 0) {
+ Rast_short_history(theState->outraster, "raster", &hist);
sprintf(hist.datsrc_1, "Based on map <%s>", inraster);
if (percent)
sprintf(hist.datsrc_2,
@@ -46,7 +47,7 @@
sprintf(hist.datsrc_2,
"%ld random points on the base map <%s>",
theState->nRand, theState->inraster);
- G_write_history(theState->outraster, &hist);
+ Rast_write_history(theState->outraster, &hist);
}
@@ -60,13 +61,13 @@
}
/* set colors for output raster */
- if (G_read_colors(inraster, "", &clr) >= 0) {
+ if (Rast_read_colors(inraster, "", &clr) >= 0) {
if (theState->use_nulls) {
- G_add_raster_color_rule(nulls.data.v, 127, 127, 127,
+ Rast_add_raster_color_rule(nulls.data.v, 127, 127, 127,
nulls.data.v, 127, 127, 127, &clr,
nulls.type);
}
- G_write_colors(theState->outraster, G_mapset(), &clr);
+ Rast_write_colors(theState->outraster, G_mapset(), &clr);
}
return 0;
Modified: grass/trunk/raster/r.random.cells/flag.c
===================================================================
--- grass/trunk/raster/r.random.cells/flag.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.cells/flag.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
Modified: grass/trunk/raster/r.random.cells/indep.c
===================================================================
--- grass/trunk/raster/r.random.cells/indep.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.cells/indep.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
/* indep.c */
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ransurf.h"
@@ -128,7 +129,7 @@
}
G_debug(2, "outputting()");
- OutFD = G_open_cell_new(Output->answer);
+ OutFD = Rast_open_cell_new(Output->answer);
if (OutFD < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
Output->answer);
@@ -140,12 +141,12 @@
for (C = 0; C < Cs; C++) {
CellBuffer[C] = Out[R][C];
}
- G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
+ Rast_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
}
G_percent(1, 1, 1);
- G_close_cell(OutFD);
- G_short_history(Output->answer, "raster", &history);
- G_command_history(&history);
- G_write_history(Output->answer, &history);
+ Rast_close_cell(OutFD);
+ Rast_short_history(Output->answer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(Output->answer, &history);
}
Modified: grass/trunk/raster/r.random.cells/init.c
===================================================================
--- grass/trunk/raster/r.random.cells/init.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.cells/init.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ransurf.h"
@@ -29,24 +30,24 @@
MinRes = EW;
else
MinRes = NS;
- CellBuffer = G_allocate_cell_buf();
+ CellBuffer = Rast_allocate_cell_buf();
/* Out = FlagCreate( Rs, Cs); */
Out = (CELL **) G_malloc(sizeof(CELL *) * Rs);
for (row = 0; row < Rs; row++) {
- Out[row] = G_allocate_cell_buf();
- G_zero_cell_buf(Out[row]);
+ Out[row] = Rast_allocate_cell_buf();
+ Rast_zero_cell_buf(Out[row]);
}
Cells = FlagCreate(Rs, Cs);
CellCount = 0;
if (NULL != G_find_file("cell", "MASK", G_mapset())) {
- if ((FD = G_open_cell_old("MASK", G_mapset())) < 0) {
+ if ((FD = Rast_open_cell_old("MASK", G_mapset())) < 0) {
G_fatal_error(_("Unable to open raster map <%s>"), "MASK");
}
else {
for (row = 0; row < Rs; row++) {
- G_get_map_row_nomask(FD, CellBuffer, row);
+ Rast_get_map_row_nomask(FD, CellBuffer, row);
for (col = 0; col < Cs; col++) {
if (CellBuffer[col]) {
FLAG_SET(Cells, row, col);
@@ -54,7 +55,7 @@
}
}
}
- G_close_cell(FD);
+ Rast_close_cell(FD);
}
}
else {
Modified: grass/trunk/raster/r.random.cells/main.c
===================================================================
--- grass/trunk/raster/r.random.cells/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.cells/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
*****************************************************************************/
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ransurf.h"
Modified: grass/trunk/raster/r.random.cells/random.c
===================================================================
--- grass/trunk/raster/r.random.cells/random.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.cells/random.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
/* random.c */
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ransurf.h"
Modified: grass/trunk/raster/r.random.cells/ransurf.h
===================================================================
--- grass/trunk/raster/r.random.cells/ransurf.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.cells/ransurf.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
#define ODD(a) ((a) & 1)
Modified: grass/trunk/raster/r.random.surface/calcsurf.c
===================================================================
--- grass/trunk/raster/r.random.surface/calcsurf.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.surface/calcsurf.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
/* calcsurf.c */
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ransurf.h"
#include "local_proto.h"
@@ -108,7 +109,7 @@
}
else {
for (Row = 0; Row < Rs; Row++) {
- G_get_map_row_nomask(FDM, CellBuffer, Row);
+ Rast_get_map_row_nomask(FDM, CellBuffer, Row);
if (ODD(Row)) {
for (Col = Cs - 1; Col >= 0; Col--) {
if (CellBuffer[Col] == 0)
Modified: grass/trunk/raster/r.random.surface/gennorm.c
===================================================================
--- grass/trunk/raster/r.random.surface/gennorm.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.surface/gennorm.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
/* gennorm.c */
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ransurf.h"
void GenNorm(void)
Modified: grass/trunk/raster/r.random.surface/init.c
===================================================================
--- grass/trunk/raster/r.random.surface/init.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.surface/init.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ransurf.h"
@@ -41,14 +42,14 @@
FDM = -1;
}
else {
- if ((FDM = G_open_cell_old("MASK", G_mapset())) < 0) {
+ if ((FDM = Rast_open_cell_old("MASK", G_mapset())) < 0) {
G_fatal_error(_("Unable to open raster map <%s>"), "MASK");
}
else {
MapCount = 0;
- CellBuffer = G_allocate_cell_buf();
+ CellBuffer = Rast_allocate_cell_buf();
for (row = 0; row < Rs; row++) {
- G_get_map_row_nomask(FDM, CellBuffer, row);
+ Rast_get_map_row_nomask(FDM, CellBuffer, row);
for (col = 0; col < Cs; col++) {
if (CellBuffer[col])
MapCount++;
@@ -125,7 +126,7 @@
} /* /for */
} /* /else */
- CellBuffer = G_allocate_cell_buf();
+ CellBuffer = Rast_allocate_cell_buf();
CatInfo.NumValue = (int *)G_malloc(CatInfo.NumCat * sizeof(int));
CatInfo.Average = (double *)G_malloc(CatInfo.NumCat * sizeof(double));
CatInfo.Min = (double *)G_malloc(CatInfo.NumCat * sizeof(double));
Modified: grass/trunk/raster/r.random.surface/main.c
===================================================================
--- grass/trunk/raster/r.random.surface/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.surface/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ransurf.h"
@@ -120,7 +121,7 @@
CalcSD();
for (DoMap = 0; DoMap < NumMaps; DoMap++) {
- OutFD = G_open_cell_new(OutNames[DoMap]);
+ OutFD = Rast_open_cell_new(OutNames[DoMap]);
if (OutFD < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
OutNames[DoMap]);
Modified: grass/trunk/raster/r.random.surface/random.c
===================================================================
--- grass/trunk/raster/r.random.surface/random.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.surface/random.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
/* random.c */
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ransurf.h"
#define M1 259200
Modified: grass/trunk/raster/r.random.surface/ransurf.h
===================================================================
--- grass/trunk/raster/r.random.surface/ransurf.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.surface/ransurf.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#define ODD(a) ((a) & 1)
Modified: grass/trunk/raster/r.random.surface/save.c
===================================================================
--- grass/trunk/raster/r.random.surface/save.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.random.surface/save.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
/* save.c */
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "ransurf.h"
@@ -17,7 +18,7 @@
G_debug(2, "SaveMap()");
- OutFD = G_open_cell_new(OutNames[NumMap]);
+ OutFD = Rast_open_cell_new(OutNames[NumMap]);
if (OutFD < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
OutNames[NumMap]);
@@ -56,7 +57,7 @@
}
else {
for (Row = 0; Row < Rs; Row++) {
- G_get_map_row_nomask(FDM, CellBuffer, Row);
+ Rast_get_map_row_nomask(FDM, CellBuffer, Row);
for (Col = 0; Col < Cs; Col++) {
if (CellBuffer[Col] != 0) {
Value = Surface[Row][Col];
@@ -75,7 +76,7 @@
DownInterval = UpInterval = Value;
for (Row = 0; Row < Rs; Row++) {
- G_get_map_row_nomask(FDM, CellBuffer, Row);
+ Rast_get_map_row_nomask(FDM, CellBuffer, Row);
for (Col = 0; Col < Cs; Col++) {
if (CellBuffer[Col] != 0) {
Value = Surface[Row][Col];
@@ -168,14 +169,14 @@
for (Col = 0; Col < Cs; Col++) {
CellBuffer[Col] = (CELL) Surface[Row][Col];
}
- G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
+ Rast_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
}
G_percent(1, 1, 1);
- G_close_cell(OutFD);
- G_short_history(OutNames[NumMap], "raster", &history);
- G_command_history(&history);
- G_write_history(OutNames[NumMap], &history);
+ Rast_close_cell(OutFD);
+ Rast_short_history(OutNames[NumMap], "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(OutNames[NumMap], &history);
strcpy(Label, Buf);
sprintf(String, " seed=%d", MapSeed);
@@ -186,19 +187,19 @@
TheoryCovariance( TheoryName, Label);
*/
- G_init_cats(CatInfo.NumCat, Label, &Cats);
+ Rast_init_cats(CatInfo.NumCat, Label, &Cats);
for (Index = 0; Index < CatInfo.NumCat; Index++) {
if (CatInfo.NumValue[Index] != 0) {
CatInfo.Average[Index] /= CatInfo.NumValue[Index];
sprintf(Label, "%+lf %+lf to %+lf",
CatInfo.Average[Index],
CatInfo.Min[Index], CatInfo.Max[Index]);
- G_set_cat(1 + Index, Label, &Cats);
+ Rast_set_cat(1 + Index, Label, &Cats);
}
}
- G_write_cats(OutNames[NumMap], &Cats);
- G_init_colors(&Colr);
+ Rast_write_cats(OutNames[NumMap], &Cats);
+ Rast_init_colors(&Colr);
LowColor = (int)(127.5 * (CatInfo.Average[0] + 3.5) / 3.5);
HighColor = (int)(255.0 - 127.5 *
(3.5 - CatInfo.Average[CatInfo.NumCat - 1]) / 3.5);
@@ -210,10 +211,10 @@
G_debug(3, "(LowColor):%d", LowColor);
G_debug(3, "(HighColor):%d", HighColor);
- G_add_color_rule(1, LowColor, LowColor, LowColor,
+ Rast_add_color_rule(1, LowColor, LowColor, LowColor,
High, HighColor, HighColor, HighColor, &Colr);
- if (G_write_colors(OutNames[NumMap], G_mapset(), &Colr) == -1)
+ if (Rast_write_colors(OutNames[NumMap], G_mapset(), &Colr) == -1)
G_warning(_("Unable to write color table for raster map <%s>"),
OutNames[NumMap]);
}
Modified: grass/trunk/raster/r.reclass/input.c
===================================================================
--- grass/trunk/raster/r.reclass/input.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.reclass/input.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
int input(FILE * fp, int tty, char *buf)
{
Modified: grass/trunk/raster/r.reclass/main.c
===================================================================
--- grass/trunk/raster/r.reclass/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.reclass/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <string.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "rule.h"
@@ -91,10 +92,10 @@
}
tty = isatty(fileno(srcfp));
- G_init_cats(0, "", &cats);
- fp = G_raster_map_is_fp(parm.input->answer, old_mapset);
- G_read_fp_range(parm.input->answer, old_mapset, &range);
- G_get_fp_range_min_max(&range, &min, &max);
+ Rast_init_cats(0, "", &cats);
+ fp = Rast_raster_map_is_fp(parm.input->answer, old_mapset);
+ Rast_read_fp_range(parm.input->answer, old_mapset, &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
rules = tail = NULL;
any = 0;
Modified: grass/trunk/raster/r.reclass/parse.c
===================================================================
--- grass/trunk/raster/r.reclass/parse.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.reclass/parse.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "rule.h"
@@ -54,7 +55,7 @@
}
if (!scan_value(&v))
return -1;
- if (G_is_c_null_value(&v)) {
+ if (Rast_is_c_null_value(&v)) {
G_warning(_("Can't have null on the left-hand side of the rule"));
return -1;
}
@@ -71,7 +72,7 @@
return -1;
if (!scan_value(&v))
return -1;
- if (G_is_c_null_value(&v))
+ if (Rast_is_c_null_value(&v))
last_null = 1;
else
last_null = 0;
@@ -95,7 +96,7 @@
case 3:
if (!scan_value(&v))
return -1;
- if (G_is_c_null_value(&v)) {
+ if (Rast_is_c_null_value(&v)) {
G_warning(_("Can't have null on the right-hand side of the rule"));
return -1;
}
@@ -141,7 +142,7 @@
if (*rules == NULL)
*rules = *tail;
if (*label)
- G_set_cat(new, label, cats);
+ Rast_set_cat(new, label, cats);
}
return count;
}
@@ -153,7 +154,7 @@
if (strncmp(cur, "null", 4) == 0 || strncmp(cur, "NULL", 4) == 0) {
cur += 4;
- G_set_c_null_value(v, 1);
+ Rast_set_c_null_value(v, 1);
}
else {
sign = 1;
Modified: grass/trunk/raster/r.reclass/range.c
===================================================================
--- grass/trunk/raster/r.reclass/range.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.reclass/range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,15 +1,16 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
int new_range(char *name, struct Reclass *reclass)
{
int i;
struct Range range;
- G_init_range(&range);
+ Rast_init_range(&range);
for (i = 0; i < reclass->num; i++)
- G_update_range(reclass->table[i], &range);
- G_write_range(name, &range);
+ Rast_update_range(reclass->table[i], &range);
+ Rast_write_range(name, &range);
return 0;
}
Modified: grass/trunk/raster/r.reclass/reclass.c
===================================================================
--- grass/trunk/raster/r.reclass/reclass.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.reclass/reclass.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "rule.h"
@@ -20,11 +21,11 @@
for (i = old->min; i <= old->max; i++) {
j = old->table[i - old->min];
- if (G_is_c_null_value(&j) || j < mid->min || j > mid->max)
+ if (Rast_is_c_null_value(&j) || j < mid->min || j > mid->max)
continue;
k = mid->table[j - mid->min];
- if (G_is_c_null_value(&k))
+ if (Rast_is_c_null_value(&k))
continue;
if (first) {
@@ -53,8 +54,8 @@
for (i = new->min; i <= new->max; i++) {
j = old->table[i - old->min];
- if (G_is_c_null_value(&j) || j < mid->min || j > mid->max) {
- G_set_c_null_value(&new->table[i - new->min], 1);
+ if (Rast_is_c_null_value(&j) || j < mid->min || j > mid->max) {
+ Rast_set_c_null_value(&new->table[i - new->min], 1);
continue;
}
@@ -72,12 +73,12 @@
first = 1;
- if (default_rule && !G_is_c_null_value(&DEFAULT)) {
+ if (default_rule && !Rast_is_c_null_value(&DEFAULT)) {
struct Range range;
- G_read_range(rec->name, rec->mapset, &range);
- G_get_range_min_max(&range, &rec->min, &rec->max);
- if (!G_is_c_null_value(&rec->min) && !G_is_c_null_value(&rec->max))
+ Rast_read_range(rec->name, rec->mapset, &range);
+ Rast_get_range_min_max(&range, &rec->min, &rec->max);
+ if (!Rast_is_c_null_value(&rec->min) && !Rast_is_c_null_value(&rec->max))
first = 0;
}
@@ -125,7 +126,7 @@
is_default[i] = 1;
}
else {
- G_set_c_null_value(&rec->table[i], 1);
+ Rast_set_c_null_value(&rec->table[i], 1);
is_default[i] = 0;
}
}
@@ -152,7 +153,7 @@
int cats_read = 0;
if (default_rule && default_to_itself)
- cats_read = (G_read_cats(rec->name, rec->mapset, &old_cats) >= 0);
+ cats_read = (Rast_read_cats(rec->name, rec->mapset, &old_cats) >= 0);
if (cats_read) {
int i;
@@ -160,13 +161,13 @@
for (i = 0; i < rec->num; i++)
if (is_default[i]) {
int x = i + rec->min;
- char *label = G_get_cat(x, &old_cats);
+ char *label = Rast_get_cat(x, &old_cats);
- G_set_cat(x, label, cats);
+ Rast_set_cat(x, label, cats);
}
}
else if (default_rule)
- G_set_cat(DEFAULT, default_label, cats);
+ Rast_set_cat(DEFAULT, default_label, cats);
}
static int _reclass( /* const */ RULE * rules, struct Categories *cats,
@@ -209,7 +210,7 @@
FILE *fd;
char buf[256];
- is_reclass = G_get_reclass(old_name, old_mapset, &old);
+ is_reclass = Rast_get_reclass(old_name, old_mapset, &old);
if (is_reclass < 0)
G_fatal_error(_("Cannot read header file of <%s@%s>"), old_name,
old_mapset);
@@ -225,7 +226,7 @@
_reclass(rules, cats, &new);
}
- if (G_put_reclass(new_name, &new) < 0)
+ if (Rast_put_reclass(new_name, &new) < 0)
G_fatal_error(_("Cannot create reclass file of <%s>"), new_name);
if (!title) {
@@ -239,16 +240,16 @@
fprintf(fd, "Don't remove me\n");
fclose(fd);
- G_set_cats_title(title, cats);
- if (G_write_cats(new_name, cats) == -1)
+ Rast_set_cats_title(title, cats);
+ if (Rast_write_cats(new_name, cats) == -1)
G_fatal_error(_("Cannot create category file of <%s>"), new_name);
- G_free_cats(cats);
+ Rast_free_cats(cats);
- G_short_history(new_name, "reclass", &hist);
+ Rast_short_history(new_name, "reclass", &hist);
strcpy(hist.datsrc_1, "Reclassified map based on:");
sprintf(hist.datsrc_2, " Map [%s] in mapset [%s]", new.name, new.mapset);
- G_write_history(new_name, &hist);
+ Rast_write_history(new_name, &hist);
new_range(new_name, &new);
Modified: grass/trunk/raster/r.reclass/rule.h
===================================================================
--- grass/trunk/raster/r.reclass/rule.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.reclass/rule.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#define RULE struct _rule_
RULE {
Modified: grass/trunk/raster/r.reclass/stats.c
===================================================================
--- grass/trunk/raster/r.reclass/stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.reclass/stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "rule.h"
#define LIST struct Histogram_list
@@ -16,22 +17,22 @@
/* read histogram for original file */
G_suppress_warnings(1);
- i = G_read_histogram(reclass->name, reclass->mapset, &histo);
+ i = Rast_read_histogram(reclass->name, reclass->mapset, &histo);
G_suppress_warnings(0);
if (i <= 0)
return;
/* compute data rage for reclass */
- G_init_range(&range);
+ Rast_init_range(&range);
for (i = 0; i < histo.num; i++) {
cat = histo.list[i].cat;
if (cat < min || cat > max)
continue;
cat2 = reclass->table[cat - min];
- G_update_range(cat2, &range);
+ Rast_update_range(cat2, &range);
}
- G_write_range(name, &range);
+ Rast_write_range(name, &range);
/* now generate a histogram from the original */
@@ -51,11 +52,11 @@
for (i = 0; i < histo.num; i++) {
cat = histo.list[i].cat;
if (cat < min || cat > max)
- G_set_c_null_value(&cat, 1);
+ Rast_set_c_null_value(&cat, 1);
else
cat2 = reclass->table[cat - min];
- if (!G_is_c_null_value(&cat))
+ if (!Rast_is_c_null_value(&cat))
histo2.list[cat2 - range.min].count += histo.list[i].count;
}
- G_write_histogram(name, &histo2);
+ Rast_write_histogram(name, &histo2);
}
Modified: grass/trunk/raster/r.recode/global.h
===================================================================
--- grass/trunk/raster/r.recode/global.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.recode/global.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
extern RASTER_MAP_TYPE in_type;
extern RASTER_MAP_TYPE out_type;
Modified: grass/trunk/raster/r.recode/main.c
===================================================================
--- grass/trunk/raster/r.recode/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.recode/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <string.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
Modified: grass/trunk/raster/r.recode/read_rules.c
===================================================================
--- grass/trunk/raster/r.recode/read_rules.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.recode/read_rules.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,13 +13,13 @@
char buff[1024], buff2[300];
RASTER_MAP_TYPE inp_type;
- inp_type = G_raster_map_type(name, "");
+ inp_type = Rast_raster_map_type(name, "");
if (inp_type != CELL_TYPE) {
- if (G_read_fp_range(name, "", &drange) <= 0)
+ if (Rast_read_fp_range(name, "", &drange) <= 0)
G_fatal_error(_("Unable to read f_range for map %s"), name);
- G_get_fp_range_min_max(&drange, &old_dmin, &old_dmax);
- if (G_is_d_null_value(&old_dmin) || G_is_d_null_value(&old_dmax))
+ Rast_get_fp_range_min_max(&drange, &old_dmin, &old_dmax);
+ if (Rast_is_d_null_value(&old_dmin) || Rast_is_d_null_value(&old_dmax))
G_message(_("Data range is empty"));
else {
sprintf(buff, "%.10f", old_dmin);
@@ -30,11 +30,11 @@
buff, buff2);
}
}
- if (G_read_range(name, "", &range) <= 0)
+ if (Rast_read_range(name, "", &range) <= 0)
G_fatal_error(_("Unable to read range for map <%s>"), name);
- G_get_range_min_max(&range, &old_min, &old_max);
- if (G_is_c_null_value(&old_min) || G_is_c_null_value(&old_max))
+ Rast_get_range_min_max(&range, &old_min, &old_max);
+ if (Rast_is_c_null_value(&old_min) || Rast_is_c_null_value(&old_max))
G_message(_("Integer data range of %s is empty"), name);
else
G_message(_("Integer data range of %s is %d to %d"),
@@ -58,7 +58,7 @@
report_range();
G_message(_("Enter the rule or 'help' for the format description"));
}
- G_fpreclass_init(&rcl_struct);
+ Rast_fpreclass_init(&rcl_struct);
for (line = 1;; line++) {
if (isatty(fileno(fp)))
fprintf(stderr, "> ");
@@ -101,7 +101,7 @@
update_type(&in_type, oHigh);
update_type(&out_type, nLow);
update_rules(buf);
- G_fpreclass_add_rule(&rcl_struct, oLow, oHigh, nLow, nLow);
+ Rast_fpreclass_add_rule(&rcl_struct, oLow, oHigh, nLow, nLow);
break;
case 4:
@@ -110,7 +110,7 @@
update_type(&out_type, nLow);
update_type(&out_type, nHigh);
update_rules(buf);
- G_fpreclass_add_rule(&rcl_struct, oLow, oHigh, nLow, nHigh);
+ Rast_fpreclass_add_rule(&rcl_struct, oLow, oHigh, nLow, nHigh);
break;
default:
@@ -118,13 +118,13 @@
update_type(&in_type, oLow);
update_type(&out_type, nLow);
update_rules(buf);
- G_fpreclass_set_pos_infinite_rule(&rcl_struct, oLow, nLow);
+ Rast_fpreclass_set_pos_infinite_rule(&rcl_struct, oLow, nLow);
}
else if (sscanf(buf, "*:%lf:%lf", &oHigh, &nLow) == 2) {
update_type(&in_type, oHigh);
update_type(&out_type, nLow);
update_rules(buf);
- G_fpreclass_set_neg_infinite_rule(&rcl_struct, oHigh, nLow);
+ Rast_fpreclass_set_neg_infinite_rule(&rcl_struct, oHigh, nLow);
}
else
G_message(_("%s is not a valid rule"), buf);
Modified: grass/trunk/raster/r.recode/recode.c
===================================================================
--- grass/trunk/raster/r.recode/recode.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.recode/recode.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -28,7 +28,7 @@
/* set the window from the header for the input file */
if (align_wind) {
G_get_window(&window);
- if (G_get_cellhd(name, "", &cellhd) >= 0) {
+ if (Rast_get_cellhd(name, "", &cellhd) >= 0) {
G_align_window(&window, &cellhd);
G_set_window(&window);
}
@@ -40,25 +40,25 @@
ncols = G_window_cols();
/* open the input file for reading */
- in_fd = G_open_cell_old(name, "");
+ in_fd = Rast_open_cell_old(name, "");
if (in_fd < 0)
G_fatal_error("Can't open input map");
- out_fd = G_open_raster_new(result, out_type);
+ out_fd = Rast_open_raster_new(result, out_type);
- out_rast = G_allocate_raster_buf(out_type);
- in_rast = G_allocate_raster_buf(in_type);
+ out_rast = Rast_allocate_raster_buf(out_type);
+ in_rast = Rast_allocate_raster_buf(in_type);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
PROCESS_ROW(row);
}
G_percent(row, nrows, 2);
- G_close_cell(in_fd);
- G_close_cell(out_fd);
+ Rast_close_cell(in_fd);
+ Rast_close_cell(out_fd);
/* writing history file */
- G_short_history(result, "raster", &hist);
+ Rast_short_history(result, "raster", &hist);
sprintf(hist.edhist[0], "recode of raster map %s", name);
/* if there are more rules than history lines allocated, write only
MAXEDLINES-1 rules , and "...." as a last rule */
@@ -71,7 +71,7 @@
else
hist.edlinecnt = nrules + 1;
sprintf(hist.datsrc_1, "raster map %s", name);
- G_write_history(result, &hist);
+ Rast_write_history(result, &hist);
return 0;
}
@@ -79,98 +79,98 @@
static void process_row_ii(int row)
{
if (no_mask)
- G_get_c_raster_row_nomask(in_fd, (CELL *) in_rast, row);
+ Rast_get_c_raster_row_nomask(in_fd, (CELL *) in_rast, row);
else
- G_get_c_raster_row(in_fd, (CELL *) in_rast, row);
- G_fpreclass_perform_ii(&rcl_struct, (CELL *) in_rast, (CELL *) out_rast,
+ Rast_get_c_raster_row(in_fd, (CELL *) in_rast, row);
+ Rast_fpreclass_perform_ii(&rcl_struct, (CELL *) in_rast, (CELL *) out_rast,
ncols);
- G_put_raster_row(out_fd, (CELL *) out_rast, CELL_TYPE);
+ Rast_put_raster_row(out_fd, (CELL *) out_rast, CELL_TYPE);
}
static void process_row_if(int row)
{
if (no_mask)
- G_get_c_raster_row_nomask(in_fd, (CELL *) in_rast, row);
+ Rast_get_c_raster_row_nomask(in_fd, (CELL *) in_rast, row);
else
- G_get_c_raster_row(in_fd, (CELL *) in_rast, row);
- G_fpreclass_perform_if(&rcl_struct, (CELL *) in_rast, (FCELL *) out_rast,
+ Rast_get_c_raster_row(in_fd, (CELL *) in_rast, row);
+ Rast_fpreclass_perform_if(&rcl_struct, (CELL *) in_rast, (FCELL *) out_rast,
ncols);
- G_put_f_raster_row(out_fd, (FCELL *) out_rast);
+ Rast_put_f_raster_row(out_fd, (FCELL *) out_rast);
}
static void process_row_id(int row)
{
if (no_mask)
- G_get_c_raster_row_nomask(in_fd, (CELL *) in_rast, row);
+ Rast_get_c_raster_row_nomask(in_fd, (CELL *) in_rast, row);
else
- G_get_c_raster_row(in_fd, (CELL *) in_rast, row);
- G_fpreclass_perform_id(&rcl_struct, (CELL *) in_rast, (DCELL *) out_rast,
+ Rast_get_c_raster_row(in_fd, (CELL *) in_rast, row);
+ Rast_fpreclass_perform_id(&rcl_struct, (CELL *) in_rast, (DCELL *) out_rast,
ncols);
- G_put_raster_row(out_fd, (DCELL *) out_rast, DCELL_TYPE);
+ Rast_put_raster_row(out_fd, (DCELL *) out_rast, DCELL_TYPE);
}
static void process_row_fi(int row)
{
if (no_mask)
- G_get_f_raster_row_nomask(in_fd, (FCELL *) in_rast, row);
+ Rast_get_f_raster_row_nomask(in_fd, (FCELL *) in_rast, row);
else
- G_get_f_raster_row(in_fd, (FCELL *) in_rast, row);
- G_fpreclass_perform_fi(&rcl_struct, (FCELL *) in_rast, (CELL *) out_rast,
+ Rast_get_f_raster_row(in_fd, (FCELL *) in_rast, row);
+ Rast_fpreclass_perform_fi(&rcl_struct, (FCELL *) in_rast, (CELL *) out_rast,
ncols);
- G_put_raster_row(out_fd, (CELL *) out_rast, CELL_TYPE);
+ Rast_put_raster_row(out_fd, (CELL *) out_rast, CELL_TYPE);
}
static void process_row_ff(int row)
{
if (no_mask)
- G_get_f_raster_row_nomask(in_fd, (FCELL *) in_rast, row);
+ Rast_get_f_raster_row_nomask(in_fd, (FCELL *) in_rast, row);
else
- G_get_f_raster_row(in_fd, (FCELL *) in_rast, row);
- G_fpreclass_perform_ff(&rcl_struct, (FCELL *) in_rast, (FCELL *) out_rast,
+ Rast_get_f_raster_row(in_fd, (FCELL *) in_rast, row);
+ Rast_fpreclass_perform_ff(&rcl_struct, (FCELL *) in_rast, (FCELL *) out_rast,
ncols);
- G_put_f_raster_row(out_fd, (FCELL *) out_rast);
+ Rast_put_f_raster_row(out_fd, (FCELL *) out_rast);
}
static void process_row_fd(int row)
{
if (no_mask)
- G_get_f_raster_row_nomask(in_fd, (FCELL *) in_rast, row);
+ Rast_get_f_raster_row_nomask(in_fd, (FCELL *) in_rast, row);
else
- G_get_f_raster_row(in_fd, (FCELL *) in_rast, row);
- G_fpreclass_perform_fd(&rcl_struct, (FCELL *) in_rast, (DCELL *) out_rast,
+ Rast_get_f_raster_row(in_fd, (FCELL *) in_rast, row);
+ Rast_fpreclass_perform_fd(&rcl_struct, (FCELL *) in_rast, (DCELL *) out_rast,
ncols);
- G_put_raster_row(out_fd, (DCELL *) out_rast, DCELL_TYPE);
+ Rast_put_raster_row(out_fd, (DCELL *) out_rast, DCELL_TYPE);
}
static void process_row_di(int row)
{
if (no_mask)
- G_get_d_raster_row_nomask(in_fd, (DCELL *) in_rast, row);
+ Rast_get_d_raster_row_nomask(in_fd, (DCELL *) in_rast, row);
else
- G_get_d_raster_row(in_fd, (DCELL *) in_rast, row);
- G_fpreclass_perform_di(&rcl_struct, (DCELL *) in_rast, (CELL *) out_rast,
+ Rast_get_d_raster_row(in_fd, (DCELL *) in_rast, row);
+ Rast_fpreclass_perform_di(&rcl_struct, (DCELL *) in_rast, (CELL *) out_rast,
ncols);
- G_put_raster_row(out_fd, (CELL *) out_rast, CELL_TYPE);
+ Rast_put_raster_row(out_fd, (CELL *) out_rast, CELL_TYPE);
}
static void process_row_df(int row)
{
if (no_mask)
- G_get_d_raster_row_nomask(in_fd, (DCELL *) in_rast, row);
+ Rast_get_d_raster_row_nomask(in_fd, (DCELL *) in_rast, row);
else
- G_get_d_raster_row(in_fd, (DCELL *) in_rast, row);
- G_fpreclass_perform_df(&rcl_struct, (DCELL *) in_rast, (FCELL *) out_rast,
+ Rast_get_d_raster_row(in_fd, (DCELL *) in_rast, row);
+ Rast_fpreclass_perform_df(&rcl_struct, (DCELL *) in_rast, (FCELL *) out_rast,
ncols);
- G_put_f_raster_row(out_fd, (FCELL *) out_rast);
+ Rast_put_f_raster_row(out_fd, (FCELL *) out_rast);
}
static void process_row_dd(int row)
{
if (no_mask)
- G_get_d_raster_row_nomask(in_fd, (DCELL *) in_rast, row);
+ Rast_get_d_raster_row_nomask(in_fd, (DCELL *) in_rast, row);
else
- G_get_d_raster_row(in_fd, (DCELL *) in_rast, row);
- G_fpreclass_perform_dd(&rcl_struct, (DCELL *) in_rast, (DCELL *) out_rast,
+ Rast_get_d_raster_row(in_fd, (DCELL *) in_rast, row);
+ Rast_fpreclass_perform_dd(&rcl_struct, (DCELL *) in_rast, (DCELL *) out_rast,
ncols);
- G_put_raster_row(out_fd, (DCELL *) out_rast, DCELL_TYPE);
+ Rast_put_raster_row(out_fd, (DCELL *) out_rast, DCELL_TYPE);
}
Modified: grass/trunk/raster/r.region/main.c
===================================================================
--- grass/trunk/raster/r.region/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.region/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -152,7 +153,7 @@
name = parm.map->answer;
- if (G_get_cellhd(name, G_mapset(), &cellhd) < 0)
+ if (Rast_get_cellhd(name, G_mapset(), &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), name);
G_copy(&window, &cellhd, sizeof(window));
@@ -196,7 +197,7 @@
}
if ((name = parm.raster->answer)) { /* raster= */
- if (G_get_cellhd(name, "", &window) < 0)
+ if (Rast_get_cellhd(name, "", &window) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), name);
}
@@ -310,7 +311,7 @@
if ((name = parm.align->answer)) { /* align= */
struct Cell_head temp_window;
- if (G_get_cellhd(name, "", &temp_window) < 0)
+ if (Rast_get_cellhd(name, "", &temp_window) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), name);
if ((err = G_align_window(&window, &temp_window)))
G_fatal_error("%s: %s", name, err);
@@ -319,7 +320,7 @@
window.rows = cellhd.rows;
window.cols = cellhd.cols;
- if ((err = G_adjust_Cell_head(&window, 1, 1)))
+ if ((err = Rast_adjust_Cell_head(&window, 1, 1)))
G_fatal_error(_("Invalid region: %s"), err);
cellhd.north = window.north;
@@ -327,7 +328,7 @@
cellhd.east = window.east;
cellhd.west = window.west;
- if (G_put_cellhd(parm.map->answer, &cellhd) < 0)
+ if (Rast_put_cellhd(parm.map->answer, &cellhd) < 0)
G_fatal_error(_("Unable to update boundaries"));
G_done_msg(" ");
Modified: grass/trunk/raster/r.report/global.h
===================================================================
--- grass/trunk/raster/r.report/global.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.report/global.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -6,6 +6,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
extern struct Cell_head window;
Modified: grass/trunk/raster/r.report/header.c
===================================================================
--- grass/trunk/raster/r.report/header.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.report/header.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -92,7 +92,7 @@
for (i = 0; i < nlayers; i++) {
char *title;
- title = G_get_cats_title(&(layers[i].labels));
+ title = Rast_get_cats_title(&(layers[i].labels));
if (title)
G_strip(title);
if (title == NULL || *title == 0)
Modified: grass/trunk/raster/r.report/maskinfo.c
===================================================================
--- grass/trunk/raster/r.report/maskinfo.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.report/maskinfo.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
static char *append(char *, char *);
static int do_text(char *, long, long);
@@ -16,7 +17,7 @@
results = NULL;
if (G_find_cell("MASK", G_mapset()) == NULL)
return "none";
- if (G_get_reclass("MASK", G_mapset(), &reclass) <= 0) {
+ if (Rast_get_reclass("MASK", G_mapset(), &reclass) <= 0) {
sprintf(text, "MASK in %s", G_mapset());
return append(results, text);
}
@@ -37,7 +38,7 @@
results = append(results, text);
}
while (next >= 0);
- G_free_reclass(&reclass);
+ Rast_free_reclass(&reclass);
return results;
}
Modified: grass/trunk/raster/r.report/parse.c
===================================================================
--- grass/trunk/raster/r.report/parse.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.report/parse.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -248,19 +248,19 @@
DMAX = (DCELL *) G_realloc(DMAX, (nlayers + 1) * sizeof(DCELL));
DMIN = (DCELL *) G_realloc(DMIN, (nlayers + 1) * sizeof(DCELL));
if (!as_int)
- is_fp[n] = G_raster_map_is_fp(name, mapset);
+ is_fp[n] = Rast_raster_map_is_fp(name, mapset);
else
is_fp[n] = 0;
if (is_fp[n]) {
- if (G_read_fp_range(name, mapset, &fp_range) < 0)
+ if (Rast_read_fp_range(name, mapset, &fp_range) < 0)
G_fatal_error(_("Unable to read fp range for raster map <%s>"),
name);
- G_get_fp_range_min_max(&fp_range, &DMIN[n], &DMAX[n]);
+ Rast_get_fp_range_min_max(&fp_range, &DMIN[n], &DMAX[n]);
}
layers[n].name = G_store(name);
layers[n].mapset = mapset;
- if (G_read_cats(name, mapset, &layers[n].labels) < 0)
+ if (Rast_read_cats(name, mapset, &layers[n].labels) < 0)
G_fatal_error(_("Unable to read category file of raster map <%s@%s>"),
name, mapset);
Modified: grass/trunk/raster/r.report/prt_report.c
===================================================================
--- grass/trunk/raster/r.report/prt_report.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.report/prt_report.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -262,14 +262,14 @@
char *descr;
DCELL dLow, dHigh;
- if (G_is_c_null_value(pval))
+ if (Rast_is_c_null_value(pval))
sprintf(str, "%s", no_data_str);
else if (!is_fp[nl] || as_int)
sprintf(str, "%d", *pval);
else { /* find out which floating point range to print */
if (cat_ranges)
- descr = G_get_ith_d_raster_cat(&layers[nl].labels, *pval,
+ descr = Rast_get_ith_d_raster_cat(&layers[nl].labels, *pval,
&dLow, &dHigh);
else {
dLow = (DMAX[nl] - DMIN[nl]) / nsteps *
@@ -295,13 +295,13 @@
static char str[500];
if (!is_fp[nl] || as_int)
- return G_get_cat(cat, &layers[nl].labels);
+ return Rast_get_cat(cat, &layers[nl].labels);
else { /* find or construct the label for
floating point range to print */
- if (G_is_c_null_value(&tmp))
+ if (Rast_is_c_null_value(&tmp))
return G_store("no data");
if (cat_ranges)
- return G_get_ith_d_raster_cat(&layers[nl].labels, cat,
+ return Rast_get_ith_d_raster_cat(&layers[nl].labels, cat,
&dLow, &dHigh);
else {
dLow = (DMAX[nl] - DMIN[nl]) / (double)nsteps *
@@ -309,8 +309,8 @@
dHigh = (DMAX[nl] - DMIN[nl]) / (double)nsteps *
(double)cat + DMIN[nl];
sprintf(str, "from %s to %s",
- G_get_d_raster_cat(&dLow, &layers[nl].labels),
- G_get_d_raster_cat(&dHigh, &layers[nl].labels));
+ Rast_get_d_raster_cat(&dLow, &layers[nl].labels),
+ Rast_get_d_raster_cat(&dHigh, &layers[nl].labels));
return str;
}
} /* fp label */
Modified: grass/trunk/raster/r.report/stats.c
===================================================================
--- grass/trunk/raster/r.report/stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.report/stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -73,7 +73,7 @@
for (nl = 0; nl < nlayers; nl++) {
if (sscanf(tokens[i], "%d", &Gstats[ns].cats[nl]) != 1) {
if (tokens[i][0] == '*')
- G_set_c_null_value(&Gstats[ns].cats[nl], 1);
+ Rast_set_c_null_value(&Gstats[ns].cats[nl], 1);
else
die();
}
Modified: grass/trunk/raster/r.resamp.interp/main.c
===================================================================
--- grass/trunk/raster/r.resamp.interp/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.resamp.interp/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
static int neighbors;
@@ -47,7 +48,7 @@
keep = 0;
for (i = keep; i < neighbors; i++)
- G_get_d_raster_row(infile, bufs[i], first_row + i);
+ Rast_get_d_raster_row(infile, bufs[i], first_row + i);
cur_row = first_row;
}
@@ -98,7 +99,7 @@
G_get_set_window(&dst_w);
/* set window to old map */
- G_get_cellhd(rastin->answer, "", &src_w);
+ Rast_get_cellhd(rastin->answer, "", &src_w);
/* enlarge source window */
{
@@ -123,22 +124,22 @@
/* allocate buffers for input rows */
for (row = 0; row < neighbors; row++)
- bufs[row] = G_allocate_d_raster_buf();
+ bufs[row] = Rast_allocate_d_raster_buf();
cur_row = -100;
/* open old map */
- infile = G_open_cell_old(rastin->answer, "");
+ infile = Rast_open_cell_old(rastin->answer, "");
if (infile < 0)
G_fatal_error(_("Unable to open raster map <%s>"), rastin->answer);
/* reset window to current region */
G_set_window(&dst_w);
- outbuf = G_allocate_d_raster_buf();
+ outbuf = Rast_allocate_d_raster_buf();
/* open new map */
- outfile = G_open_raster_new(rastout->answer, DCELL_TYPE);
+ outfile = Rast_open_raster_new(rastout->answer, DCELL_TYPE);
if (outfile < 0)
G_fatal_error(_("Unable to create raster map <%s>"), rastout->answer);
@@ -164,8 +165,8 @@
double c = bufs[0][mapcol0];
- if (G_is_d_null_value(&c)) {
- G_set_d_null_value(&outbuf[col], 1);
+ if (Rast_is_d_null_value(&c)) {
+ Rast_set_d_null_value(&outbuf[col], 1);
}
else {
outbuf[col] = c;
@@ -173,7 +174,7 @@
}
G_set_window(&dst_w);
- G_put_d_raster_row(outfile, outbuf);
+ Rast_put_d_raster_row(outfile, outbuf);
}
break;
@@ -201,18 +202,18 @@
double c10 = bufs[1][mapcol0];
double c11 = bufs[1][mapcol1];
- if (G_is_d_null_value(&c00) ||
- G_is_d_null_value(&c01) ||
- G_is_d_null_value(&c10) || G_is_d_null_value(&c11)) {
- G_set_d_null_value(&outbuf[col], 1);
+ if (Rast_is_d_null_value(&c00) ||
+ Rast_is_d_null_value(&c01) ||
+ Rast_is_d_null_value(&c10) || Rast_is_d_null_value(&c11)) {
+ Rast_set_d_null_value(&outbuf[col], 1);
}
else {
- outbuf[col] = G_interp_bilinear(u, v, c00, c01, c10, c11);
+ outbuf[col] = Rast_interp_bilinear(u, v, c00, c01, c10, c11);
}
}
G_set_window(&dst_w);
- G_put_d_raster_row(outfile, outbuf);
+ Rast_put_d_raster_row(outfile, outbuf);
}
break;
@@ -258,25 +259,25 @@
double c32 = bufs[3][mapcol2];
double c33 = bufs[3][mapcol3];
- if (G_is_d_null_value(&c00) ||
- G_is_d_null_value(&c01) ||
- G_is_d_null_value(&c02) ||
- G_is_d_null_value(&c03) ||
- G_is_d_null_value(&c10) ||
- G_is_d_null_value(&c11) ||
- G_is_d_null_value(&c12) ||
- G_is_d_null_value(&c13) ||
- G_is_d_null_value(&c20) ||
- G_is_d_null_value(&c21) ||
- G_is_d_null_value(&c22) ||
- G_is_d_null_value(&c23) ||
- G_is_d_null_value(&c30) ||
- G_is_d_null_value(&c31) ||
- G_is_d_null_value(&c32) || G_is_d_null_value(&c33)) {
- G_set_d_null_value(&outbuf[col], 1);
+ if (Rast_is_d_null_value(&c00) ||
+ Rast_is_d_null_value(&c01) ||
+ Rast_is_d_null_value(&c02) ||
+ Rast_is_d_null_value(&c03) ||
+ Rast_is_d_null_value(&c10) ||
+ Rast_is_d_null_value(&c11) ||
+ Rast_is_d_null_value(&c12) ||
+ Rast_is_d_null_value(&c13) ||
+ Rast_is_d_null_value(&c20) ||
+ Rast_is_d_null_value(&c21) ||
+ Rast_is_d_null_value(&c22) ||
+ Rast_is_d_null_value(&c23) ||
+ Rast_is_d_null_value(&c30) ||
+ Rast_is_d_null_value(&c31) ||
+ Rast_is_d_null_value(&c32) || Rast_is_d_null_value(&c33)) {
+ Rast_set_d_null_value(&outbuf[col], 1);
}
else {
- outbuf[col] = G_interp_bicubic(u, v,
+ outbuf[col] = Rast_interp_bicubic(u, v,
c00, c01, c02, c03,
c10, c11, c12, c13,
c20, c21, c22, c23,
@@ -285,36 +286,36 @@
}
G_set_window(&dst_w);
- G_put_d_raster_row(outfile, outbuf);
+ Rast_put_d_raster_row(outfile, outbuf);
}
break;
}
G_percent(dst_w.rows, dst_w.rows, 2);
- G_close_cell(infile);
- G_close_cell(outfile);
+ Rast_close_cell(infile);
+ Rast_close_cell(outfile);
/* record map metadata/history info */
sprintf(title, "Resample by %s interpolation", method->answer);
- G_put_cell_title(rastout->answer, title);
+ Rast_put_cell_title(rastout->answer, title);
- G_short_history(rastout->answer, "raster", &history);
+ Rast_short_history(rastout->answer, "raster", &history);
strncpy(history.datsrc_1, rastin->answer, RECORD_LEN);
history.datsrc_1[RECORD_LEN - 1] = '\0'; /* strncpy() doesn't null terminate if maxfill */
G_format_resolution(src_w.ns_res, buf_nsres, src_w.proj);
G_format_resolution(src_w.ew_res, buf_ewres, src_w.proj);
sprintf(history.datsrc_2, "Source map NS res: %s EW res: %s", buf_nsres,
buf_ewres);
- G_command_history(&history);
- G_write_history(rastout->answer, &history);
+ Rast_command_history(&history);
+ Rast_write_history(rastout->answer, &history);
/* copy color table from source map */
- if (G_read_colors(rastin->answer, "", &colors) < 0)
+ if (Rast_read_colors(rastin->answer, "", &colors) < 0)
G_fatal_error(_("Unable to read color table for %s"), rastin->answer);
- G_mark_colors_as_fp(&colors);
- if (G_write_colors(rastout->answer, G_mapset(), &colors) < 0)
+ Rast_mark_colors_as_fp(&colors);
+ if (Rast_write_colors(rastout->answer, G_mapset(), &colors) < 0)
G_fatal_error(_("Unable to write color table for %s"),
rastout->answer);
Modified: grass/trunk/raster/r.resamp.rst/main.c
===================================================================
--- grass/trunk/raster/r.resamp.rst/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.resamp.rst/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -37,6 +37,7 @@
#include <grass/dbmi.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/linkm.h>
#include <grass/bitmap.h>
#include "surf.h"
@@ -344,7 +345,7 @@
outhd.south = winhd.south;
outhd.proj = winhd.proj;
outhd.zone = winhd.zone;
- G_adjust_Cell_head(&outhd, 0, 0);
+ Rast_adjust_Cell_head(&outhd, 0, 0);
ew_res = outhd.ew_res;
ns_res = outhd.ns_res;
nsizc = outhd.cols;
@@ -365,31 +366,31 @@
if (smooth != NULL) {
- if ((fdsmooth = G_open_cell_old(smooth, "")) < 0)
+ if ((fdsmooth = Rast_open_cell_old(smooth, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), smooth);
- if (G_get_cellhd(smooth, "", &smhd) < 0)
+ if (Rast_get_cellhd(smooth, "", &smhd) < 0)
G_fatal_error(_("Unable to read header for <%s>"), smooth);
if ((winhd.ew_res != smhd.ew_res) || (winhd.ns_res != smhd.ns_res))
G_fatal_error(_("Map <%s> is the wrong resolution"), smooth);
- if (G_read_fp_range(smooth, "", &range) >= 0)
- G_get_fp_range_min_max(&range, &cellmin, &cellmax);
+ if (Rast_read_fp_range(smooth, "", &range) >= 0)
+ Rast_get_fp_range_min_max(&range, &cellmin, &cellmax);
fcellmin = (float)cellmin;
- if (G_is_f_null_value(&fcellmin) || fcellmin < 0.0)
+ if (Rast_is_f_null_value(&fcellmin) || fcellmin < 0.0)
G_fatal_error(_("Smoothing values can not be negative or NULL"));
}
- if (G_get_cellhd(input, "", &inphd) < 0)
+ if (Rast_get_cellhd(input, "", &inphd) < 0)
G_fatal_error(_("Unable to read header for <%s>"), input);
if ((winhd.ew_res != inphd.ew_res) || (winhd.ns_res != inphd.ns_res))
G_fatal_error(_("Input map resolution differs from current region resolution!"));
- if ((fdinp = G_open_cell_old(input, "")) < 0)
+ if ((fdinp = Rast_open_cell_old(input, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), input);
@@ -425,24 +426,24 @@
smc = 0.01;
- if (G_read_fp_range(input, "", &range) >= 0) {
- G_get_fp_range_min_max(&range, &cellmin, &cellmax);
+ if (Rast_read_fp_range(input, "", &range) >= 0) {
+ Rast_get_fp_range_min_max(&range, &cellmin, &cellmax);
}
else {
- cellrow = G_allocate_f_raster_buf();
+ cellrow = Rast_allocate_f_raster_buf();
for (m1 = 0; m1 < inp_rows; m1++) {
- ret_val = G_get_f_raster_row(fdinp, cellrow, m1);
+ ret_val = Rast_get_f_raster_row(fdinp, cellrow, m1);
if (ret_val < 0)
G_fatal_error(_("Error reading row %d (error = %d)"),
m1, ret_val);
- G_row_update_fp_range(cellrow, m1, &range, FCELL_TYPE);
+ Rast_row_update_fp_range(cellrow, m1, &range, FCELL_TYPE);
}
- G_get_fp_range_min_max(&range, &cellmin, &cellmax);
+ Rast_get_fp_range_min_max(&range, &cellmin, &cellmax);
}
fcellmin = (float)cellmin;
- if (G_is_f_null_value(&fcellmin))
+ if (Rast_is_f_null_value(&fcellmin))
G_fatal_error(_("Maximum value of a raster map is NULL."));
zmin = (double)cellmin *zmult;
@@ -527,9 +528,9 @@
clean();
if (fd4)
fclose(fd4);
- G_close_cell(fdinp);
+ Rast_close_cell(fdinp);
if (smooth != NULL)
- G_close_cell(fdsmooth);
+ Rast_close_cell(fdsmooth);
G_done_msg("");
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.resamp.stats/main.c
===================================================================
--- grass/trunk/raster/r.resamp.stats/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.resamp.stats/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/stats.h>
@@ -119,7 +120,7 @@
G_set_window(&src_w);
for (i = 0; i < count; i++)
- G_get_d_raster_row(infile, bufs[i], maprow0 + i);
+ Rast_get_d_raster_row(infile, bufs[i], maprow0 + i);
for (col = 0; col < dst_w.cols; col++) {
int mapcol0 = col_map[col + 0];
@@ -133,8 +134,8 @@
DCELL *src = &bufs[i - maprow0][j];
DCELL *dst = &values[n++];
- if (G_is_d_null_value(src)) {
- G_set_d_null_value(dst, 1);
+ if (Rast_is_d_null_value(src)) {
+ Rast_set_d_null_value(dst, 1);
null = 1;
}
else
@@ -142,13 +143,13 @@
}
if (null && nulls)
- G_set_d_null_value(&outbuf[col], 1);
+ Rast_set_d_null_value(&outbuf[col], 1);
else
(*method_fn) (&outbuf[col], values, n, closure);
}
G_set_window(&dst_w);
- G_put_d_raster_row(outfile, outbuf);
+ Rast_put_d_raster_row(outfile, outbuf);
}
}
@@ -192,7 +193,7 @@
G_set_window(&src_w);
for (i = 0; i < count; i++)
- G_get_d_raster_row(infile, bufs[i], maprow0 + i);
+ Rast_get_d_raster_row(infile, bufs[i], maprow0 + i);
for (col = 0; col < dst_w.cols; col++) {
double x0 = col_map[col + 0];
@@ -216,8 +217,8 @@
DCELL *src = &bufs[i - maprow0][j];
DCELL *dst = &values[n++][0];
- if (G_is_d_null_value(src)) {
- G_set_d_null_value(&dst[0], 1);
+ if (Rast_is_d_null_value(src)) {
+ Rast_set_d_null_value(&dst[0], 1);
null = 1;
}
else {
@@ -228,13 +229,13 @@
}
if (null && nulls)
- G_set_d_null_value(&outbuf[col], 1);
+ Rast_set_d_null_value(&outbuf[col], 1);
else
(*method_fn) (&outbuf[col], values, n, closure);
}
G_set_window(&dst_w);
- G_put_d_raster_row(outfile, outbuf);
+ Rast_put_d_raster_row(outfile, outbuf);
}
}
@@ -307,7 +308,7 @@
G_get_set_window(&dst_w);
/* set window to old map */
- G_get_cellhd(parm.rastin->answer, "", &src_w);
+ Rast_get_cellhd(parm.rastin->answer, "", &src_w);
/* enlarge source window */
{
@@ -332,10 +333,10 @@
/* allocate buffers for input rows */
bufs = G_malloc(row_scale * sizeof(DCELL *));
for (row = 0; row < row_scale; row++)
- bufs[row] = G_allocate_d_raster_buf();
+ bufs[row] = Rast_allocate_d_raster_buf();
/* open old map */
- infile = G_open_cell_old(parm.rastin->answer, "");
+ infile = Rast_open_cell_old(parm.rastin->answer, "");
if (infile < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
parm.rastin->answer);
@@ -344,10 +345,10 @@
G_set_window(&dst_w);
/* allocate output buffer */
- outbuf = G_allocate_d_raster_buf();
+ outbuf = Rast_allocate_d_raster_buf();
/* open new map */
- outfile = G_open_raster_new(parm.rastout->answer, DCELL_TYPE);
+ outfile = Rast_open_raster_new(parm.rastout->answer, DCELL_TYPE);
if (outfile < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
parm.rastout->answer);
@@ -362,30 +363,30 @@
G_percent(dst_w.rows, dst_w.rows, 2);
- G_close_cell(infile);
- G_close_cell(outfile);
+ Rast_close_cell(infile);
+ Rast_close_cell(outfile);
/* record map metadata/history info */
sprintf(title, "Aggregate resample by %s", parm.method->answer);
- G_put_cell_title(parm.rastout->answer, title);
+ Rast_put_cell_title(parm.rastout->answer, title);
- G_short_history(parm.rastout->answer, "raster", &history);
+ Rast_short_history(parm.rastout->answer, "raster", &history);
strncpy(history.datsrc_1, parm.rastin->answer, RECORD_LEN);
history.datsrc_1[RECORD_LEN - 1] = '\0'; /* strncpy() doesn't null terminate if maxfill */
G_format_resolution(src_w.ns_res, buf_nsres, src_w.proj);
G_format_resolution(src_w.ew_res, buf_ewres, src_w.proj);
sprintf(history.datsrc_2, "Source map NS res: %s EW res: %s", buf_nsres,
buf_ewres);
- G_command_history(&history);
- G_write_history(parm.rastout->answer, &history);
+ Rast_command_history(&history);
+ Rast_write_history(parm.rastout->answer, &history);
/* copy color table from source map */
if (strcmp(parm.method->answer, "sum") != 0) {
- if (G_read_colors(parm.rastin->answer, "", &colors) < 0)
+ if (Rast_read_colors(parm.rastin->answer, "", &colors) < 0)
G_fatal_error(_("Unable to read color table for %s"),
parm.rastin->answer);
- G_mark_colors_as_fp(&colors);
- if (G_write_colors(parm.rastout->answer, G_mapset(), &colors) < 0)
+ Rast_mark_colors_as_fp(&colors);
+ if (Rast_write_colors(parm.rastout->answer, G_mapset(), &colors) < 0)
G_fatal_error(_("Unable to write color table for %s"),
parm.rastout->answer);
}
Modified: grass/trunk/raster/r.resample/main.c
===================================================================
--- grass/trunk/raster/r.resample/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.resample/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int main(int argc, char *argv[])
@@ -78,37 +79,37 @@
name = option.input->answer;
result = option.output->answer;
- hist_ok = G_read_history(name, "", &hist) >= 0;
- colr_ok = G_read_colors(name, "", &colr) > 0;
- cats_ok = G_read_cats(name, "", &cats) >= 0;
+ hist_ok = Rast_read_history(name, "", &hist) >= 0;
+ colr_ok = Rast_read_colors(name, "", &colr) > 0;
+ cats_ok = Rast_read_cats(name, "", &cats) >= 0;
if (cats_ok) {
- G_unmark_raster_cats(&cats);
- G_init_cats((CELL) 0, G_get_cats_title(&cats), &newcats);
+ Rast_unmark_raster_cats(&cats);
+ Rast_init_cats((CELL) 0, Rast_get_cats_title(&cats), &newcats);
}
- infd = G_open_cell_old(name, "");
+ infd = Rast_open_cell_old(name, "");
if (infd < 0)
G_fatal_error(_("Unable to open input map <%s>"), name);
/* determine the map type;
data_type is the type of data being processed,
out_type is the type of map being created. */
- data_type = G_get_raster_map_type(infd);
+ data_type = Rast_get_raster_map_type(infd);
out_type = data_type;
- if (G_get_cellhd(name, "", &cellhd) < 0)
+ if (Rast_get_cellhd(name, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header for <%s>"), name);
/* raster buffer is big enough to hold data */
- rast = G_allocate_raster_buf(data_type);
+ rast = Rast_allocate_raster_buf(data_type);
nrows = G_window_rows();
ncols = G_window_cols();
if (ncols <= 1)
- rast = G_realloc(rast, 2 * G_raster_size(data_type));
+ rast = G_realloc(rast, 2 * Rast_raster_size(data_type));
/* we need the buffer at least 2 cells large */
- outfd = G_open_raster_new(result, out_type);
- G_set_null_value(rast, ncols, out_type);
+ outfd = Rast_open_raster_new(result, out_type);
+ Rast_set_null_value(rast, ncols, out_type);
if (outfd < 0)
G_fatal_error(_("Unable to open output map <%s>"), name);
@@ -117,59 +118,59 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(infd, rast, row, data_type) < 0)
+ if (Rast_get_raster_row(infd, rast, row, data_type) < 0)
G_fatal_error(_("Error reading row %d"), row);
- if (G_put_raster_row(outfd, rast, out_type) < 0)
+ if (Rast_put_raster_row(outfd, rast, out_type) < 0)
G_fatal_error(_("Error writing row %d"), row);
- G_mark_raster_cats(rast, ncols, &cats, data_type);
+ Rast_mark_raster_cats(rast, ncols, &cats, data_type);
}
G_percent(row, nrows, 2);
- G_close_cell(infd);
+ Rast_close_cell(infd);
G_message(_("Creating support files for <%s>..."), result);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
- G_rewind_raster_cats(&cats);
+ Rast_rewind_raster_cats(&cats);
if (cats_ok) {
long count;
void *rast1, *rast2;
rast1 = rast;
- rast2 = G_incr_void_ptr(rast, G_raster_size(data_type));
+ rast2 = Rast_incr_void_ptr(rast, Rast_raster_size(data_type));
G_message(_("Creating new cats file..."));
- while (G_get_next_marked_raster_cat(&cats,
+ while (Rast_get_next_marked_raster_cat(&cats,
rast1, rast2, &count, data_type))
- G_set_raster_cat(rast1, rast2,
- G_get_raster_cat(rast1, &cats, data_type),
+ Rast_set_raster_cat(rast1, rast2,
+ Rast_get_raster_cat(rast1, &cats, data_type),
&newcats, data_type);
- G_write_cats(result, &newcats);
- G_free_cats(&cats);
- G_free_cats(&newcats);
+ Rast_write_cats(result, &newcats);
+ Rast_free_cats(&cats);
+ Rast_free_cats(&newcats);
}
if (colr_ok) {
- if (G_read_range(result, G_mapset(), &range) > 0) {
+ if (Rast_read_range(result, G_mapset(), &range) > 0) {
CELL min, max, cmin, cmax;
- G_get_range_min_max(&range, &min, &max);
- G_get_color_range(&cmin, &cmax, &colr);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_get_color_range(&cmin, &cmax, &colr);
if (min > cmin)
cmin = min;
if (max < cmax)
cmax = max;
- G_set_color_range(cmin, cmax, &colr);
+ Rast_set_color_range(cmin, cmax, &colr);
}
- G_write_colors(result, G_mapset(), &colr);
+ Rast_write_colors(result, G_mapset(), &colr);
}
if (hist_ok)
- G_write_history(result, &hist);
+ Rast_write_history(result, &hist);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.rescale/get_range.c
===================================================================
--- grass/trunk/raster/r.rescale/get_range.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.rescale/get_range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -12,12 +13,12 @@
CELL cmin, cmax;
struct Cell_head cellhd;
- if (G_read_range(name, "", &range) < 0) {
- G_init_range(&range); /* read the file to get the range */
- G_get_cellhd(name, "", &cellhd);
+ if (Rast_read_range(name, "", &range) < 0) {
+ Rast_init_range(&range); /* read the file to get the range */
+ Rast_get_cellhd(name, "", &cellhd);
G_set_window(&cellhd);
- cell = G_allocate_cell_buf();
- fd = G_open_cell_old(name, "");
+ cell = Rast_allocate_cell_buf();
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
exit(1);
nrows = G_window_rows();
@@ -25,17 +26,17 @@
G_message(_("Reading %s ..."), name);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_map_row_nomask(fd, cell, row) < 0)
+ if (Rast_get_map_row_nomask(fd, cell, row) < 0)
exit(1);
for (col = 0; col < ncols; col++)
- G_update_range(cell[col], &range);
+ Rast_update_range(cell[col], &range);
}
G_percent(row, nrows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(cell);
}
- G_get_range_min_max(&range, &cmin, &cmax);
+ Rast_get_range_min_max(&range, &cmin, &cmax);
*min = cmin;
*max = cmax;
Modified: grass/trunk/raster/r.rescale/main.c
===================================================================
--- grass/trunk/raster/r.rescale/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.rescale/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.rescale.eq/get_range.c
===================================================================
--- grass/trunk/raster/r.rescale.eq/get_range.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.rescale.eq/get_range.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
int get_range(struct Cell_stats *statf, CELL * min, CELL * max, int zero)
{
@@ -8,8 +9,8 @@
any = *min = *max = 0;
- G_rewind_cell_stats(statf);
- while (!any && G_next_cell_stat(&cat, &count, statf)) {
+ Rast_rewind_cell_stats(statf);
+ while (!any && Rast_next_cell_stat(&cat, &count, statf)) {
if (zero || cat)
any = 1;
}
@@ -17,7 +18,7 @@
return 0;
*min = *max = cat;
- while (G_next_cell_stat(&cat, &count, statf)) {
+ while (Rast_next_cell_stat(&cat, &count, statf)) {
if (zero || cat)
*max = cat;
}
Modified: grass/trunk/raster/r.rescale.eq/get_stats.c
===================================================================
--- grass/trunk/raster/r.rescale.eq/get_stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.rescale.eq/get_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -9,24 +10,24 @@
CELL *cell;
int row, nrows, ncols;
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
exit(1);
nrows = G_window_rows();
ncols = G_window_cols();
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
- G_init_cell_stats(statf);
+ Rast_init_cell_stats(statf);
G_message(_("Reading %s ..."), name);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_map_row(fd, cell, row) < 0)
+ if (Rast_get_map_row(fd, cell, row) < 0)
break;
- G_update_cell_stats(cell, ncols, statf);
+ Rast_update_cell_stats(cell, ncols, statf);
}
if (row < nrows)
exit(1);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(cell);
G_percent(row, nrows, 2);
Modified: grass/trunk/raster/r.rescale.eq/main.c
===================================================================
--- grass/trunk/raster/r.rescale.eq/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.rescale.eq/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
@@ -127,7 +128,7 @@
strcat(buf, "\"");
fd = popen(buf, "w");
- G_cell_stats_histo_eq(&statf, (CELL) old_min, (CELL) old_max,
+ Rast_cell_stats_histo_eq(&statf, (CELL) old_min, (CELL) old_max,
(CELL) new_min, (CELL) new_max, 0, reclass);
if (fd != stdout)
pclose(fd);
Modified: grass/trunk/raster/r.ros/main.c
===================================================================
--- grass/trunk/raster/r.ros/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.ros/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -68,6 +68,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -443,28 +444,28 @@
nrows = G_window_rows();
ncols = G_window_cols();
- fuel = G_allocate_cell_buf();
- mois_1h = G_allocate_cell_buf();
- mois_10h = G_allocate_cell_buf();
- mois_100h = G_allocate_cell_buf();
- mois_live = G_allocate_cell_buf();
- vel = G_allocate_cell_buf();
- dir = G_allocate_cell_buf();
- slope = G_allocate_cell_buf();
- aspect = G_allocate_cell_buf();
- base = G_allocate_cell_buf();
- max = G_allocate_cell_buf();
- maxdir = G_allocate_cell_buf();
+ fuel = Rast_allocate_cell_buf();
+ mois_1h = Rast_allocate_cell_buf();
+ mois_10h = Rast_allocate_cell_buf();
+ mois_100h = Rast_allocate_cell_buf();
+ mois_live = Rast_allocate_cell_buf();
+ vel = Rast_allocate_cell_buf();
+ dir = Rast_allocate_cell_buf();
+ slope = Rast_allocate_cell_buf();
+ aspect = Rast_allocate_cell_buf();
+ base = Rast_allocate_cell_buf();
+ max = Rast_allocate_cell_buf();
+ maxdir = Rast_allocate_cell_buf();
if (spotting) {
- spotdist = G_allocate_cell_buf();
- elev = G_allocate_cell_buf();
+ spotdist = Rast_allocate_cell_buf();
+ elev = Rast_allocate_cell_buf();
map_elev = (CELL *) G_calloc(nrows * ncols, sizeof(CELL));
}
/* Open input cell layers for reading */
fuel_fd =
- G_open_cell_old(parm.model->answer,
+ Rast_open_cell_old(parm.model->answer,
G_find_cell2(parm.model->answer, ""));
if (fuel_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -472,7 +473,7 @@
if (parm.mois_1h->answer) {
mois_1h_fd =
- G_open_cell_old(parm.mois_1h->answer,
+ Rast_open_cell_old(parm.mois_1h->answer,
G_find_cell2(parm.mois_1h->answer, ""));
if (mois_1h_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -480,7 +481,7 @@
}
if (parm.mois_10h->answer) {
mois_10h_fd =
- G_open_cell_old(parm.mois_10h->answer,
+ Rast_open_cell_old(parm.mois_10h->answer,
G_find_cell2(parm.mois_10h->answer, ""));
if (mois_10h_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -488,7 +489,7 @@
}
if (parm.mois_100h->answer) {
mois_100h_fd =
- G_open_cell_old(parm.mois_100h->answer,
+ Rast_open_cell_old(parm.mois_100h->answer,
G_find_cell2(parm.mois_100h->answer, ""));
if (mois_100h_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -496,7 +497,7 @@
}
mois_live_fd =
- G_open_cell_old(parm.mois_live->answer,
+ Rast_open_cell_old(parm.mois_live->answer,
G_find_cell2(parm.mois_live->answer, ""));
if (mois_live_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -504,7 +505,7 @@
if (parm.vel->answer) {
vel_fd =
- G_open_cell_old(parm.vel->answer,
+ Rast_open_cell_old(parm.vel->answer,
G_find_cell2(parm.vel->answer, ""));
if (vel_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -512,7 +513,7 @@
}
if (parm.dir->answer) {
dir_fd =
- G_open_cell_old(parm.dir->answer,
+ Rast_open_cell_old(parm.dir->answer,
G_find_cell2(parm.dir->answer, ""));
if (dir_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -521,7 +522,7 @@
if (parm.slope->answer) {
slope_fd =
- G_open_cell_old(parm.slope->answer,
+ Rast_open_cell_old(parm.slope->answer,
G_find_cell2(parm.slope->answer, ""));
if (slope_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -529,7 +530,7 @@
}
if (parm.aspect->answer) {
aspect_fd =
- G_open_cell_old(parm.aspect->answer,
+ Rast_open_cell_old(parm.aspect->answer,
G_find_cell2(parm.aspect->answer, ""));
if (aspect_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
@@ -538,18 +539,18 @@
if (spotting) {
elev_fd =
- G_open_cell_old(parm.elev->answer,
+ Rast_open_cell_old(parm.elev->answer,
G_find_cell2(parm.elev->answer, ""));
if (elev_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
parm.elev->answer);
}
- base_fd = G_open_cell_new(name_base);
- max_fd = G_open_cell_new(name_max);
- maxdir_fd = G_open_cell_new(name_maxdir);
+ base_fd = Rast_open_cell_new(name_base);
+ max_fd = Rast_open_cell_new(name_max);
+ maxdir_fd = Rast_open_cell_new(name_maxdir);
if (spotting)
- spotdist_fd = G_open_cell_new(name_spotdist);
+ spotdist_fd = Rast_open_cell_new(name_spotdist);
/*compute weights, combined wo, and combined sigma */
/*wo[model] -- simple sum of WO[class][model] by all fuel subCLASS */
@@ -625,7 +626,7 @@
/*if considering spotting, read elevation map into an array */
if (spotting)
for (row = 0; row < nrows; row++) {
- if (G_get_map_row(elev_fd, elev, row) < 0)
+ if (Rast_get_map_row(elev_fd, elev, row) < 0)
G_fatal_error("cannot get map row!");
for (col = 0; col < ncols; col++)
DATA(map_elev, row, col) = elev[col];
@@ -636,30 +637,30 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_map_row(fuel_fd, fuel, row) < 0)
+ if (Rast_get_map_row(fuel_fd, fuel, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
if (parm.mois_1h->answer)
- if (G_get_map_row(mois_1h_fd, mois_1h, row) < 0)
+ if (Rast_get_map_row(mois_1h_fd, mois_1h, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
if (parm.mois_10h->answer)
- if (G_get_map_row(mois_10h_fd, mois_10h, row) < 0)
+ if (Rast_get_map_row(mois_10h_fd, mois_10h, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
if (parm.mois_100h->answer)
- if (G_get_map_row(mois_100h_fd, mois_100h, row) < 0)
+ if (Rast_get_map_row(mois_100h_fd, mois_100h, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
- if (G_get_map_row(mois_live_fd, mois_live, row) < 0)
+ if (Rast_get_map_row(mois_live_fd, mois_live, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
if (parm.vel->answer)
- if (G_get_map_row(vel_fd, vel, row) < 0)
+ if (Rast_get_map_row(vel_fd, vel, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
if (parm.dir->answer)
- if (G_get_map_row(dir_fd, dir, row) < 0)
+ if (Rast_get_map_row(dir_fd, dir, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
if (parm.slope->answer)
- if (G_get_map_row(slope_fd, slope, row) < 0)
+ if (Rast_get_map_row(slope_fd, slope, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
if (parm.aspect->answer)
- if (G_get_map_row(aspect_fd, aspect, row) < 0)
+ if (Rast_get_map_row(aspect_fd, aspect, row) < 0)
G_fatal_error("cannot get map row: %d!", row);
/*initialize cell buffers for output map layers */
@@ -855,36 +856,36 @@
maxdir[col] = (int)Rdir;
/*printf("(%d, %d)\nR0=%.2f, vel=%d, dir=%d, phiw=%.2f, s=%d, as=%d, phis=%.2f, R=%.1f, Rdir=%.0f\n", row, col, R0, vel[col], dir[col], phiw, slope[col], aspect[col], phis, R, Rdir); */
}
- G_put_raster_row(base_fd, base, CELL_TYPE);
- G_put_raster_row(max_fd, max, CELL_TYPE);
- G_put_raster_row(maxdir_fd, maxdir, CELL_TYPE);
+ Rast_put_raster_row(base_fd, base, CELL_TYPE);
+ Rast_put_raster_row(max_fd, max, CELL_TYPE);
+ Rast_put_raster_row(maxdir_fd, maxdir, CELL_TYPE);
if (spotting)
- G_put_raster_row(spotdist_fd, spotdist, CELL_TYPE);
+ Rast_put_raster_row(spotdist_fd, spotdist, CELL_TYPE);
}
G_percent(row, nrows, 2);
- G_close_cell(fuel_fd);
+ Rast_close_cell(fuel_fd);
if (parm.mois_1h->answer)
- G_close_cell(mois_1h_fd);
+ Rast_close_cell(mois_1h_fd);
if (parm.mois_10h->answer)
- G_close_cell(mois_10h_fd);
+ Rast_close_cell(mois_10h_fd);
if (parm.mois_100h->answer)
- G_close_cell(mois_100h_fd);
- G_close_cell(mois_live_fd);
+ Rast_close_cell(mois_100h_fd);
+ Rast_close_cell(mois_live_fd);
if (parm.vel->answer)
- G_close_cell(vel_fd);
+ Rast_close_cell(vel_fd);
if (parm.dir->answer)
- G_close_cell(dir_fd);
+ Rast_close_cell(dir_fd);
if (parm.slope->answer)
- G_close_cell(slope_fd);
+ Rast_close_cell(slope_fd);
if (parm.aspect->answer)
- G_close_cell(aspect_fd);
- G_close_cell(base_fd);
- G_close_cell(max_fd);
- G_close_cell(maxdir_fd);
+ Rast_close_cell(aspect_fd);
+ Rast_close_cell(base_fd);
+ Rast_close_cell(max_fd);
+ Rast_close_cell(maxdir_fd);
if (spotting) {
- G_close_cell(spotdist_fd);
- G_close_cell(spotdist_fd);
+ Rast_close_cell(spotdist_fd);
+ Rast_close_cell(spotdist_fd);
G_free(map_elev);
}
Modified: grass/trunk/raster/r.ros/spot_dist.c
===================================================================
--- grass/trunk/raster/r.ros/spot_dist.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.ros/spot_dist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -33,6 +33,7 @@
******************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <math.h>
Modified: grass/trunk/raster/r.series/main.c
===================================================================
--- grass/trunk/raster/r.series/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.series/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/stats.h>
@@ -186,11 +187,11 @@
p->name = parm.input->answers[i];
G_message(_("Reading raster map <%s>..."), p->name);
- p->fd = G_open_cell_old(p->name, "");
+ p->fd = Rast_open_cell_old(p->name, "");
if (p->fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
p->name);
- p->buf = G_allocate_d_raster_buf();
+ p->buf = Rast_allocate_d_raster_buf();
}
/* process the output maps */
@@ -216,8 +217,8 @@
out->quantile = (parm.quantile->answer && parm.quantile->answers[i])
? atof(parm.quantile->answers[i])
: 0;
- out->buf = G_allocate_d_raster_buf();
- out->fd = G_open_raster_new(
+ out->buf = Rast_allocate_d_raster_buf();
+ out->fd = Rast_open_raster_new(
output_name, menu[method].is_int ? CELL_TYPE : DCELL_TYPE);
if (out->fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), out->name);
@@ -237,7 +238,7 @@
G_percent(row, nrows, 2);
for (i = 0; i < num_inputs; i++)
- G_get_d_raster_row(inputs[i].fd, inputs[i].buf, row);
+ Rast_get_d_raster_row(inputs[i].fd, inputs[i].buf, row);
for (col = 0; col < ncols; col++) {
int null = 0;
@@ -245,10 +246,10 @@
for (i = 0; i < num_inputs; i++) {
DCELL v = inputs[i].buf[col];
- if (G_is_d_null_value(&v))
+ if (Rast_is_d_null_value(&v))
null = 1;
else if (parm.range->answer && (v < lo || v > hi)) {
- G_set_d_null_value(&v, 1);
+ Rast_set_d_null_value(&v, 1);
null = 1;
}
@@ -259,7 +260,7 @@
struct output *out = &outputs[i];
if (null && flag.nulls->answer)
- G_set_d_null_value(&out->buf[col], 1);
+ Rast_set_d_null_value(&out->buf[col], 1);
else {
memcpy(values_tmp, values, num_inputs * sizeof(DCELL));
(*out->method_fn)(&out->buf[col], values_tmp, num_inputs, &out->quantile);
@@ -268,7 +269,7 @@
}
for (i = 0; i < num_outputs; i++)
- G_put_d_raster_row(outputs[i].fd, outputs[i].buf);
+ Rast_put_d_raster_row(outputs[i].fd, outputs[i].buf);
}
G_percent(row, nrows, 2);
@@ -277,15 +278,15 @@
for (i = 0; i < num_outputs; i++) {
struct output *out = &outputs[i];
- G_close_cell(out->fd);
+ Rast_close_cell(out->fd);
- G_short_history(out->name, "raster", &history);
- G_command_history(&history);
- G_write_history(out->name, &history);
+ Rast_short_history(out->name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out->name, &history);
}
for (i = 0; i < num_inputs; i++)
- G_close_cell(inputs[i].fd);
+ Rast_close_cell(inputs[i].fd);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.slope.aspect/main.c
===================================================================
--- grass/trunk/raster/r.slope.aspect/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.slope.aspect/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -26,6 +26,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -364,7 +365,7 @@
/* set the window from the header for the elevation file */
if (!flag.a->answer) {
G_get_window(&window);
- if (G_get_cellhd(elev_name, "", &cellhd) >= 0) {
+ if (Rast_get_cellhd(elev_name, "", &cellhd) >= 0) {
G_align_window(&window, &cellhd);
G_set_window(&window);
}
@@ -438,21 +439,21 @@
*/
/* open the elevation file for reading */
- elevation_fd = G_open_cell_old(elev_name, "");
+ elevation_fd = Rast_open_cell_old(elev_name, "");
if (elevation_fd < 0)
exit(EXIT_FAILURE);
elev_cell[0] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(elev_cell[0], ncols);
+ Rast_set_d_null_value(elev_cell[0], ncols);
elev_cell[1] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(elev_cell[1], ncols);
+ Rast_set_d_null_value(elev_cell[1], ncols);
elev_cell[2] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(elev_cell[2], ncols);
+ Rast_set_d_null_value(elev_cell[2], ncols);
if (slope_name != NULL) {
slope_fd = opennew(slope_name, out_type);
- slp_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(slp_raster, G_window_cols(), data_type);
- G_put_raster_row(slope_fd, slp_raster, data_type);
+ slp_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(slp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(slope_fd, slp_raster, data_type);
}
else {
slp_raster = NULL;
@@ -461,9 +462,9 @@
if (aspect_name != NULL) {
aspect_fd = opennew(aspect_name, out_type);
- asp_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(asp_raster, G_window_cols(), data_type);
- G_put_raster_row(aspect_fd, asp_raster, data_type);
+ asp_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(asp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(aspect_fd, asp_raster, data_type);
}
else {
asp_raster = NULL;
@@ -472,9 +473,9 @@
if (pcurv_name != NULL) {
pcurv_fd = opennew(pcurv_name, out_type);
- pcurv_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(pcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(pcurv_fd, pcurv_raster, data_type);
+ pcurv_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(pcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(pcurv_fd, pcurv_raster, data_type);
}
else {
pcurv_raster = NULL;
@@ -483,9 +484,9 @@
if (tcurv_name != NULL) {
tcurv_fd = opennew(tcurv_name, out_type);
- tcurv_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(tcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(tcurv_fd, tcurv_raster, data_type);
+ tcurv_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(tcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(tcurv_fd, tcurv_raster, data_type);
}
else {
tcurv_raster = NULL;
@@ -494,9 +495,9 @@
if (dx_name != NULL) {
dx_fd = opennew(dx_name, out_type);
- dx_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dx_raster, G_window_cols(), data_type);
- G_put_raster_row(dx_fd, dx_raster, data_type);
+ dx_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dx_fd, dx_raster, data_type);
}
else {
dx_raster = NULL;
@@ -505,9 +506,9 @@
if (dy_name != NULL) {
dy_fd = opennew(dy_name, out_type);
- dy_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dy_raster, G_window_cols(), data_type);
- G_put_raster_row(dy_fd, dy_raster, data_type);
+ dy_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dy_fd, dy_raster, data_type);
}
else {
dy_raster = NULL;
@@ -516,9 +517,9 @@
if (dxx_name != NULL) {
dxx_fd = opennew(dxx_name, out_type);
- dxx_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dxx_raster, G_window_cols(), data_type);
- G_put_raster_row(dxx_fd, dxx_raster, data_type);
+ dxx_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dxx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxx_fd, dxx_raster, data_type);
}
else {
dxx_raster = NULL;
@@ -527,9 +528,9 @@
if (dyy_name != NULL) {
dyy_fd = opennew(dyy_name, out_type);
- dyy_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dyy_raster, G_window_cols(), data_type);
- G_put_raster_row(dyy_fd, dyy_raster, data_type);
+ dyy_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dyy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dyy_fd, dyy_raster, data_type);
}
else {
dyy_raster = NULL;
@@ -538,9 +539,9 @@
if (dxy_name != NULL) {
dxy_fd = opennew(dxy_name, out_type);
- dxy_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dxy_raster, G_window_cols(), data_type);
- G_put_raster_row(dxy_fd, dxy_raster, data_type);
+ dxy_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dxy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxy_fd, dxy_raster, data_type);
}
else {
dxy_raster = NULL;
@@ -552,20 +553,20 @@
exit(EXIT_FAILURE);
if (Wrap) {
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[1] + 1, 0);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[1] + 1, 0);
elev_cell[1][0] = elev_cell[1][G_window_cols() - 1];
elev_cell[1][G_window_cols() + 1] = elev_cell[1][2];
}
else
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[1], 0);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[1], 0);
if (Wrap) {
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, 1);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, 1);
elev_cell[2][0] = elev_cell[2][G_window_cols() - 1];
elev_cell[2][G_window_cols() + 1] = elev_cell[2][2];
}
else
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2], 1);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2], 1);
G_verbose_message(_("Percent complete..."));
@@ -605,12 +606,12 @@
elev_cell[2] = temp;
if (Wrap) {
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, row);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, row);
elev_cell[2][0] = elev_cell[2][G_window_cols() - 1];
elev_cell[2][G_window_cols() + 1] = elev_cell[2][2];
}
else
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2], row);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2], row);
c1 = elev_cell[0];
c2 = c1 + 1;
@@ -627,14 +628,14 @@
asp_ptr = asp_raster;
else
asp_ptr =
- G_incr_void_ptr(asp_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(asp_raster, Rast_raster_size(data_type));
}
if (slope_fd >= 0) {
if (Wrap)
slp_ptr = slp_raster;
else
slp_ptr =
- G_incr_void_ptr(slp_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(slp_raster, Rast_raster_size(data_type));
}
if (pcurv_fd >= 0) {
@@ -642,7 +643,7 @@
pcurv_ptr = pcurv_raster;
else
pcurv_ptr =
- G_incr_void_ptr(pcurv_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(pcurv_raster, Rast_raster_size(data_type));
}
if (tcurv_fd >= 0) {
@@ -650,21 +651,21 @@
tcurv_ptr = tcurv_raster;
else
tcurv_ptr =
- G_incr_void_ptr(tcurv_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(tcurv_raster, Rast_raster_size(data_type));
}
if (dx_fd >= 0) {
if (Wrap)
dx_ptr = dx_raster;
else
- dx_ptr = G_incr_void_ptr(dx_raster, G_raster_size(data_type));
+ dx_ptr = Rast_incr_void_ptr(dx_raster, Rast_raster_size(data_type));
}
if (dy_fd >= 0) {
if (Wrap)
dy_ptr = dy_raster;
else
- dy_ptr = G_incr_void_ptr(dy_raster, G_raster_size(data_type));
+ dy_ptr = Rast_incr_void_ptr(dy_raster, Rast_raster_size(data_type));
}
if (dxx_fd >= 0) {
@@ -672,7 +673,7 @@
dxx_ptr = dxx_raster;
else
dxx_ptr =
- G_incr_void_ptr(dxx_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxx_raster, Rast_raster_size(data_type));
}
if (dyy_fd >= 0) {
@@ -680,7 +681,7 @@
dyy_ptr = dyy_raster;
else
dyy_ptr =
- G_incr_void_ptr(dyy_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(dyy_raster, Rast_raster_size(data_type));
}
if (dxy_fd >= 0) {
@@ -688,7 +689,7 @@
dxy_ptr = dxy_raster;
else
dxy_ptr =
- G_incr_void_ptr(dxy_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxy_raster, Rast_raster_size(data_type));
}
@@ -701,55 +702,55 @@
*c1, *c2, *c3, *c4, *c5, *c6, *c7, *c8, *c9);
*/
- if (G_is_d_null_value(c1) || G_is_d_null_value(c2) ||
- G_is_d_null_value(c3) || G_is_d_null_value(c4) ||
- G_is_d_null_value(c5) || G_is_d_null_value(c6) ||
- G_is_d_null_value(c7) || G_is_d_null_value(c8) ||
- G_is_d_null_value(c9)) {
+ if (Rast_is_d_null_value(c1) || Rast_is_d_null_value(c2) ||
+ Rast_is_d_null_value(c3) || Rast_is_d_null_value(c4) ||
+ Rast_is_d_null_value(c5) || Rast_is_d_null_value(c6) ||
+ Rast_is_d_null_value(c7) || Rast_is_d_null_value(c8) ||
+ Rast_is_d_null_value(c9)) {
if (slope_fd > 0) {
- G_set_null_value(slp_ptr, 1, data_type);
+ Rast_set_null_value(slp_ptr, 1, data_type);
slp_ptr =
- G_incr_void_ptr(slp_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(slp_ptr, Rast_raster_size(data_type));
}
if (aspect_fd > 0) {
- G_set_null_value(asp_ptr, 1, data_type);
+ Rast_set_null_value(asp_ptr, 1, data_type);
asp_ptr =
- G_incr_void_ptr(asp_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(asp_ptr, Rast_raster_size(data_type));
}
if (pcurv_fd > 0) {
- G_set_null_value(pcurv_ptr, 1, data_type);
+ Rast_set_null_value(pcurv_ptr, 1, data_type);
pcurv_ptr =
- G_incr_void_ptr(pcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(pcurv_ptr, Rast_raster_size(data_type));
}
if (tcurv_fd > 0) {
- G_set_null_value(tcurv_ptr, 1, data_type);
+ Rast_set_null_value(tcurv_ptr, 1, data_type);
tcurv_ptr =
- G_incr_void_ptr(tcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(tcurv_ptr, Rast_raster_size(data_type));
}
if (dx_fd > 0) {
- G_set_null_value(dx_ptr, 1, data_type);
+ Rast_set_null_value(dx_ptr, 1, data_type);
dx_ptr =
- G_incr_void_ptr(dx_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dx_ptr, Rast_raster_size(data_type));
}
if (dy_fd > 0) {
- G_set_null_value(dy_ptr, 1, data_type);
+ Rast_set_null_value(dy_ptr, 1, data_type);
dy_ptr =
- G_incr_void_ptr(dy_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dy_ptr, Rast_raster_size(data_type));
}
if (dxx_fd > 0) {
- G_set_null_value(dxx_ptr, 1, data_type);
+ Rast_set_null_value(dxx_ptr, 1, data_type);
dxx_ptr =
- G_incr_void_ptr(dxx_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxx_ptr, Rast_raster_size(data_type));
}
if (dyy_fd > 0) {
- G_set_null_value(dyy_ptr, 1, data_type);
+ Rast_set_null_value(dyy_ptr, 1, data_type);
dyy_ptr =
- G_incr_void_ptr(dyy_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dyy_ptr, Rast_raster_size(data_type));
}
if (dxy_fd > 0) {
- G_set_null_value(dxy_ptr, 1, data_type);
+ Rast_set_null_value(dxy_ptr, 1, data_type);
dxy_ptr =
- G_incr_void_ptr(dxy_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxy_ptr, Rast_raster_size(data_type));
}
continue;
} /* no data */
@@ -808,13 +809,13 @@
*((CELL *) slp_ptr) = (CELL) test;
else {
if (deg)
- G_set_raster_value_d(slp_ptr,
+ Rast_set_raster_value_d(slp_ptr,
(DCELL) slp_in_deg, data_type);
else
- G_set_raster_value_d(slp_ptr,
+ Rast_set_raster_value_d(slp_ptr,
(DCELL) slp_in_perc, data_type);
}
- slp_ptr = G_incr_void_ptr(slp_ptr, G_raster_size(data_type));
+ slp_ptr = Rast_incr_void_ptr(slp_ptr, Rast_raster_size(data_type));
} /* computing slope */
if (aspect_fd > 0) {
@@ -841,12 +842,12 @@
if (out_type == CELL_TYPE)
*((CELL *) asp_ptr) = (CELL) (aspect + .5);
else
- G_set_raster_value_d(asp_ptr,
+ Rast_set_raster_value_d(asp_ptr,
(DCELL) aspect, data_type);
}
else
- G_set_null_value(asp_ptr, 1, data_type);
- asp_ptr = G_incr_void_ptr(asp_ptr, G_raster_size(data_type));
+ Rast_set_null_value(asp_ptr, 1, data_type);
+ asp_ptr = Rast_incr_void_ptr(asp_ptr, Rast_raster_size(data_type));
/* now update min and max */
if (min_asp > aspect)
@@ -859,16 +860,16 @@
if (out_type == CELL_TYPE)
*((CELL *) dx_ptr) = (CELL) (scik1 * dx);
else
- G_set_raster_value_d(dx_ptr, (DCELL) dx, data_type);
- dx_ptr = G_incr_void_ptr(dx_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dx_ptr, (DCELL) dx, data_type);
+ dx_ptr = Rast_incr_void_ptr(dx_ptr, Rast_raster_size(data_type));
}
if (dy_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) dy_ptr) = (CELL) (scik1 * dy);
else
- G_set_raster_value_d(dy_ptr, (DCELL) dy, data_type);
- dy_ptr = G_incr_void_ptr(dy_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dy_ptr, (DCELL) dy, data_type);
+ dy_ptr = Rast_incr_void_ptr(dy_ptr, Rast_raster_size(data_type));
}
if (dxx_fd <= 0 && dxy_fd <= 0 && dyy_fd <= 0 &&
@@ -889,24 +890,24 @@
if (out_type == CELL_TYPE)
*((CELL *) dxx_ptr) = (CELL) (scik1 * dxx);
else
- G_set_raster_value_d(dxx_ptr, (DCELL) dxx, data_type);
- dxx_ptr = G_incr_void_ptr(dxx_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dxx_ptr, (DCELL) dxx, data_type);
+ dxx_ptr = Rast_incr_void_ptr(dxx_ptr, Rast_raster_size(data_type));
}
if (dyy_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) dyy_ptr) = (CELL) (scik1 * dyy);
else
- G_set_raster_value_d(dyy_ptr, (DCELL) dyy, data_type);
- dyy_ptr = G_incr_void_ptr(dyy_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dyy_ptr, (DCELL) dyy, data_type);
+ dyy_ptr = Rast_incr_void_ptr(dyy_ptr, Rast_raster_size(data_type));
}
if (dxy_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) dxy_ptr) = (CELL) (scik1 * dxy);
else
- G_set_raster_value_d(dxy_ptr, (DCELL) dxy, data_type);
- dxy_ptr = G_incr_void_ptr(dxy_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dxy_ptr, (DCELL) dxy, data_type);
+ dxy_ptr = Rast_incr_void_ptr(dxy_ptr, Rast_raster_size(data_type));
}
/* compute curvature */
@@ -941,54 +942,54 @@
if (out_type == CELL_TYPE)
*((CELL *) pcurv_ptr) = (CELL) (scik1 * pcurv);
else
- G_set_raster_value_d(pcurv_ptr, (DCELL) pcurv, data_type);
+ Rast_set_raster_value_d(pcurv_ptr, (DCELL) pcurv, data_type);
pcurv_ptr =
- G_incr_void_ptr(pcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(pcurv_ptr, Rast_raster_size(data_type));
}
if (tcurv_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) tcurv_ptr) = (CELL) (scik1 * tcurv);
else
- G_set_raster_value_d(tcurv_ptr, (DCELL) tcurv, data_type);
+ Rast_set_raster_value_d(tcurv_ptr, (DCELL) tcurv, data_type);
tcurv_ptr =
- G_incr_void_ptr(tcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(tcurv_ptr, Rast_raster_size(data_type));
}
} /* column for loop */
if (aspect_fd > 0)
- G_put_raster_row(aspect_fd, asp_raster, data_type);
+ Rast_put_raster_row(aspect_fd, asp_raster, data_type);
if (slope_fd > 0)
- G_put_raster_row(slope_fd, slp_raster, data_type);
+ Rast_put_raster_row(slope_fd, slp_raster, data_type);
if (pcurv_fd > 0)
- G_put_raster_row(pcurv_fd, pcurv_raster, data_type);
+ Rast_put_raster_row(pcurv_fd, pcurv_raster, data_type);
if (tcurv_fd > 0)
- G_put_raster_row(tcurv_fd, tcurv_raster, data_type);
+ Rast_put_raster_row(tcurv_fd, tcurv_raster, data_type);
if (dx_fd > 0)
- G_put_raster_row(dx_fd, dx_raster, data_type);
+ Rast_put_raster_row(dx_fd, dx_raster, data_type);
if (dy_fd > 0)
- G_put_raster_row(dy_fd, dy_raster, data_type);
+ Rast_put_raster_row(dy_fd, dy_raster, data_type);
if (dxx_fd > 0)
- G_put_raster_row(dxx_fd, dxx_raster, data_type);
+ Rast_put_raster_row(dxx_fd, dxx_raster, data_type);
if (dyy_fd > 0)
- G_put_raster_row(dyy_fd, dyy_raster, data_type);
+ Rast_put_raster_row(dyy_fd, dyy_raster, data_type);
if (dxy_fd > 0)
- G_put_raster_row(dxy_fd, dxy_raster, data_type);
+ Rast_put_raster_row(dxy_fd, dxy_raster, data_type);
} /* row loop */
G_percent(row, nrows, 2);
- G_close_cell(elevation_fd);
+ Rast_close_cell(elevation_fd);
G_debug(1, "Creating support files...");
G_verbose_message(_("Elevation products for mapset <%s> in <%s>"),
@@ -998,16 +999,16 @@
DCELL min, max;
struct FPRange range;
- G_set_null_value(asp_raster, G_window_cols(), data_type);
- G_put_raster_row(aspect_fd, asp_raster, data_type);
- G_close_cell(aspect_fd);
+ Rast_set_null_value(asp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(aspect_fd, asp_raster, data_type);
+ Rast_close_cell(aspect_fd);
if (out_type != CELL_TYPE)
- G_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
+ Rast_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
360);
- G_read_raster_cats(aspect_name, G_mapset(), &cats);
- G_set_raster_cats_title
+ Rast_read_raster_cats(aspect_name, G_mapset(), &cats);
+ Rast_set_raster_cats_title
("Aspect counterclockwise in degrees from east", &cats);
G_verbose_message(_("Min computed aspect %.4f, max computed aspect %.4f"),
@@ -1039,80 +1040,80 @@
sprintf(buf, "%d degree%s ccw from east", i,
i == 1 ? "" : "s");
if (data_type == CELL_TYPE) {
- G_set_cat(i, buf, &cats);
+ Rast_set_cat(i, buf, &cats);
continue;
}
tmp1 = (double)i - .5;
tmp2 = (double)i + .5;
- G_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
}
if (data_type == CELL_TYPE)
- G_set_cat(0, "no aspect", &cats);
+ Rast_set_cat(0, "no aspect", &cats);
else {
tmp1 = 0.;
tmp2 = .5;
- G_set_d_raster_cat(&tmp1, &tmp2, "no aspect", &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, "no aspect", &cats);
}
- G_write_raster_cats(aspect_name, &cats);
- G_free_raster_cats(&cats);
+ Rast_write_raster_cats(aspect_name, &cats);
+ Rast_free_raster_cats(&cats);
/* write colors for aspect file */
- G_init_colors(&colors);
- G_read_fp_range(aspect_name, G_mapset(), &range);
- G_get_fp_range_min_max(&range, &min, &max);
- G_make_aspect_fp_colors(&colors, min, max);
- G_write_colors(aspect_name, G_mapset(), &colors);
+ Rast_init_colors(&colors);
+ Rast_read_fp_range(aspect_name, G_mapset(), &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
+ Rast_make_aspect_fp_colors(&colors, min, max);
+ Rast_write_colors(aspect_name, G_mapset(), &colors);
/* writing history file */
- G_short_history(aspect_name, "raster", &hist);
+ Rast_short_history(aspect_name, "raster", &hist);
sprintf(hist.edhist[0], "aspect map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(aspect_name, &hist);
+ Rast_write_history(aspect_name, &hist);
G_message(_("Aspect raster map <%s> complete"), aspect_name);
}
if (slope_fd >= 0) {
/* colortable for slopes */
- G_init_colors(&colors);
- G_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
- G_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
- G_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
- G_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
- G_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
- G_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
- G_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
+ Rast_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
+ Rast_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
+ Rast_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
+ Rast_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
+ Rast_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
+ Rast_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
- G_set_null_value(slp_raster, G_window_cols(), data_type);
- G_put_raster_row(slope_fd, slp_raster, data_type);
- G_close_cell(slope_fd);
+ Rast_set_null_value(slp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(slope_fd, slp_raster, data_type);
+ Rast_close_cell(slope_fd);
if (out_type != CELL_TYPE) {
/* INCR_BY_ONE
if(deg)
- G_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 1, 91);
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 1, 91);
else
- G_quantize_fp_map_range(slope_name, G_mapset(), min_slp, max_slp,
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), min_slp, max_slp,
(CELL) min_slp + 1, (CELL) ceil(max_slp) + 1);
*/
- G_write_colors(slope_name, G_mapset(), &colors);
+ Rast_write_colors(slope_name, G_mapset(), &colors);
if (deg)
- G_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 0,
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 0,
90);
else /* percent */
- G_quantize_fp_map_range(slope_name, G_mapset(), min_slp,
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), min_slp,
max_slp, (CELL) min_slp,
(CELL) ceil(max_slp));
}
- G_read_raster_cats(slope_name, G_mapset(), &cats);
+ Rast_read_raster_cats(slope_name, G_mapset(), &cats);
if (deg)
- G_set_raster_cats_title("slope in degrees", &cats);
+ Rast_set_raster_cats_title("slope in degrees", &cats);
else if (perc)
- G_set_raster_cats_title("percent slope", &cats);
+ Rast_set_raster_cats_title("percent slope", &cats);
G_verbose_message(_("Min computed slope %.4f, max computed slope %.4f"),
min_slp, max_slp);
@@ -1127,9 +1128,9 @@
sprintf(buf, "%d percent", i);
if (data_type == CELL_TYPE) {
/* INCR_BY_ONE
- G_set_cat(i+1, buf, &cats);
+ Rast_set_cat(i+1, buf, &cats);
*/
- G_set_cat(i, buf, &cats);
+ Rast_set_cat(i, buf, &cats);
continue;
}
/* INCR_BY_ONE
@@ -1138,70 +1139,70 @@
*/
tmp1 = (DCELL) i - .5;
tmp2 = (DCELL) i + .5;
- G_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
}
if (data_type == CELL_TYPE)
- G_set_cat(0, "zero slope", &cats);
+ Rast_set_cat(0, "zero slope", &cats);
/* INCR_BY_ONE
- G_set_cat(0, "no data", &cats);
+ Rast_set_cat(0, "no data", &cats);
*/
else {
tmp1 = 0;
tmp2 = 0.5;
- G_set_d_raster_cat(&tmp1, &tmp2, "zero slope", &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, "zero slope", &cats);
}
/* INCR_BY_ONE
- G_set_d_raster_cat (&tmp1, &tmp1, "no data", &cats);
+ Rast_set_d_raster_cat (&tmp1, &tmp1, "no data", &cats);
*/
- G_write_raster_cats(slope_name, &cats);
+ Rast_write_raster_cats(slope_name, &cats);
/* writing history file */
- G_short_history(slope_name, "raster", &hist);
+ Rast_short_history(slope_name, "raster", &hist);
sprintf(hist.edhist[0], "slope map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f format = %s", zfactor,
parm.slope_fmt->answer);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(slope_name, &hist);
+ Rast_write_history(slope_name, &hist);
G_message(_("Slope raster map <%s> complete"), slope_name);
}
/* colortable for curvatures */
if (pcurv_fd >= 0 || tcurv_fd >= 0) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
if (c1min < c2min)
dat1 = (FCELL) c1min;
else
dat1 = (FCELL) c2min;
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 127, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 127, 0, 255,
&dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.001;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255,
&dat2, 0, 127, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.00001;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255,
&dat2, 0, 255, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.0;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255,
&dat2, 200, 255, 200, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.00001;
- G_add_f_raster_color_rule(&dat1, 200, 255, 200,
+ Rast_add_f_raster_color_rule(&dat1, 200, 255, 200,
&dat2, 255, 255, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0,
&dat2, 255, 127, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0,
&dat2, 255, 0, 0, &colors);
dat1 = dat2;
if (c1max > c2max)
@@ -1209,178 +1210,178 @@
else
dat2 = (FCELL) c2max;
- G_add_f_raster_color_rule(&dat1, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0,
&dat2, 255, 0, 200, &colors);
}
if (pcurv_fd >= 0) {
- G_set_null_value(pcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(pcurv_fd, pcurv_raster, data_type);
- G_close_cell(pcurv_fd);
+ Rast_set_null_value(pcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(pcurv_fd, pcurv_raster, data_type);
+ Rast_close_cell(pcurv_fd);
- G_write_colors(pcurv_name, G_mapset(), &colors);
+ Rast_write_colors(pcurv_name, G_mapset(), &colors);
if (out_type != CELL_TYPE)
- G_round_fp_map(pcurv_name, G_mapset());
+ Rast_round_fp_map(pcurv_name, G_mapset());
- G_read_cats(pcurv_name, G_mapset(), &cats);
- G_set_cats_title("profile curvature", &cats);
- G_set_cat((CELL) 0, "no profile curve", &cats);
+ Rast_read_cats(pcurv_name, G_mapset(), &cats);
+ Rast_set_cats_title("profile curvature", &cats);
+ Rast_set_cat((CELL) 0, "no profile curve", &cats);
/* writing history file */
- G_short_history(pcurv_name, "raster", &hist);
+ Rast_short_history(pcurv_name, "raster", &hist);
sprintf(hist.edhist[0], "profile curve map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(pcurv_name, &hist);
+ Rast_write_history(pcurv_name, &hist);
G_message(_("Profile curve raster map <%s> complete"), pcurv_name);
}
if (tcurv_fd >= 0) {
- G_set_null_value(tcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(tcurv_fd, tcurv_raster, data_type);
- G_close_cell(tcurv_fd);
+ Rast_set_null_value(tcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(tcurv_fd, tcurv_raster, data_type);
+ Rast_close_cell(tcurv_fd);
- G_write_colors(tcurv_name, G_mapset(), &colors);
+ Rast_write_colors(tcurv_name, G_mapset(), &colors);
if (out_type != CELL_TYPE)
- G_round_fp_map(tcurv_name, G_mapset());
+ Rast_round_fp_map(tcurv_name, G_mapset());
- G_read_cats(tcurv_name, G_mapset(), &cats);
- G_set_cats_title("tangential curvature", &cats);
- G_set_cat((CELL) 0, "no tangential curve", &cats);
+ Rast_read_cats(tcurv_name, G_mapset(), &cats);
+ Rast_set_cats_title("tangential curvature", &cats);
+ Rast_set_cat((CELL) 0, "no tangential curve", &cats);
/* writing history file */
- G_short_history(tcurv_name, "raster", &hist);
+ Rast_short_history(tcurv_name, "raster", &hist);
sprintf(hist.edhist[0], "tangential curve map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(tcurv_name, &hist);
+ Rast_write_history(tcurv_name, &hist);
G_message(_("Tangential curve raster map <%s> complete"), tcurv_name);
}
if (dx_fd >= 0) {
- G_set_null_value(dx_raster, G_window_cols(), data_type);
- G_put_raster_row(dx_fd, dx_raster, data_type);
- G_close_cell(dx_fd);
+ Rast_set_null_value(dx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dx_fd, dx_raster, data_type);
+ Rast_close_cell(dx_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dx_name, G_mapset());
+ Rast_round_fp_map(dx_name, G_mapset());
- G_read_cats(dx_name, G_mapset(), &cats);
- G_set_cats_title("E-W slope", &cats);
- G_set_cat((CELL) 0, "no E-W slope", &cats);
+ Rast_read_cats(dx_name, G_mapset(), &cats);
+ Rast_set_cats_title("E-W slope", &cats);
+ Rast_set_cat((CELL) 0, "no E-W slope", &cats);
/* writing history file */
- G_short_history(dx_name, "raster", &hist);
+ Rast_short_history(dx_name, "raster", &hist);
sprintf(hist.edhist[0], "E-W slope map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dx_name, &hist);
+ Rast_write_history(dx_name, &hist);
G_message(_("E-W slope raster map <%s> complete"), dx_name);
}
if (dy_fd >= 0) {
- G_set_null_value(dy_raster, G_window_cols(), data_type);
- G_put_raster_row(dy_fd, dy_raster, data_type);
- G_close_cell(dy_fd);
+ Rast_set_null_value(dy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dy_fd, dy_raster, data_type);
+ Rast_close_cell(dy_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dy_name, G_mapset());
+ Rast_round_fp_map(dy_name, G_mapset());
- G_read_cats(dy_name, G_mapset(), &cats);
- G_set_cats_title("N-S slope", &cats);
- G_set_cat((CELL) 0, "no N-S slope", &cats);
+ Rast_read_cats(dy_name, G_mapset(), &cats);
+ Rast_set_cats_title("N-S slope", &cats);
+ Rast_set_cat((CELL) 0, "no N-S slope", &cats);
/* writing history file */
- G_short_history(dy_name, "raster", &hist);
+ Rast_short_history(dy_name, "raster", &hist);
sprintf(hist.edhist[0], "N-S slope map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dy_name, &hist);
+ Rast_write_history(dy_name, &hist);
G_message(_("N-S slope raster map <%s> complete"), dy_name);
}
if (dxx_fd >= 0) {
- G_set_null_value(dxx_raster, G_window_cols(), data_type);
- G_put_raster_row(dxx_fd, dxx_raster, data_type);
- G_close_cell(dxx_fd);
+ Rast_set_null_value(dxx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxx_fd, dxx_raster, data_type);
+ Rast_close_cell(dxx_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dxx_name, G_mapset());
+ Rast_round_fp_map(dxx_name, G_mapset());
- G_read_cats(dxx_name, G_mapset(), &cats);
- G_set_cats_title("DXX", &cats);
- G_set_cat((CELL) 0, "DXX", &cats);
+ Rast_read_cats(dxx_name, G_mapset(), &cats);
+ Rast_set_cats_title("DXX", &cats);
+ Rast_set_cat((CELL) 0, "DXX", &cats);
/* writing history file */
- G_short_history(dxx_name, "raster", &hist);
+ Rast_short_history(dxx_name, "raster", &hist);
sprintf(hist.edhist[0], "DXX map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dxx_name, &hist);
+ Rast_write_history(dxx_name, &hist);
G_message(_("Dxx raster map <%s> complete"), dxx_name);
}
if (dyy_fd >= 0) {
- G_set_null_value(dyy_raster, G_window_cols(), data_type);
- G_put_raster_row(dyy_fd, dyy_raster, data_type);
- G_close_cell(dyy_fd);
+ Rast_set_null_value(dyy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dyy_fd, dyy_raster, data_type);
+ Rast_close_cell(dyy_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dyy_name, G_mapset());
+ Rast_round_fp_map(dyy_name, G_mapset());
- G_read_cats(dyy_name, G_mapset(), &cats);
- G_set_cats_title("DYY", &cats);
- G_set_cat((CELL) 0, "DYY", &cats);
+ Rast_read_cats(dyy_name, G_mapset(), &cats);
+ Rast_set_cats_title("DYY", &cats);
+ Rast_set_cat((CELL) 0, "DYY", &cats);
/* writing history file */
- G_short_history(dyy_name, "raster", &hist);
+ Rast_short_history(dyy_name, "raster", &hist);
sprintf(hist.edhist[0], "DYY map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dyy_name, &hist);
+ Rast_write_history(dyy_name, &hist);
G_message(_("Dyy raster map <%s> complete"), dyy_name);
}
if (dxy_fd >= 0) {
- G_set_null_value(dxy_raster, G_window_cols(), data_type);
- G_put_raster_row(dxy_fd, dxy_raster, data_type);
- G_close_cell(dxy_fd);
+ Rast_set_null_value(dxy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxy_fd, dxy_raster, data_type);
+ Rast_close_cell(dxy_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dxy_name, G_mapset());
+ Rast_round_fp_map(dxy_name, G_mapset());
- G_read_cats(dxy_name, G_mapset(), &cats);
- G_set_cats_title("DXY", &cats);
- G_set_cat((CELL) 0, "DXY", &cats);
+ Rast_read_cats(dxy_name, G_mapset(), &cats);
+ Rast_set_cats_title("DXY", &cats);
+ Rast_set_cat((CELL) 0, "DXY", &cats);
/* writing history file */
- G_short_history(dxy_name, "raster", &hist);
+ Rast_short_history(dxy_name, "raster", &hist);
sprintf(hist.edhist[0], "DXY map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dxy_name, &hist);
+ Rast_write_history(dxy_name, &hist);
G_message(_("Dxy raster map <%s> complete"), dxy_name);
}
Modified: grass/trunk/raster/r.slope.aspect/opennew.c
===================================================================
--- grass/trunk/raster/r.slope.aspect/opennew.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.slope.aspect/opennew.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -8,9 +9,9 @@
int fd;
if (wr_type < 0) /* default fp type */
- fd = G_open_fp_cell_new(name);
+ fd = Rast_open_fp_cell_new(name);
else
- fd = G_open_raster_new(name, wr_type);
+ fd = Rast_open_raster_new(name, wr_type);
if (fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), name);
Modified: grass/trunk/raster/r.spread/collect_ori.c
===================================================================
--- grass/trunk/raster/r.spread/collect_ori.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/collect_ori.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "cmd_line.h"
#include "costHa.h"
#include "local_proto.h"
@@ -58,7 +59,7 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_map_row(start_fd, cell, row) < 0)
+ if (Rast_get_map_row(start_fd, cell, row) < 0)
exit(1);
for (col = 0; col < ncols; col++) {
Modified: grass/trunk/raster/r.spread/display.c
===================================================================
--- grass/trunk/raster/r.spread/display.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/display.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <string.h>
#include <time.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/display.h>
#include <grass/display_raster.h>
#include "cmd_line.h"
@@ -116,7 +117,7 @@
/*figure scaling factors of a file cell to a screen unit */
R_open_driver();
- G_make_grey_scale_colors(&colors, 0, 59);
+ Rast_make_grey_scale_colors(&colors, 0, 59);
width = r - l;
height = 0.9 * (b - t) - 1;
if (width * nrows > height * ncols) {
Modified: grass/trunk/raster/r.spread/insert2Ha.c
===================================================================
--- grass/trunk/raster/r.spread/insert2Ha.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/insert2Ha.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
/***************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "cell_ptrHa.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.spread/main.c
===================================================================
--- grass/trunk/raster/r.spread/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "cmd_line.h"
#include "costHa.h"
@@ -374,40 +375,40 @@
/* Open input cell layers for reading */
- max_fd = G_open_cell_old(max_layer, G_find_cell2(max_layer, ""));
+ max_fd = Rast_open_cell_old(max_layer, G_find_cell2(max_layer, ""));
if (max_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), max_layer);
- dir_fd = G_open_cell_old(dir_layer, G_find_cell2(dir_layer, ""));
+ dir_fd = Rast_open_cell_old(dir_layer, G_find_cell2(dir_layer, ""));
if (dir_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), dir_layer);
- base_fd = G_open_cell_old(base_layer, G_find_cell2(base_layer, ""));
+ base_fd = Rast_open_cell_old(base_layer, G_find_cell2(base_layer, ""));
if (base_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), base_layer);
if (spotting) {
spotdist_fd =
- G_open_cell_old(spotdist_layer, G_find_cell2(spotdist_layer, ""));
+ Rast_open_cell_old(spotdist_layer, G_find_cell2(spotdist_layer, ""));
if (spotdist_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), spotdist_layer);
velocity_fd =
- G_open_cell_old(velocity_layer, G_find_cell2(velocity_layer, ""));
+ Rast_open_cell_old(velocity_layer, G_find_cell2(velocity_layer, ""));
if (velocity_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), velocity_layer);
- mois_fd = G_open_cell_old(mois_layer, G_find_cell2(mois_layer, ""));
+ mois_fd = Rast_open_cell_old(mois_layer, G_find_cell2(mois_layer, ""));
if (mois_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), mois_layer);
}
/* Allocate memories for a row */
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
if (x_out)
- x_cell = G_allocate_cell_buf();
+ x_cell = Rast_allocate_cell_buf();
if (y_out)
- y_cell = G_allocate_cell_buf();
+ y_cell = Rast_allocate_cell_buf();
/* Allocate memories for a map */
map_max = (CELL *) G_calloc(nrows * ncols + 1, sizeof(CELL));
@@ -432,28 +433,28 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_map_row(max_fd, cell, row) < 0)
+ if (Rast_get_map_row(max_fd, cell, row) < 0)
exit(EXIT_FAILURE);
for (col = 0; col < ncols; col++)
DATA(map_max, row, col) = cell[col];
- if (G_get_map_row(dir_fd, cell, row) < 0)
+ if (Rast_get_map_row(dir_fd, cell, row) < 0)
exit(EXIT_FAILURE);
for (col = 0; col < ncols; col++)
DATA(map_dir, row, col) = cell[col];
- if (G_get_map_row(base_fd, cell, row) < 0)
+ if (Rast_get_map_row(base_fd, cell, row) < 0)
exit(EXIT_FAILURE);
for (col = 0; col < ncols; col++)
DATA(map_base, row, col) = cell[col];
if (spotting) {
- if (G_get_map_row(spotdist_fd, cell, row) < 0)
+ if (Rast_get_map_row(spotdist_fd, cell, row) < 0)
exit(EXIT_FAILURE);
for (col = 0; col < ncols; col++)
DATA(map_spotdist, row, col) = cell[col];
- if (G_get_map_row(velocity_fd, cell, row) < 0)
+ if (Rast_get_map_row(velocity_fd, cell, row) < 0)
exit(EXIT_FAILURE);
for (col = 0; col < ncols; col++)
DATA(map_velocity, row, col) = cell[col];
- if (G_get_map_row(mois_fd, cell, row) < 0)
+ if (Rast_get_map_row(mois_fd, cell, row) < 0)
exit(EXIT_FAILURE);
for (col = 0; col < ncols; col++)
DATA(map_mois, row, col) = cell[col];
@@ -466,12 +467,12 @@
* Create an array of starting points (min_heap) ordered by costs.
*/
- start_fd = G_open_cell_old(start_layer, G_find_cell2(start_layer, ""));
+ start_fd = Rast_open_cell_old(start_layer, G_find_cell2(start_layer, ""));
if (start_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), start_layer);
- G_read_range(start_layer, G_find_file("cell", start_layer, ""), &range);
- G_get_range_min_max(&range, &range_min, &range_max);
+ Rast_read_range(start_layer, G_find_file("cell", start_layer, ""), &range);
+ Rast_get_range_min_max(&range, &range_min, &range_max);
/* Initialize the heap */
heap =
@@ -492,11 +493,11 @@
/* Open cumulative cost layer (and x, y direction layers) for writing */
- cum_fd = G_open_cell_new(out_layer);
+ cum_fd = Rast_open_cell_new(out_layer);
if (x_out)
- x_fd = G_open_cell_new(x_out_layer);
+ x_fd = Rast_open_cell_new(x_out_layer);
if (y_out)
- y_fd = G_open_cell_new(y_out_layer);
+ y_fd = Rast_open_cell_new(y_out_layer);
/* prepare output -- adjust from cm to m */
window.ew_res = window.ew_res / 100;
@@ -520,19 +521,19 @@
G_free(map_velocity);
}
- G_close_cell(max_fd);
- G_close_cell(dir_fd);
- G_close_cell(base_fd);
- G_close_cell(start_fd);
- G_close_cell(cum_fd);
+ Rast_close_cell(max_fd);
+ Rast_close_cell(dir_fd);
+ Rast_close_cell(base_fd);
+ Rast_close_cell(start_fd);
+ Rast_close_cell(cum_fd);
if (x_out)
- G_close_cell(x_fd);
+ Rast_close_cell(x_fd);
if (y_out)
- G_close_cell(y_fd);
+ Rast_close_cell(y_fd);
if (spotting) {
- G_close_cell(spotdist_fd);
- G_close_cell(velocity_fd);
- G_close_cell(mois_fd);
+ Rast_close_cell(spotdist_fd);
+ Rast_close_cell(velocity_fd);
+ Rast_close_cell(mois_fd);
}
/* close graphics */
Modified: grass/trunk/raster/r.spread/ram2out.c
===================================================================
--- grass/trunk/raster/r.spread/ram2out.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/ram2out.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "cmd_line.h"
#include "costHa.h"
#include "local_proto.h"
@@ -44,11 +45,11 @@
window.ns_res * DATA(map_y_out, row, col));
}
}
- G_put_raster_row(cum_fd, cell, CELL_TYPE);
+ Rast_put_raster_row(cum_fd, cell, CELL_TYPE);
if (x_out)
- G_put_raster_row(x_fd, x_cell, CELL_TYPE);
+ Rast_put_raster_row(x_fd, x_cell, CELL_TYPE);
if (y_out)
- G_put_raster_row(y_fd, y_cell, CELL_TYPE);
+ Rast_put_raster_row(y_fd, y_cell, CELL_TYPE);
}
G_percent(row, nrows, 2);
}
Modified: grass/trunk/raster/r.spread/replaceHa.c
===================================================================
--- grass/trunk/raster/r.spread/replaceHa.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/replaceHa.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "costHa.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.spread/select_linksB.c
===================================================================
--- grass/trunk/raster/r.spread/select_linksB.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/select_linksB.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "costHa.h"
#include "cell_ptrHa.h"
#include "local_proto.h"
Modified: grass/trunk/raster/r.spread/spot.c
===================================================================
--- grass/trunk/raster/r.spread/spot.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/spot.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -44,6 +44,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "cmd_line.h"
#include "costHa.h"
#include "cell_ptrHa.h"
Modified: grass/trunk/raster/r.spread/spread.c
===================================================================
--- grass/trunk/raster/r.spread/spread.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spread/spread.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "cmd_line.h"
#include "costHa.h"
#include "cell_ptrHa.h"
Modified: grass/trunk/raster/r.spreadpath/insert.c
===================================================================
--- grass/trunk/raster/r.spreadpath/insert.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spreadpath/insert.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "point.h"
Modified: grass/trunk/raster/r.spreadpath/main.c
===================================================================
--- grass/trunk/raster/r.spreadpath/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.spreadpath/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -33,6 +33,7 @@
#include <fcntl.h>
#include <grass/segment.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "stash.h"
#include <grass/glocale.h>
@@ -164,14 +165,14 @@
nrows = G_window_rows();
ncols = G_window_cols();
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
/* Open back cell layers for reading */
- backrow_fd = G_open_cell_old(backrow_layer, backrow_mapset);
+ backrow_fd = Rast_open_cell_old(backrow_layer, backrow_mapset);
if (backrow_fd < 0)
G_fatal_error("%s - can't open raster map", backrow_layer);
- backcol_fd = G_open_cell_old(backcol_layer, backcol_mapset);
+ backcol_fd = Rast_open_cell_old(backcol_layer, backcol_mapset);
if (backcol_fd < 0)
G_fatal_error("%s - can't open raster map", backcol_layer);
@@ -210,7 +211,7 @@
/* Write the back cell layers in the segmented files, and
* Change UTM coordinates to ROWs and COLUMNs */
for (row = 0; row < nrows; row++) {
- if (G_get_map_row(backrow_fd, cell, row) < 0)
+ if (Rast_get_map_row(backrow_fd, cell, row) < 0)
G_fatal_error("unable to get map row %d", row);
for (col = 0; col < ncols; col++)
@@ -220,7 +221,7 @@
else
cell[col] = -1;
segment_put_row(&in_row_seg, cell, row);
- if (G_get_map_row(backcol_fd, cell, row) < 0)
+ if (Rast_get_map_row(backcol_fd, cell, row) < 0)
G_fatal_error("unable to get map row %d", row);
for (col = 0; col < ncols; col++)
@@ -276,13 +277,13 @@
/* If the output layer containing the starting positions */
/* create a linked list of of them */
if (flag == 1) {
- path_fd = G_open_cell_old(path_layer, path_mapset);
+ path_fd = Rast_open_cell_old(path_layer, path_mapset);
if (path_fd < 0)
G_fatal_error("%s -can't open raster map", path_layer);
/* Search for the marked starting pts and make list */
for (row = 0; row < nrows; row++) {
- if (G_get_map_row(path_fd, cell, row) < 0)
+ if (Rast_get_map_row(path_fd, cell, row) < 0)
G_fatal_error("unable to get map row %d", row);
for (col = 0; col < ncols; col++) {
@@ -304,7 +305,7 @@
} /* loop over cols */
} /* loop over rows */
- G_close_cell(path_fd);
+ Rast_close_cell(path_fd);
}
/* loop over the starting points to find the least cost paths */
@@ -327,10 +328,10 @@
if (verbose)
G_message("\nWriting the output map -%s-...", path_layer);
- path_fd = G_open_cell_new(path_layer);
+ path_fd = Rast_open_cell_new(path_layer);
for (row = 0; row < nrows; row++) {
segment_get_row(&out_seg, cell, row);
- if (G_put_raster_row(path_fd, cell, CELL_TYPE) < 0)
+ if (Rast_put_raster_row(path_fd, cell, CELL_TYPE) < 0)
G_fatal_error("unable to write map row %d", row);
}
@@ -345,9 +346,9 @@
close(in_col_fd);
close(out_fd);
- G_close_cell(path_fd);
- G_close_cell(backrow_fd);
- G_close_cell(backcol_fd);
+ Rast_close_cell(path_fd);
+ Rast_close_cell(backrow_fd);
+ Rast_close_cell(backcol_fd);
unlink(in_row_file); /* remove submatrix files */
unlink(in_col_file);
Modified: grass/trunk/raster/r.statistics/main.c
===================================================================
--- grass/trunk/raster/r.statistics/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -92,13 +93,13 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- if (G_raster_map_is_fp(basemap->answer, "") != 0)
+ if (Rast_raster_map_is_fp(basemap->answer, "") != 0)
G_fatal_error(_("This module currently only works for integer (CELL) maps"));
- if (G_raster_map_is_fp(covermap->answer, "") != 0)
+ if (Rast_raster_map_is_fp(covermap->answer, "") != 0)
G_fatal_error(_("This module currently only works for integer (CELL) maps"));
- if (G_read_cats(covermap->answer, "", &cats) < 0) {
+ if (Rast_read_cats(covermap->answer, "", &cats) < 0) {
G_fatal_error(_("Unable to read category file of raster map <%s>"),
covermap->answer);
}
Modified: grass/trunk/raster/r.statistics/o_adev.c
===================================================================
--- grass/trunk/raster/r.statistics/o_adev.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_adev.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -53,7 +54,7 @@
}
if (usecats)
- sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
+ sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
else
x = covercat;
Modified: grass/trunk/raster/r.statistics/o_average.c
===================================================================
--- grass/trunk/raster/r.statistics/o_average.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_average.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -53,7 +54,7 @@
catb = basecat;
}
if (usecats)
- sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
+ sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
else
x = covercat;
sum1 += x * area;
Modified: grass/trunk/raster/r.statistics/o_distrib.c
===================================================================
--- grass/trunk/raster/r.statistics/o_distrib.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_distrib.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
Modified: grass/trunk/raster/r.statistics/o_divr.c
===================================================================
--- grass/trunk/raster/r.statistics/o_divr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_divr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "method.h"
int
@@ -30,7 +31,7 @@
catc = 0;
}
if (basecat != catb) {
- write_reclass(reclass_fd, catb, catc, G_get_cat(catc, cats),
+ write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats),
usecats);
catb = basecat;
catc = 0;
@@ -38,7 +39,7 @@
catc++;
}
if (!first)
- write_reclass(reclass_fd, catb, catc, G_get_cat(catc, cats), usecats);
+ write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats), usecats);
pclose(stats_fd);
pclose(reclass_fd);
Modified: grass/trunk/raster/r.statistics/o_kurt.c
===================================================================
--- grass/trunk/raster/r.statistics/o_kurt.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_kurt.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -52,7 +53,7 @@
}
if (usecats)
- sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
+ sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
else
x = covercat;
Modified: grass/trunk/raster/r.statistics/o_max.c
===================================================================
--- grass/trunk/raster/r.statistics/o_max.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_max.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "method.h"
int
@@ -29,7 +30,7 @@
}
if (basecat != catb) {
- write_reclass(reclass, catb, catc, G_get_cat(catc, cats),
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats),
usecats);
catb = basecat;
catc = covercat;
@@ -43,7 +44,7 @@
catb = catc = 0;
}
- write_reclass(reclass, catb, catc, G_get_cat(catc, cats), usecats);
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats), usecats);
pclose(stats);
pclose(reclass);
Modified: grass/trunk/raster/r.statistics/o_median.c
===================================================================
--- grass/trunk/raster/r.statistics/o_median.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_median.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "method.h"
/* function prototypes */
@@ -41,7 +42,7 @@
}
if (basecat != catb) {
catc = median(&stats);
- write_reclass(reclass_fd, catb, catc, G_get_cat(catc, cats),
+ write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats),
usecats);
catb = basecat;
stats.n = 0;
@@ -59,7 +60,7 @@
}
if (!first) {
catc = median(&stats);
- write_reclass(reclass_fd, catb, catc, G_get_cat(catc, cats), usecats);
+ write_reclass(reclass_fd, catb, catc, Rast_get_cat(catc, cats), usecats);
}
pclose(stats_fd);
Modified: grass/trunk/raster/r.statistics/o_min.c
===================================================================
--- grass/trunk/raster/r.statistics/o_min.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_min.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "method.h"
int
@@ -29,7 +30,7 @@
}
if (basecat != catb) {
- write_reclass(reclass, catb, catc, G_get_cat(catc, cats),
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats),
usecats);
catb = basecat;
catc = covercat;
@@ -43,7 +44,7 @@
catb = catc = 0;
}
- write_reclass(reclass, catb, catc, G_get_cat(catc, cats), usecats);
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats), usecats);
pclose(stats);
pclose(reclass);
Modified: grass/trunk/raster/r.statistics/o_mode.c
===================================================================
--- grass/trunk/raster/r.statistics/o_mode.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_mode.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "method.h"
int
@@ -31,7 +32,7 @@
}
if (basecat != catb) {
- write_reclass(reclass, catb, catc, G_get_cat(catc, cats),
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats),
usecats);
catb = basecat;
catc = covercat;
@@ -48,7 +49,7 @@
catb = catc = 0;
}
- write_reclass(reclass, catb, catc, G_get_cat(catc, cats), usecats);
+ write_reclass(reclass, catb, catc, Rast_get_cat(catc, cats), usecats);
pclose(stats);
pclose(reclass);
Modified: grass/trunk/raster/r.statistics/o_sdev.c
===================================================================
--- grass/trunk/raster/r.statistics/o_sdev.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_sdev.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -55,7 +56,7 @@
}
if (usecats)
- sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
+ sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
else
x = covercat;
Modified: grass/trunk/raster/r.statistics/o_skew.c
===================================================================
--- grass/trunk/raster/r.statistics/o_skew.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_skew.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -54,7 +55,7 @@
}
if (usecats)
- sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
+ sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
else
x = covercat;
Modified: grass/trunk/raster/r.statistics/o_sum.c
===================================================================
--- grass/trunk/raster/r.statistics/o_sum.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_sum.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -55,7 +56,7 @@
catb = basecat;
}
if (usecats)
- sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
+ sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
else
x = covercat;
sum1 += x * area;
Modified: grass/trunk/raster/r.statistics/o_var.c
===================================================================
--- grass/trunk/raster/r.statistics/o_var.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/o_var.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "method.h"
@@ -55,7 +56,7 @@
}
if (usecats)
- sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
+ sscanf(Rast_get_cat((CELL) covercat, cats), "%lf", &x);
else
x = covercat;
Modified: grass/trunk/raster/r.statistics/read_stats.c
===================================================================
--- grass/trunk/raster/r.statistics/read_stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics/read_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.statistics2/main.c
===================================================================
--- grass/trunk/raster/r.statistics2/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics2/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/spawn.h>
#include <grass/glocale.h>
@@ -167,21 +168,21 @@
method = menu[i].val;
- base_fd = G_open_cell_old(basemap, "");
+ base_fd = Rast_open_cell_old(basemap, "");
if (base_fd < 0)
G_fatal_error(_("Unable to open base map <%s>"), basemap);
- cover_fd = G_open_cell_old(covermap, "");
+ cover_fd = Rast_open_cell_old(covermap, "");
if (cover_fd < 0)
G_fatal_error(_("Unable to open cover map <%s>"), covermap);
- if (usecats && G_read_cats(covermap, "", &cats) < 0)
+ if (usecats && Rast_read_cats(covermap, "", &cats) < 0)
G_fatal_error(_("Unable to read category file of cover map <%s>"), covermap);
- if (G_raster_map_is_fp(basemap, "") != 0)
+ if (Rast_raster_map_is_fp(basemap, "") != 0)
G_fatal_error(_("The base map must be an integer (CELL) map"));
- if (G_read_range(basemap, "", &range) < 0)
+ if (Rast_read_range(basemap, "", &range) < 0)
G_fatal_error(_("Unable to read range of base map <%s>"), basemap);
mincat = range.min;
@@ -243,22 +244,22 @@
for (i = 0; i < ncats; i++)
max[i] = -1e300;
- base_buf = G_allocate_c_raster_buf();
- cover_buf = G_allocate_d_raster_buf();
+ base_buf = Rast_allocate_c_raster_buf();
+ cover_buf = Rast_allocate_d_raster_buf();
G_message(_("First pass"));
for (row = 0; row < rows; row++) {
- G_get_c_raster_row(base_fd, base_buf, row);
- G_get_d_raster_row(cover_fd, cover_buf, row);
+ Rast_get_c_raster_row(base_fd, base_buf, row);
+ Rast_get_d_raster_row(cover_fd, cover_buf, row);
for (col = 0; col < cols; col++) {
int n;
DCELL v;
- if (G_is_c_null_value(&base_buf[col]))
+ if (Rast_is_c_null_value(&base_buf[col]))
continue;
- if (G_is_d_null_value(&cover_buf[col]))
+ if (Rast_is_d_null_value(&cover_buf[col]))
continue;
n = base_buf[col] - mincat;
@@ -268,7 +269,7 @@
v = cover_buf[col];
if (usecats)
- sscanf(G_get_cat((CELL) v, &cats), "%lf", &v);
+ sscanf(Rast_get_cat((CELL) v, &cats), "%lf", &v);
if (count)
count[n]++;
@@ -328,16 +329,16 @@
G_message(_("Second pass"));
for (row = 0; row < rows; row++) {
- G_get_c_raster_row(base_fd, base_buf, row);
- G_get_d_raster_row(cover_fd, cover_buf, row);
+ Rast_get_c_raster_row(base_fd, base_buf, row);
+ Rast_get_d_raster_row(cover_fd, cover_buf, row);
for (col = 0; col < cols; col++) {
int n;
DCELL v, d;
- if (G_is_c_null_value(&base_buf[col]))
+ if (Rast_is_c_null_value(&base_buf[col]))
continue;
- if (G_is_d_null_value(&cover_buf[col]))
+ if (Rast_is_d_null_value(&cover_buf[col]))
continue;
n = base_buf[col] - mincat;
@@ -347,7 +348,7 @@
v = cover_buf[col];
if (usecats)
- sscanf(G_get_cat((CELL) v, &cats), "%lf", &v);
+ sscanf(Rast_get_cat((CELL) v, &cats), "%lf", &v);
d = v - mean[n];
if (sumu)
@@ -495,32 +496,32 @@
G_message(_("Writing output map"));
- out_fd = G_open_fp_cell_new(output);
+ out_fd = Rast_open_fp_cell_new(output);
if (out_fd < 0)
G_fatal_error(_("Unable to open output map <%s>"), output);
- out_buf = G_allocate_d_raster_buf();
+ out_buf = Rast_allocate_d_raster_buf();
for (row = 0; row < rows; row++) {
- G_get_c_raster_row(base_fd, base_buf, row);
+ Rast_get_c_raster_row(base_fd, base_buf, row);
for (col = 0; col < cols; col++)
- if (G_is_c_null_value(&base_buf[col]))
- G_set_d_null_value(&out_buf[col], 1);
+ if (Rast_is_c_null_value(&base_buf[col]))
+ Rast_set_d_null_value(&out_buf[col], 1);
else
out_buf[col] = result[base_buf[col] - mincat];
- G_put_d_raster_row(out_fd, out_buf);
+ Rast_put_d_raster_row(out_fd, out_buf);
G_percent(row, rows, 2);
}
G_percent(row, rows, 2);
- G_close_cell(out_fd);
+ Rast_close_cell(out_fd);
- if (G_read_colors(covermap, "", &colors) > 0)
- G_write_colors(output, G_mapset(), &colors);
+ if (Rast_read_colors(covermap, "", &colors) > 0)
+ Rast_write_colors(output, G_mapset(), &colors);
}
return 0;
Modified: grass/trunk/raster/r.statistics3/main.c
===================================================================
--- grass/trunk/raster/r.statistics3/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.statistics3/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -14,6 +14,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/spawn.h>
@@ -68,24 +69,24 @@
static void get_slot_counts(int basefile, int coverfile)
{
- CELL *basebuf = G_allocate_c_raster_buf();
- DCELL *coverbuf = G_allocate_d_raster_buf();
+ CELL *basebuf = Rast_allocate_c_raster_buf();
+ DCELL *coverbuf = Rast_allocate_d_raster_buf();
int row, col;
G_message(_("Computing histograms"));
for (row = 0; row < rows; row++) {
- G_get_c_raster_row(basefile, basebuf, row);
- G_get_d_raster_row(coverfile, coverbuf, row);
+ Rast_get_c_raster_row(basefile, basebuf, row);
+ Rast_get_d_raster_row(coverfile, coverbuf, row);
for (col = 0; col < cols; col++) {
struct basecat *bc;
int i;
- if (G_is_c_null_value(&basebuf[col]))
+ if (Rast_is_c_null_value(&basebuf[col]))
continue;
- if (G_is_d_null_value(&coverbuf[col]))
+ if (Rast_is_d_null_value(&coverbuf[col]))
continue;
i = get_slot(coverbuf[col]);
@@ -158,25 +159,25 @@
static void fill_bins(int basefile, int coverfile)
{
- CELL *basebuf = G_allocate_c_raster_buf();
- DCELL *coverbuf = G_allocate_d_raster_buf();
+ CELL *basebuf = Rast_allocate_c_raster_buf();
+ DCELL *coverbuf = Rast_allocate_d_raster_buf();
int row, col;
G_message(_("Binning data"));
for (row = 0; row < rows; row++) {
- G_get_c_raster_row(basefile, basebuf, row);
- G_get_d_raster_row(coverfile, coverbuf, row);
+ Rast_get_c_raster_row(basefile, basebuf, row);
+ Rast_get_d_raster_row(coverfile, coverbuf, row);
for (col = 0; col < cols; col++) {
struct basecat *bc;
int i, bin;
struct bin *b;
- if (G_is_c_null_value(&basebuf[col]))
+ if (Rast_is_c_null_value(&basebuf[col]))
continue;
- if (G_is_d_null_value(&coverbuf[col]))
+ if (Rast_is_d_null_value(&coverbuf[col]))
continue;
i = get_slot(coverbuf[col]);
@@ -321,8 +322,8 @@
static void do_output(int base_fd, char **outputs, const char *covermap)
{
int *out_fd = G_malloc(num_quants * sizeof(int));
- CELL *base_buf = G_allocate_c_raster_buf();
- DCELL *out_buf = G_allocate_d_raster_buf();
+ CELL *base_buf = Rast_allocate_c_raster_buf();
+ DCELL *out_buf = Rast_allocate_d_raster_buf();
const char *mapset = G_mapset();
struct Colors colors;
int have_colors;
@@ -334,24 +335,24 @@
for (quant = 0; quant < num_quants; quant++) {
const char *output = outputs[quant];
- out_fd[quant] = G_open_fp_cell_new(output);
+ out_fd[quant] = Rast_open_fp_cell_new(output);
if (out_fd[quant] < 0)
G_fatal_error(_("Unable to open output map <%s>"), output);
}
- have_colors = G_read_colors(covermap, "", &colors) > 0;
+ have_colors = Rast_read_colors(covermap, "", &colors) > 0;
for (row = 0; row < rows; row++) {
- G_get_c_raster_row(base_fd, base_buf, row);
+ Rast_get_c_raster_row(base_fd, base_buf, row);
for (quant = 0; quant < num_quants; quant++) {
for (col = 0; col < cols; col++)
- if (G_is_c_null_value(&base_buf[col]))
- G_set_d_null_value(&out_buf[col], 1);
+ if (Rast_is_c_null_value(&base_buf[col]))
+ Rast_set_d_null_value(&out_buf[col], 1);
else
out_buf[col] = basecats[base_buf[col] - min].quants[quant];
- G_put_d_raster_row(out_fd[quant], out_buf);
+ Rast_put_d_raster_row(out_fd[quant], out_buf);
}
G_percent(row, rows, 2);
@@ -360,9 +361,9 @@
G_percent(row, rows, 2);
for (quant = 0; quant < num_quants; quant++) {
- G_close_cell(out_fd[quant]);
+ Rast_close_cell(out_fd[quant]);
if (have_colors)
- G_write_colors(outputs[quant], mapset, &colors);
+ Rast_write_colors(outputs[quant], mapset, &colors);
}
}
@@ -470,28 +471,28 @@
num_quants, i);
}
- base_fd = G_open_cell_old(basemap, "");
+ base_fd = Rast_open_cell_old(basemap, "");
if (base_fd < 0)
G_fatal_error(_("Unable to open base map <%s>"), basemap);
- cover_fd = G_open_cell_old(covermap, "");
+ cover_fd = Rast_open_cell_old(covermap, "");
if (cover_fd < 0)
G_fatal_error(_("Unable to open cover map <%s>"), covermap);
- if (G_raster_map_is_fp(basemap, "") != 0)
+ if (Rast_raster_map_is_fp(basemap, "") != 0)
G_fatal_error(_("The base map must be an integer (CELL) map"));
- if (G_read_range(basemap, "", &range) < 0)
+ if (Rast_read_range(basemap, "", &range) < 0)
G_fatal_error(_("Unable to read range of base map <%s>"), basemap);
- G_get_range_min_max(&range, &min, &max);
+ Rast_get_range_min_max(&range, &min, &max);
num_cats = max - min + 1;
if (num_cats > MAX_CATS)
G_fatal_error(_("Base map <%s> has too many categories (max: %d)"),
basemap, MAX_CATS);
- G_read_fp_range(covermap, "", &fprange);
- G_get_fp_range_min_max(&fprange, &f_min, &f_max);
+ Rast_read_fp_range(covermap, "", &fprange);
+ Rast_get_fp_range_min_max(&fprange, &f_min, &f_max);
slot_size = (f_max - f_min) / num_slots;
basecats = G_calloc(num_cats, sizeof(struct basecat));
@@ -518,8 +519,8 @@
else
do_output(base_fd, outputs, covermap);
- G_close_cell(cover_fd);
- G_close_cell(base_fd);
+ Rast_close_cell(cover_fd);
+ Rast_close_cell(base_fd);
return (EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.stats/cell_stats.c
===================================================================
--- grass/trunk/raster/r.stats/cell_stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.stats/cell_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,7 +16,7 @@
/* allocate i/o buffers for each raster map */
cell = (CELL **) G_calloc(nfiles, sizeof(CELL *));
for (i = 0; i < nfiles; i++)
- cell[i] = G_allocate_cell_buf();
+ cell[i] = Rast_allocate_cell_buf();
/* if we want area totals, set this up.
* distinguish projections which are planimetric (all cells same size)
@@ -47,7 +47,7 @@
G_percent(row, nrows, 2);
for (i = 0; i < nfiles; i++) {
- if (G_get_c_raster_row(fd[i], cell[i], row) < 0)
+ if (Rast_get_c_raster_row(fd[i], cell[i], row) < 0)
G_fatal_error(_("Unable to read raster <map %d of %d> row %d"),
i+1, nfiles, row);
Modified: grass/trunk/raster/r.stats/global.h
===================================================================
--- grass/trunk/raster/r.stats/global.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.stats/global.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
extern char *no_data_str;
extern int nfiles;
Modified: grass/trunk/raster/r.stats/main.c
===================================================================
--- grass/trunk/raster/r.stats/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.stats/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -269,11 +269,11 @@
DMAX = (DCELL *) G_realloc(DMAX, (nfiles + 1) * sizeof(DCELL));
DMIN = (DCELL *) G_realloc(DMIN, (nfiles + 1) * sizeof(DCELL));
- fd[nfiles] = G_open_cell_old(name, "");
+ fd[nfiles] = Rast_open_cell_old(name, "");
if (fd[nfiles] < 0)
exit(1);
if (!as_int)
- is_fp[nfiles] = G_raster_map_is_fp(name, "");
+ is_fp[nfiles] = Rast_raster_map_is_fp(name, "");
else {
is_fp[nfiles] = 0;
if (cat_ranges || nsteps != 255)
@@ -284,15 +284,15 @@
if (with_labels || (cat_ranges && is_fp[nfiles])) {
labels = (struct Categories *)
G_realloc(labels, (nfiles + 1) * sizeof(struct Categories));
- if (G_read_cats(name, "", &labels[nfiles]) < 0)
- G_init_cats((CELL) 0, "", &labels[nfiles]);
+ if (Rast_read_cats(name, "", &labels[nfiles]) < 0)
+ Rast_init_cats((CELL) 0, "", &labels[nfiles]);
}
if (is_fp[nfiles])
/* floating point map */
{
- G_quant_init(&q);
+ Rast_quant_init(&q);
if (cat_ranges) {
- if (!G_quant_nof_rules(&labels[nfiles].q)) {
+ if (!Rast_quant_nof_rules(&labels[nfiles].q)) {
G_warning(_("Cats for raster map <%s> are either missing or have no explicit labels. "
"Using %s=%d."),
name, option.nsteps->key, nsteps);
@@ -304,36 +304,36 @@
flag.C->key, name, option.nsteps->key);
}
if (!cat_ranges) { /* DO NOT use else here, cat_ranges can change */
- if (G_read_fp_range(name, "", &fp_range) < 0)
+ if (Rast_read_fp_range(name, "", &fp_range) < 0)
G_fatal_error(_("Unable to read fp range of raster map <%s>"),
name);
- G_get_fp_range_min_max(&fp_range, &DMIN[nfiles],
+ Rast_get_fp_range_min_max(&fp_range, &DMIN[nfiles],
&DMAX[nfiles]);
G_debug(3, "file %2d: dmin=%f dmax=%f", nfiles, DMIN[nfiles],
DMAX[nfiles]);
- G_quant_add_rule(&q, DMIN[nfiles], DMAX[nfiles], 1, nsteps+1);
+ Rast_quant_add_rule(&q, DMIN[nfiles], DMAX[nfiles], 1, nsteps+1);
/* set the quant rules for reading the map */
- G_set_quant_rules(fd[nfiles], &q);
- G_quant_get_limits(&q, &dmin, &dmax, &min, &max);
+ Rast_set_quant_rules(fd[nfiles], &q);
+ Rast_quant_get_limits(&q, &dmin, &dmax, &min, &max);
G_debug(2, "overall: dmin=%f dmax=%f, qmin=%d qmax=%d",
dmin, dmax, min, max);
- G_quant_free(&q);
+ Rast_quant_free(&q);
}
else { /* cats ranges */
/* set the quant rules for reading the map */
- G_set_quant_rules(fd[nfiles], &labels[nfiles].q);
- G_quant_get_limits(&labels[nfiles].q, &dmin, &dmax, &min,
+ Rast_set_quant_rules(fd[nfiles], &labels[nfiles].q);
+ Rast_quant_get_limits(&labels[nfiles].q, &dmin, &dmax, &min,
&max);
}
}
else {
- if (G_read_range(name, "", &range) < 0)
+ if (Rast_read_range(name, "", &range) < 0)
G_fatal_error(_("Unable to read range for map <%s>"), name);
- G_get_range_min_max(&range, &min, &max);
+ Rast_get_range_min_max(&range, &min, &max);
}
if (!null_set) {
null_set = 1;
Modified: grass/trunk/raster/r.stats/raw_stats.c
===================================================================
--- grass/trunk/raster/r.stats/raw_stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.stats/raw_stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "global.h"
int raw_stats(int fd[], int with_coordinates, int with_xy, int with_labels)
@@ -24,7 +25,7 @@
map_type[i] = DCELL_TYPE;
else
map_type[i] = CELL_TYPE;
- rast[i] = G_allocate_raster_buf(map_type[i]);
+ rast[i] = Rast_allocate_raster_buf(map_type[i]);
}
/* get window */
@@ -32,13 +33,13 @@
G_get_set_window(&window);
/* here we go */
- G_set_c_null_value(&null_cell, 1);
+ Rast_set_c_null_value(&null_cell, 1);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
/* read the rows and set the pointers */
for (i = 0; i < nfiles; i++) {
- if (G_get_raster_row(fd[i], rast[i], row, map_type[i]) < 0)
+ if (Rast_get_raster_row(fd[i], rast[i], row, map_type[i]) < 0)
exit(1);
rastp[i] = rast[i];
}
@@ -52,18 +53,18 @@
nulls_found = 0;
for (i = 0; i < nfiles; i++) {
/*
- G_set_raster_value_d(zero_val, 0.0, map_type[i]);
- if (G_raster_cmp(rastp[i], zero_val, map_type[i]) != 0)
+ Rast_set_raster_value_d(zero_val, 0.0, map_type[i]);
+ if (Rast_raster_cmp(rastp[i], zero_val, map_type[i]) != 0)
break;
*/
- if (G_is_null_value(rastp[i], map_type[i]))
+ if (Rast_is_null_value(rastp[i], map_type[i]))
nulls_found++;
}
if ((nulls_found == nfiles) || (nulls_found && no_nulls)) {
for (i = 0; i < nfiles; i++)
- rastp[i] = G_incr_void_ptr(rastp[i],
- G_raster_size(map_type
+ rastp[i] = Rast_incr_void_ptr(rastp[i],
+ Rast_raster_size(map_type
[i]));
continue;
}
@@ -77,18 +78,18 @@
fprintf(stdout, "%d%s%d%s", col + 1, fs, row + 1, fs);
for (i = 0; i < nfiles; i++) {
- if (G_is_null_value(rastp[i], map_type[i])) {
+ if (Rast_is_null_value(rastp[i], map_type[i])) {
fprintf(stdout, "%s%s", i ? fs : "", no_data_str);
if (with_labels)
fprintf(stdout, "%s%s", fs,
- G_get_cat(null_cell, &labels[i]));
+ Rast_get_cat(null_cell, &labels[i]));
}
else if (map_type[i] == CELL_TYPE) {
fprintf(stdout, "%s%ld", i ? fs : "",
(long)*((CELL *) rastp[i]));
if (with_labels && !is_fp[i])
fprintf(stdout, "%s%s", fs,
- G_get_cat(*((CELL *) rastp[i]), &labels[i]));
+ Rast_get_cat(*((CELL *) rastp[i]), &labels[i]));
}
else { /* floating point cell */
@@ -98,11 +99,11 @@
fprintf(stdout, "%s%s", i ? fs : "", str1);
if (with_labels)
fprintf(stdout, "%s%s", fs,
- G_get_d_raster_cat((DCELL *) rastp[i],
+ Rast_get_d_raster_cat((DCELL *) rastp[i],
&labels[i]));
}
rastp[i] =
- G_incr_void_ptr(rastp[i], G_raster_size(map_type[i]));
+ Rast_incr_void_ptr(rastp[i], Rast_raster_size(map_type[i]));
}
fprintf(stdout, "\n");
}
Modified: grass/trunk/raster/r.stats/stats.c
===================================================================
--- grass/trunk/raster/r.stats/stats.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.stats/stats.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -88,7 +88,7 @@
}
-/* Essentially, G_quant_add_rule() treats the ranges as half-open,
+/* Essentially, Rast_quant_add_rule() treats the ranges as half-open,
* i.e. the values range from low (inclusive) to high (exclusive).
* While half-open ranges are a common concept (e.g. floor() behaves
* the same way), the range of a GRASS raster is closed, i.e. both the
@@ -112,7 +112,7 @@
void reset_null_vals(CELL *cell, int ncols)
{
while (ncols-- > 0) {
- if (G_is_c_null_value(&cell[ncols]))
+ if (Rast_is_c_null_value(&cell[ncols]))
cell[ncols] = NULL_CELL;
}
return;
@@ -230,7 +230,7 @@
if (no_nulls)
total_count -= sorted_list[node_count - 1]->count;
- G_set_c_null_value(&null_cell, 1);
+ Rast_set_c_null_value(&null_cell, 1);
if (node_count <= 0) {
fprintf(stdout, "0");
for (i = 1; i < nfiles; i++)
@@ -242,7 +242,7 @@
if (with_percents)
fprintf(stdout, "%s0.00%%", fs);
if (with_labels)
- fprintf(stdout, "%s%s", fs, G_get_cat(null_cell, &labels[i]));
+ fprintf(stdout, "%s%s", fs, Rast_get_cat(null_cell, &labels[i]));
fprintf(stdout, "\n");
}
else {
@@ -271,20 +271,20 @@
fprintf(stdout, "%s%s", i ? fs : "", no_data_str);
if (with_labels && !(raw_output && is_fp[i]))
fprintf(stdout, "%s%s", fs,
- G_get_cat(null_cell, &labels[i]));
+ Rast_get_cat(null_cell, &labels[i]));
}
else if (raw_output || !is_fp[i] || as_int) {
fprintf(stdout, "%s%ld", i ? fs : "",
(long)node->values[i]);
if (with_labels && !is_fp[i])
fprintf(stdout, "%s%s", fs,
- G_get_cat((CELL) node->values[i],
+ Rast_get_cat((CELL) node->values[i],
&labels[i]));
}
else { /* find out which floating point range to print */
if (cat_ranges)
- G_quant_get_ith_rule(&labels[i].q, node->values[i],
+ Rast_quant_get_ith_rule(&labels[i].q, node->values[i],
&dLow, &dHigh, &tmp_cell,
&tmp_cell);
else {
@@ -316,8 +316,8 @@
labels[i].labels[node->values[i]]);
else
fprintf(stdout, "%sfrom %s to %s", fs,
- G_get_d_raster_cat(&dLow, &labels[i]),
- G_get_d_raster_cat(&dHigh, &labels[i]));
+ Rast_get_d_raster_cat(&dLow, &labels[i]),
+ Rast_get_d_raster_cat(&dHigh, &labels[i]));
}
}
Modified: grass/trunk/raster/r.sun/main.c
===================================================================
--- grass/trunk/raster/r.sun/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.sun/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -500,9 +500,9 @@
int fr1, fr2;
int l, i, j;
- cell1 = G_allocate_f_raster_buf();
- cell2 = G_allocate_f_raster_buf();
- cell3 = G_allocate_f_raster_buf();
+ cell1 = Rast_allocate_f_raster_buf();
+ cell2 = Rast_allocate_f_raster_buf();
+ cell3 = Rast_allocate_f_raster_buf();
z = (float **)G_malloc(sizeof(float *) * (m));
o = (float **)G_malloc(sizeof(float *) * (m));
@@ -515,121 +515,121 @@
}
- fd1 = G_open_cell_old(elevin, "");
- fd2 = G_open_cell_old(aspin, "");
- fd3 = G_open_cell_old(slopein, "");
+ fd1 = Rast_open_cell_old(elevin, "");
+ fd2 = Rast_open_cell_old(aspin, "");
+ fd3 = Rast_open_cell_old(slopein, "");
if (linkein != NULL) {
- cell4 = G_allocate_f_raster_buf();
+ cell4 = Rast_allocate_f_raster_buf();
li = (float **)G_malloc(sizeof(float *) * (m));
for (l = 0; l < m; l++)
li[l] = (float *)G_malloc(sizeof(float) * (n));
- fd4 = G_open_cell_old(linkein, "");
+ fd4 = Rast_open_cell_old(linkein, "");
}
if (albedo != NULL) {
- cell5 = G_allocate_f_raster_buf();
+ cell5 = Rast_allocate_f_raster_buf();
a = (float **)G_malloc(sizeof(float *) * (m));
for (l = 0; l < m; l++)
a[l] = (float *)G_malloc(sizeof(float) * (n));
- fd5 = G_open_cell_old(albedo, "");
+ fd5 = Rast_open_cell_old(albedo, "");
}
if (latin != NULL) {
- cell6 = G_allocate_f_raster_buf();
+ cell6 = Rast_allocate_f_raster_buf();
la = (float **)G_malloc(sizeof(float *) * (m));
for (l = 0; l < m; l++)
la[l] = (float *)G_malloc(sizeof(float) * (n));
- fd6 = G_open_cell_old(latin, "");
+ fd6 = Rast_open_cell_old(latin, "");
}
if (coefbh != NULL) {
- rast1 = G_allocate_f_raster_buf();
+ rast1 = Rast_allocate_f_raster_buf();
cbhr = (float **)G_malloc(sizeof(float *) * (m));
for (l = 0; l < m; l++)
cbhr[l] = (float *)G_malloc(sizeof(float) * (n));
- fr1 = G_open_cell_old(coefbh, "");
+ fr1 = Rast_open_cell_old(coefbh, "");
}
if (coefdh != NULL) {
- rast2 = G_allocate_f_raster_buf();
+ rast2 = Rast_allocate_f_raster_buf();
cdhr = (float **)G_malloc(sizeof(float *) * (m));
for (l = 0; l < m; l++)
cdhr[l] = (float *)G_malloc(sizeof(float) * (n));
- fr2 = G_open_cell_old(coefdh, "");
+ fr2 = Rast_open_cell_old(coefdh, "");
}
for (row = 0; row < m; row++) {
- G_get_f_raster_row(fd1, cell1, row);
- G_get_f_raster_row(fd2, cell2, row);
- G_get_f_raster_row(fd3, cell3, row);
+ Rast_get_f_raster_row(fd1, cell1, row);
+ Rast_get_f_raster_row(fd2, cell2, row);
+ Rast_get_f_raster_row(fd3, cell3, row);
if (linkein != NULL)
- G_get_f_raster_row(fd4, cell4, row);
+ Rast_get_f_raster_row(fd4, cell4, row);
if (albedo != NULL)
- G_get_f_raster_row(fd5, cell5, row);
+ Rast_get_f_raster_row(fd5, cell5, row);
if (latin != NULL)
- G_get_f_raster_row(fd6, cell6, row);
+ Rast_get_f_raster_row(fd6, cell6, row);
if (coefbh != NULL)
- G_get_f_raster_row(fr1, rast1, row);
+ Rast_get_f_raster_row(fr1, rast1, row);
if (coefdh != NULL)
- G_get_f_raster_row(fr2, rast2, row);
+ Rast_get_f_raster_row(fr2, rast2, row);
for (j = 0; j < n; j++) {
row_rev = m - row - 1;
- if (!G_is_f_null_value(cell1 + j))
+ if (!Rast_is_f_null_value(cell1 + j))
z[row_rev][j] = (float)cell1[j];
else
z[row_rev][j] = UNDEFZ;
- if (!G_is_f_null_value(cell2 + j))
+ if (!Rast_is_f_null_value(cell2 + j))
o[row_rev][j] = (float)cell2[j];
else
o[row_rev][j] = UNDEFZ;
- if (!G_is_f_null_value(cell3 + j))
+ if (!Rast_is_f_null_value(cell3 + j))
s[row_rev][j] = (float)cell3[j];
else
s[row_rev][j] = UNDEFZ;
if (linkein != NULL) {
- if (!G_is_f_null_value(cell4 + j))
+ if (!Rast_is_f_null_value(cell4 + j))
li[row_rev][j] = (float)cell4[j];
else
li[row_rev][j] = UNDEFZ;
}
if (albedo != NULL) {
- if (!G_is_f_null_value(cell5 + j))
+ if (!Rast_is_f_null_value(cell5 + j))
a[row_rev][j] = (float)cell5[j];
else
a[row_rev][j] = UNDEFZ;
}
if (latin != NULL) {
- if (!G_is_f_null_value(cell6 + j))
+ if (!Rast_is_f_null_value(cell6 + j))
la[row_rev][j] = (float)cell6[j];
else
la[row_rev][j] = UNDEFZ;
}
if (coefbh != NULL) {
- if (!G_is_f_null_value(rast1 + j))
+ if (!Rast_is_f_null_value(rast1 + j))
cbhr[row_rev][j] = (float)rast1[j];
else
cbhr[row_rev][j] = UNDEFZ;
}
if (coefdh != NULL) {
- if (!G_is_f_null_value(rast2 + j))
+ if (!Rast_is_f_null_value(rast2 + j))
cdhr[row_rev][j] = (float)rast2[j];
else
cdhr[row_rev][j] = UNDEFZ;
@@ -638,19 +638,19 @@
}
}
- G_close_cell(fd1);
- G_close_cell(fd2);
- G_close_cell(fd3);
+ Rast_close_cell(fd1);
+ Rast_close_cell(fd2);
+ Rast_close_cell(fd3);
if (linkein != NULL)
- G_close_cell(fd4);
+ Rast_close_cell(fd4);
if (albedo != NULL)
- G_close_cell(fd5);
+ Rast_close_cell(fd5);
if (latin != NULL)
- G_close_cell(fd6);
+ Rast_close_cell(fd6);
if (coefbh != NULL)
- G_close_cell(fr1);
+ Rast_close_cell(fr1);
if (coefdh != NULL)
- G_close_cell(fr2);
+ Rast_close_cell(fr2);
/*******transformation of angles from 0 to east counterclock
to 0 to north clocwise, for ori=0 upslope flowlines
@@ -696,36 +696,36 @@
int i, iarc, j;
if (incidout != NULL) {
- cell7 = G_allocate_f_raster_buf();
- fd7 = G_open_fp_cell_new(incidout);
+ cell7 = Rast_allocate_f_raster_buf();
+ fd7 = Rast_open_fp_cell_new(incidout);
if (fd7 < 0)
G_fatal_error(_("Unable to create raster map %s"), incidout);
}
if (beam_rad != NULL) {
- cell8 = G_allocate_f_raster_buf();
- fd8 = G_open_fp_cell_new(beam_rad);
+ cell8 = Rast_allocate_f_raster_buf();
+ fd8 = Rast_open_fp_cell_new(beam_rad);
if (fd8 < 0)
G_fatal_error(_("Unable to create raster map %s"), beam_rad);
}
if (insol_time != NULL) {
- cell11 = G_allocate_f_raster_buf();
- fd11 = G_open_fp_cell_new(insol_time);
+ cell11 = Rast_allocate_f_raster_buf();
+ fd11 = Rast_open_fp_cell_new(insol_time);
if (fd11 < 0)
G_fatal_error(_("Unable to create raster map %s"), insol_time);
}
if (diff_rad != NULL) {
- cell9 = G_allocate_f_raster_buf();
- fd9 = G_open_fp_cell_new(diff_rad);
+ cell9 = Rast_allocate_f_raster_buf();
+ fd9 = Rast_open_fp_cell_new(diff_rad);
if (fd9 < 0)
G_fatal_error(_("Unable to create raster map %s"), diff_rad);
}
if (refl_rad != NULL) {
- cell10 = G_allocate_f_raster_buf();
- fd10 = G_open_fp_cell_new(refl_rad);
+ cell10 = Rast_allocate_f_raster_buf();
+ fd10 = Rast_open_fp_cell_new(refl_rad);
if (fd10 < 0)
G_fatal_error(_("Unable to create raster map %s"), refl_rad);
}
@@ -746,76 +746,76 @@
if (incidout != NULL) {
for (j = 0; j < n; j++) {
if (lumcl[i][j] == UNDEFZ)
- G_set_f_null_value(cell7 + j, 1);
+ Rast_set_f_null_value(cell7 + j, 1);
else
cell7[j] = (FCELL) lumcl[i][j];
}
- G_put_f_raster_row(fd7, cell7);
+ Rast_put_f_raster_row(fd7, cell7);
}
if (beam_rad != NULL) {
for (j = 0; j < n; j++) {
if (beam[i][j] == UNDEFZ)
- G_set_f_null_value(cell8 + j, 1);
+ Rast_set_f_null_value(cell8 + j, 1);
else
cell8[j] = (FCELL) beam[i][j];
}
- G_put_f_raster_row(fd8, cell8);
+ Rast_put_f_raster_row(fd8, cell8);
}
if (insol_time != NULL) {
for (j = 0; j < n; j++) {
if (insol[i][j] == UNDEFZ)
- G_set_f_null_value(cell11 + j, 1);
+ Rast_set_f_null_value(cell11 + j, 1);
else
cell11[j] = (FCELL) insol[i][j];
}
- G_put_f_raster_row(fd11, cell11);
+ Rast_put_f_raster_row(fd11, cell11);
}
if (diff_rad != NULL) {
for (j = 0; j < n; j++) {
if (diff[i][j] == UNDEFZ)
- G_set_f_null_value(cell9 + j, 1);
+ Rast_set_f_null_value(cell9 + j, 1);
else
cell9[j] = (FCELL) diff[i][j];
}
- G_put_f_raster_row(fd9, cell9);
+ Rast_put_f_raster_row(fd9, cell9);
}
if (refl_rad != NULL) {
for (j = 0; j < n; j++) {
if (refl[i][j] == UNDEFZ)
- G_set_f_null_value(cell10 + j, 1);
+ Rast_set_f_null_value(cell10 + j, 1);
else
cell10[j] = (FCELL) refl[i][j];
}
- G_put_f_raster_row(fd10, cell10);
+ Rast_put_f_raster_row(fd10, cell10);
}
}
if (incidout != NULL) {
- G_close_cell(fd7);
- G_write_history(incidout, &hist);
+ Rast_close_cell(fd7);
+ Rast_write_history(incidout, &hist);
}
if (beam_rad != NULL) {
- G_close_cell(fd8);
- G_write_history(beam_rad, &hist);
+ Rast_close_cell(fd8);
+ Rast_write_history(beam_rad, &hist);
}
if (diff_rad != NULL) {
- G_close_cell(fd9);
- G_write_history(diff_rad, &hist);
+ Rast_close_cell(fd9);
+ Rast_write_history(diff_rad, &hist);
}
if (refl_rad != NULL) {
- G_close_cell(fd10);
- G_write_history(refl_rad, &hist);
+ Rast_close_cell(fd10);
+ Rast_write_history(refl_rad, &hist);
}
if (insol_time != NULL) {
- G_close_cell(fd11);
- G_write_history(insol_time, &hist);
+ Rast_close_cell(fd11);
+ Rast_write_history(insol_time, &hist);
}
return 1;
@@ -1378,7 +1378,7 @@
}
- G_short_history("r.sun solar model output", "raster", &hist);
+ Rast_short_history("r.sun solar model output", "raster", &hist);
sprintf(hist.edhist[0],
" ----------------------------------------------------------------");
@@ -1463,8 +1463,8 @@
" -----------------------------------------------------------------");
hist.edlinecnt++;
- G_command_history(&hist);
- /* don't call G_write_history() until after G_close_cell() or it just gets overwritten */
+ Rast_command_history(&hist);
+ /* don't call Rast_write_history() until after Rast_close_cell() or it just gets overwritten */
}
double com_sol_const(int no_of_day)
Modified: grass/trunk/raster/r.sun2/main.c
===================================================================
--- grass/trunk/raster/r.sun2/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.sun2/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
#include "sunradstruct.h"
@@ -796,7 +797,7 @@
numRows = m / numPartitions;
- cell1 = G_allocate_f_raster_buf();
+ cell1 = Rast_allocate_f_raster_buf();
if (z == NULL) {
z = (float **)G_malloc(sizeof(float *) * (numRows));
@@ -812,10 +813,10 @@
G_fatal_error(_("Raster map <%s> not found"), elevin);
- fd1 = G_open_cell_old(elevin, mapset);
+ fd1 = Rast_open_cell_old(elevin, mapset);
if (slopein != NULL) {
- cell3 = G_allocate_f_raster_buf();
+ cell3 = Rast_allocate_f_raster_buf();
if (s == NULL) {
s = (float **)G_malloc(sizeof(float *) * (numRows));
@@ -825,12 +826,12 @@
}
if ((mapset = G_find_cell2(slopein, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), slopein);
- fd3 = G_open_cell_old(slopein, mapset);
+ fd3 = Rast_open_cell_old(slopein, mapset);
}
if (aspin != NULL) {
- cell2 = G_allocate_f_raster_buf();
+ cell2 = Rast_allocate_f_raster_buf();
if (o == NULL) {
o = (float **)G_malloc(sizeof(float *) * (numRows));
@@ -842,12 +843,12 @@
if ((mapset = G_find_cell2(aspin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), aspin);
- fd2 = G_open_cell_old(aspin, mapset);
+ fd2 = Rast_open_cell_old(aspin, mapset);
}
if (linkein != NULL) {
- cell4 = G_allocate_f_raster_buf();
+ cell4 = Rast_allocate_f_raster_buf();
if (li == NULL) {
li = (float **)G_malloc(sizeof(float *) * (numRows));
for (l = 0; l < numRows; l++)
@@ -856,11 +857,11 @@
}
if ((mapset = G_find_cell2(linkein, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), linkein);
- fd4 = G_open_cell_old(linkein, mapset);
+ fd4 = Rast_open_cell_old(linkein, mapset);
}
if (albedo != NULL) {
- cell5 = G_allocate_f_raster_buf();
+ cell5 = Rast_allocate_f_raster_buf();
if (a == NULL) {
a = (float **)G_malloc(sizeof(float *) * (numRows));
for (l = 0; l < numRows; l++)
@@ -868,11 +869,11 @@
}
if ((mapset = G_find_cell2(albedo, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), albedo);
- fd5 = G_open_cell_old(albedo, mapset);
+ fd5 = Rast_open_cell_old(albedo, mapset);
}
if (latin != NULL) {
- cell6 = G_allocate_f_raster_buf();
+ cell6 = Rast_allocate_f_raster_buf();
if (la == NULL) {
la = (float **)G_malloc(sizeof(float *) * (numRows));
for (l = 0; l < numRows; l++)
@@ -880,22 +881,22 @@
}
if ((mapset = G_find_cell2(latin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), latin);
- fd6 = G_open_cell_old(latin, mapset);
+ fd6 = Rast_open_cell_old(latin, mapset);
}
if (longin != NULL) {
- cell7 = G_allocate_f_raster_buf();
+ cell7 = Rast_allocate_f_raster_buf();
longitArray = (float **)G_malloc(sizeof(float *) * (numRows));
for (l = 0; l < numRows; l++)
longitArray[l] = (float *)G_malloc(sizeof(float) * (n));
if ((mapset = G_find_cell2(longin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), longin);
- fd7 = G_open_cell_old(longin, mapset);
+ fd7 = Rast_open_cell_old(longin, mapset);
}
if (coefbh != NULL) {
- rast1 = G_allocate_f_raster_buf();
+ rast1 = Rast_allocate_f_raster_buf();
if (cbhr == NULL) {
cbhr = (float **)G_malloc(sizeof(float *) * (numRows));
for (l = 0; l < numRows; l++)
@@ -903,11 +904,11 @@
}
if ((mapset = G_find_cell2(coefbh, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), coefbh);
- fr1 = G_open_cell_old(coefbh, mapset);
+ fr1 = Rast_open_cell_old(coefbh, mapset);
}
if (coefdh != NULL) {
- rast2 = G_allocate_f_raster_buf();
+ rast2 = Rast_allocate_f_raster_buf();
if (cdhr == NULL) {
cdhr = (float **)G_malloc(sizeof(float *) * (numRows));
for (l = 0; l < numRows; l++)
@@ -915,7 +916,7 @@
}
if ((mapset = G_find_cell2(coefdh, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), coefdh);
- fr2 = G_open_cell_old(coefdh, mapset);
+ fr2 = Rast_open_cell_old(coefdh, mapset);
}
if (useHorizonData()) {
@@ -931,12 +932,12 @@
* if(tt != NULL)
* {
*
- * horizonbuf[0]=G_allocate_f_raster_buf();
+ * horizonbuf[0]=Rast_allocate_f_raster_buf();
* sprintf(shad_filename, "%s_%02d", horizon, arrayNumInt);
* if((mapset=G_find_cell2(shad_filename,""))==NULL)
* G_message("Horizon file no. %d not found\n", arrayNumInt);
*
- * fd_shad[0] = G_open_cell_old(shad_filename,mapset);
+ * fd_shad[0] = Rast_open_cell_old(shad_filename,mapset);
* }
* else
* {
@@ -944,12 +945,12 @@
numDigits = (int)(log10(1. * arrayNumInt)) + 1;
sprintf(formatString, "%%s_%%0%dd", numDigits);
for (i = 0; i < arrayNumInt; i++) {
- horizonbuf[i] = G_allocate_f_raster_buf();
+ horizonbuf[i] = Rast_allocate_f_raster_buf();
sprintf(shad_filename, formatString, horizon, i);
if ((mapset = G_find_cell2(shad_filename, "")) == NULL)
G_fatal_error(_("Horizon file no. %d <%s> not found"), i,
shad_filename);
- fd_shad[i] = G_open_cell_old(shad_filename, mapset);
+ fd_shad[i] = Rast_open_cell_old(shad_filename, mapset);
}
}
/*
@@ -963,7 +964,7 @@
row_rev = m - row - 1;
rowrevoffset = row_rev - offset;
- G_get_f_raster_row(fd_shad[i], horizonbuf[i], row);
+ Rast_get_f_raster_row(fd_shad[i], horizonbuf[i], row);
horizonpointer =
horizonarray + (ssize_t) arrayNumInt *n * rowrevoffset;
for (j = 0; j < n; j++) {
@@ -981,83 +982,83 @@
for (row = m - offset - 1; row >= finalRow; row--) {
- G_get_f_raster_row(fd1, cell1, row);
+ Rast_get_f_raster_row(fd1, cell1, row);
if (aspin != NULL)
- G_get_f_raster_row(fd2, cell2, row);
+ Rast_get_f_raster_row(fd2, cell2, row);
if (slopein != NULL)
- G_get_f_raster_row(fd3, cell3, row);
+ Rast_get_f_raster_row(fd3, cell3, row);
if (linkein != NULL)
- G_get_f_raster_row(fd4, cell4, row);
+ Rast_get_f_raster_row(fd4, cell4, row);
if (albedo != NULL)
- G_get_f_raster_row(fd5, cell5, row);
+ Rast_get_f_raster_row(fd5, cell5, row);
if (latin != NULL)
- G_get_f_raster_row(fd6, cell6, row);
+ Rast_get_f_raster_row(fd6, cell6, row);
if (longin != NULL)
- G_get_f_raster_row(fd7, cell7, row);
+ Rast_get_f_raster_row(fd7, cell7, row);
if (coefbh != NULL)
- G_get_f_raster_row(fr1, rast1, row);
+ Rast_get_f_raster_row(fr1, rast1, row);
if (coefdh != NULL)
- G_get_f_raster_row(fr2, rast2, row);
+ Rast_get_f_raster_row(fr2, rast2, row);
row_rev = m - row - 1;
rowrevoffset = row_rev - offset;
for (j = 0; j < n; j++) {
- if (!G_is_f_null_value(cell1 + j))
+ if (!Rast_is_f_null_value(cell1 + j))
z[rowrevoffset][j] = (float)cell1[j];
else
z[rowrevoffset][j] = UNDEFZ;
if (aspin != NULL) {
- if (!G_is_f_null_value(cell2 + j))
+ if (!Rast_is_f_null_value(cell2 + j))
o[rowrevoffset][j] = (float)cell2[j];
else
o[rowrevoffset][j] = UNDEFZ;
}
if (slopein != NULL) {
- if (!G_is_f_null_value(cell3 + j))
+ if (!Rast_is_f_null_value(cell3 + j))
s[rowrevoffset][j] = (float)cell3[j];
else
s[rowrevoffset][j] = UNDEFZ;
}
if (linkein != NULL) {
- if (!G_is_f_null_value(cell4 + j))
+ if (!Rast_is_f_null_value(cell4 + j))
li[rowrevoffset][j] = (float)cell4[j];
else
li[rowrevoffset][j] = UNDEFZ;
}
if (albedo != NULL) {
- if (!G_is_f_null_value(cell5 + j))
+ if (!Rast_is_f_null_value(cell5 + j))
a[rowrevoffset][j] = (float)cell5[j];
else
a[rowrevoffset][j] = UNDEFZ;
}
if (latin != NULL) {
- if (!G_is_f_null_value(cell6 + j))
+ if (!Rast_is_f_null_value(cell6 + j))
la[rowrevoffset][j] = (float)cell6[j];
else
la[rowrevoffset][j] = UNDEFZ;
}
if (longin != NULL) {
- if (!G_is_f_null_value(cell7 + j))
+ if (!Rast_is_f_null_value(cell7 + j))
longitArray[rowrevoffset][j] = (float)cell7[j];
else
longitArray[rowrevoffset][j] = UNDEFZ;
}
if (coefbh != NULL) {
- if (!G_is_f_null_value(rast1 + j))
+ if (!Rast_is_f_null_value(rast1 + j))
cbhr[rowrevoffset][j] = (float)rast1[j];
else
cbhr[rowrevoffset][j] = UNDEFZ;
}
if (coefdh != NULL) {
- if (!G_is_f_null_value(rast2 + j))
+ if (!Rast_is_f_null_value(rast2 + j))
cdhr[rowrevoffset][j] = (float)rast2[j];
else
cdhr[rowrevoffset][j] = UNDEFZ;
@@ -1065,46 +1066,46 @@
}
}
- G_close_cell(fd1);
+ Rast_close_cell(fd1);
G_free(cell1);
if (aspin != NULL) {
G_free(cell2);
- G_close_cell(fd2);
+ Rast_close_cell(fd2);
}
if (slopein != NULL) {
G_free(cell3);
- G_close_cell(fd3);
+ Rast_close_cell(fd3);
}
if (linkein != NULL) {
G_free(cell4);
- G_close_cell(fd4);
+ Rast_close_cell(fd4);
}
if (albedo != NULL) {
G_free(cell5);
- G_close_cell(fd5);
+ Rast_close_cell(fd5);
}
if (latin != NULL) {
G_free(cell6);
- G_close_cell(fd6);
+ Rast_close_cell(fd6);
}
if (longin != NULL) {
G_free(cell7);
- G_close_cell(fd7);
+ Rast_close_cell(fd7);
}
if (coefbh != NULL) {
G_free(rast1);
- G_close_cell(fr1);
+ Rast_close_cell(fr1);
}
if (coefdh != NULL) {
G_free(rast2);
- G_close_cell(fr2);
+ Rast_close_cell(fr2);
}
if (useHorizonData()) {
for (i = 0; i < arrayNumInt; i++) {
- G_close_cell(fd_shad[i]);
+ Rast_close_cell(fd_shad[i]);
G_free(horizonbuf[i]);
}
}
@@ -1159,43 +1160,43 @@
int i, iarc, j;
if (incidout != NULL) {
- cell7 = G_allocate_f_raster_buf();
- fd7 = G_open_fp_cell_new(incidout);
+ cell7 = Rast_allocate_f_raster_buf();
+ fd7 = Rast_open_fp_cell_new(incidout);
if (fd7 < 0)
G_fatal_error(_("Unable to create raster map <%s>"), incidout);
}
if (beam_rad != NULL) {
- cell8 = G_allocate_f_raster_buf();
- fd8 = G_open_fp_cell_new(beam_rad);
+ cell8 = Rast_allocate_f_raster_buf();
+ fd8 = Rast_open_fp_cell_new(beam_rad);
if (fd8 < 0)
G_fatal_error(_("Unable to create raster map <%s>"), beam_rad);
}
if (insol_time != NULL) {
- cell11 = G_allocate_f_raster_buf();
- fd11 = G_open_fp_cell_new(insol_time);
+ cell11 = Rast_allocate_f_raster_buf();
+ fd11 = Rast_open_fp_cell_new(insol_time);
if (fd11 < 0)
G_fatal_error(_("Unable to create raster map <%s>"), insol_time);
}
if (diff_rad != NULL) {
- cell9 = G_allocate_f_raster_buf();
- fd9 = G_open_fp_cell_new(diff_rad);
+ cell9 = Rast_allocate_f_raster_buf();
+ fd9 = Rast_open_fp_cell_new(diff_rad);
if (fd9 < 0)
G_fatal_error(_("Unable to create raster map <%s>"), diff_rad);
}
if (refl_rad != NULL) {
- cell10 = G_allocate_f_raster_buf();
- fd10 = G_open_fp_cell_new(refl_rad);
+ cell10 = Rast_allocate_f_raster_buf();
+ fd10 = Rast_open_fp_cell_new(refl_rad);
if (fd10 < 0)
G_fatal_error(_("Unable to create raster map <%s>"), refl_rad);
}
if (glob_rad != NULL) {
- cell12 = G_allocate_f_raster_buf();
- fd12 = G_open_fp_cell_new(glob_rad);
+ cell12 = Rast_allocate_f_raster_buf();
+ fd12 = Rast_open_fp_cell_new(glob_rad);
if (fd12 < 0)
G_fatal_error(_("Unable to create raster map <%s>"), glob_rad);
}
@@ -1214,90 +1215,90 @@
if (incidout != NULL) {
for (j = 0; j < n; j++) {
if (lumcl[i][j] == UNDEFZ)
- G_set_f_null_value(cell7 + j, 1);
+ Rast_set_f_null_value(cell7 + j, 1);
else
cell7[j] = (FCELL) lumcl[i][j];
}
- G_put_f_raster_row(fd7, cell7);
+ Rast_put_f_raster_row(fd7, cell7);
}
if (beam_rad != NULL) {
for (j = 0; j < n; j++) {
if (beam[i][j] == UNDEFZ)
- G_set_f_null_value(cell8 + j, 1);
+ Rast_set_f_null_value(cell8 + j, 1);
else
cell8[j] = (FCELL) beam[i][j];
}
- G_put_f_raster_row(fd8, cell8);
+ Rast_put_f_raster_row(fd8, cell8);
}
if (glob_rad != NULL) {
for (j = 0; j < n; j++) {
if (globrad[i][j] == UNDEFZ)
- G_set_f_null_value(cell12 + j, 1);
+ Rast_set_f_null_value(cell12 + j, 1);
else
cell12[j] = (FCELL) globrad[i][j];
}
- G_put_f_raster_row(fd12, cell12);
+ Rast_put_f_raster_row(fd12, cell12);
}
if (insol_time != NULL) {
for (j = 0; j < n; j++) {
if (insol[i][j] == UNDEFZ)
- G_set_f_null_value(cell11 + j, 1);
+ Rast_set_f_null_value(cell11 + j, 1);
else
cell11[j] = (FCELL) insol[i][j];
}
- G_put_f_raster_row(fd11, cell11);
+ Rast_put_f_raster_row(fd11, cell11);
}
if (diff_rad != NULL) {
for (j = 0; j < n; j++) {
if (diff[i][j] == UNDEFZ)
- G_set_f_null_value(cell9 + j, 1);
+ Rast_set_f_null_value(cell9 + j, 1);
else
cell9[j] = (FCELL) diff[i][j];
}
- G_put_f_raster_row(fd9, cell9);
+ Rast_put_f_raster_row(fd9, cell9);
}
if (refl_rad != NULL) {
for (j = 0; j < n; j++) {
if (refl[i][j] == UNDEFZ)
- G_set_f_null_value(cell10 + j, 1);
+ Rast_set_f_null_value(cell10 + j, 1);
else
cell10[j] = (FCELL) refl[i][j];
}
- G_put_f_raster_row(fd10, cell10);
+ Rast_put_f_raster_row(fd10, cell10);
}
}
if (incidout != NULL) {
- G_close_cell(fd7);
- G_write_history(incidout, &hist);
+ Rast_close_cell(fd7);
+ Rast_write_history(incidout, &hist);
}
if (beam_rad != NULL) {
- G_close_cell(fd8);
- G_write_history(beam_rad, &hist);
+ Rast_close_cell(fd8);
+ Rast_write_history(beam_rad, &hist);
}
if (diff_rad != NULL) {
- G_close_cell(fd9);
- G_write_history(diff_rad, &hist);
+ Rast_close_cell(fd9);
+ Rast_write_history(diff_rad, &hist);
}
if (refl_rad != NULL) {
- G_close_cell(fd10);
- G_write_history(refl_rad, &hist);
+ Rast_close_cell(fd10);
+ Rast_write_history(refl_rad, &hist);
}
if (insol_time != NULL) {
- G_close_cell(fd11);
- G_write_history(insol_time, &hist);
+ Rast_close_cell(fd11);
+ Rast_write_history(insol_time, &hist);
}
if (glob_rad != NULL) {
- G_close_cell(fd12);
- G_write_history(glob_rad, &hist);
+ Rast_close_cell(fd12);
+ Rast_write_history(glob_rad, &hist);
}
return 1;
@@ -1951,22 +1952,22 @@
/* re-use &hist, but try all to initiate it for any case */
/* note this will result in incorrect map titles */
if (incidout != NULL) {
- G_short_history(incidout, "raster", &hist);
+ Rast_short_history(incidout, "raster", &hist);
}
else if (beam_rad != NULL) {
- G_short_history(beam_rad, "raster", &hist);
+ Rast_short_history(beam_rad, "raster", &hist);
}
else if (diff_rad != NULL) {
- G_short_history(diff_rad, "raster", &hist);
+ Rast_short_history(diff_rad, "raster", &hist);
}
else if (refl_rad != NULL) {
- G_short_history(refl_rad, "raster", &hist);
+ Rast_short_history(refl_rad, "raster", &hist);
}
else if (insol_time != NULL) {
- G_short_history(insol_time, "raster", &hist);
+ Rast_short_history(insol_time, "raster", &hist);
}
else if (glob_rad != NULL) {
- G_short_history(glob_rad, "raster", &hist);
+ Rast_short_history(glob_rad, "raster", &hist);
}
else
G_fatal_error
@@ -2060,8 +2061,8 @@
" -----------------------------------------------------------------");
hist.edlinecnt++;
- G_command_history(&hist);
- /* don't call G_write_history() until after G_close_cell() or it just gets overwritten */
+ Rast_command_history(&hist);
+ /* don't call Rast_write_history() until after Rast_close_cell() or it just gets overwritten */
} /* End of ) function */
Modified: grass/trunk/raster/r.sun2/rsunlib.c
===================================================================
--- grass/trunk/raster/r.sun2/rsunlib.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.sun2/rsunlib.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -32,6 +32,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
#include "sunradstruct.h"
Modified: grass/trunk/raster/r.sunmask/g_solposition.c
===================================================================
--- grass/trunk/raster/r.sunmask/g_solposition.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.sunmask/g_solposition.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gprojects.h>
#include "solpos00.h"
Modified: grass/trunk/raster/r.sunmask/main.c
===================================================================
--- grass/trunk/raster/r.sunmask/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.sunmask/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -45,6 +45,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "solpos00.h"
#include <grass/glocale.h>
@@ -450,26 +451,26 @@
exit(EXIT_SUCCESS);
}
- if ((elev_fd = G_open_cell_old(name, "")) < 0)
+ if ((elev_fd = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
- if ((output_fd = G_open_cell_new(outname)) < 0)
+ if ((output_fd = Rast_open_cell_new(outname)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), outname);
- data_type = G_get_raster_map_type(elev_fd);
- elevbuf.v = G_allocate_raster_buf(data_type);
- tmpbuf.v = G_allocate_raster_buf(data_type);
- outbuf.v = G_allocate_raster_buf(CELL_TYPE); /* binary map */
+ data_type = Rast_get_raster_map_type(elev_fd);
+ elevbuf.v = Rast_allocate_raster_buf(data_type);
+ tmpbuf.v = Rast_allocate_raster_buf(data_type);
+ outbuf.v = Rast_allocate_raster_buf(CELL_TYPE); /* binary map */
if (data_type == CELL_TYPE) {
- if ((G_read_range(name, "", &range)) < 0)
+ if ((Rast_read_range(name, "", &range)) < 0)
G_fatal_error(_("Can't open range file for %s"), name);
- G_get_range_min_max(&range, &min, &max);
+ Rast_get_range_min_max(&range, &min, &max);
dmin = (double)min;
dmax = (double)max;
}
else {
- G_read_fp_range(name, "", &fprange);
- G_get_fp_range_min_max(&fprange, &dmin, &dmax);
+ Rast_read_fp_range(name, "", &fprange);
+ Rast_get_fp_range_min_max(&fprange, &dmin, &dmax);
}
azi = 2 * M_PI * dazi / 360;
@@ -484,13 +485,13 @@
G_percent(row1, window.rows, 2);
col1 = 0;
drow = -1;
- if (G_get_raster_row(elev_fd, elevbuf.v, row1, data_type) < 0)
+ if (Rast_get_raster_row(elev_fd, elevbuf.v, row1, data_type) < 0)
G_fatal_error(_("Can't read row in input elevation map"));
while (col1 < window.cols) {
dvalue = raster_value(elevbuf, data_type, col1);
/* outbuf.c[col1]=1; */
- G_set_null_value(&outbuf.c[col1], 1, CELL_TYPE);
+ Rast_set_null_value(&outbuf.c[col1], 1, CELL_TYPE);
OK = 1;
east = G_col_to_easting(col1 + 0.5, &window);
north = G_row_to_northing(row1 + 0.5, &window);
@@ -515,7 +516,7 @@
dcol = G_easting_to_col(east, &window);
if (drow != G_northing_to_row(north, &window)) {
drow = G_northing_to_row(north, &window);
- G_get_raster_row(elev_fd, tmpbuf.v, (int)drow,
+ Rast_get_raster_row(elev_fd, tmpbuf.v, (int)drow,
data_type);
}
dvalue2 = raster_value(tmpbuf, data_type, (int)dcol);
@@ -530,21 +531,21 @@
col1 += 1;
}
G_debug(3, "Writing result row %i of %i", row1, window.rows);
- G_put_raster_row(output_fd, outbuf.c, CELL_TYPE);
+ Rast_put_raster_row(output_fd, outbuf.c, CELL_TYPE);
row1 += 1;
}
- G_close_cell(output_fd);
- G_close_cell(elev_fd);
+ Rast_close_cell(output_fd);
+ Rast_close_cell(elev_fd);
/* writing history file */
- G_short_history(outname, "raster", &hist);
+ Rast_short_history(outname, "raster", &hist);
sprintf(hist.edhist[0], "%s", *argv);
sprintf(hist.datsrc_1, "raster elevation file %s", name);
/* bug: long lines are truncated */
sprintf(hist.datsrc_2, "%s", G_recreate_command());
hist.edlinecnt = 3;
- G_write_history(outname, &hist);
+ Rast_write_history(outname, &hist);
G_done_msg(" ");
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.sunmask/solpos00.c
===================================================================
--- grass/trunk/raster/r.sunmask/solpos00.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.sunmask/solpos00.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -96,6 +96,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "solpos00.h"
Modified: grass/trunk/raster/r.support/check.c
===================================================================
--- grass/trunk/raster/r.support/check.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.support/check.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -20,44 +21,44 @@
int cats_ok;
int max;
- data_type = G_raster_map_type(name, "");
+ data_type = Rast_raster_map_type(name, "");
G_message(_("\n Updating statistics for [%s]"), name);
if (do_histogram(name) < 0)
return 0;
- if (G_read_histogram(name, "", &histogram) <= 0)
+ if (Rast_read_histogram(name, "", &histogram) <= 0)
return 0;
/* Init histogram range */
if (data_type == CELL_TYPE)
- G_init_range(&range);
+ Rast_init_range(&range);
else
- G_init_fp_range(&fprange);
+ Rast_init_fp_range(&fprange);
/* Update histogram range */
- i = G_get_histogram_num(&histogram);
+ i = Rast_get_histogram_num(&histogram);
while (i >= 0) {
if (data_type == CELL_TYPE)
- G_update_range(G_get_histogram_cat(i--, &histogram), &range);
+ Rast_update_range(Rast_get_histogram_cat(i--, &histogram), &range);
else
- G_update_fp_range((DCELL) G_get_histogram_cat(i--, &histogram),
+ Rast_update_fp_range((DCELL) Rast_get_histogram_cat(i--, &histogram),
&fprange);
}
/* Write histogram range */
if (data_type == CELL_TYPE)
- G_write_range(name, &range);
+ Rast_write_range(name, &range);
else
- G_write_fp_range(name, &fprange);
+ Rast_write_fp_range(name, &fprange);
/* Get category status and max */
- cats_ok = (G_read_cats(name, "", &cats) >= 0);
+ cats_ok = (Rast_read_cats(name, "", &cats) >= 0);
max = (data_type == CELL_TYPE ? range.max : fprange.max);
/* Further category checks */
if (!cats_ok)
- G_init_cats(max, "", &cats);
+ Rast_init_cats(max, "", &cats);
else if (cats.num != max) {
cats.num = max;
cats_ok = 0;
@@ -67,11 +68,11 @@
if (!cats_ok) {
G_message(_(" Updating the number of categories for "
"[%s]\n\n"), name);
- G_write_cats(name, &cats);
+ Rast_write_cats(name, &cats);
}
- G_free_histogram(&histogram);
- G_free_cats(&cats);
+ Rast_free_histogram(&histogram);
+ Rast_free_cats(&cats);
return 0;
}
Modified: grass/trunk/raster/r.support/histo.c
===================================================================
--- grass/trunk/raster/r.support/histo.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.support/histo.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -17,32 +18,32 @@
int row;
int fd;
- if (G_get_cellhd(name, "", &cellhd) < 0)
+ if (Rast_get_cellhd(name, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header for <%s>"), name);
G_set_window(&cellhd);
- if ((fd = G_open_cell_old(name, "")) < 0)
+ if ((fd = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open <%s>"), name);
nrows = G_window_rows();
ncols = G_window_cols();
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
- G_init_cell_stats(&statf);
+ Rast_init_cell_stats(&statf);
for (row = 0; row < nrows; row++) {
- if (G_get_map_row_nomask(fd, cell, row) < 0) {
+ if (Rast_get_map_row_nomask(fd, cell, row) < 0) {
G_warning(_("Unable to read row %d"), row);
break;
}
- G_update_cell_stats(cell, ncols, &statf);
+ Rast_update_cell_stats(cell, ncols, &statf);
}
if (row == nrows)
- G_write_histogram_cs(name, &statf);
+ Rast_write_histogram_cs(name, &statf);
- G_free_cell_stats(&statf);
- G_close_cell(fd);
+ Rast_free_cell_stats(&statf);
+ Rast_close_cell(fd);
G_free(cell);
if (row < nrows)
Modified: grass/trunk/raster/r.support/main.c
===================================================================
--- grass/trunk/raster/r.support/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.support/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,10 +23,11 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
-/* two less than lib/gis/put_title.c G_put_cell_title()
+/* two less than lib/gis/put_title.c Rast_put_cell_title()
if only one less a newline gets appended in the cats file. bug? */
#define MAX_TITLE_LEN 1022
@@ -146,15 +147,15 @@
if (!mapset || strcmp(mapset, G_mapset()) != 0)
G_fatal_error(_("Raster map <%s> not found in current mapset"), infile);
- cellhd_ok = (G_get_cellhd(raster->answer, "", &cellhd) >= 0);
- is_reclass = (G_is_reclass(raster->answer, "", rname, rmapset) > 0);
+ cellhd_ok = (Rast_get_cellhd(raster->answer, "", &cellhd) >= 0);
+ is_reclass = (Rast_is_reclass(raster->answer, "", rname, rmapset) > 0);
if (title_opt->answer) {
strncpy(title, title_opt->answer, MAX_TITLE_LEN);
title[MAX_TITLE_LEN] = '\0'; /* strncpy doesn't null terminate oversized input */
G_strip(title);
G_debug(3, "map title= [%s] (%d chars)", title, strlen(title));
- G_put_cell_title(raster->answer, title);
+ Rast_put_cell_title(raster->answer, title);
}
if (save_opt->answer) {
@@ -164,7 +165,7 @@
if (!fp)
G_fatal_error(_("Unable to open output file <%s>"), save_opt->answer);
- G_read_history(raster->answer, "", &hist);
+ Rast_read_history(raster->answer, "", &hist);
for (i = 0; i < hist.edlinecnt; i++)
fprintf(fp, "%s\n", hist.edhist[i]);
@@ -179,7 +180,7 @@
if (!fp)
G_fatal_error(_("Unable to open input file <%s>"), load_opt->answer);
- G_read_history(raster->answer, "", &hist);
+ Rast_read_history(raster->answer, "", &hist);
for (i = 0; ; i++) {
if (i >= MAXEDLINES) {
@@ -194,11 +195,11 @@
hist.edlinecnt = i;
- G_write_history(raster->answer, &hist);
+ Rast_write_history(raster->answer, &hist);
}
if (history_opt->answer) {
- G_read_history(raster->answer, "", &hist);
+ Rast_read_history(raster->answer, "", &hist);
if (hist.edlinecnt >= MAXEDLINES)
G_fatal_error(_("Not enough room in history file"));
@@ -235,17 +236,17 @@
strlen(hist.edhist[hist.edlinecnt]));
}
- G_write_history(raster->answer, &hist);
+ Rast_write_history(raster->answer, &hist);
}
if (units_opt->answer)
- G_write_raster_units(raster->answer, units_opt->answer);
+ Rast_write_raster_units(raster->answer, units_opt->answer);
if (vdatum_opt->answer)
- G_write_raster_vdatum(raster->answer, vdatum_opt->answer);
+ Rast_write_raster_vdatum(raster->answer, vdatum_opt->answer);
if (datasrc1_opt->answer || datasrc2_opt->answer || datadesc_opt->answer) {
- G_read_history(raster->answer, "", &hist);
+ Rast_read_history(raster->answer, "", &hist);
if (datasrc1_opt->answer) {
strncpy(datasrc, datasrc1_opt->answer, RECORD_LEN);
@@ -273,25 +274,25 @@
strncpy(hist.keywrd, datasrc, RECORD_LEN);
}
- G_write_history(raster->answer, &hist);
+ Rast_write_history(raster->answer, &hist);
}
if (map_opt->answer) { /* use cats from another map */
int fd;
struct Categories cats;
- if ((fd = G_open_cell_old(infile, "")) < 0)
+ if ((fd = Rast_open_cell_old(infile, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), infile);
- G_init_cats((CELL) 0, "", &cats);
- if (G_read_cats(map_opt->answer, "", &cats) < 0)
+ Rast_init_cats((CELL) 0, "", &cats);
+ if (Rast_read_cats(map_opt->answer, "", &cats) < 0)
G_fatal_error(_("Unable to read category file of raster map <%s>"),
map_opt->answer);
- if (G_write_cats(infile, &cats) >= 0)
+ if (Rast_write_cats(infile, &cats) >= 0)
G_message(_("cats table for [%s] set to %s"), infile,
map_opt->answer);
- G_close_cell(fd);
- G_free_cats(&cats);
+ Rast_close_cell(fd);
+ Rast_free_cats(&cats);
}
@@ -316,8 +317,8 @@
raster->answer);
/* Create a file of no-nulls */
- null_bits = G__allocate_null_bits(cellhd.cols);
- for (col = 0; col < G__null_bitstream_size(cellhd.cols); col++)
+ null_bits = Rast__allocate_null_bits(cellhd.cols);
+ for (col = 0; col < Rast__null_bitstream_size(cellhd.cols); col++)
null_bits[col] = 0;
/* Open null file for writing */
@@ -326,7 +327,7 @@
G_message(_("Writing new null file for [%s]... "), raster->answer);
for (row = 0; row < cellhd.rows; row++) {
G_percent(row, cellhd.rows, 1);
- if (G__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0) <
+ if (Rast__write_null_bits(null_fd, null_bits, row, cellhd.cols, 0) <
0)
G_fatal_error(_("Error writing null row [%d]."), row);
}
Modified: grass/trunk/raster/r.support.stats/check.c
===================================================================
--- grass/trunk/raster/r.support.stats/check.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.support.stats/check.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -37,46 +38,46 @@
int cats_ok;
int max;
- data_type = G_raster_map_type(name, "");
+ data_type = Rast_raster_map_type(name, "");
G_message(_("Updating statistics for [%s]..."), name);
if (!do_histogram(name))
return 1;
- if (G_read_histogram(name, "", &histogram) <= 0)
+ if (Rast_read_histogram(name, "", &histogram) <= 0)
return 1;
/* Init histogram range */
if (data_type == CELL_TYPE)
- G_init_range(&range);
+ Rast_init_range(&range);
else
- G_init_fp_range(&fprange);
+ Rast_init_fp_range(&fprange);
G_message(_("Updating histogram range..."));
- i = histo_num = G_get_histogram_num(&histogram);
+ i = histo_num = Rast_get_histogram_num(&histogram);
while (i >= 0) {
G_percent(i, histo_num, 2);
if (data_type == CELL_TYPE)
- G_update_range(G_get_histogram_cat(i--, &histogram), &range);
+ Rast_update_range(Rast_get_histogram_cat(i--, &histogram), &range);
else
- G_update_fp_range((DCELL) G_get_histogram_cat(i--, &histogram),
+ Rast_update_fp_range((DCELL) Rast_get_histogram_cat(i--, &histogram),
&fprange);
}
/* Write histogram range */
if (data_type == CELL_TYPE)
- G_write_range(name, &range);
+ Rast_write_range(name, &range);
else
- G_write_fp_range(name, &fprange);
+ Rast_write_fp_range(name, &fprange);
/* Get category status and max */
- cats_ok = (G_read_cats(name, "", &cats) >= 0);
+ cats_ok = (Rast_read_cats(name, "", &cats) >= 0);
max = (data_type == CELL_TYPE ? range.max : fprange.max);
/* Further category checks */
if (!cats_ok)
- G_init_cats(max, "", &cats);
+ Rast_init_cats(max, "", &cats);
else if (cats.num != max) {
cats.num = max;
cats_ok = 0;
@@ -85,11 +86,11 @@
/* Update categories if needed */
if (!cats_ok) {
G_message(_("Updating the number of categories for [%s]..."), name);
- G_write_cats(name, &cats);
+ Rast_write_cats(name, &cats);
}
- G_free_histogram(&histogram);
- G_free_cats(&cats);
+ Rast_free_histogram(&histogram);
+ Rast_free_cats(&cats);
return 0;
}
Modified: grass/trunk/raster/r.support.stats/histo.c
===================================================================
--- grass/trunk/raster/r.support.stats/histo.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.support.stats/histo.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
/*
@@ -33,35 +34,35 @@
int row;
int fd;
- if (G_get_cellhd(name, "", &cellhd) < 0)
+ if (Rast_get_cellhd(name, "", &cellhd) < 0)
return 1;
G_set_window(&cellhd);
- if ((fd = G_open_cell_old(name, "")) < 0)
+ if ((fd = Rast_open_cell_old(name, "")) < 0)
return 1;
nrows = G_window_rows();
ncols = G_window_cols();
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
- G_init_cell_stats(&statf);
+ Rast_init_cell_stats(&statf);
/* Update statistics for each row */
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_map_row_nomask(fd, cell, row) < 0)
+ if (Rast_get_map_row_nomask(fd, cell, row) < 0)
break;
- G_update_cell_stats(cell, ncols, &statf);
+ Rast_update_cell_stats(cell, ncols, &statf);
}
/* Write histogram if it made it through the loop */
if (row == nrows)
- G_write_histogram_cs(name, &statf);
+ Rast_write_histogram_cs(name, &statf);
- G_free_cell_stats(&statf);
- G_close_cell(fd);
+ Rast_free_cell_stats(&statf);
+ Rast_close_cell(fd);
G_free(cell);
if (row == nrows)
Modified: grass/trunk/raster/r.support.stats/main.c
===================================================================
--- grass/trunk/raster/r.support.stats/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.support.stats/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.surf.area/main.c
===================================================================
--- grass/trunk/raster/r.surf.area/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.area/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -56,6 +56,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -114,12 +115,12 @@
/* open raster map for reading */
{
- if ((cellfile = G_open_cell_old(surf->answer, "")) == -1)
+ if ((cellfile = Rast_open_cell_old(surf->answer, "")) == -1)
G_fatal_error(_("Unable to open raster map <%s>"), surf->answer);
}
- cell_buf[0] = (DCELL *) G_malloc(w.cols * G_raster_size(DCELL_TYPE));
- cell_buf[1] = (DCELL *) G_malloc(w.cols * G_raster_size(DCELL_TYPE));
+ cell_buf[0] = (DCELL *) G_malloc(w.cols * Rast_raster_size(DCELL_TYPE));
+ cell_buf[1] = (DCELL *) G_malloc(w.cols * Rast_raster_size(DCELL_TYPE));
fprintf(stdout, "\n");
{
@@ -128,10 +129,10 @@
minarea = maxarea = nullarea = 0.0;
for (row = 0; row < w.rows - 1; row++) {
if (!row) {
- G_get_raster_row(cellfile, cell_buf[1], 0, DCELL_TYPE);
+ Rast_get_raster_row(cellfile, cell_buf[1], 0, DCELL_TYPE);
top = cell_buf[1];
}
- G_get_raster_row(cellfile, cell_buf[row % 2], row + 1,
+ Rast_get_raster_row(cellfile, cell_buf[row % 2], row + 1,
DCELL_TYPE);
bottom = cell_buf[row % 2];
add_row_area(top, bottom, sz, &w, &minarea, &maxarea);
@@ -146,7 +147,7 @@
G_free(cell_buf[0]);
G_free(cell_buf[1]);
- G_close_cell(cellfile);
+ Rast_close_cell(cellfile);
{ /* report */
double reg_area, flat_area, estavg;
@@ -195,10 +196,10 @@
*/
/* If NAN go to next or we get NAN for everything */
- if (G_is_d_null_value(&(bottom[col + 1])) ||
- G_is_d_null_value(&(top[col])) ||
- G_is_d_null_value(&(top[col + 1])) ||
- G_is_d_null_value(&(bottom[col]))
+ if (Rast_is_d_null_value(&(bottom[col + 1])) ||
+ Rast_is_d_null_value(&(top[col])) ||
+ Rast_is_d_null_value(&(top[col + 1])) ||
+ Rast_is_d_null_value(&(bottom[col]))
)
continue;
@@ -265,7 +266,7 @@
int col;
for (col = 0; col < region->cols; col++) {
- if (G_is_d_null_value(&(rast[col]))) {
+ if (Rast_is_d_null_value(&(rast[col]))) {
*area += region->ew_res * region->ns_res;
}
}
Modified: grass/trunk/raster/r.surf.contour/contour.h
===================================================================
--- grass/trunk/raster/r.surf.contour/contour.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.contour/contour.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
#define NODE struct _n_o_d_e_
Modified: grass/trunk/raster/r.surf.contour/flag_create.c
===================================================================
--- grass/trunk/raster/r.surf.contour/flag_create.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.contour/flag_create.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
FLAG *flag_create(int nrows, int ncols)
Modified: grass/trunk/raster/r.surf.contour/flag_destroy.c
===================================================================
--- grass/trunk/raster/r.surf.contour/flag_destroy.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.contour/flag_destroy.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
int flag_destroy(FLAG * flags)
Modified: grass/trunk/raster/r.surf.contour/main.c
===================================================================
--- grass/trunk/raster/r.surf.contour/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.contour/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include "contour.h"
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int nrows;
@@ -94,22 +95,22 @@
seen = flag_create(nrows, ncols);
mask = flag_create(nrows, ncols);
if (NULL != G_find_file("cell", "MASK", G_mapset())) {
- if ((file_fd = G_open_cell_old("MASK", G_mapset())) < 0)
+ if ((file_fd = Rast_open_cell_old("MASK", G_mapset())) < 0)
G_fatal_error("Unable to open MASK");
for (r = 0; r < nrows; r++) {
- G_get_map_row_nomask(file_fd, alt_row, r);
+ Rast_get_map_row_nomask(file_fd, alt_row, r);
for (c = 0; c < ncols; c++)
if (!alt_row[c])
FLAG_SET(mask, r, c);
}
- G_close_cell(file_fd);
+ Rast_close_cell(file_fd);
}
zero = (NODE *) G_malloc(INIT_AR * sizeof(NODE));
minc = minr = 0;
maxc = ncols - 1;
maxr = nrows - 1;
array_size = INIT_AR;
- file_fd = G_open_cell_new(alt_name);
+ file_fd = Rast_open_cell_new(alt_name);
if (!file_fd)
G_fatal_error("Unable to open output map");
for (r = 0; r < nrows; r++) {
@@ -129,17 +130,17 @@
else
alt_row[c] = con1;
}
- G_put_raster_row(file_fd, alt_row, CELL_TYPE);
+ Rast_put_raster_row(file_fd, alt_row, CELL_TYPE);
}
G_percent(r, nrows, 1);
free_cell(con);
flag_destroy(seen);
flag_destroy(mask);
- G_close_cell(file_fd);
+ Rast_close_cell(file_fd);
- G_short_history(alt_name, "raster", &history);
- G_command_history(&history);
- G_write_history(alt_name, &history);
+ Rast_short_history(alt_name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(alt_name, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.surf.contour/read_cell.c
===================================================================
--- grass/trunk/raster/r.surf.contour/read_cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.contour/read_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,7 +9,7 @@
int fd;
int row;
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd < 0)
G_fatal_error(_("unable to open map <%s> in <%s>"),
name, mapset);
@@ -20,12 +20,12 @@
for (row = 0; row < nrows; row++) {
idx[row] = &buf[row * ncols];
- if (G_get_map_row(fd, idx[row], row) < 0)
+ if (Rast_get_map_row(fd, idx[row], row) < 0)
G_fatal_error(_("unable to read map <%s> in <%s>"),
name, mapset);
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
return idx;
}
Modified: grass/trunk/raster/r.surf.fractal/frac.h
===================================================================
--- grass/trunk/raster/r.surf.fractal/frac.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.fractal/frac.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
/* programs. It sets up the necessary */
/* prototypes for GRASS library calls. */
Modified: grass/trunk/raster/r.surf.fractal/spec_syn.c
===================================================================
--- grass/trunk/raster/r.surf.fractal/spec_syn.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.fractal/spec_syn.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "frac.h"
#include <grass/gmath.h>
Modified: grass/trunk/raster/r.surf.fractal/write_rast.c
===================================================================
--- grass/trunk/raster/r.surf.fractal/write_rast.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.fractal/write_rast.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -42,7 +42,7 @@
nrows = G_window_rows(); /* Find out the number of rows and */
ncols = G_window_cols(); /* columns of the raster view. */
- row_out = G_allocate_d_raster_buf();
+ row_out = Rast_allocate_d_raster_buf();
/*------------------------------------------------------------------*/
/* Open new file and set the output file descriptor. */
@@ -54,7 +54,7 @@
else
strcpy(file_name, rast_out_name);
- if ((fd_out = G_open_raster_new(file_name, DCELL_TYPE)) < 0) {
+ if ((fd_out = Rast_open_raster_new(file_name, DCELL_TYPE)) < 0) {
G_fatal_error(_("Unable to create raster map <%s>"),
file_name);
}
@@ -68,13 +68,13 @@
for (col = 0; col < ncols; col++)
*(row_out + col) = (DCELL) (*(data[0] + row * nn + col) * 100000);
- G_put_raster_row(fd_out, (DCELL *) row_out, DCELL_TYPE);
+ Rast_put_raster_row(fd_out, (DCELL *) row_out, DCELL_TYPE);
}
- G_close_cell(fd_out);
- G_short_history(file_name, "raster", &history);
- G_command_history(&history);
- G_write_history(file_name, &history);
+ Rast_close_cell(fd_out);
+ Rast_short_history(file_name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(file_name, &history);
return 0;
}
Modified: grass/trunk/raster/r.surf.gauss/gaussurf.c
===================================================================
--- grass/trunk/raster/r.surf.gauss/gaussurf.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.gauss/gaussurf.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
@@ -35,12 +36,12 @@
/****** OPEN CELL FILES AND GET CELL DETAILS ******/
- fd_out = G_open_raster_new(out, DCELL_TYPE);
+ fd_out = Rast_open_raster_new(out, DCELL_TYPE);
nrows = G_window_rows();
ncols = G_window_cols();
- row_out = G_allocate_d_raster_buf();
+ row_out = Rast_allocate_d_raster_buf();
/****** PASS THROUGH EACH CELL ASSIGNING RANDOM VALUE ******/
@@ -51,16 +52,16 @@
(DCELL) (G_math_rand_gauss(2742, sigma) + mean);
/* Write contents row by row */
- G_put_d_raster_row(fd_out, (DCELL *) row_out);
+ Rast_put_d_raster_row(fd_out, (DCELL *) row_out);
}
/****** CLOSE THE CELL FILE ******/
- G_close_cell(fd_out);
- G_short_history(out, "raster", &history);
- G_command_history(&history);
- G_write_history(out, &history);
+ Rast_close_cell(fd_out);
+ Rast_short_history(out, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out, &history);
return 0;
}
Modified: grass/trunk/raster/r.surf.gauss/main.c
===================================================================
--- grass/trunk/raster/r.surf.gauss/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.gauss/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.surf.idw/dist.c
===================================================================
--- grass/trunk/raster/r.surf.idw/dist.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.idw/dist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "pi.h"
/* distance from point to point along a geodesic
Modified: grass/trunk/raster/r.surf.idw/ll.c
===================================================================
--- grass/trunk/raster/r.surf.idw/ll.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.idw/ll.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "main.h"
/************************************************************************/
Modified: grass/trunk/raster/r.surf.idw/main.c
===================================================================
--- grass/trunk/raster/r.surf.idw/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.idw/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "main.h"
@@ -142,29 +143,29 @@
lookup_and_function_ptrs(nrows, ncols);
/* allocate buffers for row i/o */
- cell = G_allocate_cell_buf();
- if ((maskfd = G_maskfd()) >= 0 || error_flag) { /* apply mask to output */
+ cell = Rast_allocate_cell_buf();
+ if ((maskfd = Rast_maskfd()) >= 0 || error_flag) { /* apply mask to output */
if (error_flag) /* use input as mask when -e option chosen */
- maskfd = G_open_cell_old(input, "");
- mask = G_allocate_cell_buf();
+ maskfd = Rast_open_cell_old(input, "");
+ mask = Rast_allocate_cell_buf();
}
else
mask = NULL;
/* Open input cell layer for reading */
- fd = G_open_cell_old(input, "");
+ fd = Rast_open_cell_old(input, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), input);
/* Store input data in array-indexed doubly-linked lists and close input file */
rowlist = row_lists(nrows, ncols, &datarows, &n, fd, cell);
- G_close_cell(fd);
+ Rast_close_cell(fd);
if (npoints > n)
npoints = n;
/* open cell layer for writing output */
- fd = G_open_cell_new(output);
+ fd = Rast_open_cell_new(output);
if (fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), output);
@@ -177,11 +178,11 @@
G_free(collook);
if (ll)
free_dist_params();
- G_close_cell(fd);
+ Rast_close_cell(fd);
/* writing history file */
- G_short_history(output, "raster", &history);
- G_command_history(&history);
- G_write_history(output, &history);
+ Rast_short_history(output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(output, &history);
G_done_msg(" ");
@@ -259,7 +260,7 @@
G_percent(row+1, nrows, 2);
/* if mask occurs, read current row of the mask */
- if (mask && G_get_map_row(maskfd, mask, row) < 0)
+ if (mask && Rast_get_map_row(maskfd, mask, row) < 0)
G_fatal_error(_("Cannot read row"));
/* prepare search array for next row of interpolations */
@@ -300,7 +301,7 @@
}
} /* end of loop over columns */
- G_put_raster_row(out_fd, cell, CELL_TYPE);
+ Rast_put_raster_row(out_fd, cell, CELL_TYPE);
/* advance current row pointer if necessary */
if (current_row->start->y == row && current_row != lastrow)
@@ -708,7 +709,7 @@
for (row = 0, Rptr = rowlist; row < rows; row++) {
G_percent(row+1, rows, 2);
- if (G_get_map_row_nomask(fd, cell, row) < 0)
+ if (Rast_get_map_row_nomask(fd, cell, row) < 0)
G_fatal_error(_("Unable to read raster map row %d"),
row);
Modified: grass/trunk/raster/r.surf.idw/pi.h
===================================================================
--- grass/trunk/raster/r.surf.idw/pi.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.idw/pi.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#define PI M_PI
#define Radians(x) ((x) * PI/180.0)
Modified: grass/trunk/raster/r.surf.idw2/main.c
===================================================================
--- grass/trunk/raster/r.surf.idw2/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.idw2/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
@@ -96,14 +97,14 @@
/* get the window, allocate buffers, etc. */
G_get_set_window(&window);
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
- if ((maskfd = G_maskfd()) >= 0)
- mask = G_allocate_cell_buf();
+ if ((maskfd = Rast_maskfd()) >= 0)
+ mask = Rast_allocate_cell_buf();
else
mask = NULL;
- fd = G_open_cell_new(parm.output->answer);
+ fd = Rast_open_cell_new(parm.output->answer);
if (fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
parm.output->answer);
@@ -116,7 +117,7 @@
G_percent(row, window.rows, 2);
if (mask) {
- if (G_get_map_row(maskfd, mask, row) < 0)
+ if (Rast_get_map_row(maskfd, mask, row) < 0)
G_fatal_error(_("Cannot get row"));
}
north += window.ns_res;
@@ -176,17 +177,17 @@
cell[col] = (CELL) (sum1 / sum2 + 0.5);
}
- G_put_raster_row(fd, cell, CELL_TYPE);
+ Rast_put_raster_row(fd, cell, CELL_TYPE);
}
G_free(points);
G_free(cell);
- G_close_cell(fd);
+ Rast_close_cell(fd);
/* writing history file */
- G_short_history(parm.output->answer, "raster", &history);
- G_command_history(&history);
- G_write_history(parm.output->answer, &history);
+ Rast_short_history(parm.output->answer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(parm.output->answer, &history);
G_done_msg(" ");
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.surf.idw2/read_cell.c
===================================================================
--- grass/trunk/raster/r.surf.idw2/read_cell.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.idw2/read_cell.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -16,13 +17,13 @@
G_get_window(&window);
/* Set window to align with input raster map */
- G_get_cellhd(name, "", &cellhd);
+ Rast_get_cellhd(name, "", &cellhd);
G_align_window(&window, &cellhd);
G_set_window(&window);
- cell = G_allocate_cell_buf();
+ cell = Rast_allocate_cell_buf();
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0) {
G_fatal_error(_("Unable to open raster map <%s>"), name);
exit(EXIT_FAILURE);
@@ -34,7 +35,7 @@
for (row = 0; row < window.rows; row++) {
G_percent(row, window.rows, 1);
north += window.ns_res;
- if (G_get_map_row_nomask(fd, cell, row) < 0)
+ if (Rast_get_map_row_nomask(fd, cell, row) < 0)
exit(1);
for (col = 0; col < window.cols; col++)
if ((z = cell[col]))
@@ -42,7 +43,7 @@
}
G_percent(row, window.rows, 1);
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(cell);
/* reset the window */
Modified: grass/trunk/raster/r.surf.random/main.c
===================================================================
--- grass/trunk/raster/r.surf.random/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.random/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.surf.random/randsurf.c
===================================================================
--- grass/trunk/raster/r.surf.random/randsurf.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.surf.random/randsurf.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <unistd.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/gmath.h>
#include <grass/glocale.h>
@@ -24,11 +25,11 @@
/****** OPEN CELL FILES AND GET CELL DETAILS ******/
if (int_map) {
- if ((fd_out = G_open_raster_new(out, CELL_TYPE)) < 0)
+ if ((fd_out = Rast_open_raster_new(out, CELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), out);
}
else {
- if ((fd_out = G_open_raster_new(out, DCELL_TYPE)) < 0)
+ if ((fd_out = Rast_open_raster_new(out, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), out);
}
@@ -36,9 +37,9 @@
ncols = G_window_cols();
if (int_map)
- row_out_C = G_allocate_c_raster_buf();
+ row_out_C = Rast_allocate_c_raster_buf();
else
- row_out_D = G_allocate_d_raster_buf();
+ row_out_D = Rast_allocate_d_raster_buf();
/****** PASS THROUGH EACH CELL ASSIGNING RANDOM VALUE ******/
for (row_count = 0; row_count < nrows; row_count++) {
@@ -55,12 +56,12 @@
/* Write contents row by row */
if (int_map)
- G_put_c_raster_row(fd_out, (CELL *) row_out_C);
+ Rast_put_c_raster_row(fd_out, (CELL *) row_out_C);
else
- G_put_d_raster_row(fd_out, (DCELL *) row_out_D);
+ Rast_put_d_raster_row(fd_out, (DCELL *) row_out_D);
}
- G_close_cell(fd_out);
+ Rast_close_cell(fd_out);
return 0;
}
Modified: grass/trunk/raster/r.terraflow/common.h
===================================================================
--- grass/trunk/raster/r.terraflow/common.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.terraflow/common.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
#include "types.h" /* for dimension_type */
extern "C" {
#include <grass/gis.h>
+#include <grass/Rast.h>
}
Modified: grass/trunk/raster/r.terraflow/grass2str.h
===================================================================
--- grass/trunk/raster/r.terraflow/grass2str.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.terraflow/grass2str.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -61,16 +61,16 @@
/* open map */
int infd;
- if ( (infd = G_open_cell_old (cellname, mapset)) < 0)
+ if ( (infd = Rast_open_cell_old (cellname, mapset)) < 0)
G_fatal_error (_("Unable to open raster map <%s>"), cellname);
/* determine map type (CELL/FCELL/DCELL) */
RASTER_MAP_TYPE data_type;
- data_type = G_raster_map_type(cellname, mapset);
+ data_type = Rast_raster_map_type(cellname, mapset);
/* Allocate input buffer */
void *inrast;
- inrast = G_allocate_raster_buf(data_type);
+ inrast = Rast_allocate_raster_buf(data_type);
CELL c;
FCELL f;
@@ -81,7 +81,7 @@
for (int i = 0; i< nrows; i++) {
/* read input map */
- if (G_get_raster_row (infd, inrast, i, data_type) < 0)
+ if (Rast_get_raster_row (infd, inrast, i, data_type) < 0)
G_fatal_error (_("Unable to read raster map <%s>, row %d"),cellname, i);
for (int j=0; j<ncols; j++) {
@@ -89,21 +89,21 @@
switch (data_type) {
case CELL_TYPE:
c = ((CELL *) inrast)[j];
- isnull = G_is_c_null_value(&c);
+ isnull = Rast_is_c_null_value(&c);
if (!isnull) {
x = (T)c; d = (DCELL)c;
}
break;
case FCELL_TYPE:
f = ((FCELL *) inrast)[j];
- isnull = G_is_f_null_value(&f);
+ isnull = Rast_is_f_null_value(&f);
if (!isnull) {
x = (T)f; d = (DCELL)f;
}
break;
case DCELL_TYPE:
d = ((DCELL *) inrast)[j];
- isnull = G_is_d_null_value(&d);
+ isnull = Rast_is_d_null_value(&d);
if (!isnull) {
x = (T)d;
}
@@ -139,7 +139,7 @@
/* delete buffers */
G_free(inrast);
/* close map files */
- G_close_cell (infd);
+ Rast_close_cell (infd);
assert(nrows * ncols == str->stream_len());
rt_stop(rt);
@@ -174,13 +174,13 @@
/* open output raster map */
int outfd;
- if ( (outfd = G_open_raster_new (cellname, mtype)) < 0) {
+ if ( (outfd = Rast_open_raster_new (cellname, mtype)) < 0) {
G_fatal_error (_("Unable to create raster map <%s>"), cellname);
}
/* Allocate output buffer */
unsigned char *outrast;
- outrast = (unsigned char *)G_allocate_raster_buf(mtype);
+ outrast = (unsigned char *)Rast_allocate_raster_buf(mtype);
assert(outrast);
T* elt;
@@ -198,20 +198,20 @@
/* WRITE VALUE */
if(usefcell){
if (is_nodata(*elt)) {
- G_set_f_null_value( &( ((FCELL *) outrast)[j]), 1);
+ Rast_set_f_null_value( &( ((FCELL *) outrast)[j]), 1);
} else {
((FCELL *) outrast)[j] = (FCELL)(*elt);
}
}else{
if (is_nodata(*elt)) {
- G_set_c_null_value( &( ((CELL *) outrast)[j]), 1);
+ Rast_set_c_null_value( &( ((CELL *) outrast)[j]), 1);
} else {
((CELL *) outrast)[j] = (CELL)(*elt);
}
}
} /* for j*/
- if (G_put_raster_row (outfd, outrast, mtype) < 0)
+ if (Rast_put_raster_row (outfd, outrast, mtype) < 0)
G_fatal_error ("Cannot write to <%s>",cellname);
G_percent(i, nrows, 2);
@@ -219,7 +219,7 @@
G_percent(1, 1, 2); /* finish it */
G_free(outrast);
- G_close_cell (outfd);
+ Rast_close_cell (outfd);
rt_stop(rt);
stats->recordTime("writing raster map", rt);
@@ -259,13 +259,13 @@
/* open output raster map */
int outfd;
- if ( (outfd = G_open_raster_new (cellname, CELL_TYPE)) < 0) {
+ if ( (outfd = Rast_open_raster_new (cellname, CELL_TYPE)) < 0) {
G_fatal_error ("Could not open <%s>", cellname);
}
/* Allocate output buffer */
unsigned char *outrast;
- outrast = (unsigned char *)G_allocate_raster_buf(CELL_TYPE);
+ outrast = (unsigned char *)Rast_allocate_raster_buf(CELL_TYPE);
assert(outrast);
T* elt;
@@ -277,7 +277,7 @@
if(ae == AMI_ERROR_NO_ERROR && elt->i == i && elt->j == j) {
/* WRITE VALUE */
if (is_nodata ( fmt(*elt) )) {
- G_set_c_null_value( &( ((CELL *) outrast)[j]), 1);
+ Rast_set_c_null_value( &( ((CELL *) outrast)[j]), 1);
} else {
((CELL *) outrast)[j] = (CELL)(fmt(*elt));
}
@@ -286,11 +286,11 @@
} else {
/* WRITE NODATA */
- G_set_c_null_value( &( ((CELL *) outrast)[j]), 1);
+ Rast_set_c_null_value( &( ((CELL *) outrast)[j]), 1);
}
} /* for j*/
- if (G_put_raster_row (outfd, outrast, CELL_TYPE) < 0)
+ if (Rast_put_raster_row (outfd, outrast, CELL_TYPE) < 0)
G_fatal_error ("Cannot write to <%s>",cellname);
G_percent(i, nrows, 2);
@@ -298,7 +298,7 @@
G_percent(1, 1, 2); /* finish it */
G_free(outrast);
- G_close_cell (outfd);
+ Rast_close_cell (outfd);
rt_stop(rt);
stats->recordTime("writing raster map", rt);
@@ -333,13 +333,13 @@
/* open output raster map */
int outfd;
- if ( (outfd = G_open_raster_new (cellname, FCELL_TYPE)) < 0) {
+ if ( (outfd = Rast_open_raster_new (cellname, FCELL_TYPE)) < 0) {
G_fatal_error ("Could not open <%s>", cellname);
}
/* Allocate output buffer */
unsigned char *outrast;
- outrast = (unsigned char *)G_allocate_raster_buf(FCELL_TYPE);
+ outrast = (unsigned char *)Rast_allocate_raster_buf(FCELL_TYPE);
assert(outrast);
T* elt;
@@ -351,7 +351,7 @@
if(ae == AMI_ERROR_NO_ERROR && elt->i == i && elt->j == j) {
/* WRITE VALUE */
if (is_nodata ( fmt(*elt) )) {
- G_set_f_null_value( &( ((FCELL *) outrast)[j]), 1);
+ Rast_set_f_null_value( &( ((FCELL *) outrast)[j]), 1);
} else {
((FCELL *) outrast)[j] = (FCELL)(fmt(*elt));
}
@@ -360,11 +360,11 @@
} else {
/* WRITE NODATA */
- G_set_f_null_value( &( ((FCELL *) outrast)[j]), 1);
+ Rast_set_f_null_value( &( ((FCELL *) outrast)[j]), 1);
}
} /* for j*/
- if (G_put_raster_row (outfd, outrast, FCELL_TYPE) < 0)
+ if (Rast_put_raster_row (outfd, outrast, FCELL_TYPE) < 0)
G_fatal_error ("Cannot write to <%s>",cellname);
G_percent(i, nrows, 2);
@@ -372,7 +372,7 @@
G_percent(1, 1, 2); /* finish it */
G_free(outrast);
- G_close_cell (outfd);
+ Rast_close_cell (outfd);
rt_stop(rt);
stats->recordTime("writing raster map", rt);
@@ -425,21 +425,21 @@
/* open raster maps */
int fd1;
- if ( (fd1 = G_open_raster_new (cellname1, FCELL_TYPE)) < 0) {
+ if ( (fd1 = Rast_open_raster_new (cellname1, FCELL_TYPE)) < 0) {
G_fatal_error ("Could not open <%s>", cellname1);
}
int fd2;
- if ( (fd2 = G_open_raster_new (cellname2, FCELL_TYPE)) < 0) {
+ if ( (fd2 = Rast_open_raster_new (cellname2, FCELL_TYPE)) < 0) {
G_fatal_error ("Could not open <%s>", cellname2);
}
/* Allocate output buffers */
FCELL *rast1;
- rast1 = (FCELL*)G_allocate_raster_buf(FCELL_TYPE);
+ rast1 = (FCELL*)Rast_allocate_raster_buf(FCELL_TYPE);
assert(rast1);
FCELL *rast2;
- rast2 = (FCELL*)G_allocate_raster_buf(FCELL_TYPE);
+ rast2 = (FCELL*)Rast_allocate_raster_buf(FCELL_TYPE);
assert(rast2);
T* elt;
@@ -451,12 +451,12 @@
if(ae == AMI_ERROR_NO_ERROR && elt->i == i && elt->j == j) {
/* WRITE VALUE */
if (is_nodata(fmt1(*elt))) {
- G_set_f_null_value(&(rast1[j]), 1);
+ Rast_set_f_null_value(&(rast1[j]), 1);
} else {
rast1[j] = fmt1(*elt);
};
if (is_nodata( fmt2(*elt))) {
- G_set_f_null_value(&(rast2[j]), 1);
+ Rast_set_f_null_value(&(rast2[j]), 1);
} else {
rast2[j] = fmt2(*elt);
}
@@ -467,15 +467,15 @@
} else {
/* WRITE NODATA */
- G_set_f_null_value(&(rast1[j]), 1);
- G_set_f_null_value(&(rast2[j]), 1);
+ Rast_set_f_null_value(&(rast1[j]), 1);
+ Rast_set_f_null_value(&(rast2[j]), 1);
}
} /* for j*/
- if (G_put_raster_row (fd1, rast1, FCELL_TYPE) < 0)
+ if (Rast_put_raster_row (fd1, rast1, FCELL_TYPE) < 0)
G_fatal_error ("Cannot write to <%s>", cellname1);
- if (G_put_raster_row (fd2, rast2, FCELL_TYPE) < 0)
+ if (Rast_put_raster_row (fd2, rast2, FCELL_TYPE) < 0)
G_fatal_error ("Cannot write to <%s>", cellname2);
G_percent(i, nrows, 2);
@@ -484,9 +484,9 @@
G_percent(1, 1, 2); /* finish it */
G_free(rast1);
- G_close_cell (fd1);
+ Rast_close_cell (fd1);
G_free(rast2);
- G_close_cell (fd2);
+ Rast_close_cell (fd2);
rt_stop(rt);
Modified: grass/trunk/raster/r.terraflow/main.cc
===================================================================
--- grass/trunk/raster/r.terraflow/main.cc 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.terraflow/main.cc 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
extern "C" {
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
}
@@ -188,7 +189,7 @@
}
/* read cell header */
struct Cell_head cell_hd;
- if (G_get_cellhd (cellname, mapset, &cell_hd) < 0)
+ if (Rast_get_cellhd (cellname, mapset, &cell_hd) < 0)
G_fatal_error(_("Cannot read header of [%s]"), cellname);
/* check compatibility with module region */
@@ -207,7 +208,7 @@
/* check type of input elevation raster and check if precision is lost */
RASTER_MAP_TYPE data_type;
- data_type = G_raster_map_type(opt->elev_grid, mapset);
+ data_type = Rast_raster_map_type(opt->elev_grid, mapset);
#ifdef ELEV_SHORT
G_verbose_message(_("Elevation stored as SHORT (%dB)"),
sizeof(elevation_type));
@@ -335,7 +336,7 @@
if (mapset == NULL) {
G_fatal_error (_("Raster map <%s> not found"), cellname);
}
- if (G_read_range(cellname, mapset, &r) == -1) {
+ if (Rast_read_range(cellname, mapset, &r) == -1) {
G_fatal_error(_("cannot read range"));
}
/*fprintf(stderr, "%s range is: min=%d, max=%d\n", cellname, r.min, r.max);*/
@@ -348,19 +349,19 @@
v[5] = r.max;
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
- G_add_color_rule(v[0], 255,255,255, v[1], 255,255,0, &colors);
- G_add_color_rule(v[1], 255,255,0, v[2], 0,255,255, &colors);
- G_add_color_rule(v[2], 0,255,255, v[3], 0,127,255, &colors);
- G_add_color_rule(v[3], 0,127,255, v[4], 0,0,255, &colors);
- G_add_color_rule(v[4], 0,0,255, (CELL)v[5], 0,0,0, &colors);
+ Rast_add_color_rule(v[0], 255,255,255, v[1], 255,255,0, &colors);
+ Rast_add_color_rule(v[1], 255,255,0, v[2], 0,255,255, &colors);
+ Rast_add_color_rule(v[2], 0,255,255, v[3], 0,127,255, &colors);
+ Rast_add_color_rule(v[3], 0,127,255, v[4], 0,0,255, &colors);
+ Rast_add_color_rule(v[4], 0,0,255, (CELL)v[5], 0,0,0, &colors);
- if (G_write_colors(cellname, mapset, &colors) == -1) {
+ if (Rast_write_colors(cellname, mapset, &colors) == -1) {
G_fatal_error(_("cannot write colors"));
}
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
@@ -375,17 +376,17 @@
if (mapset == NULL) {
G_fatal_error (_("Raster map <%s> not found"), cellname);
}
- if (G_read_range(cellname, mapset, &r) == -1) {
+ if (Rast_read_range(cellname, mapset, &r) == -1) {
G_fatal_error(_("cannot read range"));
}
- G_init_colors(&colors);
- G_make_random_colors(&colors, 1, r.max);
+ Rast_init_colors(&colors);
+ Rast_make_random_colors(&colors, 1, r.max);
- if (G_write_colors(cellname, mapset, &colors) == -1) {
+ if (Rast_write_colors(cellname, mapset, &colors) == -1) {
G_fatal_error(_("cannot write colors"));
}
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
Modified: grass/trunk/raster/r.texture/h_measure.c
===================================================================
--- grass/trunk/raster/r.texture/h_measure.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.texture/h_measure.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define RADIX 2.0
Modified: grass/trunk/raster/r.texture/main.c
===================================================================
--- grass/trunk/raster/r.texture/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.texture/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "h_measure.h"
@@ -210,18 +211,18 @@
&& moc2 && mcc)
G_fatal_error(_("Nothing to compute. Use at least one of the flags."));
- if ((infd = G_open_cell_old(name, "")) < 0)
+ if ((infd = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
/* determine the inputmap type (CELL/FCELL/DCELL) */
- data_type = G_get_raster_map_type(infd);
+ data_type = Rast_get_raster_map_type(infd);
- if (G_get_cellhd(name, "", &cellhd) < 0)
+ if (Rast_get_cellhd(name, "", &cellhd) < 0)
G_fatal_error(_("Unable to read header of raster map <%s>"), name);
out_data_type = FCELL_TYPE;
/* Allocate output buffer, use FCELL data_type */
- outrast = G_allocate_raster_buf(out_data_type);
+ outrast = Rast_allocate_raster_buf(out_data_type);
nrows = G_window_rows();
ncols = G_window_cols();
@@ -229,7 +230,7 @@
/* Load raster map. */
/* allocate the space for one row of cell map data *A* */
- cell_row = G_allocate_cell_buf();
+ cell_row = Rast_allocate_cell_buf();
/* Allocate appropriate memory for the structure containing the image */
data = (int **)G_malloc(nrows * sizeof(int *));
@@ -240,13 +241,13 @@
/* Read in cell map values */
G_important_message(_("Reading raster map..."));
for (j = 0; j < nrows; j++) {
- G_get_raster_row(infd, cell_row, j, CELL_TYPE);
+ Rast_get_raster_row(infd, cell_row, j, CELL_TYPE);
for (i = 0; i < ncols; i++)
data[j][i] = (int)cell_row[i];
}
/* close input cell map and release the row buffer */
- G_close_cell(infd);
+ Rast_close_cell(infd);
G_free(cell_row);
/* Now raster map is into memory. */
@@ -284,7 +285,7 @@
t_measure += 3;
else {
if ((outfd =
- G_open_raster_new(strcat(filename, suffixes[t_measure]),
+ Rast_open_raster_new(strcat(filename, suffixes[t_measure]),
out_data_type)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
*result = '\0';
@@ -331,31 +332,31 @@
/* The early (size/2) samples take value from (size/2+1)'th sample */
if (row == 0)
for (j = 0; j < (size / 2); j++)
- if (G_put_raster_row(outfd, outrast, out_data_type) <
+ if (Rast_put_raster_row(outfd, outrast, out_data_type) <
0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
result, row);
- if (G_put_raster_row(outfd, outrast, out_data_type) < 0)
+ if (Rast_put_raster_row(outfd, outrast, out_data_type) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
result, row);
}
/* The last few (size/2) samples take value from nrows-(size/2+1)'th sample */
if ((row >= nrows - (size - 1)) && (row < nrows))
for (j = 0; j < (size / 2); j++)
- if (G_put_raster_row(outfd, outrast, out_data_type) < 0)
+ if (Rast_put_raster_row(outfd, outrast, out_data_type) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
result, row);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
strcpy(mapname, filename);
strcat(mapname, suffixes[t_measure]);
G_important_message(_("Calculated measure #%d <%s> (56 measures available)"),
(t_measure + 1), mapname);
- G_short_history(mapname, "raster", &history);
- G_command_history(&history);
- G_write_history(mapname, &history);
+ Rast_short_history(mapname, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(mapname, &history);
}
G_free(outrast);
Modified: grass/trunk/raster/r.thin/io.c
===================================================================
--- grass/trunk/raster/r.thin/io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.thin/io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -34,6 +34,7 @@
#include <fcntl.h>
#include <grass/config.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/rowio.h>
@@ -90,7 +91,7 @@
/* open raster map */
strcpy(cell, name);
- if ((cell_file = G_open_cell_old(cell, "")) < 0) {
+ if ((cell_file = Rast_open_cell_old(cell, "")) < 0) {
unlink(work_file_name);
G_fatal_error(_("Unable to open raster map <%s>"), cell);
}
@@ -121,7 +122,7 @@
}
}
for (row = 0; row < n_rows; row++) {
- if (G_get_map_row(cell_file, buf + PAD, row) < 0) {
+ if (Rast_get_map_row(cell_file, buf + PAD, row) < 0) {
unlink(work_file_name);
G_fatal_error(_("%s: Error reading from raster map <%s>"),
error_prefix, cell);
@@ -145,7 +146,7 @@
}
n_rows += (PAD << 1);
G_free(buf);
- G_close_cell(cell_file);
+ Rast_close_cell(cell_file);
rowio_setup(&row_io, work_file, MAX_ROW, n_cols * sizeof(CELL), read_row,
write_row);
@@ -158,7 +159,7 @@
int row_count, col_count, col;
CELL *buf;
- if ((cell_file = G_open_cell_new(name)) < 0) {
+ if ((cell_file = Rast_open_cell_new(name)) < 0) {
unlink(work_file_name);
G_fatal_error(_("Unable to create raster map <%s>"), name);
}
@@ -173,11 +174,11 @@
buf = get_a_row(k);
for (col = 0; col < n_cols; col++) {
if (buf[col] == 0)
- G_set_null_value(&buf[col], 1, CELL_TYPE);
+ Rast_set_null_value(&buf[col], 1, CELL_TYPE);
}
- G_put_raster_row(cell_file, buf + PAD, CELL_TYPE);
+ Rast_put_raster_row(cell_file, buf + PAD, CELL_TYPE);
}
- G_close_cell(cell_file);
+ Rast_close_cell(cell_file);
rowio_flush(&row_io);
close(rowio_fileno(&row_io));
rowio_release(&row_io);
Modified: grass/trunk/raster/r.thin/main.c
===================================================================
--- grass/trunk/raster/r.thin/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.thin/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -36,6 +36,7 @@
#include <stdio.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include <grass/glocale.h>
@@ -79,10 +80,10 @@
thin_lines(iterations);
close_file(output);
- G_put_cell_title(output, "Thinned linear features");
- G_short_history(output, "raster", &history);
- G_command_history(&history);
- G_write_history(output, &history);
+ Rast_put_cell_title(output, "Thinned linear features");
+ Rast_short_history(output, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(output, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.thin/thin_lines.c
===================================================================
--- grass/trunk/raster/r.thin/thin_lines.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.thin/thin_lines.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "local_proto.h"
Modified: grass/trunk/raster/r.to.rast3/main.c
===================================================================
--- grass/trunk/raster/r.to.rast3/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.rast3/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
#include <grass/config.h>
@@ -102,7 +103,7 @@
cols = region.cols;
depths = region.depths;
- rast = G_allocate_raster_buf(globalRastMapType);
+ rast = Rast_allocate_raster_buf(globalRastMapType);
G_debug(3, "raster_to_g3d: Writing %i raster maps with %i rows %i cols.",
depths, rows, cols);
@@ -113,14 +114,14 @@
for (y = 0; y < rows; y++) {
G_percent(y, rows - 1, 10);
- if (!G_get_raster_row(fd[z], rast, y, globalRastMapType))
+ if (!Rast_get_raster_row(fd[z], rast, y, globalRastMapType))
fatal_error(map, fd, depths, _("Could not get raster row"));
for (x = 0, ptr = rast; x < cols; x++,
ptr =
- G_incr_void_ptr(ptr, G_raster_size(globalRastMapType))) {
+ Rast_incr_void_ptr(ptr, Rast_raster_size(globalRastMapType))) {
if (globalRastMapType == CELL_TYPE) {
- if (G_is_null_value(ptr, globalRastMapType)) {
+ if (Rast_is_null_value(ptr, globalRastMapType)) {
G3d_setNullValue(&dvalue, 1, DCELL_TYPE);
}
else {
@@ -132,7 +133,7 @@
"Error writing double data");
}
else if (globalRastMapType == FCELL_TYPE) {
- if (G_is_null_value(ptr, globalRastMapType)) {
+ if (Rast_is_null_value(ptr, globalRastMapType)) {
G3d_setNullValue(&fvalue, 1, FCELL_TYPE);
}
else {
@@ -145,7 +146,7 @@
}
else if (globalRastMapType == DCELL_TYPE) {
- if (G_is_null_value(ptr, globalRastMapType)) {
+ if (Rast_is_null_value(ptr, globalRastMapType)) {
G3d_setNullValue(&dvalue, 1, DCELL_TYPE);
}
else {
@@ -255,7 +256,7 @@
fd[i] = open_input_raster_map(name);
opencells++;
- maptype_tmp = G_get_raster_map_type(fd[i]);
+ maptype_tmp = Rast_get_raster_map_type(fd[i]);
/*maptype */
if (i == 0)
@@ -345,7 +346,7 @@
/* open raster map */
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
@@ -359,6 +360,6 @@
/* ************************************************************************* */
void close_input_raster_map(int fd)
{
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_fatal_error(_("Unable to close input map"));
}
Modified: grass/trunk/raster/r.to.rast3elev/main.c
===================================================================
--- grass/trunk/raster/r.to.rast3elev/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.rast3elev/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
#include <grass/config.h>
@@ -63,7 +64,7 @@
/* ************************************************************************* */
double get_raster_value_as_double(int MapType, void *ptr, double nullval)
{
- if (G_is_null_value(ptr, MapType))
+ if (Rast_is_null_value(ptr, MapType))
return nullval;
switch (MapType) {
@@ -112,7 +113,7 @@
G_debug(3, "Open Raster file %s", name);
/* open raster map */
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
@@ -125,7 +126,7 @@
/* ************************************************************************* */
void close_input_raster_map(int fd)
{
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_fatal_error(_("Unable to close input map"));
}
@@ -216,8 +217,8 @@
tbres = (top - bottom) / depths;
/*memory */
- input_rast = G_allocate_raster_buf(db.inputmaptype);
- elev_rast = G_allocate_raster_buf(db.elevmaptype);
+ input_rast = Rast_allocate_raster_buf(db.inputmaptype);
+ elev_rast = Rast_allocate_raster_buf(db.elevmaptype);
G3d_setNullValue(&null, 1, DCELL_TYPE);
@@ -230,16 +231,16 @@
for (y = 0; y < rows; y++) {
G_percent(y, rows - 1, 10);
- if (!G_get_raster_row(db.input, input_rast, y, db.inputmaptype))
+ if (!Rast_get_raster_row(db.input, input_rast, y, db.inputmaptype))
fatal_error(db, _("Could not get raster row from input map"));
- if (!G_get_raster_row(db.elev, elev_rast, y, db.elevmaptype))
+ if (!Rast_get_raster_row(db.elev, elev_rast, y, db.elevmaptype))
fatal_error(db, _("Could not get raster row from elev map"));
for (x = 0, input_ptr = input_rast, elev_ptr = elev_rast; x < cols;
x++, input_ptr =
- G_incr_void_ptr(input_ptr, G_raster_size(db.inputmaptype)),
+ Rast_incr_void_ptr(input_ptr, Rast_raster_size(db.inputmaptype)),
elev_ptr =
- G_incr_void_ptr(elev_ptr, G_raster_size(db.elevmaptype))) {
+ Rast_incr_void_ptr(elev_ptr, Rast_raster_size(db.elevmaptype))) {
/*Get the elevation and the input map value */
inval =
@@ -460,14 +461,14 @@
/*Open input map */
name = param.input->answers[i];
db.input = open_input_raster_map(name);
- db.inputmaptype = G_raster_map_type(name, "");
+ db.inputmaptype = Rast_raster_map_type(name, "");
G_debug(2, "Open elev raster map %s", param.elev->answers[i]);
/*Open elev map */
name = param.elev->answers[i];
db.elev = open_input_raster_map(name);
- db.elevmaptype = G_raster_map_type(name, "");
+ db.elevmaptype = Rast_raster_map_type(name, "");
/****************************************/
/*Write the data into the G3D Rastermap */
Modified: grass/trunk/raster/r.to.vect/areas.c
===================================================================
--- grass/trunk/raster/r.to.vect/areas.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.vect/areas.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -68,6 +68,7 @@
#include <stdio.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include "global.h"
@@ -99,7 +100,7 @@
static int nabors(void);
#define get_raster_value(ptr, col) \
- G_get_raster_value_d(G_incr_void_ptr(ptr, (col)*data_size), data_type)
+ Rast_get_raster_value_d(Rast_incr_void_ptr(ptr, (col)*data_size), data_type)
/* extract_areas - trace boundaries of polygons in file */
@@ -112,7 +113,7 @@
area_num = 0;
tl_area = 0;
- G_set_d_null_value(&nullVal, 1);
+ Rast_set_d_null_value(&nullVal, 1);
/* represents the "outside", the external null values */
assign_area(nullVal, 0);
@@ -174,7 +175,7 @@
new_ptr1->fptr = new_ptr3;
new_ptr2->bptr = new_ptr3->bptr = new_ptr1;
- /* if(G_is_c_null_value(&tl_area)) {
+ /* if(Rast_is_c_null_value(&tl_area)) {
new_ptr1->left = new_ptr2->right = new_ptr3->left = 0;
assign_area(tl,1);
} else {
@@ -413,10 +414,10 @@
static int nabors(void)
{
- int tl_null = G_is_d_null_value(&tl);
- int tr_null = G_is_d_null_value(&tr);
- int bl_null = G_is_d_null_value(&bl);
- int br_null = G_is_d_null_value(&br);
+ int tl_null = Rast_is_d_null_value(&tl);
+ int tr_null = Rast_is_d_null_value(&tr);
+ int bl_null = Rast_is_d_null_value(&bl);
+ int br_null = Rast_is_d_null_value(&br);
/* if both a and b are NULLs, thery are equal */
#define cmp(a, b) (a##_null+b##_null==1 || (a##_null+b##_null==0 && a != b))
Modified: grass/trunk/raster/r.to.vect/areas_io.c
===================================================================
--- grass/trunk/raster/r.to.vect/areas_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.vect/areas_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
@@ -298,7 +299,7 @@
catNum = 1;
for (i = 0, p = a_list; i < n_areas; i++, p++) {
- if (equivs[i] == i && p->width > 0 && !G_is_d_null_value(&(p->cat))) {
+ if (equivs[i] == i && p->width > 0 && !Rast_is_d_null_value(&(p->cat))) {
char buf[1000];
if (value_flag) { /* raster value */
@@ -356,7 +357,7 @@
db_append_string(&sql, buf);
if (has_cats) {
- temp_buf = G_get_cat(p->cat, &RastCats);
+ temp_buf = Rast_get_cat(p->cat, &RastCats);
db_set_string(&label, temp_buf);
db_double_quote_string(&label);
Modified: grass/trunk/raster/r.to.vect/lines.c
===================================================================
--- grass/trunk/raster/r.to.vect/lines.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.vect/lines.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include "global.h"
@@ -85,15 +86,15 @@
t = &((CELL *) top)[col];
b = &((CELL *) bottom)[col];
- if ((mc = !G_is_c_null_value(m))) {
- tl = !G_is_c_null_value(t - 1);
- tc = !G_is_c_null_value(t);
- tr = !G_is_c_null_value(t + 1);
- ml = !G_is_c_null_value(m - 1);
- mr = !G_is_c_null_value(m + 1);
- bl = !G_is_c_null_value(b - 1);
- bc = !G_is_c_null_value(b);
- br = !G_is_c_null_value(b + 1);
+ if ((mc = !Rast_is_c_null_value(m))) {
+ tl = !Rast_is_c_null_value(t - 1);
+ tc = !Rast_is_c_null_value(t);
+ tr = !Rast_is_c_null_value(t + 1);
+ ml = !Rast_is_c_null_value(m - 1);
+ mr = !Rast_is_c_null_value(m + 1);
+ bl = !Rast_is_c_null_value(b - 1);
+ bc = !Rast_is_c_null_value(b);
+ br = !Rast_is_c_null_value(b + 1);
update_list(nabors());
}
}
@@ -120,15 +121,15 @@
t = &((FCELL *) top)[col];
b = &((FCELL *) bottom)[col];
- if ((mc = !G_is_f_null_value(m))) {
- tl = !G_is_f_null_value(t - 1);
- tc = !G_is_f_null_value(t);
- tr = !G_is_f_null_value(t + 1);
- ml = !G_is_f_null_value(m - 1);
- mr = !G_is_f_null_value(m + 1);
- bl = !G_is_f_null_value(b - 1);
- bc = !G_is_f_null_value(b);
- br = !G_is_f_null_value(b + 1);
+ if ((mc = !Rast_is_f_null_value(m))) {
+ tl = !Rast_is_f_null_value(t - 1);
+ tc = !Rast_is_f_null_value(t);
+ tr = !Rast_is_f_null_value(t + 1);
+ ml = !Rast_is_f_null_value(m - 1);
+ mr = !Rast_is_f_null_value(m + 1);
+ bl = !Rast_is_f_null_value(b - 1);
+ bc = !Rast_is_f_null_value(b);
+ br = !Rast_is_f_null_value(b + 1);
update_list(nabors());
}
}
@@ -154,15 +155,15 @@
m = &((DCELL *) middle)[col];
t = &((DCELL *) top)[col];
b = &((DCELL *) bottom)[col];
- if ((mc = !G_is_d_null_value(m))) {
- tl = !G_is_d_null_value(t - 1);
- tc = !G_is_d_null_value(t);
- tr = !G_is_d_null_value(t + 1);
- ml = !G_is_d_null_value(m - 1);
- mr = !G_is_d_null_value(m + 1);
- bl = !G_is_d_null_value(b - 1);
- bc = !G_is_d_null_value(b);
- br = !G_is_d_null_value(b + 1);
+ if ((mc = !Rast_is_d_null_value(m))) {
+ tl = !Rast_is_d_null_value(t - 1);
+ tc = !Rast_is_d_null_value(t);
+ tr = !Rast_is_d_null_value(t + 1);
+ ml = !Rast_is_d_null_value(m - 1);
+ mr = !Rast_is_d_null_value(m + 1);
+ bl = !Rast_is_d_null_value(b - 1);
+ bc = !Rast_is_d_null_value(b);
+ br = !Rast_is_d_null_value(b + 1);
update_list(nabors());
}
}
Modified: grass/trunk/raster/r.to.vect/lines_io.c
===================================================================
--- grass/trunk/raster/r.to.vect/lines_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.vect/lines_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -33,6 +33,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
Modified: grass/trunk/raster/r.to.vect/main.c
===================================================================
--- grass/trunk/raster/r.to.vect/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.vect/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -114,11 +115,11 @@
G_fatal_error(_("z flag is supported only for points"));
/* Open files */
- if ((input_fd = G_open_cell_old(in_opt->answer, "")) < 0)
+ if ((input_fd = Rast_open_cell_old(in_opt->answer, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), in_opt->answer);
- data_type = G_get_raster_map_type(input_fd);
- data_size = G_raster_size(data_type);
+ data_type = Rast_get_raster_map_type(input_fd);
+ data_size = Rast_raster_size(data_type);
G_get_window(&cell_head);
if (value_flag && data_type != CELL_TYPE) {
@@ -137,7 +138,7 @@
/* Open category labels */
if (data_type == CELL_TYPE) {
- if (0 == G_read_cats(in_opt->answer, "", &RastCats))
+ if (0 == Rast_read_cats(in_opt->answer, "", &RastCats))
has_cats = 1;
}
else
@@ -233,7 +234,7 @@
extract_points(z_flg->answer);
}
- G_close_cell(input_fd);
+ Rast_close_cell(input_fd);
if (!no_topol->answer)
Vect_build(&Map);
@@ -281,7 +282,7 @@
}
if (has_cats)
- G_free_cats(&RastCats);
+ Rast_free_cats(&RastCats);
if (driver != NULL) {
db_commit_transaction(driver);
Modified: grass/trunk/raster/r.to.vect/points.c
===================================================================
--- grass/trunk/raster/r.to.vect/points.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.vect/points.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <strings.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
@@ -22,13 +23,13 @@
switch (data_type) {
case CELL_TYPE:
- cellbuf = G_allocate_c_raster_buf();
+ cellbuf = Rast_allocate_c_raster_buf();
break;
case FCELL_TYPE:
- fcellbuf = G_allocate_f_raster_buf();
+ fcellbuf = Rast_allocate_f_raster_buf();
break;
case DCELL_TYPE:
- dcellbuf = G_allocate_d_raster_buf();
+ dcellbuf = Rast_allocate_d_raster_buf();
break;
}
@@ -42,13 +43,13 @@
switch (data_type) {
case CELL_TYPE:
- G_get_c_raster_row(input_fd, cellbuf, row);
+ Rast_get_c_raster_row(input_fd, cellbuf, row);
break;
case FCELL_TYPE:
- G_get_f_raster_row(input_fd, fcellbuf, row);
+ Rast_get_f_raster_row(input_fd, fcellbuf, row);
break;
case DCELL_TYPE:
- G_get_d_raster_row(input_fd, dcellbuf, row);
+ Rast_get_d_raster_row(input_fd, dcellbuf, row);
break;
}
@@ -60,18 +61,18 @@
switch (data_type) {
case CELL_TYPE:
- if (G_is_c_null_value(cellbuf + col))
+ if (Rast_is_c_null_value(cellbuf + col))
continue;
val = cellbuf[col];
dval = val;
break;
case FCELL_TYPE:
- if (G_is_f_null_value(fcellbuf + col))
+ if (Rast_is_f_null_value(fcellbuf + col))
continue;
dval = fcellbuf[col];
break;
case DCELL_TYPE:
- if (G_is_d_null_value(dcellbuf + col))
+ if (Rast_is_d_null_value(dcellbuf + col))
continue;
dval = dcellbuf[col];
break;
Modified: grass/trunk/raster/r.to.vect/util.c
===================================================================
--- grass/trunk/raster/r.to.vect/util.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.to.vect/util.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
#endif
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -101,15 +102,15 @@
/* bytes and cast the buf variable to char * before */
/* incrementing */
p = ((char *)buf) + data_size;
- G_get_raster_row(input_fd, p, row_count++, data_type);
+ Rast_get_raster_row(input_fd, p, row_count++, data_type);
p = buf;
- G_set_null_value(p, 1, data_type);
+ Rast_set_null_value(p, 1, data_type);
/* Again we need to cast p to char * under the */
/* assumption that the increment is the proper */
/* number of bytes. */
p = ((char *)p) + (row_length + 1) * data_size;
- G_set_null_value(p, 1, data_type);
+ Rast_set_null_value(p, 1, data_type);
}
}
return (row_length + 2);
@@ -117,7 +118,7 @@
static int blank_line(void *buf)
{
- G_set_null_value(buf, row_length + 2, data_type);
+ Rast_set_null_value(buf, row_length + 2, data_type);
return 0;
}
@@ -140,7 +141,7 @@
if (has_cats) {
char *lab;
- lab = G_get_cat(val, &RastCats); /*cats are loaded only for CELL type */
+ lab = Rast_get_cat(val, &RastCats); /*cats are loaded only for CELL type */
db_set_string(&label, lab);
db_double_quote_string(&label);
Modified: grass/trunk/raster/r.topidx/file_io.c
===================================================================
--- grass/trunk/raster/r.topidx/file_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topidx/file_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
@@ -11,11 +12,11 @@
FCELL *fcell = NULL;
struct Cell_head inhead;
- if ((fd = G_open_cell_old(iname, "")) < 0)
+ if ((fd = Rast_open_cell_old(iname, "")) < 0)
G_fatal_error(_("Cannot open raster map <%s>"), iname);
- data_type = G_get_raster_map_type(fd);
- if (G_get_cellhd(iname, "", &inhead) < 0 )
+ data_type = Rast_get_raster_map_type(fd);
+ if (Rast_get_cellhd(iname, "", &inhead) < 0 )
G_fatal_error(_("Unable to read header of raster map <%s>"), iname);
if (data_type == CELL_TYPE)
@@ -40,29 +41,29 @@
a[i] = (DCELL *) G_malloc(sizeof(DCELL) * window.cols);
if (data_type == CELL_TYPE) {
- if (G_get_c_raster_row(fd, ccell, i) < 0) {
- G_close_cell(fd);
+ if (Rast_get_c_raster_row(fd, ccell, i) < 0) {
+ Rast_close_cell(fd);
}
for (j = 0; j < window.cols; j++) {
- if (G_is_c_null_value(&ccell[j]))
- G_set_d_null_value(&cell[i][j], 1);
+ if (Rast_is_c_null_value(&ccell[j]))
+ Rast_set_d_null_value(&cell[i][j], 1);
else
cell[i][j] = (DCELL) ccell[j];
}
}
else if (data_type == FCELL_TYPE) {
- if (G_get_f_raster_row(fd, fcell, i) < 0) {
- G_close_cell(fd);
+ if (Rast_get_f_raster_row(fd, fcell, i) < 0) {
+ Rast_close_cell(fd);
}
for (j = 0; j < window.cols; j++) {
- if (G_is_f_null_value(&fcell[j]))
- G_set_d_null_value(&cell[i][j], 1);
+ if (Rast_is_f_null_value(&fcell[j]))
+ Rast_set_d_null_value(&cell[i][j], 1);
else
cell[i][j] = (DCELL) fcell[j];
}
}
- else if (G_get_d_raster_row(fd, cell[i], i) < 0) {
- G_close_cell(fd);
+ else if (Rast_get_d_raster_row(fd, cell[i], i) < 0) {
+ Rast_close_cell(fd);
G_fatal_error(_("Unable to read raster map <%s> row %d"), iname,
i);
}
@@ -72,7 +73,7 @@
else if (data_type == FCELL_TYPE)
G_free(fcell);
G_percent(i, window.rows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
@@ -81,20 +82,20 @@
int fd, i;
struct History history;
- if ((fd = G_open_raster_new(oname, DCELL_TYPE)) < 0)
+ if ((fd = Rast_open_raster_new(oname, DCELL_TYPE)) < 0)
G_fatal_error(_("Cannot create raster map <%s>"), oname);
G_important_message(_("Writing topographic index map..."));
for (i = 0; i < window.rows; i++) {
G_percent(i, window.rows, 2);
- G_put_d_raster_row(fd, atb[i]);
+ Rast_put_d_raster_row(fd, atb[i]);
}
G_percent(i, window.rows, 2);
- G_close_cell(fd);
+ Rast_close_cell(fd);
- G_short_history(oname, "raster", &history);
+ Rast_short_history(oname, "raster", &history);
strncpy(history.datsrc_1, iname, RECORD_LEN);
history.datsrc_1[RECORD_LEN - 1] = '\0'; /* strncpy() doesn't null terminate if maxfill */
- G_write_history(oname, &history);
+ Rast_write_history(oname, &history);
}
Modified: grass/trunk/raster/r.topidx/global.h
===================================================================
--- grass/trunk/raster/r.topidx/global.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topidx/global.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,10 +1,11 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#define cv(i,j) cell[i][j]
#define av(i,j) a[i][j]
#define atbv(i,j) atb[i][j]
-#define IScvNULL(i,j) G_is_d_null_value(&cv(i,j))
-#define ISatbvNULL(i,j) G_is_d_null_value(&atbv(i,j))
+#define IScvNULL(i,j) Rast_is_d_null_value(&cv(i,j))
+#define ISatbvNULL(i,j) Rast_is_d_null_value(&atbv(i,j))
#define ZERO 0.0000001
Modified: grass/trunk/raster/r.topidx/main.c
===================================================================
--- grass/trunk/raster/r.topidx/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topidx/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#define _MAIN_C_
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
Modified: grass/trunk/raster/r.topidx/topidx.c
===================================================================
--- grass/trunk/raster/r.topidx/topidx.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topidx/topidx.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "global.h"
@@ -15,7 +16,7 @@
av(i, j) = window.ns_res * window.ew_res;
if (IScvNULL(i, j)) {
natb++;
- G_set_d_null_value(&atbv(i, j), 1);
+ Rast_set_d_null_value(&atbv(i, j), 1);
}
else {
atbv(i, j) = -10.0;
@@ -236,7 +237,7 @@
atbv(i, j) = log((av(i, j) / (2 * dx * sumtb)));
}
else {
- G_set_d_null_value(&atbv(i, j), 1);
+ Rast_set_d_null_value(&atbv(i, j), 1);
}
natb++;
continue;
Modified: grass/trunk/raster/r.topmodel/file_io.c
===================================================================
--- grass/trunk/raster/r.topmodel/file_io.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topmodel/file_io.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "global.h"
@@ -284,7 +285,7 @@
if (file.Qobs) {
fprintf(fp, "%-10s ", "Em:");
- if (!G_is_d_null_value(&misc.Em))
+ if (!Rast_is_d_null_value(&misc.Em))
fprintf(fp, "%10.5lf\n", misc.Em);
else
fprintf(fp, "Not resolved due to constant observed Q\n");
Modified: grass/trunk/raster/r.topmodel/global.h
===================================================================
--- grass/trunk/raster/r.topmodel/global.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topmodel/global.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
#include <math.h>
#include <time.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#define FILL 0x1
Modified: grass/trunk/raster/r.topmodel/infiltration.c
===================================================================
--- grass/trunk/raster/r.topmodel/infiltration.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topmodel/infiltration.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -66,7 +66,7 @@
break;
}
if (i == MAXITER) {
- G_set_d_null_value(&f, 1);
+ Rast_set_d_null_value(&f, 1);
return f;
}
pt = t - input.dt + (f_ - cumf) / R;
@@ -108,7 +108,7 @@
break;
}
if (i == MAXITER) {
- G_set_d_null_value(&f, 1);
+ Rast_set_d_null_value(&f, 1);
return f;
}
Modified: grass/trunk/raster/r.topmodel/topmodel.c
===================================================================
--- grass/trunk/raster/r.topmodel/topmodel.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.topmodel/topmodel.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "global.h"
@@ -270,7 +271,7 @@
if (denominator == 0.0) {
G_warning("Em can not be resolved due to constant " "observed Q");
- G_set_d_null_value(&Em, 1);
+ Rast_set_d_null_value(&Em, 1);
}
else {
Em = 1.0 - numerator / denominator;
Modified: grass/trunk/raster/r.univar/globals.h
===================================================================
--- grass/trunk/raster/r.univar/globals.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.univar/globals.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.univar/r.univar_main.c
===================================================================
--- grass/trunk/raster/r.univar/r.univar_main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.univar/r.univar_main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -107,7 +107,7 @@
if (map_type != -1) {
/* NB: map_type must match when doing extended stats */
- int this_type = G_get_raster_map_type(fd);
+ int this_type = Rast_get_raster_map_type(fd);
assert(this_type > -1);
if (map_type < -1) {
@@ -140,7 +140,7 @@
{
int fd;
- fd = G_open_cell_old(infile, "");
+ fd = Rast_open_cell_old(infile, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), infile);
@@ -172,13 +172,13 @@
const int cols = region->cols;
int first = (stats->n < 1);
- const RASTER_MAP_TYPE map_type = G_get_raster_map_type(fd);
+ const RASTER_MAP_TYPE map_type = Rast_get_raster_map_type(fd);
void *nextp
= ((!param.extended->answer) ? 0
: (map_type == DCELL_TYPE) ? (void *)stats->dcell_array
: (map_type == FCELL_TYPE) ? (void *)stats->fcell_array
: (void *)stats->cell_array);
- const size_t value_sz = G_raster_size(map_type);
+ const size_t value_sz = Rast_raster_size(map_type);
unsigned int row;
void *raster_row;
@@ -188,22 +188,22 @@
void *ptr;
unsigned int col;
- if (G_get_raster_row(fd, raster_row, row, map_type) < 0)
+ if (Rast_get_raster_row(fd, raster_row, row, map_type) < 0)
G_fatal_error(_("Reading row %d"), row);
ptr = raster_row;
for (col = 0; col < cols; col++) {
- if (G_is_null_value(ptr, map_type)) {
- ptr = G_incr_void_ptr(ptr, value_sz);
+ if (Rast_is_null_value(ptr, map_type)) {
+ ptr = Rast_incr_void_ptr(ptr, value_sz);
continue;
}
if (nextp) {
/* put the value into stats->XXXcell_array */
memcpy(nextp, ptr, value_sz);
- nextp = G_incr_void_ptr(nextp, value_sz);
+ nextp = Rast_incr_void_ptr(nextp, value_sz);
}
{
@@ -228,7 +228,7 @@
}
}
- ptr = G_incr_void_ptr(ptr, value_sz);
+ ptr = Rast_incr_void_ptr(ptr, value_sz);
stats->n++;
}
if (!(param.shell_style->answer))
Modified: grass/trunk/raster/r.uslek/main.c
===================================================================
--- grass/trunk/raster/r.uslek/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.uslek/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#define POLYGON_DIMENSION 20
@@ -84,28 +85,28 @@
result = output1->answer;
/***************************************************/
- if ((infd_psand = G_open_cell_old(psand, "")) < 0)
+ if ((infd_psand = Rast_open_cell_old(psand, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), psand);
- inrast_psand = G_allocate_d_raster_buf();
+ inrast_psand = Rast_allocate_d_raster_buf();
- if ((infd_psilt = G_open_cell_old(psilt, "")) < 0)
+ if ((infd_psilt = Rast_open_cell_old(psilt, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), psilt);
- inrast_psilt = G_allocate_d_raster_buf();
+ inrast_psilt = Rast_allocate_d_raster_buf();
- if ((infd_pclay = G_open_cell_old(pclay, "")) < 0)
+ if ((infd_pclay = Rast_open_cell_old(pclay, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), pclay);
- inrast_pclay = G_allocate_d_raster_buf();
+ inrast_pclay = Rast_allocate_d_raster_buf();
- if ((infd_pomat = G_open_cell_old(pomat, "")) < 0)
+ if ((infd_pomat = Rast_open_cell_old(pomat, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), pomat);
- inrast_pomat = G_allocate_d_raster_buf();
+ inrast_pomat = Rast_allocate_d_raster_buf();
/***************************************************/
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_d_raster_buf();
+ outrast = Rast_allocate_d_raster_buf();
/* Create New raster files */
- if ((outfd = G_open_raster_new(result, DCELL_TYPE)) < 0)
+ if ((outfd = Rast_open_raster_new(result, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/* Process pixels */
@@ -119,16 +120,16 @@
G_percent(row, nrows, 2);
/* read soil input maps */
- if (G_get_d_raster_row(infd_psand, inrast_psand, row) < 0)
+ if (Rast_get_d_raster_row(infd_psand, inrast_psand, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
psand, row);
- if (G_get_d_raster_row(infd_psilt, inrast_psilt, row) < 0)
+ if (Rast_get_d_raster_row(infd_psilt, inrast_psilt, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
psilt, row);
- if (G_get_d_raster_row(infd_pclay, inrast_pclay, row) < 0)
+ if (Rast_get_d_raster_row(infd_pclay, inrast_pclay, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
pclay, row);
- if (G_get_d_raster_row(infd_pomat, inrast_pomat, row) < 0)
+ if (Rast_get_d_raster_row(infd_pomat, inrast_pomat, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
pomat, row);
@@ -139,17 +140,17 @@
d_silt = ((DCELL *) inrast_psilt)[col];
d_clay = ((DCELL *) inrast_pclay)[col];
d_om = ((DCELL *) inrast_pomat)[col];
- if (G_is_d_null_value(&d_sand) ||
- G_is_d_null_value(&d_clay) ||
- G_is_d_null_value(&d_silt))
- G_set_d_null_value(&outrast[col], 1);
+ if (Rast_is_d_null_value(&d_sand) ||
+ Rast_is_d_null_value(&d_clay) ||
+ Rast_is_d_null_value(&d_silt))
+ Rast_set_d_null_value(&outrast[col], 1);
else {
/***************************************/
/* In case some map input not standard */
if ((d_sand + d_clay + d_silt) != 1.0)
- G_set_d_null_value(&outrast[col], 1);
+ Rast_set_d_null_value(&outrast[col], 1);
/* if OM==NULL then make it 0.0 */
- else if (G_is_d_null_value(&d_om))
+ else if (Rast_is_d_null_value(&d_om))
d_om = 0.0;
else {
/************************************/
@@ -160,7 +161,7 @@
}
}
}
- if (G_put_d_raster_row(outfd, outrast) < 0)
+ if (Rast_put_d_raster_row(outfd, outrast) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
result, row);
}
@@ -168,16 +169,16 @@
G_free(inrast_psilt);
G_free(inrast_pclay);
G_free(inrast_pomat);
- G_close_cell(infd_psand);
- G_close_cell(infd_psilt);
- G_close_cell(infd_pclay);
- G_close_cell(infd_pomat);
+ Rast_close_cell(infd_psand);
+ Rast_close_cell(infd_psilt);
+ Rast_close_cell(infd_pclay);
+ Rast_close_cell(infd_pomat);
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.usler/main.c
===================================================================
--- grass/trunk/raster/r.usler/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.usler/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
double elswaify_1985(double annual_pmm);
@@ -78,17 +79,17 @@
result = output->answer;
/***************************************************/
- if ((infd_annual_pmm = G_open_cell_old(annual_pmm, "")) < 0)
+ if ((infd_annual_pmm = Rast_open_cell_old(annual_pmm, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), annual_pmm);
- inrast_annual_pmm = G_allocate_d_raster_buf();
+ inrast_annual_pmm = Rast_allocate_d_raster_buf();
/***************************************************/
nrows = G_window_rows();
ncols = G_window_cols();
- outrast = G_allocate_d_raster_buf();
+ outrast = Rast_allocate_d_raster_buf();
/* Create New raster files */
- if ((outfd = G_open_raster_new(result, DCELL_TYPE)) < 0)
+ if ((outfd = Rast_open_raster_new(result, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), result);
/* Process pixels */
@@ -99,7 +100,7 @@
G_percent(row, nrows, 2);
/* read input map */
- if (G_get_d_raster_row(infd_annual_pmm, inrast_annual_pmm, row) < 0)
+ if (Rast_get_d_raster_row(infd_annual_pmm, inrast_annual_pmm, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
annual_pmm, row);
@@ -107,8 +108,8 @@
for (col = 0; col < ncols; col++)
{
d_annual_pmm = ((DCELL *) inrast_annual_pmm)[col];
- if (G_is_d_null_value(&d_annual_pmm))
- G_set_d_null_value(&outrast[col], 1);
+ if (Rast_is_d_null_value(&d_annual_pmm))
+ Rast_set_d_null_value(&outrast[col], 1);
else
{
/*calculate morgan */
@@ -126,18 +127,18 @@
outrast[col] = d ;
}
}
- if (G_put_d_raster_row(outfd, outrast) < 0)
+ if (Rast_put_d_raster_row(outfd, outrast) < 0)
G_fatal_error(_("Failed writing raster map <%s> row %d"),
result, row);
}
G_free(inrast_annual_pmm);
- G_close_cell(infd_annual_pmm);
+ Rast_close_cell(infd_annual_pmm);
G_free(outrast);
- G_close_cell(outfd);
+ Rast_close_cell(outfd);
- G_short_history(result, "raster", &history);
- G_command_history(&history);
- G_write_history(result, &history);
+ Rast_short_history(result, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(result, &history);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/raster/r.volume/centroids.c
===================================================================
--- grass/trunk/raster/r.volume/centroids.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.volume/centroids.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
* col = sigma(col)/n.
*/
#include <grass/gis.h>
+#include <grass/Rast.h>
int centroids(int fd, /* File descriptor of map layer to process */
/* This file is assumed to be opened before calling */
@@ -32,7 +33,7 @@
adjusted = 0;
- cell_buf = G_allocate_cell_buf();
+ cell_buf = Rast_allocate_cell_buf();
/* space to accumulate counts */
count = (int *)G_malloc((max + 1) * sizeof(int));
@@ -48,7 +49,7 @@
rows = G_window_rows();
cols = G_window_cols();
for (row = 0; row < rows; row++) {
- G_get_map_row(fd, cell_buf, row); /* get a row */
+ Rast_get_map_row(fd, cell_buf, row); /* get a row */
for (col = 0; col < cols; col++) {
v = cell_buf[col]; /* next cell value in row */
if (v < 1)
@@ -78,7 +79,7 @@
row = n[i];
col = e[i];
/* get cell at row,col */
- G_get_map_row(fd, cell_buf, row);
+ Rast_get_map_row(fd, cell_buf, row);
v = cell_buf[col];
if (v > 0) {
if (v == i)
@@ -96,7 +97,7 @@
/* go through map again */
for (row = 0; row < rows; row++) {
- G_get_map_row(fd, cell_buf, row);
+ Rast_get_map_row(fd, cell_buf, row);
for (col = 0; col < cols; col++) {
v = cell_buf[col];
if (v < 1)
Modified: grass/trunk/raster/r.volume/main.c
===================================================================
--- grass/trunk/raster/r.volume/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.volume/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/site.h>
#include <grass/glocale.h>
@@ -116,13 +117,13 @@
clumpmap = "MASK";
use_MASK = 1;
}
- fd_data = G_open_cell_old(datamap, "");
+ fd_data = Rast_open_cell_old(datamap, "");
if (use_MASK)
clump_mapset = G_mapset();
else
clump_mapset = "";
- fd_clump = G_open_cell_old(clumpmap, clump_mapset);
+ fd_clump = Rast_open_cell_old(clumpmap, clump_mapset);
/* initialize sites file (for centroids) if needed */
if (*site_list) {
@@ -132,7 +133,7 @@
}
/* initialize data accumulation arrays */
- max = G_number_of_cats(clumpmap, clump_mapset);
+ max = Rast_number_of_cats(clumpmap, clump_mapset);
sum = (double *)G_malloc((max + 1) * sizeof(double));
count = (long int *)G_malloc((max + 1) * sizeof(long int));
@@ -142,8 +143,8 @@
count[i] = 0;
}
- data_buf = G_allocate_cell_buf();
- clump_buf = G_allocate_cell_buf();
+ data_buf = Rast_allocate_cell_buf();
+ clump_buf = Rast_allocate_cell_buf();
/* get window size */
rows = window.rows;
@@ -156,14 +157,14 @@
G_message("Complete ...");
for (row = 0; row < rows; row++) {
G_percent(row, rows, 2);
- G_get_map_row(fd_data, data_buf, row);
- G_get_map_row(fd_clump, clump_buf, row);
+ Rast_get_map_row(fd_data, data_buf, row);
+ Rast_get_map_row(fd_clump, clump_buf, row);
for (col = 0; col < cols; col++) {
i = clump_buf[col];
if (i > max)
G_fatal_error(
"Row=%d Col=%d Cat=%d in clump map [%s]; max=%d.\n"
- "Cat value > max returned by G_number_of_cats.",
+ "Cat value > max returned by Rast_number_of_cats.",
row, col, i, clumpmap, max);
if (i < 1)
continue; /* ignore zeros and negs */
Modified: grass/trunk/raster/r.walk/btree.c
===================================================================
--- grass/trunk/raster/r.walk/btree.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.walk/btree.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -15,6 +15,7 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "local_proto.h"
#include "memory.h"
#include <stdlib.h>
Modified: grass/trunk/raster/r.walk/main.c
===================================================================
--- grass/trunk/raster/r.walk/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.walk/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -100,6 +100,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/site.h>
#include <grass/segment.h>
#include "cost.h"
@@ -366,7 +367,7 @@
H_DIAG_fac =
(double)sqrt((double)(NS_fac * NS_fac + 4 * EW_fac * EW_fac));
- G_set_d_null_value(&null_cost, 1);
+ Rast_set_d_null_value(&null_cost, 1);
if (flag2->answer)
total_reviewed = 16;
@@ -425,7 +426,7 @@
(sscanf(opt6->answer, "%lf", &null_cost) != 1)) {
G_message(_("Null cells excluded from cost evaluation."));
- G_set_d_null_value(&null_cost, 1);
+ Rast_set_d_null_value(&null_cost, 1);
}
else if (keep_nulls)
G_message(_("Input null cell will be retained into output map"));
@@ -515,10 +516,10 @@
G_sites_close(fp);
}
- if (!G_is_d_null_value(&null_cost)) {
+ if (!Rast_is_d_null_value(&null_cost)) {
if (null_cost < 0.0) {
G_warning(_("Warning: assigning negative cost to null cell. Null cells excluded."));
- G_set_d_null_value(&null_cost, 1);
+ Rast_set_d_null_value(&null_cost, 1);
}
}
else {
@@ -540,8 +541,8 @@
/* Open cost cell layer for reading */
- dtm_fd = G_open_cell_old(dtm_layer, "");
- cost_fd = G_open_cell_old(cost_layer, "");
+ dtm_fd = Rast_open_cell_old(dtm_layer, "");
+ cost_fd = Rast_open_cell_old(cost_layer, "");
if (dtm_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), dtm_layer);
@@ -549,8 +550,8 @@
if (cost_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), cost_layer);
- dtm_head_ok = G_get_cellhd(dtm_layer, "", &dtm_cellhd) >= 0;
- cost_head_ok = G_get_cellhd(cost_layer, "", &cost_cellhd) >= 0;
+ dtm_head_ok = Rast_get_cellhd(dtm_layer, "", &dtm_cellhd) >= 0;
+ cost_head_ok = Rast_get_cellhd(cost_layer, "", &cost_cellhd) >= 0;
/*Reading headers from maps */
@@ -564,10 +565,10 @@
if (dtm_cellhd.proj != cost_cellhd.proj)
G_fatal_error(_("Map with different projection"));
- dtm_data_type = G_get_raster_map_type(dtm_fd);
- cost_data_type = G_get_raster_map_type(cost_fd);
- dtm_cell = G_allocate_raster_buf(dtm_data_type);
- cost_cell = G_allocate_raster_buf(cost_data_type);
+ dtm_data_type = Rast_get_raster_map_type(dtm_fd);
+ cost_data_type = Rast_get_raster_map_type(cost_fd);
+ dtm_cell = Rast_allocate_raster_buf(dtm_data_type);
+ cost_cell = Rast_allocate_raster_buf(cost_data_type);
/* Parameters for map submatrices */
@@ -700,13 +701,13 @@
int i;
double p;
- dtm_dsize = G_raster_size(dtm_data_type);
+ dtm_dsize = Rast_raster_size(dtm_data_type);
p = 0.0;
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(dtm_fd, dtm_cell, row, dtm_data_type) < 0)
+ if (Rast_get_raster_row(dtm_fd, dtm_cell, row, dtm_data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
dtm_layer, row);
/* INPUT NULL VALUES: ??? */
@@ -714,39 +715,39 @@
switch (dtm_data_type) {
case CELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, dtm_data_type)) {
+ if (Rast_is_null_value(ptr2, dtm_data_type)) {
p = null_cost;
}
else {
p = *(int *)ptr2;
}
segment_put(&dtm_in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, dtm_dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, dtm_dsize);
}
break;
case FCELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, dtm_data_type)) {
+ if (Rast_is_null_value(ptr2, dtm_data_type)) {
p = null_cost;
}
else {
p = *(float *)ptr2;
}
segment_put(&dtm_in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, dtm_dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, dtm_dsize);
}
break;
case DCELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, dtm_data_type)) {
+ if (Rast_is_null_value(ptr2, dtm_data_type)) {
p = null_cost;
}
else {
p = *(double *)ptr2;
}
segment_put(&dtm_in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, dtm_dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, dtm_dsize);
}
break;
}
@@ -760,12 +761,12 @@
int i;
double p;
- cost_dsize = G_raster_size(cost_data_type);
+ cost_dsize = Rast_raster_size(cost_data_type);
p = 0.0;
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(cost_fd, cost_cell, row, cost_data_type) < 0)
+ if (Rast_get_raster_row(cost_fd, cost_cell, row, cost_data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cost_layer, row);
/* INPUT NULL VALUES: ??? */
@@ -773,39 +774,39 @@
switch (cost_data_type) {
case CELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, cost_data_type)) {
+ if (Rast_is_null_value(ptr2, cost_data_type)) {
p = null_cost;
}
else {
p = *(int *)ptr2;
}
segment_put(&cost_in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, cost_dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, cost_dsize);
}
break;
case FCELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, cost_data_type)) {
+ if (Rast_is_null_value(ptr2, cost_data_type)) {
p = null_cost;
}
else {
p = *(float *)ptr2;
}
segment_put(&cost_in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, cost_dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, cost_dsize);
}
break;
case DCELL_TYPE:
for (i = 0; i < ncols; i++) {
- if (G_is_null_value(ptr2, cost_data_type)) {
+ if (Rast_is_null_value(ptr2, cost_data_type)) {
p = null_cost;
}
else {
p = *(double *)ptr2;
}
segment_put(&cost_in_seg, &p, row, i);
- ptr2 = G_incr_void_ptr(ptr2, cost_dsize);
+ ptr2 = Rast_incr_void_ptr(ptr2, cost_dsize);
}
break;
}
@@ -832,7 +833,7 @@
if (fbuff == NULL)
G_fatal_error(_("Unable to allocate memory for segment fbuff == NULL"));
- G_set_d_null_value(fbuff, ncols);
+ Rast_set_d_null_value(fbuff, ncols);
for (row = 0; row < nrows; row++) {
{
@@ -860,7 +861,7 @@
if (fbuff == NULL)
G_fatal_error(_("Unable to allocate memory for segment fbuff == NULL"));
- G_set_d_null_value(fbuff, ncols);
+ Rast_set_d_null_value(fbuff, ncols);
for (row = 0; row < nrows; row++) {
{
@@ -883,32 +884,32 @@
int dsize2;
- cum_fd = G_open_cell_old(start_layer, "");
+ cum_fd = Rast_open_cell_old(start_layer, "");
if (cum_fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
start_layer);
- data_type2 = G_get_raster_map_type(cum_fd);
+ data_type2 = Rast_get_raster_map_type(cum_fd);
- dsize2 = G_raster_size(data_type2);
+ dsize2 = Rast_raster_size(data_type2);
- cell2 = G_allocate_raster_buf(data_type2);
+ cell2 = Rast_allocate_raster_buf(data_type2);
G_message(_("Reading %s... "), cum_cost_layer);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- if (G_get_raster_row(cum_fd, cell2, row, data_type2) < 0)
+ if (Rast_get_raster_row(cum_fd, cell2, row, data_type2) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cum_cost_layer, row);
ptr2 = cell2;
for (col = 0; col < ncols; col++) {
/* Did I understand that concept of cummulative cost map? - (pmx) 12 april 2000 */
- if (!G_is_null_value(ptr2, data_type2)) {
+ if (!Rast_is_null_value(ptr2, data_type2)) {
double cellval;
if (start_with_raster_vals == 1) {
- cellval = G_get_raster_value_d(ptr2, data_type2);
+ cellval = Rast_get_raster_value_d(ptr2, data_type2);
new_cell = insert(cellval, row, col);
segment_put(&out_seg, &cellval, row, col);
}
@@ -918,13 +919,13 @@
segment_put(&out_seg, value_start_pt, row, col);
}
}
- ptr2 = G_incr_void_ptr(ptr2, dsize2);
+ ptr2 = Rast_incr_void_ptr(ptr2, dsize2);
}
}
G_percent(row, nrows, 2);
- G_close_cell(cum_fd);
+ Rast_close_cell(cum_fd);
G_free(cell2);
}
@@ -981,7 +982,7 @@
/* If I've already been updated, delete me */
segment_get(&out_seg, &old_min_cost, pres_cell->row, pres_cell->col);
- if (!G_is_d_null_value(&old_min_cost)) {
+ if (!Rast_is_d_null_value(&old_min_cost)) {
if (pres_cell->min_cost > old_min_cost) {
delete(pres_cell);
pres_cell = get_lowest();
@@ -990,10 +991,10 @@
}
segment_get(&dtm_in_seg, &my_dtm, pres_cell->row, pres_cell->col);
- if (G_is_d_null_value(&my_dtm))
+ if (Rast_is_d_null_value(&my_dtm))
continue;
segment_get(&cost_in_seg, &my_cost, pres_cell->row, pres_cell->col);
- if (G_is_d_null_value(&my_cost))
+ if (Rast_is_d_null_value(&my_cost))
continue;
@@ -1100,7 +1101,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &W_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((W_dtm - my_dtm) / EW_fac) >= 0)
fcost_dtm = (double)((double)(W_dtm - my_dtm) * b);
@@ -1118,7 +1119,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &E_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((E_dtm - my_dtm) / EW_fac) >= 0)
fcost_dtm = (double)(E_dtm - my_dtm) * b;
@@ -1136,7 +1137,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &N_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((N_dtm - my_dtm) / NS_fac) >= 0)
fcost_dtm = (double)(N_dtm - my_dtm) * b;
@@ -1154,7 +1155,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &S_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((S_dtm - my_dtm) / NS_fac) >= 0)
fcost_dtm = (double)(S_dtm - my_dtm) * b;
@@ -1172,7 +1173,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &NW_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((NW_dtm - my_dtm) / DIAG_fac) >= 0)
fcost_dtm = (double)(NW_dtm - my_dtm) * b;
@@ -1190,7 +1191,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &NE_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((NE_dtm - my_dtm) / DIAG_fac) >= 0)
fcost_dtm = (double)(NE_dtm - my_dtm) * b;
@@ -1208,7 +1209,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &SE_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((SE_dtm - my_dtm) / DIAG_fac) >= 0)
fcost_dtm = (double)(SE_dtm - my_dtm) * b;
@@ -1226,7 +1227,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &SW_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((SW_dtm - my_dtm) / DIAG_fac) >= 0)
fcost_dtm = (double)(SW_dtm - my_dtm) * b;
@@ -1244,7 +1245,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &NNW_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((NNW_dtm - my_dtm) / V_DIAG_fac) >= 0)
fcost_dtm = (double)(NNW_dtm - my_dtm) * b;
@@ -1264,7 +1265,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &NNE_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((NNE_dtm - my_dtm) / V_DIAG_fac) >= 0)
fcost_dtm = (double)(NNE_dtm - my_dtm) * b;
@@ -1284,7 +1285,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &SSE_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((SSE_dtm - my_dtm) / V_DIAG_fac) >= 0)
fcost_dtm = (double)(SSE_dtm - my_dtm) * b;
@@ -1304,7 +1305,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &SSW_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((SSW_dtm - my_dtm) / V_DIAG_fac) >= 0)
fcost_dtm = (double)(SSW_dtm - my_dtm) * b;
@@ -1324,7 +1325,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &WNW_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((WNW_dtm - my_dtm) / H_DIAG_fac) >= 0)
fcost_dtm = (double)(WNW_dtm - my_dtm) * b;
@@ -1344,7 +1345,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &ENE_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((ENE_dtm - my_dtm) / H_DIAG_fac) >= 0)
fcost_dtm = (double)(ENE_dtm - my_dtm) * b;
@@ -1364,7 +1365,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &ESE_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((ESE_dtm - my_dtm) / H_DIAG_fac) >= 0)
fcost_dtm = (double)(ESE_dtm - my_dtm) * b;
@@ -1384,7 +1385,7 @@
segment_get(&dtm_in_seg, dtm_value, row, col);
cost_value = &WSW_cost;
segment_get(&cost_in_seg, cost_value, row, col);
- if (G_is_d_null_value(cost_value))
+ if (Rast_is_d_null_value(cost_value))
continue;
if (((WSW_dtm - my_dtm) / H_DIAG_fac) >= 0)
fcost_dtm = (double)(WSW_dtm - my_dtm) * b;
@@ -1401,14 +1402,14 @@
break;
}
- if (G_is_d_null_value(&min_cost))
+ if (Rast_is_d_null_value(&min_cost))
continue;
segment_get(&out_seg, &old_min_cost, row, col);
if (dir == 1)
segment_get(&out_seg2, &old_cur_dir, row, col);
- if (G_is_d_null_value(&old_min_cost)) {
+ if (Rast_is_d_null_value(&old_min_cost)) {
segment_put(&out_seg, &min_cost, row, col);
new_cell = insert(min_cost, row, col);
if (dir == 1)
@@ -1444,11 +1445,11 @@
OUT:
/* Open cumulative cost layer for writing */
- cum_fd = G_open_raster_new(cum_cost_layer, cum_data_type);
- cum_cell = G_allocate_raster_buf(cum_data_type);
+ cum_fd = Rast_open_raster_new(cum_cost_layer, cum_data_type);
+ cum_cell = Rast_allocate_raster_buf(cum_data_type);
if (dir == 1) {
- dir_fd = G_open_raster_new(move_dir_layer, dir_data_type);
- dir_cell = G_allocate_raster_buf(dir_data_type);
+ dir_fd = Rast_open_raster_new(move_dir_layer, dir_data_type);
+ dir_cell = Rast_allocate_raster_buf(dir_data_type);
}
/* Write pending updates by segment_put() to output map */
@@ -1465,7 +1466,7 @@
if (keep_nulls) {
G_message(_("Will copy input map null values into output map"));
- cell2 = G_allocate_raster_buf(dtm_data_type);
+ cell2 = Rast_allocate_raster_buf(dtm_data_type);
}
if (cum_data_type == CELL_TYPE) {
int *p;
@@ -1476,7 +1477,7 @@
G_percent(row, nrows, 2);
if (keep_nulls) {
- if (G_get_raster_row(dtm_fd, cell2, row, dtm_data_type) < 0)
+ if (Rast_get_raster_row(dtm_fd, cell2, row, dtm_data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
dtm_layer, row);
}
@@ -1484,14 +1485,14 @@
p2 = cell2;
for (col = 0; col < ncols; col++) {
if (keep_nulls) {
- if (G_is_null_value(p2++, dtm_data_type)) {
- G_set_null_value((p + col), 1, dtm_data_type);
+ if (Rast_is_null_value(p2++, dtm_data_type)) {
+ Rast_set_null_value((p + col), 1, dtm_data_type);
continue;
}
}
segment_get(&out_seg, &min_cost, row, col);
- if (G_is_d_null_value(&min_cost)) {
- G_set_null_value((p + col), 1, cum_data_type);
+ if (Rast_is_d_null_value(&min_cost)) {
+ Rast_set_null_value((p + col), 1, cum_data_type);
}
else {
if (min_cost > peak)
@@ -1499,7 +1500,7 @@
*(p + col) = (int)(min_cost + .5);
}
}
- G_put_raster_row(cum_fd, cum_cell, cum_data_type);
+ Rast_put_raster_row(cum_fd, cum_cell, cum_data_type);
}
}
else if (cum_data_type == FCELL_TYPE) {
@@ -1511,7 +1512,7 @@
G_percent(row, nrows, 2);
if (keep_nulls) {
- if (G_get_raster_row(dtm_fd, cell2, row, dtm_data_type) < 0)
+ if (Rast_get_raster_row(dtm_fd, cell2, row, dtm_data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
dtm_layer, row);
}
@@ -1519,14 +1520,14 @@
p2 = cell2;
for (col = 0; col < ncols; col++) {
if (keep_nulls) {
- if (G_is_null_value(p2++, dtm_data_type)) {
- G_set_null_value((p + col), 1, dtm_data_type);
+ if (Rast_is_null_value(p2++, dtm_data_type)) {
+ Rast_set_null_value((p + col), 1, dtm_data_type);
continue;
}
}
segment_get(&out_seg, &min_cost, row, col);
- if (G_is_d_null_value(&min_cost)) {
- G_set_null_value((p + col), 1, cum_data_type);
+ if (Rast_is_d_null_value(&min_cost)) {
+ Rast_set_null_value((p + col), 1, cum_data_type);
}
else {
if (min_cost > peak)
@@ -1534,7 +1535,7 @@
*(p + col) = (float)(min_cost);
}
}
- G_put_raster_row(cum_fd, cum_cell, cum_data_type);
+ Rast_put_raster_row(cum_fd, cum_cell, cum_data_type);
}
}
else if (cum_data_type == DCELL_TYPE) {
@@ -1546,7 +1547,7 @@
G_percent(row, nrows, 2);
if (keep_nulls) {
- if (G_get_raster_row(dtm_fd, cell2, row, dtm_data_type) < 0)
+ if (Rast_get_raster_row(dtm_fd, cell2, row, dtm_data_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cell2, row);
}
@@ -1554,14 +1555,14 @@
p2 = cell2;
for (col = 0; col < ncols; col++) {
if (keep_nulls) {
- if (G_is_null_value(p2++, dtm_data_type)) {
- G_set_null_value((p + col), 1, dtm_data_type);
+ if (Rast_is_null_value(p2++, dtm_data_type)) {
+ Rast_set_null_value((p + col), 1, dtm_data_type);
continue;
}
}
segment_get(&out_seg, &min_cost, row, col);
- if (G_is_d_null_value(&min_cost)) {
- G_set_null_value((p + col), 1, cum_data_type);
+ if (Rast_is_d_null_value(&min_cost)) {
+ Rast_set_null_value((p + col), 1, cum_data_type);
}
else {
if (min_cost > peak)
@@ -1569,7 +1570,7 @@
*(p + col) = min_cost;
}
}
- G_put_raster_row(cum_fd, cum_cell, cum_data_type);
+ Rast_put_raster_row(cum_fd, cum_cell, cum_data_type);
}
}
@@ -1583,7 +1584,7 @@
segment_get(&out_seg2, &cur_dir, row, col);
*(p + col) = cur_dir;
}
- G_put_raster_row(dir_fd, dir_cell, dir_data_type);
+ Rast_put_raster_row(dir_fd, dir_cell, dir_data_type);
}
G_percent(row, nrows, 2);
}
@@ -1595,11 +1596,11 @@
segment_release(&out_seg);
if (dir == 1)
segment_release(&out_seg2);
- G_close_cell(dtm_fd);
- G_close_cell(cost_fd);
- G_close_cell(cum_fd);
+ Rast_close_cell(dtm_fd);
+ Rast_close_cell(cost_fd);
+ Rast_close_cell(cum_fd);
if (dir == 1)
- G_close_cell(dir_fd);
+ Rast_close_cell(dir_fd);
close(dtm_in_fd); /* close all files */
close(out_fd);
close(cost_in_fd);
@@ -1614,21 +1615,21 @@
/* Create colours for output map */
/*
- * G_read_range (cum_cost_layer, "", &range);
- * G_get_range_min_max(&range, &min, &max);
+ * Rast_read_range (cum_cost_layer, "", &range);
+ * Rast_get_range_min_max(&range, &min, &max);
* G_make_color_wave(&colors,min, max);
- * G_write_colors (cum_cost_layer,"",&colors);
+ * Rast_write_colors (cum_cost_layer,"",&colors);
*/
/* writing history file */
- G_short_history(cum_cost_layer, "raster", &history);
- G_command_history(&history);
- G_write_history(cum_cost_layer, &history);
+ Rast_short_history(cum_cost_layer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(cum_cost_layer, &history);
if (dir == 1) {
- G_short_history(move_dir_layer, "raster", &history);
- G_command_history(&history);
- G_write_history(move_dir_layer, &history);
+ Rast_short_history(move_dir_layer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(move_dir_layer, &history);
}
exit(EXIT_SUCCESS);
Modified: grass/trunk/raster/r.walk/memory.c
===================================================================
--- grass/trunk/raster/r.walk/memory.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.walk/memory.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -17,6 +17,7 @@
#include <string.h>
#include <errno.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "memory.h"
#define NUM_IN_BLOCK 1024*8
Modified: grass/trunk/raster/r.water.outlet/basin.h
===================================================================
--- grass/trunk/raster/r.water.outlet/basin.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.water.outlet/basin.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ramseg.h"
#include "flag.h"
Modified: grass/trunk/raster/r.water.outlet/flag_create.c
===================================================================
--- grass/trunk/raster/r.water.outlet/flag_create.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.water.outlet/flag_create.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
FLAG *flag_create(int nrows, int ncols)
Modified: grass/trunk/raster/r.water.outlet/flag_destroy.c
===================================================================
--- grass/trunk/raster/r.water.outlet/flag_destroy.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.water.outlet/flag_destroy.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
int flag_destroy(FLAG * flags)
Modified: grass/trunk/raster/r.water.outlet/main.c
===================================================================
--- grass/trunk/raster/r.water.outlet/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.water.outlet/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "basin.h"
@@ -126,7 +127,7 @@
total = nrows * ncols;
nrows_less_one = nrows - 1;
ncols_less_one = ncols - 1;
- drain_fd = G_open_cell_old(drain_name, "");
+ drain_fd = Rast_open_cell_old(drain_name, "");
if (drain_fd < 0)
G_fatal_error(_("Unable to open drainage pointer map"));
@@ -134,10 +135,10 @@
drain_ptrs =
(char *)G_malloc(sizeof(char) * size_array(&pt_seg, nrows, ncols));
bas = (CELL *) G_calloc(size_array(&ba_seg, nrows, ncols), sizeof(CELL));
- cell_buf = G_allocate_cell_buf();
+ cell_buf = Rast_allocate_cell_buf();
for (row = 0; row < nrows; row++) {
- G_get_map_row(drain_fd, cell_buf, row);
+ Rast_get_map_row(drain_fd, cell_buf, row);
for (col = 0; col < ncols; col++) {
if (cell_buf[col] == 0)
total--;
@@ -150,8 +151,8 @@
if (row >= 0 && col >= 0 && row < nrows && col < ncols)
overland_cells(row, col);
G_free(drain_ptrs);
- cell_buf = G_allocate_cell_buf();
- basin_fd = G_open_cell_new(basin_name);
+ cell_buf = Rast_allocate_cell_buf();
+ basin_fd = Rast_open_cell_new(basin_name);
if (basin_fd < 0)
G_fatal_error(_("Unable to open new basin map"));
@@ -160,11 +161,11 @@
for (col = 0; col < ncols; col++) {
cell_buf[col] = bas[SEG_INDEX(ba_seg, row, col)];
}
- G_put_raster_row(basin_fd, cell_buf, CELL_TYPE);
+ Rast_put_raster_row(basin_fd, cell_buf, CELL_TYPE);
}
G_free(bas);
G_free(cell_buf);
- if (G_close_cell(basin_fd) < 0)
+ if (Rast_close_cell(basin_fd) < 0)
G_fatal_error(_("Unable to close new basin map layer"));
return 0;
Modified: grass/trunk/raster/r.watershed/front/main.c
===================================================================
--- grass/trunk/raster/r.watershed/front/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/front/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int write_hist(char *, char *, char *, int, int);
@@ -442,9 +443,9 @@
{
struct History history;
- G_put_cell_title(map_name, title);
+ Rast_put_cell_title(map_name, title);
- G_short_history(map_name, "raster", &history);
+ Rast_short_history(map_name, "raster", &history);
strncpy(history.datsrc_1, source_name, RECORD_LEN);
history.datsrc_1[RECORD_LEN - 1] = '\0'; /* strncpy() doesn't null terminate if maxfill */
sprintf(history.edhist[0],
@@ -452,7 +453,7 @@
sprintf(history.edhist[1],
"Memory mode: %s", mode ? "Segmented" : "All in RAM");
history.edlinecnt = 2;
- G_command_history(&history);
+ Rast_command_history(&history);
- return G_write_history(map_name, &history);
+ return Rast_write_history(map_name, &history);
}
Modified: grass/trunk/raster/r.watershed/ram/Gwater.h
===================================================================
--- grass/trunk/raster/r.watershed/ram/Gwater.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/Gwater.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
/* last modified 03/26/91 */
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "ramseg.h"
#include "flag.h"
Modified: grass/trunk/raster/r.watershed/ram/close_maps.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/close_maps.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/close_maps.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include "Gwater.h"
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -16,16 +17,16 @@
DCELL sum, sum_sqr, stddev, lstddev, dvalue;
if (asp_flag || dis_flag)
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
if (wat_flag || ls_flag || sl_flag || sg_flag)
- dbuf = G_allocate_d_raster_buf();
+ dbuf = Rast_allocate_d_raster_buf();
G_free(alt);
if (ls_flag || sg_flag)
G_free(r_h);
sum = sum_sqr = stddev = 0.0;
if (wat_flag) {
- fd = G_open_raster_new(wat_name, DCELL_TYPE);
+ fd = Rast_open_raster_new(wat_name, DCELL_TYPE);
if (fd < 0) {
G_warning(_("unable to open new accum map layer."));
}
@@ -34,35 +35,35 @@
G_warning("Writing out only positive flow accumulation values.");
G_warning("Cells with a likely underestimate for flow accumulation can no longer be identified.");
for (r = 0; r < nrows; r++) {
- G_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
+ Rast_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
dvalue = wat[SEG_INDEX(wat_seg, r, c)];
- if (G_is_d_null_value(&dvalue) == 0 && dvalue) {
+ if (Rast_is_d_null_value(&dvalue) == 0 && dvalue) {
dvalue = ABS(dvalue);
dbuf[c] = dvalue;
sum += dvalue;
sum_sqr += dvalue * dvalue;
}
}
- G_put_raster_row(fd, dbuf, DCELL_TYPE);
+ Rast_put_raster_row(fd, dbuf, DCELL_TYPE);
}
}
else {
for (r = 0; r < nrows; r++) {
- G_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
+ Rast_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
dvalue = wat[SEG_INDEX(wat_seg, r, c)];
- if (G_is_d_null_value(&dvalue) == 0 && dvalue) {
+ if (Rast_is_d_null_value(&dvalue) == 0 && dvalue) {
dbuf[c] = dvalue;
dvalue = ABS(dvalue);
sum += dvalue;
sum_sqr += dvalue * dvalue;
}
}
- G_put_raster_row(fd, dbuf, DCELL_TYPE);
+ Rast_put_raster_row(fd, dbuf, DCELL_TYPE);
}
}
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_warning(_("Close failed."));
stddev =
@@ -73,94 +74,94 @@
lstddev = log(stddev);
- G_read_fp_range(wat_name, this_mapset, &accRange);
+ Rast_read_fp_range(wat_name, this_mapset, &accRange);
min = max = 0;
- G_get_fp_range_min_max(&accRange, &min, &max);
+ Rast_get_fp_range_min_max(&accRange, &min, &max);
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
if (min < 0) {
if (min < (-stddev - 1)) {
clr_min = min;
clr_max = -stddev - 1;
- G_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
0, 0, &colors);
}
clr_min = -stddev - 1.;
clr_max = -1. * exp(lstddev * 0.75);
- G_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
0, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.5);
- G_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0,
255, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.35);
- G_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
255, 0, &colors);
clr_min = clr_max;
clr_max = -1.;
- G_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 255,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 255,
255, 0, &colors);
}
clr_min = -1.;
clr_max = 1.;
- G_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
+ Rast_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
255, 0, &colors);
clr_min = 1;
clr_max = exp(lstddev * 0.35);
- G_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
255, 0, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.5);
- G_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
255, 255, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.75);
- G_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
0, 255, &colors);
clr_min = clr_max;
clr_max = stddev + 1.;
- G_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
0, &colors);
if (max > 0 && max > stddev + 1) {
clr_min = stddev + 1;
clr_max = max;
- G_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0,
0, &colors);
}
- G_write_colors(wat_name, this_mapset, &colors);
+ Rast_write_colors(wat_name, this_mapset, &colors);
}
}
/* TODO: elevation == NULL -> drainage direction == NULL (wat == 0 where ele == NULL) */
/* keep drainage direction == 0 for real depressions */
if (asp_flag) {
- fd = G_open_cell_new(asp_name);
+ fd = Rast_open_cell_new(asp_name);
if (fd < 0) {
G_warning(_("unable to open new aspect map layer."));
}
else {
for (r = 0; r < nrows; r++) {
- G_set_c_null_value(buf, ncols); /* reset row to all NULL */
+ Rast_set_c_null_value(buf, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
buf[c] = asp[SEG_INDEX(asp_seg, r, c)];
}
- G_put_raster_row(fd, buf, CELL_TYPE);
+ Rast_put_raster_row(fd, buf, CELL_TYPE);
}
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_warning(_("Close failed."));
}
- G_init_colors(&colors);
- G_make_aspect_colors(&colors, 0, 8);
- G_write_colors(asp_name, this_mapset, &colors);
+ Rast_init_colors(&colors);
+ Rast_make_aspect_colors(&colors, 0, 8);
+ Rast_write_colors(asp_name, this_mapset, &colors);
}
G_free(asp);
/* visual output no longer needed */
if (dis_flag) {
- fd = G_open_cell_new(dis_name);
+ fd = Rast_open_cell_new(dis_name);
if (fd < 0) {
G_warning(_("unable to open new accum map layer."));
}
@@ -180,23 +181,23 @@
}
}
}
- G_put_raster_row(fd, buf, CELL_TYPE);
+ Rast_put_raster_row(fd, buf, CELL_TYPE);
}
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_warning(_("Close failed."));
}
- G_init_colors(&colors);
- G_make_rainbow_colors(&colors, 1, 120);
- G_write_colors(dis_name, this_mapset, &colors);
+ Rast_init_colors(&colors);
+ Rast_make_rainbow_colors(&colors, 1, 120);
+ Rast_write_colors(dis_name, this_mapset, &colors);
}
flag_destroy(swale);
/*
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
*/
G_free(wat);
if (ls_flag) {
- fd = G_open_raster_new(ls_name, DCELL_TYPE);
+ fd = Rast_open_raster_new(ls_name, DCELL_TYPE);
if (fd < 0) {
G_warning(_("unable to open new LS factor map layer."));
}
@@ -205,16 +206,16 @@
for (c = 0; c < ncols; c++) {
dbuf[c] = l_s[SEG_INDEX(l_s_seg, r, c)];
}
- G_put_raster_row(fd, dbuf, DCELL_TYPE);
+ Rast_put_raster_row(fd, dbuf, DCELL_TYPE);
}
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_warning(_("Close failed."));
}
G_free(l_s);
}
if (sl_flag) {
- fd = G_open_raster_new(sl_name, DCELL_TYPE);
+ fd = Rast_open_raster_new(sl_name, DCELL_TYPE);
if (fd < 0) {
G_warning(_("unable to open new slope length map layer."));
}
@@ -225,9 +226,9 @@
if (dbuf[c] > max_length)
dbuf[c] = max_length;
}
- G_put_raster_row(fd, dbuf, DCELL_TYPE);
+ Rast_put_raster_row(fd, dbuf, DCELL_TYPE);
}
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_warning(_("Close failed."));
}
}
@@ -236,7 +237,7 @@
G_free(s_l);
if (sg_flag) {
- fd = G_open_raster_new(sg_name, DCELL_TYPE);
+ fd = Rast_open_raster_new(sg_name, DCELL_TYPE);
if (fd < 0) {
G_warning(_("unable to open new S factor map layer."));
}
@@ -245,9 +246,9 @@
for (c = 0; c < ncols; c++) {
dbuf[c] = s_g[SEG_INDEX(s_g_seg, r, c)];
}
- G_put_raster_row(fd, dbuf, DCELL_TYPE);
+ Rast_put_raster_row(fd, dbuf, DCELL_TYPE);
}
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_warning(_("Close failed."));
}
G_free(s_g);
Modified: grass/trunk/raster/r.watershed/ram/close_maps2.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/close_maps2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/close_maps2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -10,7 +10,7 @@
CELL *theseg;
RAMSEG thesegseg;
- cellrow = G_allocate_cell_buf();
+ cellrow = Rast_allocate_cell_buf();
if (seg_flag || bas_flag || haf_flag) {
if (seg_flag) {
theseg = bas;
@@ -32,11 +32,11 @@
}
}
G_debug(1, "%d basins created", max);
- G_init_colors(&colors);
- G_make_random_colors(&colors, 1, max);
+ Rast_init_colors(&colors);
+ Rast_make_random_colors(&colors, 1, max);
if (max < 10000) {
- G_set_color((CELL) 0, 0, 0, 0, &colors);
+ Rast_set_color((CELL) 0, 0, 0, 0, &colors);
r = 1;
incr = 0;
while (incr >= 0) {
@@ -46,12 +46,12 @@
for (bl = 90 + incr; bl <= 255; bl += 40) {
flag = 1;
while (flag) {
- G_get_color(r, &red, &green, &blue, &colors);
+ Rast_get_color(r, &red, &green, &blue, &colors);
/* if existing rule is too dark then append a new
rule to override it */
if ((blue * .11 + red * .30 + green * .59) <
100) {
- G_set_color(r, rd, gr, bl, &colors);
+ Rast_set_color(r, rd, gr, bl, &colors);
flag = 0;
}
if (++r > max) {
@@ -83,52 +83,52 @@
/* stream segments map */
if (seg_flag) {
- map_fd = G_open_cell_new(seg_name);
+ map_fd = Rast_open_cell_new(seg_name);
for (r = 0; r < nrows; r++) {
- G_set_c_null_value(cellrow, ncols); /* reset row to all NULL */
+ Rast_set_c_null_value(cellrow, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
value = FLAG_GET(swale, r, c);
if (value)
cellrow[c] = bas[SEG_INDEX(bas_seg, r, c)];
}
- G_put_raster_row(map_fd, cellrow, CELL_TYPE);
+ Rast_put_raster_row(map_fd, cellrow, CELL_TYPE);
}
- G_close_cell(map_fd);
- G_write_colors(seg_name, this_mapset, &colors);
+ Rast_close_cell(map_fd);
+ Rast_write_colors(seg_name, this_mapset, &colors);
}
/* basins map */
if (bas_flag) {
- map_fd = G_open_cell_new(bas_name);
+ map_fd = Rast_open_cell_new(bas_name);
for (r = 0; r < nrows; r++) {
for (c = 0; c < ncols; c++) {
cellrow[c] = bas[SEG_INDEX(bas_seg, r, c)];
if (cellrow[c] == 0)
- G_set_c_null_value(cellrow + c, 1);
+ Rast_set_c_null_value(cellrow + c, 1);
}
- G_put_raster_row(map_fd, cellrow, CELL_TYPE);
+ Rast_put_raster_row(map_fd, cellrow, CELL_TYPE);
}
- G_close_cell(map_fd);
- G_write_colors(bas_name, this_mapset, &colors);
+ Rast_close_cell(map_fd);
+ Rast_write_colors(bas_name, this_mapset, &colors);
}
/* half_basins map */
if (haf_flag) {
- map_fd = G_open_cell_new(haf_name);
+ map_fd = Rast_open_cell_new(haf_name);
for (r = 0; r < nrows; r++) {
for (c = 0; c < ncols; c++) {
cellrow[c] = haf[SEG_INDEX(haf_seg, r, c)];
if (cellrow[c] == 0)
- G_set_c_null_value(cellrow + c, 1);
+ Rast_set_c_null_value(cellrow + c, 1);
}
- G_put_raster_row(map_fd, cellrow, CELL_TYPE);
+ Rast_put_raster_row(map_fd, cellrow, CELL_TYPE);
}
- G_close_cell(map_fd);
- G_write_colors(haf_name, this_mapset, &colors);
+ Rast_close_cell(map_fd);
+ Rast_write_colors(haf_name, this_mapset, &colors);
}
if (seg_flag || bas_flag || haf_flag)
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
G_free(haf);
G_free(bas);
Modified: grass/trunk/raster/r.watershed/ram/do_astar.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_astar.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/do_astar.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include "Gwater.h"
#include "do_astar.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int do_astar(void)
Modified: grass/trunk/raster/r.watershed/ram/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/do_cum.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/do_cum.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include "Gwater.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -194,7 +195,7 @@
is_worked = FLAG_GET(worked, r_nbr, c_nbr);
if (is_worked == 0) {
ele_nbr = alt[SEG_INDEX(alt_seg, r_nbr, c_nbr)];
- is_null = G_is_c_null_value(&ele_nbr);
+ is_null = Rast_is_c_null_value(&ele_nbr);
edge = is_null;
if (!is_null && ele_nbr <= ele) {
if (ele_nbr < ele) {
Modified: grass/trunk/raster/r.watershed/ram/flag_create.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/flag_create.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/flag_create.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
FLAG *flag_create(int nrows, int ncols)
Modified: grass/trunk/raster/r.watershed/ram/flag_destroy.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/flag_destroy.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/flag_destroy.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "flag.h"
int flag_destroy(FLAG * flags)
Modified: grass/trunk/raster/r.watershed/ram/init_vars.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/init_vars.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/init_vars.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <string.h>
#include "Gwater.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int ele_round(double);
@@ -139,14 +140,14 @@
worked = flag_create(nrows, ncols);
/* open elevation input */
- fd = G_open_cell_old(ele_name, "");
+ fd = Rast_open_cell_old(ele_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open elevation map layer"));
}
- ele_map_type = G_get_raster_map_type(fd);
- ele_size = G_raster_size(ele_map_type);
- elebuf = G_allocate_raster_buf(ele_map_type);
+ ele_map_type = Rast_get_raster_map_type(fd);
+ ele_size = Rast_raster_size(ele_map_type);
+ elebuf = Rast_allocate_raster_buf(ele_map_type);
if (ele_map_type == FCELL_TYPE || ele_map_type == DCELL_TYPE)
ele_scale = 1000; /* should be enough to do the trick */
@@ -155,7 +156,7 @@
MASK_flag = 0;
do_points = nrows * ncols;
for (r = 0; r < nrows; r++) {
- G_get_raster_row(fd, elebuf, r, ele_map_type);
+ Rast_get_raster_row(fd, elebuf, r, ele_map_type);
ptr = elebuf;
for (c = 0; c < ncols; c++) {
index = SEG_INDEX(alt_seg, r, c);
@@ -166,10 +167,10 @@
flag_unset(worked, r, c);
/* check for masked and NULL cells */
- if (G_is_null_value(ptr, ele_map_type)) {
+ if (Rast_is_null_value(ptr, ele_map_type)) {
FLAG_SET(worked, r, c);
FLAG_SET(in_list, r, c);
- G_set_c_null_value(&alt_value, 1);
+ Rast_set_c_null_value(&alt_value, 1);
do_points--;
}
else {
@@ -191,10 +192,10 @@
if (er_flag) {
r_h[index] = alt_value;
}
- ptr = G_incr_void_ptr(ptr, ele_size);
+ ptr = Rast_incr_void_ptr(ptr, ele_size);
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(elebuf);
if (do_points < nrows * ncols)
MASK_flag = 1;
@@ -204,15 +205,15 @@
(DCELL *) G_malloc(sizeof(DCELL) *
size_array(&wat_seg, nrows, ncols));
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
if (run_flag) {
/* ... with input map flow: amount of overland flow per cell */
- fd = G_open_cell_old(run_name, "");
+ fd = Rast_open_cell_old(run_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open runoff map layer"));
}
for (r = 0; r < nrows; r++) {
- G_get_c_raster_row(fd, buf, r);
+ Rast_get_c_raster_row(fd, buf, r);
for (c = 0; c < ncols; c++) {
if (MASK_flag) {
index = FLAG_GET(worked, r, c);
@@ -225,7 +226,7 @@
wat[SEG_INDEX(wat_seg, r, c)] = buf[c];
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
else {
/* ... with 1.0 */
@@ -246,41 +247,41 @@
/* depression: drainage direction will be set to zero later */
if (pit_flag) {
- fd = G_open_cell_old(pit_name, "");
+ fd = Rast_open_cell_old(pit_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open depression map layer"));
}
for (r = 0; r < nrows; r++) {
- G_get_c_raster_row(fd, buf, r);
+ Rast_get_c_raster_row(fd, buf, r);
for (c = 0; c < ncols; c++) {
asp_value = buf[c];
- if (!G_is_c_null_value(&asp_value) && asp_value)
+ if (!Rast_is_c_null_value(&asp_value) && asp_value)
asp[SEG_INDEX(asp_seg, r, c)] = 1;
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
/* this is also creating streams... */
if (ob_flag) {
- fd = G_open_cell_old(ob_name, "");
+ fd = Rast_open_cell_old(ob_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open blocking map layer"));
}
for (r = 0; r < nrows; r++) {
- G_get_c_raster_row(fd, buf, r);
+ Rast_get_c_raster_row(fd, buf, r);
for (c = 0; c < ncols; c++) {
block_value = buf[c];
- if (!G_is_c_null_value(&block_value) && block_value)
+ if (!Rast_is_c_null_value(&block_value) && block_value)
FLAG_SET(swale, r, c);
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
G_free(buf);
if (ril_flag) {
- ril_fd = G_open_cell_old(ril_name, "");
+ ril_fd = Rast_open_cell_old(ril_name, "");
if (ril_fd < 0) {
G_fatal_error(_("unable to open rill map layer"));
}
Modified: grass/trunk/raster/r.watershed/ram/main.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <unistd.h>
#include "Gwater.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct Cell_head window;
Modified: grass/trunk/raster/r.watershed/ram/sg_factor.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/sg_factor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/sg_factor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include "Gwater.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
CELL *ril_buf;
@@ -13,12 +14,12 @@
G_message(_("SECTION 4: RUSLE LS and/or S factor determination."));
if (ril_flag)
- ril_buf = G_allocate_cell_buf();
+ ril_buf = Rast_allocate_cell_buf();
for (r = 0; r < nrows; r++) {
G_percent(r, nrows, 3);
if (ril_flag) {
- G_get_c_raster_row(ril_fd, ril_buf, r);
+ Rast_get_c_raster_row(ril_fd, ril_buf, r);
}
for (c = 0; c < ncols; c++) {
low_elev = alt[SEG_INDEX(alt_seg, r, c)];
@@ -46,7 +47,7 @@
if (ril_flag) {
G_free(ril_buf);
- G_close_cell(ril_fd);
+ Rast_close_cell(ril_fd);
}
return 0;
Modified: grass/trunk/raster/r.watershed/ram/usage.c
===================================================================
--- grass/trunk/raster/r.watershed/ram/usage.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/ram/usage.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.watershed/seg/Gwater.h
===================================================================
--- grass/trunk/raster/r.watershed/seg/Gwater.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/Gwater.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
/* last modified 03/26/91 */
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "cseg.h"
#define AR_SIZE 16
Modified: grass/trunk/raster/r.watershed/seg/bseg_close.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_close.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/bseg_close.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/bseg_get.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_get.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/bseg_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/bseg_open.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_open.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/bseg_open.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include <fcntl.h>
#include <grass/segment.h>
Modified: grass/trunk/raster/r.watershed/seg/bseg_put.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_put.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/bseg_put.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/bseg_read.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_read.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/bseg_read.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include "cseg.h"
@@ -15,7 +16,7 @@
bseg->name = NULL;
bseg->mapset = NULL;
- map_fd = G_open_cell_old(map_name, mapset);
+ map_fd = Rast_open_cell_old(map_name, mapset);
if (map_fd < 0) {
sprintf(msg, "%s(): unable to open file [%s] in [%s], %d",
me, map_name, mapset, map_fd);
@@ -24,11 +25,11 @@
}
nrows = G_window_rows();
ncols = G_window_cols();
- buffer = G_allocate_cell_buf();
+ buffer = Rast_allocate_cell_buf();
for (row = 0; row < nrows; row++) {
- if (G_get_c_raster_row(map_fd, buffer, row) < 0) {
+ if (Rast_get_c_raster_row(map_fd, buffer, row) < 0) {
G_free(buffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
sprintf(msg, "%s(): unable to read file [%s] in [%s], %d %d",
me, map_name, mapset, row, nrows);
G_warning(msg);
@@ -39,7 +40,7 @@
}
}
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
G_free(buffer);
bseg->name = G_store(map_name);
Modified: grass/trunk/raster/r.watershed/seg/bseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/bseg_write.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/bseg_write.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "cseg.h"
static char *me = "bseg_write_cell";
@@ -11,28 +12,28 @@
CELL *buffer;
CELL value;
- map_fd = G_open_cell_new(map_name);
+ map_fd = Rast_open_cell_new(map_name);
if (map_fd < 0) {
G_warning("%s(): unable to open new map layer [%s]", me, map_name);
return -1;
}
nrows = G_window_rows();
ncols = G_window_cols();
- buffer = G_allocate_cell_buf();
+ buffer = Rast_allocate_cell_buf();
for (row = 0; row < nrows; row++) {
for (col = 0; col < ncols; col++) {
bseg_get(bseg, &value, row, col);
buffer[col] = value;
}
- if (G_put_raster_row(map_fd, buffer, CELL_TYPE) < 0) {
+ if (Rast_put_raster_row(map_fd, buffer, CELL_TYPE) < 0) {
G_free(buffer);
- G_unopen_cell(map_fd);
+ Rast_unopen_cell(map_fd);
G_warning("%s(): unable to write new map layer [%s], row %d",
me, map_name, row);
return -2;
}
}
G_free(buffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
return 0;
}
Modified: grass/trunk/raster/r.watershed/seg/close_maps.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/close_maps.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/close_maps.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,45 +18,45 @@
cseg_close(&alt);
if (wat_flag) {
sum = sum_sqr = stddev = 0.0;
- dbuf = G_allocate_d_raster_buf();
+ dbuf = Rast_allocate_d_raster_buf();
if (abs_acc) {
G_warning("Writing out only positive flow accumulation values.");
G_warning("Cells with a likely underestimate for flow accumulation can no longer be identified.");
- fd = G_open_raster_new(wat_name, DCELL_TYPE);
+ fd = Rast_open_raster_new(wat_name, DCELL_TYPE);
if (fd < 0) {
G_warning(_("unable to open new accum map layer."));
}
for (r = 0; r < nrows; r++) {
- G_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
+ Rast_set_d_null_value(dbuf, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
dseg_get(&wat, &dvalue, r, c);
- if (G_is_d_null_value(&dvalue) == 0 && dvalue) {
+ if (Rast_is_d_null_value(&dvalue) == 0 && dvalue) {
dvalue = ABS(dvalue);
dbuf[c] = dvalue;
sum += dvalue;
sum_sqr += dvalue * dvalue;
}
}
- G_put_raster_row(fd, dbuf, DCELL_TYPE);
+ Rast_put_raster_row(fd, dbuf, DCELL_TYPE);
}
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_warning(_("Close failed."));
}
else {
dseg_write_cellfile(&wat, wat_name);
/* get standard deviation */
- fd = G_open_cell_old(wat_name, "");
+ fd = Rast_open_cell_old(wat_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open flow accumulation map layer"));
}
for (r = 0; r < nrows; r++) {
- G_get_d_raster_row(fd, dbuf, r);
+ Rast_get_d_raster_row(fd, dbuf, r);
for (c = 0; c < ncols; c++) {
dvalue = dbuf[c];
- if (G_is_d_null_value(&dvalue) == 0 && dvalue) {
+ if (Rast_is_d_null_value(&dvalue) == 0 && dvalue) {
dvalue = ABS(dvalue);
sum += dvalue;
sum_sqr += dvalue * dvalue;
@@ -73,70 +73,70 @@
lstddev = log(stddev);
- G_read_fp_range(wat_name, this_mapset, &accRange);
+ Rast_read_fp_range(wat_name, this_mapset, &accRange);
min = max = 0;
- G_get_fp_range_min_max(&accRange, &min, &max);
+ Rast_get_fp_range_min_max(&accRange, &min, &max);
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
if (min < 0) {
if (min < (-stddev - 1)) {
clr_min = min;
clr_max = -stddev - 1;
- G_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
0, 0, &colors);
}
clr_min = -stddev - 1.;
clr_max = -1. * exp(lstddev * 0.75);
- G_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0,
0, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.5);
- G_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0,
255, 255, &colors);
clr_min = clr_max;
clr_max = -1. * exp(lstddev * 0.35);
- G_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
255, 0, &colors);
clr_min = clr_max;
clr_max = -1.;
- G_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 255,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 255,
255, 0, &colors);
}
clr_min = -1.;
clr_max = 1.;
- G_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
+ Rast_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 255,
255, 0, &colors);
clr_min = 1;
clr_max = exp(lstddev * 0.35);
- G_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 255, 255, 0, &clr_max, 0,
255, 0, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.5);
- G_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 0, &clr_max, 0,
255, 255, &colors);
clr_min = clr_max;
clr_max = exp(lstddev * 0.75);
- G_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 255, 255, &clr_max, 0,
0, 255, &colors);
clr_min = clr_max;
clr_max = stddev + 1.;
- G_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 255, &clr_max, 0, 0,
0, &colors);
if (max > 0 && max > stddev + 1) {
clr_min = stddev + 1;
clr_max = max;
- G_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0, 0,
+ Rast_add_d_raster_color_rule(&clr_min, 0, 0, 0, &clr_max, 0, 0, 0,
&colors);
}
- G_write_colors(wat_name, this_mapset, &colors);
+ Rast_write_colors(wat_name, this_mapset, &colors);
}
if (asp_flag) {
cseg_write_cellfile(&asp, asp_name);
- G_init_colors(&colors);
- G_make_grey_scale_colors(&colors, 1, 8);
- G_write_colors(asp_name, this_mapset, &colors);
+ Rast_init_colors(&colors);
+ Rast_make_grey_scale_colors(&colors, 1, 8);
+ Rast_write_colors(asp_name, this_mapset, &colors);
}
cseg_close(&asp);
/* visual ouput no longer needed */
@@ -160,12 +160,12 @@
}
}
dseg_write_cellfile(&wat, dis_name);
- G_init_colors(&colors);
- G_make_rainbow_colors(&colors, 1, 120);
- G_write_colors(dis_name, this_mapset, &colors);
+ Rast_init_colors(&colors);
+ Rast_make_rainbow_colors(&colors, 1, 120);
+ Rast_write_colors(dis_name, this_mapset, &colors);
}
/* error in gislib.a
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
*/
dseg_close(&wat);
if (ls_flag) {
Modified: grass/trunk/raster/r.watershed/seg/close_maps2.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/close_maps2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/close_maps2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,11 +25,11 @@
}
}
G_debug(1, "%d basins created", max);
- G_init_colors(&colors);
- G_make_random_colors(&colors, 1, max);
+ Rast_init_colors(&colors);
+ Rast_make_random_colors(&colors, 1, max);
if (max < 10000) {
- G_set_color((CELL) 0, 0, 0, 0, &colors);
+ Rast_set_color((CELL) 0, 0, 0, 0, &colors);
r = 1;
incr = 0;
while (incr >= 0) {
@@ -39,12 +39,12 @@
for (bl = 90 + incr; bl <= 255; bl += 40) {
flag = 1;
while (flag) {
- G_get_color(r, &red, &green, &blue, &colors);
+ Rast_get_color(r, &red, &green, &blue, &colors);
/* if existing rule is too dark then append a new
rule to override it */
if ((blue * .11 + red * .30 + green * .59) <
100) {
- G_set_color(r, rd, gr, bl, &colors);
+ Rast_set_color(r, rd, gr, bl, &colors);
flag = 0;
}
if (++r > max) {
@@ -73,35 +73,35 @@
/* stream segments map */
if (seg_flag) {
cellrow = (CELL *) G_malloc(ncols * sizeof(CELL));
- map_fd = G_open_cell_new(seg_name);
+ map_fd = Rast_open_cell_new(seg_name);
for (r = 0; r < nrows; r++) {
- G_set_c_null_value(cellrow, ncols); /* reset row to all NULL */
+ Rast_set_c_null_value(cellrow, ncols); /* reset row to all NULL */
for (c = 0; c < ncols; c++) {
bseg_get(&swale, &value, r, c);
if (value)
cseg_get(&bas, &(cellrow[c]), r, c);
}
- G_put_raster_row(map_fd, cellrow, CELL_TYPE);
+ Rast_put_raster_row(map_fd, cellrow, CELL_TYPE);
}
G_free(cellrow);
- G_close_cell(map_fd);
- G_write_colors(seg_name, this_mapset, &colors);
+ Rast_close_cell(map_fd);
+ Rast_write_colors(seg_name, this_mapset, &colors);
}
/* basins map */
if (bas_flag) {
cseg_write_cellfile(&bas, bas_name);
- G_write_colors(bas_name, this_mapset, &colors);
+ Rast_write_colors(bas_name, this_mapset, &colors);
}
/* half.basins map */
if (haf_flag) {
cseg_write_cellfile(&haf, haf_name);
- G_write_colors(haf_name, this_mapset, &colors);
+ Rast_write_colors(haf_name, this_mapset, &colors);
}
if (seg_flag || bas_flag || haf_flag)
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
cseg_close(&haf);
cseg_close(&bas);
if (arm_flag)
Modified: grass/trunk/raster/r.watershed/seg/cseg_close.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_close.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/cseg_close.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/cseg_get.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_get.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/cseg_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/cseg_open.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_open.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/cseg_open.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include <fcntl.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/cseg_put.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_put.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/cseg_put.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/cseg_read.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_read.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/cseg_read.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
@@ -14,7 +15,7 @@
cseg->name = NULL;
cseg->mapset = NULL;
- map_fd = G_open_cell_old(map_name, mapset);
+ map_fd = Rast_open_cell_old(map_name, mapset);
if (map_fd < 0) {
sprintf(msg, "%s(): unable to open file [%s] in [%s], %d",
me, map_name, mapset, map_fd);
@@ -22,11 +23,11 @@
return -3;
}
nrows = G_window_rows();
- buffer = G_allocate_cell_buf();
+ buffer = Rast_allocate_cell_buf();
for (row = 0; row < nrows; row++) {
- if (G_get_c_raster_row(map_fd, buffer, row) < 0) {
+ if (Rast_get_c_raster_row(map_fd, buffer, row) < 0) {
G_free(buffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
sprintf(msg, "%s(): unable to read file [%s] in [%s], %d %d",
me, map_name, mapset, row, nrows);
G_warning(msg);
@@ -34,7 +35,7 @@
}
if (segment_put_row(&(cseg->seg), buffer, row) < 0) {
G_free(buffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
sprintf(msg, "%s(): unable to segment put row for [%s] in [%s]",
me, map_name, mapset);
G_warning(msg);
@@ -42,7 +43,7 @@
}
}
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
G_free(buffer);
cseg->name = G_store(map_name);
Modified: grass/trunk/raster/r.watershed/seg/cseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/cseg_write.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/cseg_write.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
@@ -10,25 +11,25 @@
int row, nrows;
CELL *buffer;
- map_fd = G_open_cell_new(map_name);
+ map_fd = Rast_open_cell_new(map_name);
if (map_fd < 0) {
G_warning("%s(): unable to open new map layer [%s]", me, map_name);
return -1;
}
nrows = G_window_rows();
- buffer = G_allocate_cell_buf();
+ buffer = Rast_allocate_cell_buf();
segment_flush(&(cseg->seg));
for (row = 0; row < nrows; row++) {
segment_get_row(&(cseg->seg), buffer, row);
- if (G_put_raster_row(map_fd, buffer, CELL_TYPE) < 0) {
+ if (Rast_put_raster_row(map_fd, buffer, CELL_TYPE) < 0) {
G_free(buffer);
- G_unopen_cell(map_fd);
+ Rast_unopen_cell(map_fd);
G_warning("%s(): unable to write new map layer [%s], row %d",
me, map_name, row);
return -2;
}
}
G_free(buffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
return 0;
}
Modified: grass/trunk/raster/r.watershed/seg/do_astar.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/do_astar.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/do_astar.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "Gwater.h"
#include "do_astar.h"
Modified: grass/trunk/raster/r.watershed/seg/do_cum.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/do_cum.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/do_cum.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include "Gwater.h"
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
@@ -211,7 +212,7 @@
worked_nbr[ct_dir] = cvalue;
if (worked_nbr[ct_dir] == 0) {
cseg_get(&alt, &ele_nbr, r_nbr, c_nbr);
- is_null = G_is_c_null_value(&ele_nbr);
+ is_null = Rast_is_c_null_value(&ele_nbr);
edge = is_null;
if (!is_null && ele_nbr <= ele) {
if (ele_nbr < ele) {
Modified: grass/trunk/raster/r.watershed/seg/dseg_close.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_close.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/dseg_close.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/dseg_get.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_get.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/dseg_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/dseg_open.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_open.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/dseg_open.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include <fcntl.h>
#include <grass/segment.h>
Modified: grass/trunk/raster/r.watershed/seg/dseg_put.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_put.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/dseg_put.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/dseg_read.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_read.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/dseg_read.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
@@ -14,7 +15,7 @@
dseg->name = NULL;
dseg->mapset = NULL;
- map_fd = G_open_cell_old(map_name, mapset);
+ map_fd = Rast_open_cell_old(map_name, mapset);
if (map_fd < 0) {
sprintf(msg, "%s(): unable to open file [%s] in [%s], %d",
me, map_name, mapset, map_fd);
@@ -23,11 +24,11 @@
}
nrows = G_window_rows();
ncols = G_window_cols();
- dbuffer = G_allocate_d_raster_buf();
+ dbuffer = Rast_allocate_d_raster_buf();
for (row = 0; row < nrows; row++) {
- if (G_get_d_raster_row(map_fd, dbuffer, row) < 0) {
+ if (Rast_get_d_raster_row(map_fd, dbuffer, row) < 0) {
G_free(dbuffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
sprintf(msg, "%s(): unable to read file [%s] in [%s], %d %d",
me, map_name, mapset, row, nrows);
G_warning(msg);
@@ -35,7 +36,7 @@
}
if (segment_put_row(&(dseg->seg), (DCELL *) dbuffer, row) < 0) {
G_free(dbuffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
sprintf(msg, "%s(): unable to segment put row for [%s] in [%s]",
me, map_name, mapset);
G_warning(msg);
@@ -43,7 +44,7 @@
}
}
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
G_free(dbuffer);
dseg->name = G_store(map_name);
Modified: grass/trunk/raster/r.watershed/seg/dseg_write.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/dseg_write.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/dseg_write.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
@@ -10,26 +11,26 @@
int row, nrows, ncols;
double *dbuffer;
- map_fd = G_open_raster_new(map_name, DCELL_TYPE);
+ map_fd = Rast_open_raster_new(map_name, DCELL_TYPE);
if (map_fd < 0) {
G_warning("%s(): unable to open new map layer [%s]", me, map_name);
return -1;
}
nrows = G_window_rows();
ncols = G_window_cols();
- dbuffer = G_allocate_d_raster_buf();
+ dbuffer = Rast_allocate_d_raster_buf();
segment_flush(&(dseg->seg));
for (row = 0; row < nrows; row++) {
segment_get_row(&(dseg->seg), (DCELL *) dbuffer, row);
- if (G_put_raster_row(map_fd, dbuffer, DCELL_TYPE) < 0) {
+ if (Rast_put_raster_row(map_fd, dbuffer, DCELL_TYPE) < 0) {
G_free(dbuffer);
- G_unopen_cell(map_fd);
+ Rast_unopen_cell(map_fd);
G_warning("%s(): unable to write new map layer [%s], row %d",
me, map_name, row);
return -2;
}
}
G_free(dbuffer);
- G_close_cell(map_fd);
+ Rast_close_cell(map_fd);
return 0;
}
Modified: grass/trunk/raster/r.watershed/seg/init_vars.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/init_vars.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/init_vars.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <unistd.h>
#include "Gwater.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int ele_round(double);
@@ -186,14 +187,14 @@
G_verbose_message("Checking for masked and NULL cells in input elevation <%s>", ele_name);
/* open elevation input */
- fd = G_open_cell_old(ele_name, "");
+ fd = Rast_open_cell_old(ele_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open elevation map layer"));
}
- ele_map_type = G_get_raster_map_type(fd);
- ele_size = G_raster_size(ele_map_type);
- elebuf = G_allocate_raster_buf(ele_map_type);
+ ele_map_type = Rast_get_raster_map_type(fd);
+ ele_size = Rast_raster_size(ele_map_type);
+ elebuf = Rast_allocate_raster_buf(ele_map_type);
if (ele_map_type == FCELL_TYPE || ele_map_type == DCELL_TYPE)
ele_scale = 1000; /* should be enough to do the trick */
@@ -202,15 +203,15 @@
MASK_flag = 0;
do_points = nrows * ncols;
for (r = 0; r < nrows; r++) {
- G_get_raster_row(fd, elebuf, r, ele_map_type);
+ Rast_get_raster_row(fd, elebuf, r, ele_map_type);
ptr = elebuf;
for (c = 0; c < ncols; c++) {
/* check for masked and NULL cells */
- if (G_is_null_value(ptr, ele_map_type)) {
+ if (Rast_is_null_value(ptr, ele_map_type)) {
bseg_put(&worked, &one, r, c);
bseg_put(&in_list, &one, r, c);
- G_set_c_null_value(&alt_value, 1);
+ Rast_set_c_null_value(&alt_value, 1);
do_points--;
}
else {
@@ -232,10 +233,10 @@
if (er_flag) {
cseg_put(&r_h, &alt_value, r, c);
}
- ptr = G_incr_void_ptr(ptr, ele_size);
+ ptr = Rast_incr_void_ptr(ptr, ele_size);
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(elebuf);
if (do_points < nrows * ncols)
MASK_flag = 1;
@@ -273,16 +274,16 @@
cseg_open(&asp, seg_rows, seg_cols, num_open_segs);
/* depression: drainage direction will be set to zero later */
if (pit_flag) {
- fd = G_open_cell_old(pit_name, "");
+ fd = Rast_open_cell_old(pit_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open depression map layer"));
}
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
for (r = 0; r < nrows; r++) {
- G_get_c_raster_row(fd, buf, r);
+ Rast_get_c_raster_row(fd, buf, r);
for (c = 0; c < ncols; c++) {
asp_value = buf[c];
- if (!G_is_c_null_value(&asp_value) && asp_value) {
+ if (!Rast_is_c_null_value(&asp_value) && asp_value) {
cseg_put(&asp, &one, r, c);
}
else {
@@ -290,7 +291,7 @@
}
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(buf);
}
else {
@@ -302,16 +303,16 @@
}
bseg_open(&swale, seg_rows, seg_cols, num_open_segs);
if (ob_flag) {
- fd = G_open_cell_old(ob_name, "");
+ fd = Rast_open_cell_old(ob_name, "");
if (fd < 0) {
G_fatal_error(_("unable to open blocking map layer"));
}
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
for (r = 0; r < nrows; r++) {
- G_get_c_raster_row(fd, buf, r);
+ Rast_get_c_raster_row(fd, buf, r);
for (c = 0; c < ncols; c++) {
block_value = buf[c];
- if (!G_is_c_null_value(&block_value) && block_value) {
+ if (!Rast_is_c_null_value(&block_value) && block_value) {
bseg_put(&swale, &one, r, c);
}
else {
@@ -319,7 +320,7 @@
}
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
G_free(buf);
}
else {
Modified: grass/trunk/raster/r.watershed/seg/main.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <unistd.h>
#include "Gwater.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct Cell_head window;
Modified: grass/trunk/raster/r.watershed/seg/sg_factor.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/sg_factor.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/sg_factor.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include "Gwater.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.watershed/seg/sseg_close.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/sseg_close.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/sseg_close.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/sseg_get.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/sseg_get.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/sseg_get.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/sseg_open.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/sseg_open.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/sseg_open.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <unistd.h>
#include <fcntl.h>
#include <grass/segment.h>
Modified: grass/trunk/raster/r.watershed/seg/sseg_put.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/sseg_put.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/sseg_put.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/segment.h>
#include "cseg.h"
Modified: grass/trunk/raster/r.watershed/seg/usage.c
===================================================================
--- grass/trunk/raster/r.watershed/seg/usage.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/seg/usage.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
Modified: grass/trunk/raster/r.watershed/shed/print.c
===================================================================
--- grass/trunk/raster/r.watershed/shed/print.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/shed/print.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -67,7 +67,7 @@
do_cat = &(output->maps[b].basins[c].first_cat);
while ((output->maps[b].do_cats != 0) && do_cat) {
cat_name =
- G_get_cat(do_cat->cat_val, &(output->maps[b].cats));
+ Rast_get_cat(do_cat->cat_val, &(output->maps[b].cats));
switch (output->type_area) {
case 1:
sprintf(area, "%.3f acres",
Modified: grass/trunk/raster/r.watershed/shed/read.c
===================================================================
--- grass/trunk/raster/r.watershed/shed/read.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/shed/read.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,17 +16,17 @@
nrows = G_window_rows();
ncols = G_window_cols();
- buf = G_allocate_cell_buf();
- bas_buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
+ bas_buf = Rast_allocate_cell_buf();
mapset = G_find_cell(haf_name, "");
if (!mapset) {
G_fatal_error(_("unable to open basin/half basin map"));
}
- bas_fd = G_open_cell_old(haf_name, mapset);
+ bas_fd = Rast_open_cell_old(haf_name, mapset);
facts = output->basin_facts;
for (r = nrows - 1; r >= 0; r--) {
- G_get_c_raster_row(bas_fd, bas_buf, r);
+ Rast_get_c_raster_row(bas_fd, bas_buf, r);
for (c = ncols - 1; c >= 0; c--) {
b = bas_buf[c] / 2 - 1;
if (b >= 0)
@@ -37,7 +37,7 @@
tot_basins = output->num_basins;
for (m = 0; m < output->num_maps; m++) {
map = &(output->maps[m]);
- G_read_cats(map->name, map->mapset, &(map->cats));
+ Rast_read_cats(map->name, map->mapset, &(map->cats));
map->basins = (BASIN *) G_malloc(tot_basins * sizeof(BASIN));
for (r = 0; r < tot_basins; r++) {
map->basins[r].first_cat.num_cat = -1;
@@ -45,11 +45,11 @@
map->basins[r].first_cat.nxt = NULL;
map->basins[r].sum_values = 0.0;
}
- fd = G_open_cell_old(map->name, map->mapset);
+ fd = Rast_open_cell_old(map->name, map->mapset);
if (fd >= 0) {
for (r = 0; r < nrows; r++) {
- G_get_c_raster_row(fd, buf, r);
- G_get_c_raster_row(bas_fd, bas_buf, r);
+ Rast_get_c_raster_row(fd, buf, r);
+ Rast_get_c_raster_row(bas_fd, bas_buf, r);
for (c = 0; c < ncols; c++) {
v = buf[c];
b = bas_buf[c] / 2 - 1;
@@ -67,7 +67,7 @@
}
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
}
Modified: grass/trunk/raster/r.watershed/shed/valid.c
===================================================================
--- grass/trunk/raster/r.watershed/shed/valid.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/shed/valid.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,12 +23,12 @@
free_output(output);
G_fatal_error(_("accum file missing in valid_basins()"));
}
- if (-1 == (fd = G_open_cell_old(accum_name, mapset))) {
+ if (-1 == (fd = Rast_open_cell_old(accum_name, mapset))) {
free_output(output);
G_fatal_error(_("unable to open accum file in valid_basins()"));
}
- buf = G_allocate_cell_buf();
+ buf = Rast_allocate_cell_buf();
basin_facts = output->basin_facts;
for (i = output->num_basins - 1; i >= 0; i--) {
basin = &(basin_facts[i]);
@@ -48,7 +48,7 @@
G_fatal_error("r:%d c:%d big error", r,c);
}
*/
- G_get_c_raster_row(fd, buf, r);
+ Rast_get_c_raster_row(fd, buf, r);
if (buf[c] < 0) {
basin->valid = 0;
if (down_basin != NULL)
Modified: grass/trunk/raster/r.watershed/shed/watershed.h
===================================================================
--- grass/trunk/raster/r.watershed/shed/watershed.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.watershed/shed/watershed.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#define RAM_NAME "ram"
#define SEG_NAME "seg"
Modified: grass/trunk/raster/r.what/main.c
===================================================================
--- grass/trunk/raster/r.what/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.what/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
struct order
@@ -191,19 +192,19 @@
NFILES);
strcpy(name, *ptr);
- if ((fd[nfiles] = G_open_cell_old(name, "")) < 0)
+ if ((fd[nfiles] = Rast_open_cell_old(name, "")) < 0)
G_fatal_error(_("Unable to open <%s>"), name);
- out_type[nfiles] = G_get_raster_map_type(fd[nfiles]);
+ out_type[nfiles] = Rast_get_raster_map_type(fd[nfiles]);
if (flag3->answer)
out_type[nfiles] = CELL_TYPE;
if (flag4->answer) {
- G_read_colors(name, "", &colors);
+ Rast_read_colors(name, "", &colors);
ncolor[nfiles] = colors;
}
- if (withcats && G_read_cats(name, "", &cats[nfiles]) < 0)
+ if (withcats && Rast_read_cats(name, "", &cats[nfiles]) < 0)
G_fatal_error(_("Unable to read category file for <%s>"), name);
nfiles++;
}
@@ -212,9 +213,9 @@
if (flag3->answer)
out_type[i] = CELL_TYPE;
- cell[i] = G_allocate_c_raster_buf();
+ cell[i] = Rast_allocate_c_raster_buf();
if (out_type[i] != CELL_TYPE)
- dcell[i] = G_allocate_d_raster_buf();
+ dcell[i] = Rast_allocate_d_raster_buf();
}
G_get_window(&window);
@@ -327,11 +328,11 @@
cache_miss++;
if (row_in_window)
for (i = 0; i < nfiles; i++) {
- if (G_get_c_raster_row(fd[i], cell[i], cache[point].row) < 0)
+ if (Rast_get_c_raster_row(fd[i], cell[i], cache[point].row) < 0)
G_fatal_error(_("Error reading <%s>"), argv[i + 1]);
if (out_type[i] != CELL_TYPE) {
- if (G_get_d_raster_row(fd[i], dcell[i], cache[point].row) < 0)
+ if (Rast_get_d_raster_row(fd[i], dcell[i], cache[point].row) < 0)
G_fatal_error(_("Error reading <%s>"), argv[i + 1]);
}
}
@@ -345,20 +346,20 @@
if (in_window)
cache[point].value[i] = cell[i][cache[point].col];
else
- G_set_c_null_value(&(cache[point].value[i]), 1);
+ Rast_set_c_null_value(&(cache[point].value[i]), 1);
if (out_type[i] != CELL_TYPE) {
if (in_window)
cache[point].dvalue[i] = dcell[i][cache[point].col];
else
- G_set_d_null_value(&(cache[point].dvalue[i]), 1);
+ Rast_set_d_null_value(&(cache[point].dvalue[i]), 1);
}
if (flag4->answer) {
if (out_type[i] == CELL_TYPE)
- G_get_c_raster_color(&cell[i][cache[point].col],
+ Rast_get_c_raster_color(&cell[i][cache[point].col],
&red, &green, &blue, &ncolor[i]);
else
- G_get_d_raster_color(&dcell[i][cache[point].col],
+ Rast_get_d_raster_color(&dcell[i][cache[point].col],
&red, &green, &blue, &ncolor[i]);
sprintf(cache[point].clr_buf[i], "%03d:%03d:%03d", red,
@@ -385,7 +386,7 @@
for (i = 0; i < nfiles; i++) {
if (out_type[i] == CELL_TYPE) {
- if (G_is_c_null_value(&cache[point].value[i])) {
+ if (Rast_is_c_null_value(&cache[point].value[i])) {
fprintf(stdout, "%c%s", fs, null_str);
continue;
}
@@ -393,7 +394,7 @@
}
else { /* FCELL or DCELL */
- if (G_is_d_null_value(&cache[point].dvalue[i])) {
+ if (Rast_is_d_null_value(&cache[point].dvalue[i])) {
fprintf(stdout, "%c%s", fs, null_str);
continue;
}
@@ -403,7 +404,7 @@
}
if (withcats)
fprintf(stdout, "%c%s", fs,
- G_get_cat(cache[point].value[i], &cats[i]));
+ Rast_get_cat(cache[point].value[i], &cats[i]));
if (flag4->answer)
fprintf(stdout, "%c%s", fs, cache[point].clr_buf[i]);
}
Modified: grass/trunk/raster/r.what.color/main.c
===================================================================
--- grass/trunk/raster/r.what.color/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/r.what.color/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
static const char *fmt;
@@ -37,7 +38,7 @@
fprintf(stdout, "*: *\n");
return 0;
}
- if (!G_get_c_raster_color(&ival, &red, &grn, &blu, colors)) {
+ if (!Rast_get_c_raster_color(&ival, &red, &grn, &blu, colors)) {
fprintf(stdout, "%d: *\n", ival);
return 0;
}
@@ -52,7 +53,7 @@
fprintf(stdout, "*: *\n");
return 0;
}
- if (!G_get_d_raster_color(&fval, &red, &grn, &blu, colors)) {
+ if (!Rast_get_d_raster_color(&fval, &red, &grn, &blu, colors)) {
fprintf(stdout, "%f: *\n", fval);
return 0;
}
@@ -121,11 +122,11 @@
name = opt.input->answer;
- type = G_raster_map_type(name, "");
+ type = Rast_raster_map_type(name, "");
if (type < 0)
G_fatal_error("Unable to determine type of input map %s", name);
- if (G_read_colors(name, "", &colors) < 0)
+ if (Rast_read_colors(name, "", &colors) < 0)
G_fatal_error("Unable to read colors for input map %s", name);
fmt = opt.format->answer;
Modified: grass/trunk/raster/simwe/simlib/input.c
===================================================================
--- grass/trunk/raster/simwe/simlib/input.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/simwe/simlib/input.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -86,31 +86,31 @@
*/
/* Allocate raster buffers */
- cell1 = G_allocate_f_raster_buf();
- cell2 = G_allocate_d_raster_buf();
- cell3 = G_allocate_d_raster_buf();
+ cell1 = Rast_allocate_f_raster_buf();
+ cell2 = Rast_allocate_d_raster_buf();
+ cell3 = Rast_allocate_d_raster_buf();
if (rain != NULL)
- cell4 = G_allocate_d_raster_buf();
+ cell4 = Rast_allocate_d_raster_buf();
if (infil != NULL)
- cell4a = G_allocate_d_raster_buf();
+ cell4a = Rast_allocate_d_raster_buf();
if (traps != NULL)
- cell4b = G_allocate_f_raster_buf();
- cell5 = G_allocate_f_raster_buf();
+ cell4b = Rast_allocate_f_raster_buf();
+ cell5 = Rast_allocate_f_raster_buf();
if (detin != NULL)
- cell9 = G_allocate_f_raster_buf();
+ cell9 = Rast_allocate_f_raster_buf();
if (tranin != NULL)
- cell10 = G_allocate_f_raster_buf();
+ cell10 = Rast_allocate_f_raster_buf();
if (tauin != NULL)
- cell11 = G_allocate_f_raster_buf();
+ cell11 = Rast_allocate_f_raster_buf();
if (wdepth != NULL)
- cell12 = G_allocate_d_raster_buf();
+ cell12 = Rast_allocate_d_raster_buf();
/* Allocate some double dimension arrays for each input */
/* with length of matrix Y */
@@ -177,18 +177,18 @@
if ((mapset = G_find_cell(elevin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), elevin);
- fd1 = G_open_cell_old(elevin, mapset);
+ fd1 = Rast_open_cell_old(elevin, mapset);
/* TO REPLACE BY INTERNAL PROCESSING of dx, dy from Elevin */
if ((mapset = G_find_cell(dxin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), dxin);
- fd2 = G_open_cell_old(dxin, mapset);
+ fd2 = Rast_open_cell_old(dxin, mapset);
if ((mapset = G_find_cell(dyin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), dyin);
- fd3 = G_open_cell_old(dyin, mapset);
+ fd3 = Rast_open_cell_old(dyin, mapset);
/* END OF REPLACEMENT */
/* Rendered Mannings n input map optional to run! */
@@ -196,7 +196,7 @@
if (manin != NULL) {
if ((mapset = G_find_cell(manin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), manin);
- fd5 = G_open_cell_old(manin, mapset);
+ fd5 = Rast_open_cell_old(manin, mapset);
}
/* Rendered Rainfall input map optional to run! */
@@ -204,93 +204,93 @@
if (rain != NULL) {
if ((mapset = G_find_cell(rain, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), rain);
- fd4 = G_open_cell_old(rain, mapset);
+ fd4 = Rast_open_cell_old(rain, mapset);
}
if (infil != NULL) {
if ((mapset = G_find_cell(infil, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), infil);
- fd4a = G_open_cell_old(infil, mapset);
+ fd4a = Rast_open_cell_old(infil, mapset);
}
if (traps != NULL) {
if ((mapset = G_find_cell(traps, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), traps);
- fd4b = G_open_cell_old(traps, mapset);
+ fd4b = Rast_open_cell_old(traps, mapset);
}
if (detin != NULL) {
if ((mapset = G_find_cell(detin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), detin);
- fd9 = G_open_cell_old(detin, mapset);
+ fd9 = Rast_open_cell_old(detin, mapset);
}
if (tranin != NULL) {
if ((mapset = G_find_cell(tranin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), tranin);
- fd10 = G_open_cell_old(tranin, mapset);
+ fd10 = Rast_open_cell_old(tranin, mapset);
}
if (tauin != NULL) {
if ((mapset = G_find_cell(tauin, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), tauin);
- fd11 = G_open_cell_old(tauin, mapset);
+ fd11 = Rast_open_cell_old(tauin, mapset);
}
if (wdepth != NULL) {
if ((mapset = G_find_cell(wdepth, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), wdepth);
- fd12 = G_open_cell_old(wdepth, mapset);
+ fd12 = Rast_open_cell_old(wdepth, mapset);
}
for (row = 0; row < my; row++) {
- G_get_f_raster_row(fd1, cell1, row);
- G_get_d_raster_row(fd2, cell2, row);
- G_get_d_raster_row(fd3, cell3, row);
+ Rast_get_f_raster_row(fd1, cell1, row);
+ Rast_get_d_raster_row(fd2, cell2, row);
+ Rast_get_d_raster_row(fd3, cell3, row);
if (manin != NULL)
- G_get_f_raster_row(fd5, cell5, row);
+ Rast_get_f_raster_row(fd5, cell5, row);
if (rain != NULL)
- G_get_d_raster_row(fd4, cell4, row);
+ Rast_get_d_raster_row(fd4, cell4, row);
if (infil != NULL)
- G_get_d_raster_row(fd4a, cell4a, row);
+ Rast_get_d_raster_row(fd4a, cell4a, row);
if (traps != NULL)
- G_get_f_raster_row(fd4b, cell4b, row);
+ Rast_get_f_raster_row(fd4b, cell4b, row);
if (detin != NULL)
- G_get_f_raster_row(fd9, cell9, row);
+ Rast_get_f_raster_row(fd9, cell9, row);
if (tranin != NULL)
- G_get_f_raster_row(fd10, cell10, row);
+ Rast_get_f_raster_row(fd10, cell10, row);
if (tauin != NULL)
- G_get_f_raster_row(fd11, cell11, row);
+ Rast_get_f_raster_row(fd11, cell11, row);
if (wdepth != NULL)
- G_get_d_raster_row(fd12, cell12, row);
+ Rast_get_d_raster_row(fd12, cell12, row);
for (j = 0; j < mx; j++) {
row_rev = my - row - 1;
/*if elevation data exists store in zz[][] */
- if (!G_is_f_null_value(cell1 + j))
+ if (!Rast_is_f_null_value(cell1 + j))
zz[row_rev][j] = (float)(conv * cell1[j]);
else
zz[row_rev][j] = UNDEF;
- if (!G_is_d_null_value(cell2 + j))
+ if (!Rast_is_d_null_value(cell2 + j))
v1[row_rev][j] = (double)cell2[j];
else
v1[row_rev][j] = UNDEF;
- if (!G_is_d_null_value(cell3 + j))
+ if (!Rast_is_d_null_value(cell3 + j))
v2[row_rev][j] = (double)cell3[j];
else
v2[row_rev][j] = UNDEF;
@@ -310,7 +310,7 @@
/* If Rain Exists, then load data */
if (rain != NULL) {
- if (!G_is_d_null_value(cell4 + j))
+ if (!Rast_is_d_null_value(cell4 + j))
si[row_rev][j] = ((double)cell4[j]) * unitconv;
/*conv mm/hr to m/s */
/*printf("\n INPUTrain, convert %f %f",si[row_rev][j],unitconv); */
@@ -322,7 +322,7 @@
/* Load infiltration map too if it exists */
if (infil != NULL) {
- if (!G_is_d_null_value(cell4a + j))
+ if (!Rast_is_d_null_value(cell4a + j))
inf[row_rev][j] = (double)cell4a[j] * unitconv;
/*conv mm/hr to m/s */
/*printf("\nINPUT infilt,convert %f %f",inf[row_rev][j],unitconv); */
@@ -344,7 +344,7 @@
}
if (traps != NULL) {
- if (!G_is_f_null_value(cell4b + j))
+ if (!Rast_is_f_null_value(cell4b + j))
trap[row_rev][j] = (float)cell4b[j]; /* no conv, unitless */
else {
trap[row_rev][j] = UNDEF;
@@ -364,7 +364,7 @@
}
if (infil != NULL) {
- if (!G_is_d_null_value(cell4a + j))
+ if (!Rast_is_d_null_value(cell4a + j))
inf[row_rev][j] = (double)cell4a[j] * unitconv; /*conv mm/hr to m/s */
/*printf("\nINPUT infilt,convert %f %f",inf[row_rev][j],unitconv); */
else {
@@ -385,7 +385,7 @@
}
if (traps != NULL) {
- if (!G_is_f_null_value(cell4b + j))
+ if (!Rast_is_f_null_value(cell4b + j))
trap[row_rev][j] = (float)cell4b[j]; /* no conv, unitless */
else {
trap[row_rev][j] = UNDEF;
@@ -394,7 +394,7 @@
}
} /* End of added by Yann 20080213 */
if (manin != NULL) {
- if (!G_is_f_null_value(cell5 + j)) {
+ if (!Rast_is_f_null_value(cell5 + j)) {
cchez[row_rev][j] = (float)cell5[j]; /* units in manual */
}
else {
@@ -410,7 +410,7 @@
manin);
}
if (detin != NULL) {
- if (!G_is_f_null_value(cell9 + j))
+ if (!Rast_is_f_null_value(cell9 + j))
dc[row_rev][j] = (float)cell9[j]; /*units in manual */
else {
dc[row_rev][j] = UNDEF;
@@ -419,7 +419,7 @@
}
if (tranin != NULL) {
- if (!G_is_f_null_value(cell10 + j))
+ if (!Rast_is_f_null_value(cell10 + j))
ct[row_rev][j] = (float)cell10[j]; /*units in manual */
else {
ct[row_rev][j] = UNDEF;
@@ -428,7 +428,7 @@
}
if (tauin != NULL) {
- if (!G_is_f_null_value(cell11 + j))
+ if (!Rast_is_f_null_value(cell11 + j))
tau[row_rev][j] = (float)cell11[j]; /*units in manual */
else {
tau[row_rev][j] = UNDEF;
@@ -437,7 +437,7 @@
}
if (wdepth != NULL) {
- if (!G_is_d_null_value(cell12 + j))
+ if (!Rast_is_d_null_value(cell12 + j))
gama[row_rev][j] = (double)cell12[j]; /*units in manual */
else {
gama[row_rev][j] = UNDEF;
@@ -446,34 +446,34 @@
}
}
}
- G_close_cell(fd1);
- G_close_cell(fd2);
- G_close_cell(fd3);
+ Rast_close_cell(fd1);
+ Rast_close_cell(fd2);
+ Rast_close_cell(fd3);
if (rain != NULL)
- G_close_cell(fd4);
+ Rast_close_cell(fd4);
if (infil != NULL)
- G_close_cell(fd4a);
+ Rast_close_cell(fd4a);
if (traps != NULL)
- G_close_cell(fd4b);
+ Rast_close_cell(fd4b);
/* Maybe a conditional to manin!=NULL here ! */
- G_close_cell(fd5);
+ Rast_close_cell(fd5);
/****************/
if (detin != NULL)
- G_close_cell(fd9);
+ Rast_close_cell(fd9);
if (tranin != NULL)
- G_close_cell(fd10);
+ Rast_close_cell(fd10);
if (tauin != NULL)
- G_close_cell(fd11);
+ Rast_close_cell(fd11);
if (wdepth != NULL)
- G_close_cell(fd12);
+ Rast_close_cell(fd12);
return 1;
}
Modified: grass/trunk/raster/simwe/simlib/output.c
===================================================================
--- grass/trunk/raster/simwe/simlib/output.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster/simwe/simlib/output.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -89,40 +89,40 @@
}
*/
if (depth != NULL) {
- cell6 = G_allocate_f_raster_buf();
+ cell6 = Rast_allocate_f_raster_buf();
if (ts == 1) {
sprintf(buf, "%s.%.*d", depth, ndigit, tt);
depth0 = G_store(buf);
- fd6 = G_open_fp_cell_new(depth0);
+ fd6 = Rast_open_fp_cell_new(depth0);
}
else
- fd6 = G_open_fp_cell_new(depth);
+ fd6 = Rast_open_fp_cell_new(depth);
if (fd6 < 0)
G_fatal_error("unable to create raster map %s", depth);
}
if (disch != NULL) {
- cell7 = G_allocate_f_raster_buf();
+ cell7 = Rast_allocate_f_raster_buf();
if (ts == 1) {
sprintf(buf, "%s.%.*d", disch, ndigit, tt);
disch0 = G_store(buf);
- fd7 = G_open_fp_cell_new(disch0);
+ fd7 = Rast_open_fp_cell_new(disch0);
}
else
- fd7 = G_open_fp_cell_new(disch);
+ fd7 = Rast_open_fp_cell_new(disch);
if (fd7 < 0)
G_fatal_error("unable to create raster map %s", disch);
}
if (err != NULL) {
- cell8 = G_allocate_f_raster_buf();
+ cell8 = Rast_allocate_f_raster_buf();
if (ts == 1) {
sprintf(buf, "%s.%.*d", err, ndigit, tt);
err0 = G_store(buf);
- fd8 = G_open_fp_cell_new(err0);
+ fd8 = Rast_open_fp_cell_new(err0);
}
else
- fd8 = G_open_fp_cell_new(err);
+ fd8 = Rast_open_fp_cell_new(err);
if (fd8 < 0)
G_fatal_error("unable to create raster map %s", err);
@@ -130,42 +130,42 @@
if (conc != NULL) {
- cell14 = G_allocate_f_raster_buf();
+ cell14 = Rast_allocate_f_raster_buf();
if (ts == 1) {
sprintf(buf, "%s.%.*d", conc, ndigit, tt);
conc0 = G_store(buf);
- fd14 = G_open_fp_cell_new(conc0);
+ fd14 = Rast_open_fp_cell_new(conc0);
}
else
- fd14 = G_open_fp_cell_new(conc);
+ fd14 = Rast_open_fp_cell_new(conc);
if (fd14 < 0)
G_fatal_error("unable to create raster map %s", conc);
}
if (flux != NULL) {
- cell15 = G_allocate_f_raster_buf();
+ cell15 = Rast_allocate_f_raster_buf();
if (ts == 1) {
sprintf(buf, "%s.%.*d", flux, ndigit, tt);
flux0 = G_store(buf);
- fd15 = G_open_fp_cell_new(flux0);
+ fd15 = Rast_open_fp_cell_new(flux0);
}
else
- fd15 = G_open_fp_cell_new(flux);
+ fd15 = Rast_open_fp_cell_new(flux);
if (fd15 < 0)
G_fatal_error("unable to create raster map %s", flux);
}
if (erdep != NULL) {
- cell16 = G_allocate_f_raster_buf();
+ cell16 = Rast_allocate_f_raster_buf();
if (ts == 1) {
sprintf(buf, "%s.%.*d", erdep, ndigit, tt);
erdep0 = G_store(buf);
- fd16 = G_open_fp_cell_new(erdep0);
+ fd16 = Rast_open_fp_cell_new(erdep0);
}
else
- fd16 = G_open_fp_cell_new(erdep);
+ fd16 = Rast_open_fp_cell_new(erdep);
if (fd16 < 0)
G_fatal_error("unable to create raster map %s", erdep);
@@ -187,53 +187,53 @@
if (depth != NULL) {
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || gama[i][j] == UNDEF)
- G_set_f_null_value(cell6 + j, 1);
+ Rast_set_f_null_value(cell6 + j, 1);
else {
a1 = pow(gama[i][j], 3. / 5.);
cell6[j] = (FCELL) a1; /* add conv? */
gmax = amax1(gmax, a1);
}
}
- G_put_f_raster_row(fd6, cell6);
+ Rast_put_f_raster_row(fd6, cell6);
}
if (disch != NULL) {
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || gama[i][j] == UNDEF ||
cchez[i][j] == UNDEF)
- G_set_f_null_value(cell7 + j, 1);
+ Rast_set_f_null_value(cell7 + j, 1);
else {
a2 = step * gama[i][j] * cchez[i][j]; /* cchez incl. sqrt(sinsl) */
cell7[j] = (FCELL) a2; /* add conv? */
dismax = amax1(dismax, a2);
}
}
- G_put_f_raster_row(fd7, cell7);
+ Rast_put_f_raster_row(fd7, cell7);
}
if (err != NULL) {
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || gammas[i][j] == UNDEF)
- G_set_f_null_value(cell8 + j, 1);
+ Rast_set_f_null_value(cell8 + j, 1);
else {
cell8[j] = (FCELL) gammas[i][j];
gsmax = amax1(gsmax, gammas[i][j]); /* add conv? */
}
}
- G_put_f_raster_row(fd8, cell8);
+ Rast_put_f_raster_row(fd8, cell8);
}
if (conc != NULL) {
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || gama[i][j] == UNDEF)
- G_set_f_null_value(cell14 + j, 1);
+ Rast_set_f_null_value(cell14 + j, 1);
else {
cell14[j] = (FCELL) gama[i][j];
/* gsmax = amax1(gsmax, gama[i][j]); */
}
}
- G_put_f_raster_row(fd14, cell14);
+ Rast_put_f_raster_row(fd14, cell14);
}
@@ -241,239 +241,239 @@
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || gama[i][j] == UNDEF ||
slope[i][j] == UNDEF)
- G_set_f_null_value(cell15 + j, 1);
+ Rast_set_f_null_value(cell15 + j, 1);
else {
a2 = gama[i][j] * slope[i][j];
cell15[j] = (FCELL) a2;
dismax = amax1(dismax, a2);
}
}
- G_put_f_raster_row(fd15, cell15);
+ Rast_put_f_raster_row(fd15, cell15);
}
if (erdep != NULL) {
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || er[i][j] == UNDEF)
- G_set_f_null_value(cell16 + j, 1);
+ Rast_set_f_null_value(cell16 + j, 1);
else {
cell16[j] = (FCELL) er[i][j];
ermax = amax1(ermax, er[i][j]);
ermin = amin1(ermin, er[i][j]);
}
}
- G_put_f_raster_row(fd16, cell16);
+ Rast_put_f_raster_row(fd16, cell16);
}
}
if (depth != NULL)
- G_close_cell(fd6);
+ Rast_close_cell(fd6);
if (disch != NULL)
- G_close_cell(fd7);
+ Rast_close_cell(fd7);
if (err != NULL)
- G_close_cell(fd8);
+ Rast_close_cell(fd8);
if (conc != NULL)
- G_close_cell(fd14);
+ Rast_close_cell(fd14);
if (flux != NULL)
- G_close_cell(fd15);
+ Rast_close_cell(fd15);
if (erdep != NULL)
- G_close_cell(fd16);
+ Rast_close_cell(fd16);
if (depth != NULL) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) 0.;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.05;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 0, 255, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.1;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255, &dat2, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255, &dat2, 0, 127, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.5;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255, &dat2, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255, &dat2, 0, 0, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) gmax;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 0, 0, &colors);
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 0, 0, &colors);
if (ts == 1) {
if ((mapst = G_find_file("fcell", depth0, "")) == NULL)
G_fatal_error("cannot find file %s", depth0);
- G_write_colors(depth0, mapst, &colors);
- G_quantize_fp_map_range(depth0, mapst, 0., (FCELL) gmax, 0,
+ Rast_write_colors(depth0, mapst, &colors);
+ Rast_quantize_fp_map_range(depth0, mapst, 0., (FCELL) gmax, 0,
(CELL) gmax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
else {
if ((mapst = G_find_file("fcell", depth, "")) == NULL)
G_fatal_error("cannot find file %s", depth);
- G_write_colors(depth, mapst, &colors);
- G_quantize_fp_map_range(depth, mapst, 0., (FCELL) gmax, 0,
+ Rast_write_colors(depth, mapst, &colors);
+ Rast_quantize_fp_map_range(depth, mapst, 0., (FCELL) gmax, 0,
(CELL) gmax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
}
if (disch != NULL) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) 0.;
dat2 = (FCELL) 0.0005;
- G_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.005;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 0, 255, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.05;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255, &dat2, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255, &dat2, 0, 127, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.1;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255, &dat2, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255, &dat2, 0, 0, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) dismax;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 0, 0, &colors);
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 0, 0, &colors);
if (ts == 1) {
if ((mapst = G_find_file("cell", disch0, "")) == NULL)
G_fatal_error("cannot find file %s", disch0);
- G_write_colors(disch0, mapst, &colors);
- G_quantize_fp_map_range(disch0, mapst, 0., (FCELL) dismax, 0,
+ Rast_write_colors(disch0, mapst, &colors);
+ Rast_quantize_fp_map_range(disch0, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
else {
if ((mapst = G_find_file("cell", disch, "")) == NULL)
G_fatal_error("cannot find file %s", disch);
- G_write_colors(disch, mapst, &colors);
- G_quantize_fp_map_range(disch, mapst, 0., (FCELL) dismax, 0,
+ Rast_write_colors(disch, mapst, &colors);
+ Rast_quantize_fp_map_range(disch, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
}
if (flux != NULL) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) 0.;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.1;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) 1.;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0, &dat2, 191, 127, 63,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0, &dat2, 191, 127, 63,
&colors);
dat1 = dat2;
dat2 = (FCELL) dismax;
- G_add_f_raster_color_rule(&dat1, 191, 127, 63, &dat2, 0, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 191, 127, 63, &dat2, 0, 0, 0,
&colors);
if (ts == 1) {
if ((mapst = G_find_file("cell", flux0, "")) == NULL)
G_fatal_error("cannot find file %s", flux0);
- G_write_colors(flux0, mapst, &colors);
- G_quantize_fp_map_range(flux0, mapst, 0., (FCELL) dismax, 0,
+ Rast_write_colors(flux0, mapst, &colors);
+ Rast_quantize_fp_map_range(flux0, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
else {
if ((mapst = G_find_file("cell", flux, "")) == NULL)
G_fatal_error("cannot find file %s", flux);
- G_write_colors(flux, mapst, &colors);
- G_quantize_fp_map_range(flux, mapst, 0., (FCELL) dismax, 0,
+ Rast_write_colors(flux, mapst, &colors);
+ Rast_quantize_fp_map_range(flux, mapst, 0., (FCELL) dismax, 0,
(CELL) dismax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
}
}
if (erdep != NULL) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) ermax;
dat2 = (FCELL) 0.1;
- G_add_f_raster_color_rule(&dat1, 0, 0, 0, &dat2, 0, 0, 255, &colors);
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 0, &dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 191, 191,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 191, 191,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.0001;
- G_add_f_raster_color_rule(&dat1, 0, 191, 191, &dat2, 170, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 191, 191, &dat2, 170, 255, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.;
- G_add_f_raster_color_rule(&dat1, 170, 255, 255, &dat2, 255, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 170, 255, 255, &dat2, 255, 255, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) - 0.0001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) - 0.1;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0, &dat2, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0, &dat2, 255, 0, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) ermin;
- G_add_f_raster_color_rule(&dat1, 255, 0, 0, &dat2, 255, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0, &dat2, 255, 0, 255,
&colors);
if (ts == 1) {
if ((mapst = G_find_file("cell", erdep0, "")) == NULL)
G_fatal_error("cannot find file %s", erdep0);
- G_write_colors(erdep0, mapst, &colors);
- G_quantize_fp_map_range(erdep0, mapst, (FCELL) ermin,
+ Rast_write_colors(erdep0, mapst, &colors);
+ Rast_quantize_fp_map_range(erdep0, mapst, (FCELL) ermin,
(FCELL) ermax, (CELL) ermin,
(CELL) ermax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
type = "raster";
- G_short_history(erdep0, type, &hist1);
+ Rast_short_history(erdep0, type, &hist1);
sprintf(hist1.edhist[0], "The sediment flux file is %s", flux0);
hist1.edlinecnt = 1;
- G_write_history(erdep0, &hist1);
+ Rast_write_history(erdep0, &hist1);
}
else {
if ((mapst = G_find_file("cell", erdep, "")) == NULL)
G_fatal_error("cannot find file %s", erdep);
- G_write_colors(erdep, mapst, &colors);
- G_quantize_fp_map_range(erdep, mapst, (FCELL) ermin,
+ Rast_write_colors(erdep, mapst, &colors);
+ Rast_quantize_fp_map_range(erdep, mapst, (FCELL) ermin,
(FCELL) ermax, (CELL) ermin,
(CELL) ermax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
type = "raster";
- G_short_history(erdep, type, &hist1);
+ Rast_short_history(erdep, type, &hist1);
sprintf(hist1.edhist[0], "The sediment flux file is %s", flux);
hist1.edlinecnt = 1;
- G_write_history(erdep, &hist1);
+ Rast_write_history(erdep, &hist1);
}
}
@@ -487,10 +487,10 @@
G_warning("File [%s] not found", depth);
return -1;
}
- G_short_history(depth, type, &hist);
+ Rast_short_history(depth, type, &hist);
}
else
- G_short_history(depth0, type, &hist);
+ Rast_short_history(depth0, type, &hist);
/* fprintf (stdout, "\n history initiated\n");
fflush(stdout); */
@@ -511,12 +511,12 @@
sprintf(hist.datsrc_2, "input files: %s %s %s", rain, infil, manin);
hist.edlinecnt = 4;
- G_command_history(&hist);
+ Rast_command_history(&hist);
if (ts == 1)
- G_write_history(depth0, &hist);
+ Rast_write_history(depth0, &hist);
else
- G_write_history(depth, &hist);
+ Rast_write_history(depth, &hist);
}
if (disch != NULL) {
@@ -525,10 +525,10 @@
mapst = G_find_file("cell", disch, "");
if (mapst == NULL)
G_fatal_error("file [%s] not found\n", disch);
- G_short_history(disch, type, &hist);
+ Rast_short_history(disch, type, &hist);
}
else
- G_short_history(disch0, type, &hist);
+ Rast_short_history(disch0, type, &hist);
/* fprintf (stdout, "\n history initiated\n");
fflush(stdout); */
@@ -549,12 +549,12 @@
sprintf(hist.datsrc_2, "input files: %s %s %s", rain, infil, manin);
hist.edlinecnt = 4;
- G_command_history(&hist);
+ Rast_command_history(&hist);
if (ts == 1)
- G_write_history(disch0, &hist);
+ Rast_write_history(disch0, &hist);
else
- G_write_history(disch, &hist);
+ Rast_write_history(disch, &hist);
}
if (flux != NULL) {
@@ -563,10 +563,10 @@
mapst = G_find_file("cell", flux, "");
if (mapst == NULL)
G_fatal_error("file [%s] not found\n", flux);
- G_short_history(flux, type, &hist);
+ Rast_short_history(flux, type, &hist);
}
else
- G_short_history(flux0, type, &hist);
+ Rast_short_history(flux0, type, &hist);
/* fprintf (stdout, "\n history initiated\n");
fflush(stdout); */
@@ -588,12 +588,12 @@
hist.edlinecnt = 4;
- G_command_history(&hist);
+ Rast_command_history(&hist);
if (ts == 1)
- G_write_history(flux0, &hist);
+ Rast_write_history(flux0, &hist);
else
- G_write_history(flux, &hist);
+ Rast_write_history(flux, &hist);
}
return 1;
@@ -619,28 +619,28 @@
if (et != NULL) {
- cell17 = G_allocate_f_raster_buf();
+ cell17 = Rast_allocate_f_raster_buf();
/* if (ts == 1) {
sprintf(buf,"%s.%.*d",et,ndigit,tt);
et0 = G_store(buf);
- fd17 = G_open_fp_cell_new (et0);
+ fd17 = Rast_open_fp_cell_new (et0);
}
else */
- fd17 = G_open_fp_cell_new(et);
+ fd17 = Rast_open_fp_cell_new(et);
if (fd17 < 0)
G_fatal_error("unable to create raster map %s", et);
}
if (tc != NULL) {
- cell13 = G_allocate_f_raster_buf();
+ cell13 = Rast_allocate_f_raster_buf();
/* if (ts == 1) {
sprintf(buf,"%s.%.*d",tc,ndigit,tt);
tc0 = G_store(buf);
- fd13 = G_open_fp_cell_new (tc0);
+ fd13 = Rast_open_fp_cell_new (tc0);
}
else */
- fd13 = G_open_fp_cell_new(tc);
+ fd13 = Rast_open_fp_cell_new(tc);
if (fd13 < 0)
G_fatal_error("unable to create raster map %s", tc);
@@ -662,21 +662,21 @@
if (et != NULL) {
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || er[i][j] == UNDEF)
- G_set_f_null_value(cell17 + j, 1);
+ Rast_set_f_null_value(cell17 + j, 1);
else {
cell17[j] = (FCELL) er[i][j]; /* add conv? */
etmax = amax1(etmax, er[i][j]);
etmin = amin1(etmin, er[i][j]);
}
}
- G_put_f_raster_row(fd17, cell17);
+ Rast_put_f_raster_row(fd17, cell17);
}
if (tc != NULL) {
for (j = 0; j < mx; j++) {
if (zz[i][j] == UNDEF || sigma[i][j] == UNDEF ||
si[i][j] == UNDEF)
- G_set_f_null_value(cell13 + j, 1);
+ Rast_set_f_null_value(cell13 + j, 1);
else {
if (sigma[i][j] == 0.)
trc = 0.;
@@ -686,68 +686,68 @@
/* gsmax = amax1(gsmax, trc); */
}
}
- G_put_f_raster_row(fd13, cell13);
+ Rast_put_f_raster_row(fd13, cell13);
}
}
if (tc != NULL)
- G_close_cell(fd13);
+ Rast_close_cell(fd13);
if (et != NULL)
- G_close_cell(fd17);
+ Rast_close_cell(fd17);
if (et != NULL) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
dat1 = (FCELL) etmax;
dat2 = (FCELL) 0.1;
- G_add_f_raster_color_rule(&dat1, 0, 0, 0, &dat2, 0, 0, 255, &colors);
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 0, &dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 191, 191,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255, &dat2, 0, 191, 191,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.0001;
- G_add_f_raster_color_rule(&dat1, 0, 191, 191, &dat2, 170, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 191, 191, &dat2, 170, 255, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) 0.;
- G_add_f_raster_color_rule(&dat1, 170, 255, 255, &dat2, 255, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 170, 255, 255, &dat2, 255, 255, 255,
&colors);
dat1 = dat2;
dat2 = (FCELL) - 0.0001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 255, &dat2, 255, 255, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0, &dat2, 255, 127, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) - 0.1;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0, &dat2, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0, &dat2, 255, 0, 0,
&colors);
dat1 = dat2;
dat2 = (FCELL) etmin;
- G_add_f_raster_color_rule(&dat1, 255, 0, 0, &dat2, 255, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0, &dat2, 255, 0, 255,
&colors);
/* if (ts == 1) {
if ((mapst = G_find_file("cell", et0, "")) == NULL)
G_fatal_error ("cannot find file %s", et0);
- G_write_colors(et0, mapst, &colors);
- G_quantize_fp_map_range(et0,mapst,(FCELL)etmin,(FCELL)etmax,(CELL)etmin,(CELL)etmax);
- G_free_colors(&colors);
+ Rast_write_colors(et0, mapst, &colors);
+ Rast_quantize_fp_map_range(et0,mapst,(FCELL)etmin,(FCELL)etmax,(CELL)etmin,(CELL)etmax);
+ Rast_free_colors(&colors);
}
else { */
if ((mapst = G_find_file("cell", et, "")) == NULL)
G_fatal_error("cannot find file %s", et);
- G_write_colors(et, mapst, &colors);
- G_quantize_fp_map_range(et, mapst, (FCELL) etmin, (FCELL) etmax,
+ Rast_write_colors(et, mapst, &colors);
+ Rast_quantize_fp_map_range(et, mapst, (FCELL) etmin, (FCELL) etmax,
(CELL) etmin, (CELL) etmax);
- G_free_colors(&colors);
+ Rast_free_colors(&colors);
/* } */
}
Modified: grass/trunk/raster3d/r3.cross.rast/main.c
===================================================================
--- grass/trunk/raster3d/r3.cross.rast/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.cross.rast/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
@@ -57,7 +58,7 @@
/*unopen the output map */
if (outfd != -1)
- G_unopen_cell(outfd);
+ Rast_unopen_cell(outfd);
if (elevfd != -1)
close_output_map(elevfd);
@@ -73,7 +74,7 @@
/* ************************************************************************* */
void close_output_map(int fd)
{
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_fatal_error(_("Unable to close output map"));
}
@@ -146,28 +147,28 @@
/*Allocate mem for the output maps row */
if (typeIntern == FCELL_TYPE)
- fcell = G_allocate_f_raster_buf();
+ fcell = Rast_allocate_f_raster_buf();
else if (typeIntern == DCELL_TYPE)
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
/*Mem for the input map row */
- elevrast = G_allocate_raster_buf(globalElevMapType);
+ elevrast = Rast_allocate_raster_buf(globalElevMapType);
for (y = 0; y < rows; y++) {
G_percent(y, rows - 1, 10);
/*Read the input map row */
- if (!G_get_raster_row(elevfd, elevrast, y, globalElevMapType))
+ if (!Rast_get_raster_row(elevfd, elevrast, y, globalElevMapType))
fatal_error(map, elevfd, outfd,
_("Unable to get elevation raster row"));
for (x = 0, ptr = elevrast; x < cols; x++, ptr =
- G_incr_void_ptr(ptr, G_raster_size(globalElevMapType))) {
+ Rast_incr_void_ptr(ptr, Rast_raster_size(globalElevMapType))) {
/*we guess the elevation input map has no null values */
isnull = 0;
- if (G_is_null_value(ptr, globalElevMapType)) {
+ if (Rast_is_null_value(ptr, globalElevMapType)) {
isnull = 1; /*input map has nulls */
}
@@ -195,14 +196,14 @@
if (typeIntern == FCELL_TYPE) {
G3d_getValue(map, x, y, z, &f1, typeIntern);
if (G3d_isNullValueNum(&f1, FCELL_TYPE))
- G_set_null_value(&fcell[x], 1, FCELL_TYPE);
+ Rast_set_null_value(&fcell[x], 1, FCELL_TYPE);
else
fcell[x] = (FCELL) f1;
}
else {
G3d_getValue(map, x, y, z, &d1, typeIntern);
if (G3d_isNullValueNum(&d1, DCELL_TYPE))
- G_set_null_value(&dcell[x], 1, DCELL_TYPE);
+ Rast_set_null_value(&dcell[x], 1, DCELL_TYPE);
else
dcell[x] = (DCELL) d1;
@@ -216,22 +217,22 @@
/*Set the NULL values */
if (isnull == 1) {
if (typeIntern == FCELL_TYPE)
- G_set_null_value(&fcell[x], 1, FCELL_TYPE);
+ Rast_set_null_value(&fcell[x], 1, FCELL_TYPE);
else if (typeIntern == DCELL_TYPE)
- G_set_null_value(&dcell[x], 1, DCELL_TYPE);
+ Rast_set_null_value(&dcell[x], 1, DCELL_TYPE);
}
}
/*Write the data to the output map */
if (typeIntern == FCELL_TYPE) {
- check = G_put_f_raster_row(outfd, fcell);
+ check = Rast_put_f_raster_row(outfd, fcell);
if (check != 1)
fatal_error(map, elevfd, outfd,
_("Could not write raster row"));
}
if (typeIntern == DCELL_TYPE) {
- check = G_put_d_raster_row(outfd, dcell);
+ check = Rast_put_d_raster_row(outfd, dcell);
if (check != 1)
fatal_error(map, elevfd, outfd,
_("Could not write raster row"));
@@ -327,11 +328,11 @@
/********************************/
- elevfd = G_open_cell_old(param.elevation->answer, "");
+ elevfd = Rast_open_cell_old(param.elevation->answer, "");
if (elevfd <= 0)
fatal_error(map, -1, -1, _("Unable to open elevation map"));
- globalElevMapType = G_get_raster_map_type(elevfd);
+ globalElevMapType = Rast_get_raster_map_type(elevfd);
/**********************/
/*Open the Outputmap */
@@ -342,13 +343,13 @@
G_message(_("Output map already exists. Will be overwritten!"));
if (output_type == FCELL_TYPE) {
- outfd = G_open_raster_new(param.output->answer, FCELL_TYPE);
+ outfd = Rast_open_raster_new(param.output->answer, FCELL_TYPE);
if (outfd < 0)
fatal_error(map, elevfd, -1,
_("Unable to create raster map"));
}
else if (output_type == DCELL_TYPE) {
- outfd = G_open_raster_new(param.output->answer, DCELL_TYPE);
+ outfd = Rast_open_raster_new(param.output->answer, DCELL_TYPE);
if (outfd < 0)
fatal_error(map, elevfd, -1,
_("Unable to create raster map"));
@@ -378,9 +379,9 @@
G3d_maskOff(map);
}
- if (G_close_cell(outfd) < 0)
+ if (Rast_close_cell(outfd) < 0)
fatal_error(map, elevfd, -1, _("Unable to close output map"));
- if (G_close_cell(elevfd) < 0)
+ if (Rast_close_cell(elevfd) < 0)
fatal_error(map, -1, -1, _("Unable to close elevation map"));
}
Modified: grass/trunk/raster3d/r3.gwflow/main.c
===================================================================
--- grass/trunk/raster3d/r3.gwflow/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.gwflow/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
#include <grass/N_pde.h>
Modified: grass/trunk/raster3d/r3.mkdspf/calc_linefax.c
===================================================================
--- grass/trunk/raster3d/r3.mkdspf/calc_linefax.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.mkdspf/calc_linefax.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "vizual.h"
Modified: grass/trunk/raster3d/r3.mkdspf/iso_surface.c
===================================================================
--- grass/trunk/raster3d/r3.mkdspf/iso_surface.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.mkdspf/iso_surface.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <math.h>
#include "vizual.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include "local_proto.h"
@@ -148,14 +149,14 @@
/* CHANGED: use NULLS instead of zeros - if any are null, polygons
are undefined - or else need to define polygons which exclude nulls under
various combinations e.g., give each null a tetrahedron of influence */
- if (G_is_f_null_value((FCELL *) (DATA + 0)) ||
- G_is_f_null_value((FCELL *) (DATA + 1)) ||
- G_is_f_null_value((FCELL *) (DATA + 2)) ||
- G_is_f_null_value((FCELL *) (DATA + 3)) ||
- G_is_f_null_value((FCELL *) (DATA + 4)) ||
- G_is_f_null_value((FCELL *) (DATA + 5)) ||
- G_is_f_null_value((FCELL *) (DATA + 6)) ||
- G_is_f_null_value((FCELL *) (DATA + 7)))
+ if (Rast_is_f_null_value((FCELL *) (DATA + 0)) ||
+ Rast_is_f_null_value((FCELL *) (DATA + 1)) ||
+ Rast_is_f_null_value((FCELL *) (DATA + 2)) ||
+ Rast_is_f_null_value((FCELL *) (DATA + 3)) ||
+ Rast_is_f_null_value((FCELL *) (DATA + 4)) ||
+ Rast_is_f_null_value((FCELL *) (DATA + 5)) ||
+ Rast_is_f_null_value((FCELL *) (DATA + 6)) ||
+ Rast_is_f_null_value((FCELL *) (DATA + 7)))
c_ndx = 0;
/* c_ndx numbers (1 - 254) contain polygons */
Modified: grass/trunk/raster3d/r3.mkdspf/main.c
===================================================================
--- grass/trunk/raster3d/r3.mkdspf/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.mkdspf/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -44,6 +44,7 @@
#include <math.h>
#include "vizual.h"
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include "local_proto.h"
#include <grass/glocale.h>
Modified: grass/trunk/raster3d/r3.mkdspf/r3_find.c
===================================================================
--- grass/trunk/raster3d/r3.mkdspf/r3_find.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.mkdspf/r3_find.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -5,6 +5,7 @@
**************************************************************/
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
Modified: grass/trunk/raster3d/r3.out.vtk/errorHandling.c
===================================================================
--- grass/trunk/raster3d/r3.out.vtk/errorHandling.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.out.vtk/errorHandling.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
#include "globalDefs.h"
@@ -48,7 +49,7 @@
int CloseInputRasterMap(int fd)
{
if (fd != -1)
- if (G_close_cell(fd) < 0) {
+ if (Rast_close_cell(fd) < 0) {
G_warning(_("unable to close input raster map"));
return 1;
}
Modified: grass/trunk/raster3d/r3.out.vtk/main.c
===================================================================
--- grass/trunk/raster3d/r3.out.vtk/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.out.vtk/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
@@ -97,7 +98,7 @@
/* open raster map */
- fd = G_open_cell_old(name, mapset);
+ fd = Rast_open_cell_old(name, mapset);
if (fd < 0)
G_fatal_error(_("Could not open map %s"), name);
@@ -467,7 +468,7 @@
name = param.top->answer;
mapset = G_find_cell2(name, "");
in->top = open_input_map(name, mapset);
- in->topMapType = G_get_raster_map_type(in->top);
+ in->topMapType = Rast_get_raster_map_type(in->top);
/*open bottom */
mapset = NULL;
@@ -475,7 +476,7 @@
name = param.bottom->answer;
mapset = G_find_cell2(name, "");
in->bottom = open_input_map(name, mapset);
- in->bottomMapType = G_get_raster_map_type(in->bottom);
+ in->bottomMapType = Rast_get_raster_map_type(in->bottom);
/* Write the vtk-header and the points */
if (param.point->answer) {
@@ -488,12 +489,12 @@
write_vtk_unstructured_grid_cells(fp, region);
}
- if (G_close_cell(in->top) < 0) {
+ if (Rast_close_cell(in->top) < 0) {
G_fatal_error(_("unable to close top raster map"));
}
in->top = -1;
- if (G_close_cell(in->bottom) < 0) {
+ if (Rast_close_cell(in->bottom) < 0) {
G_fatal_error(_("unable to close bottom raster map"));
}
in->bottom = -1;
Modified: grass/trunk/raster3d/r3.out.vtk/parameters.c
===================================================================
--- grass/trunk/raster3d/r3.out.vtk/parameters.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.out.vtk/parameters.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -16,6 +16,7 @@
*
*****************************************************************************/
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include "parameters.h"
Modified: grass/trunk/raster3d/r3.out.vtk/writeVTKData.c
===================================================================
--- grass/trunk/raster3d/r3.out.vtk/writeVTKData.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.out.vtk/writeVTKData.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
#include "globalDefs.h"
@@ -41,7 +42,7 @@
double val = nullval;
if (MapType == CELL_TYPE) {
- if (G_is_null_value(ptr, MapType)) {
+ if (Rast_is_null_value(ptr, MapType)) {
val = nullval;
}
else {
@@ -49,7 +50,7 @@
}
}
if (MapType == FCELL_TYPE) {
- if (G_is_null_value(ptr, MapType)) {
+ if (Rast_is_null_value(ptr, MapType)) {
val = nullval;
}
else {
@@ -57,7 +58,7 @@
}
}
if (MapType == DCELL_TYPE) {
- if (G_is_null_value(ptr, MapType)) {
+ if (Rast_is_null_value(ptr, MapType)) {
val = nullval;
}
else {
@@ -116,8 +117,8 @@
cols = region.cols;
depths = region.depths;
- rast_top = G_allocate_raster_buf(in->topMapType);
- rast_bottom = G_allocate_raster_buf(in->bottomMapType);
+ rast_top = Rast_allocate_raster_buf(in->topMapType);
+ rast_bottom = Rast_allocate_raster_buf(in->bottomMapType);
G_debug(3, _("write_vtk_points: Writing point coordinates"));
@@ -127,20 +128,20 @@
G_percent(status, (rows * depths - 1), 10);
status++;
- if (!G_get_raster_row(in->top, rast_top, y, in->topMapType))
+ if (!Rast_get_raster_row(in->top, rast_top, y, in->topMapType))
fatal_error(_("Could not get top raster row \n"), in);
- if (!G_get_raster_row
+ if (!Rast_get_raster_row
(in->bottom, rast_bottom, y, in->bottomMapType))
fatal_error(_("Could not get bottom raster row \n"), in);
for (x = 0, ptr_top = rast_top, ptr_bottom = rast_bottom;
x < cols;
x++, ptr_top =
- G_incr_void_ptr(ptr_top, G_raster_size(in->topMapType)),
+ Rast_incr_void_ptr(ptr_top, Rast_raster_size(in->topMapType)),
ptr_bottom =
- G_incr_void_ptr(ptr_bottom,
- G_raster_size(in->bottomMapType))) {
+ Rast_incr_void_ptr(ptr_bottom,
+ Rast_raster_size(in->bottomMapType))) {
/*Get the values */
topval =
Modified: grass/trunk/raster3d/r3.out.vtk/writeVTKHead.c
===================================================================
--- grass/trunk/raster3d/r3.out.vtk/writeVTKHead.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.out.vtk/writeVTKHead.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
#include "globalDefs.h"
Modified: grass/trunk/raster3d/r3.to.rast/main.c
===================================================================
--- grass/trunk/raster3d/r3.to.rast/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/raster3d/r3.to.rast/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/glocale.h>
@@ -57,7 +58,7 @@
if (fd != NULL) {
for (i = 0; i < depths; i++)
- G_unopen_cell(fd[i]);
+ Rast_unopen_cell(fd[i]);
}
G3d_fatalError(errorMsg);
@@ -118,9 +119,9 @@
typeIntern = G3d_tileTypeMap(map);
if (typeIntern == FCELL_TYPE)
- fcell = G_allocate_f_raster_buf();
+ fcell = Rast_allocate_f_raster_buf();
else if (typeIntern == DCELL_TYPE)
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
pos = 0;
/*Every Rastermap */
@@ -133,27 +134,27 @@
if (typeIntern == FCELL_TYPE) {
G3d_getValue(map, x, y, z, &f1, typeIntern);
if (G3d_isNullValueNum(&f1, FCELL_TYPE))
- G_set_null_value(&fcell[x], 1, FCELL_TYPE);
+ Rast_set_null_value(&fcell[x], 1, FCELL_TYPE);
else
fcell[x] = (FCELL) f1;
}
else {
G3d_getValue(map, x, y, z, &d1, typeIntern);
if (G3d_isNullValueNum(&d1, DCELL_TYPE))
- G_set_null_value(&dcell[x], 1, DCELL_TYPE);
+ Rast_set_null_value(&dcell[x], 1, DCELL_TYPE);
else
dcell[x] = (DCELL) d1;
}
}
if (typeIntern == FCELL_TYPE) {
- check = G_put_f_raster_row(fd[pos], fcell);
+ check = Rast_put_f_raster_row(fd[pos], fcell);
if (check != 1)
fatal_error(map, fd, depths,
_("Unable to write raster row"));
}
if (typeIntern == DCELL_TYPE) {
- check = G_put_d_raster_row(fd[pos], dcell);
+ check = Rast_put_d_raster_row(fd[pos], dcell);
if (check != 1)
fatal_error(map, fd, depths,
_("Unable to write raster row"));
@@ -178,7 +179,7 @@
{
int fd;
- fd = G_open_raster_new((char *)name, res_type);
+ fd = Rast_open_raster_new((char *)name, res_type);
if (fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), name);
@@ -190,7 +191,7 @@
/* ************************************************************************* */
void close_output_map(int fd)
{
- if (G_close_cell(fd) < 0)
+ if (Rast_close_cell(fd) < 0)
G_fatal_error(_("Unable to close output map"));
}
@@ -339,7 +340,7 @@
/* write history */
G_asprintf(&RasterFileName, "%s_%i", param.output->answer, i + 1);
G_debug(4, "Raster map %d Filename: %s", i + 1, RasterFileName);
- G_short_history(RasterFileName, "raster", &history);
+ Rast_short_history(RasterFileName, "raster", &history);
sprintf(history.datsrc_1, "3D Raster map:");
strncpy(history.datsrc_2, param.input->answer, RECORD_LEN);
@@ -363,8 +364,8 @@
history.edlinecnt = 8;
}
- G_command_history(&history);
- G_write_history(RasterFileName, &history);
+ Rast_command_history(&history);
+ Rast_write_history(RasterFileName, &history);
}
/*We set the Mask off, if it was off before */
Modified: grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/opennew.c
===================================================================
--- grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/opennew.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/opennew.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,9 +8,9 @@
int fd;
if (wr_type < 0) /* default fp type */
- fd = G_open_fp_cell_new(name);
+ fd = Rast_open_fp_cell_new(name);
else
- fd = G_open_raster_new(name, wr_type);
+ fd = Rast_open_raster_new(name, wr_type);
if (fd < 0)
G_fatal_error(_("Failed in attempt to open %s"), name);
Modified: grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/r_slope_aspect.c
===================================================================
--- grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/r_slope_aspect.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/swig/perl/R_slope_aspect/r_slope_aspect/r_slope_aspect.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -394,8 +394,8 @@
/* set the window from the header for the elevation file */
if (!flag.a->answer) {
G_get_window(&window);
- if (G_get_cellhd(elev_name, mapset, &cellhd) >= 0) {
- G_align_window(&window, &cellhd);
+ if (Rast_get_cellhd(elev_name, mapset, &cellhd) >= 0) {
+ Rast_align_window(&window, &cellhd);
G_set_window(&window);
}
}
@@ -468,21 +468,21 @@
*/
/* open the elevation file for reading */
- elevation_fd = G_open_cell_old(elev_name, mapset);
+ elevation_fd = Rast_open_cell_old(elev_name, mapset);
if (elevation_fd < 0)
exit(EXIT_FAILURE);
elev_cell[0] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(elev_cell[0], ncols);
+ Rast_set_d_null_value(elev_cell[0], ncols);
elev_cell[1] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(elev_cell[1], ncols);
+ Rast_set_d_null_value(elev_cell[1], ncols);
elev_cell[2] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(elev_cell[2], ncols);
+ Rast_set_d_null_value(elev_cell[2], ncols);
if (slope_name != NULL) {
slope_fd = opennew(slope_name, out_type);
- slp_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(slp_raster, G_window_cols(), data_type);
- G_put_raster_row(slope_fd, slp_raster, data_type);
+ slp_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(slp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(slope_fd, slp_raster, data_type);
}
else {
slp_raster = NULL;
@@ -491,9 +491,9 @@
if (aspect_name != NULL) {
aspect_fd = opennew(aspect_name, out_type);
- asp_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(asp_raster, G_window_cols(), data_type);
- G_put_raster_row(aspect_fd, asp_raster, data_type);
+ asp_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(asp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(aspect_fd, asp_raster, data_type);
}
else {
asp_raster = NULL;
@@ -502,9 +502,9 @@
if (pcurv_name != NULL) {
pcurv_fd = opennew(pcurv_name, out_type);
- pcurv_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(pcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(pcurv_fd, pcurv_raster, data_type);
+ pcurv_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(pcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(pcurv_fd, pcurv_raster, data_type);
}
else {
pcurv_raster = NULL;
@@ -513,9 +513,9 @@
if (tcurv_name != NULL) {
tcurv_fd = opennew(tcurv_name, out_type);
- tcurv_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(tcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(tcurv_fd, tcurv_raster, data_type);
+ tcurv_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(tcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(tcurv_fd, tcurv_raster, data_type);
}
else {
tcurv_raster = NULL;
@@ -524,9 +524,9 @@
if (dx_name != NULL) {
dx_fd = opennew(dx_name, out_type);
- dx_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dx_raster, G_window_cols(), data_type);
- G_put_raster_row(dx_fd, dx_raster, data_type);
+ dx_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dx_fd, dx_raster, data_type);
}
else {
dx_raster = NULL;
@@ -535,9 +535,9 @@
if (dy_name != NULL) {
dy_fd = opennew(dy_name, out_type);
- dy_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dy_raster, G_window_cols(), data_type);
- G_put_raster_row(dy_fd, dy_raster, data_type);
+ dy_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dy_fd, dy_raster, data_type);
}
else {
dy_raster = NULL;
@@ -546,9 +546,9 @@
if (dxx_name != NULL) {
dxx_fd = opennew(dxx_name, out_type);
- dxx_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dxx_raster, G_window_cols(), data_type);
- G_put_raster_row(dxx_fd, dxx_raster, data_type);
+ dxx_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dxx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxx_fd, dxx_raster, data_type);
}
else {
dxx_raster = NULL;
@@ -557,9 +557,9 @@
if (dyy_name != NULL) {
dyy_fd = opennew(dyy_name, out_type);
- dyy_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dyy_raster, G_window_cols(), data_type);
- G_put_raster_row(dyy_fd, dyy_raster, data_type);
+ dyy_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dyy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dyy_fd, dyy_raster, data_type);
}
else {
dyy_raster = NULL;
@@ -568,9 +568,9 @@
if (dxy_name != NULL) {
dxy_fd = opennew(dxy_name, out_type);
- dxy_raster = G_allocate_raster_buf(data_type);
- G_set_null_value(dxy_raster, G_window_cols(), data_type);
- G_put_raster_row(dxy_fd, dxy_raster, data_type);
+ dxy_raster = Rast_allocate_raster_buf(data_type);
+ Rast_set_null_value(dxy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxy_fd, dxy_raster, data_type);
}
else {
dxy_raster = NULL;
@@ -582,20 +582,20 @@
exit(EXIT_FAILURE);
if (Wrap) {
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[1] + 1, 0);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[1] + 1, 0);
elev_cell[1][0] = elev_cell[1][G_window_cols() - 1];
elev_cell[1][G_window_cols() + 1] = elev_cell[1][2];
}
else
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[1], 0);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[1], 0);
if (Wrap) {
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, 1);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, 1);
elev_cell[2][0] = elev_cell[2][G_window_cols() - 1];
elev_cell[2][G_window_cols() + 1] = elev_cell[2][2];
}
else
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2], 1);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2], 1);
G_message(_("Percent complete: "));
for (row = 2; row < nrows; row++) {
@@ -634,12 +634,12 @@
elev_cell[2] = temp;
if (Wrap) {
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, row);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2] + 1, row);
elev_cell[2][0] = elev_cell[2][G_window_cols() - 1];
elev_cell[2][G_window_cols() + 1] = elev_cell[2][2];
}
else
- G_get_d_raster_row_nomask(elevation_fd, elev_cell[2], row);
+ Rast_get_d_raster_row_nomask(elevation_fd, elev_cell[2], row);
c1 = elev_cell[0];
c2 = c1 + 1;
@@ -656,14 +656,14 @@
asp_ptr = asp_raster;
else
asp_ptr =
- G_incr_void_ptr(asp_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(asp_raster, Rast_raster_size(data_type));
}
if (slope_fd >= 0) {
if (Wrap)
slp_ptr = slp_raster;
else
slp_ptr =
- G_incr_void_ptr(slp_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(slp_raster, Rast_raster_size(data_type));
}
if (pcurv_fd >= 0) {
@@ -671,7 +671,7 @@
pcurv_ptr = pcurv_raster;
else
pcurv_ptr =
- G_incr_void_ptr(pcurv_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(pcurv_raster, Rast_raster_size(data_type));
}
if (tcurv_fd >= 0) {
@@ -679,21 +679,21 @@
tcurv_ptr = tcurv_raster;
else
tcurv_ptr =
- G_incr_void_ptr(tcurv_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(tcurv_raster, Rast_raster_size(data_type));
}
if (dx_fd >= 0) {
if (Wrap)
dx_ptr = dx_raster;
else
- dx_ptr = G_incr_void_ptr(dx_raster, G_raster_size(data_type));
+ dx_ptr = Rast_incr_void_ptr(dx_raster, Rast_raster_size(data_type));
}
if (dy_fd >= 0) {
if (Wrap)
dy_ptr = dy_raster;
else
- dy_ptr = G_incr_void_ptr(dy_raster, G_raster_size(data_type));
+ dy_ptr = Rast_incr_void_ptr(dy_raster, Rast_raster_size(data_type));
}
if (dxx_fd >= 0) {
@@ -701,7 +701,7 @@
dxx_ptr = dxx_raster;
else
dxx_ptr =
- G_incr_void_ptr(dxx_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxx_raster, Rast_raster_size(data_type));
}
if (dyy_fd >= 0) {
@@ -709,7 +709,7 @@
dyy_ptr = dyy_raster;
else
dyy_ptr =
- G_incr_void_ptr(dyy_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(dyy_raster, Rast_raster_size(data_type));
}
if (dxy_fd >= 0) {
@@ -717,7 +717,7 @@
dxy_ptr = dxy_raster;
else
dxy_ptr =
- G_incr_void_ptr(dxy_raster, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxy_raster, Rast_raster_size(data_type));
}
@@ -730,55 +730,55 @@
*c1, *c2, *c3, *c4, *c5, *c6, *c7, *c8, *c9);
*/
- if (G_is_d_null_value(c1) || G_is_d_null_value(c2) ||
- G_is_d_null_value(c3) || G_is_d_null_value(c4) ||
- G_is_d_null_value(c5) || G_is_d_null_value(c6) ||
- G_is_d_null_value(c7) || G_is_d_null_value(c8) ||
- G_is_d_null_value(c9)) {
+ if (Rast_is_d_null_value(c1) || Rast_is_d_null_value(c2) ||
+ Rast_is_d_null_value(c3) || Rast_is_d_null_value(c4) ||
+ Rast_is_d_null_value(c5) || Rast_is_d_null_value(c6) ||
+ Rast_is_d_null_value(c7) || Rast_is_d_null_value(c8) ||
+ Rast_is_d_null_value(c9)) {
if (slope_fd > 0) {
- G_set_null_value(slp_ptr, 1, data_type);
+ Rast_set_null_value(slp_ptr, 1, data_type);
slp_ptr =
- G_incr_void_ptr(slp_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(slp_ptr, Rast_raster_size(data_type));
}
if (aspect_fd > 0) {
- G_set_null_value(asp_ptr, 1, data_type);
+ Rast_set_null_value(asp_ptr, 1, data_type);
asp_ptr =
- G_incr_void_ptr(asp_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(asp_ptr, Rast_raster_size(data_type));
}
if (pcurv_fd > 0) {
- G_set_null_value(pcurv_ptr, 1, data_type);
+ Rast_set_null_value(pcurv_ptr, 1, data_type);
pcurv_ptr =
- G_incr_void_ptr(pcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(pcurv_ptr, Rast_raster_size(data_type));
}
if (tcurv_fd > 0) {
- G_set_null_value(tcurv_ptr, 1, data_type);
+ Rast_set_null_value(tcurv_ptr, 1, data_type);
tcurv_ptr =
- G_incr_void_ptr(tcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(tcurv_ptr, Rast_raster_size(data_type));
}
if (dx_fd > 0) {
- G_set_null_value(dx_ptr, 1, data_type);
+ Rast_set_null_value(dx_ptr, 1, data_type);
dx_ptr =
- G_incr_void_ptr(dx_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dx_ptr, Rast_raster_size(data_type));
}
if (dy_fd > 0) {
- G_set_null_value(dy_ptr, 1, data_type);
+ Rast_set_null_value(dy_ptr, 1, data_type);
dy_ptr =
- G_incr_void_ptr(dy_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dy_ptr, Rast_raster_size(data_type));
}
if (dxx_fd > 0) {
- G_set_null_value(dxx_ptr, 1, data_type);
+ Rast_set_null_value(dxx_ptr, 1, data_type);
dxx_ptr =
- G_incr_void_ptr(dxx_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxx_ptr, Rast_raster_size(data_type));
}
if (dyy_fd > 0) {
- G_set_null_value(dyy_ptr, 1, data_type);
+ Rast_set_null_value(dyy_ptr, 1, data_type);
dyy_ptr =
- G_incr_void_ptr(dyy_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dyy_ptr, Rast_raster_size(data_type));
}
if (dxy_fd > 0) {
- G_set_null_value(dxy_ptr, 1, data_type);
+ Rast_set_null_value(dxy_ptr, 1, data_type);
dxy_ptr =
- G_incr_void_ptr(dxy_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(dxy_ptr, Rast_raster_size(data_type));
}
continue;
} /* no data */
@@ -837,13 +837,13 @@
*((CELL *) slp_ptr) = (CELL) test;
else {
if (deg)
- G_set_raster_value_d(slp_ptr,
+ Rast_set_raster_value_d(slp_ptr,
(DCELL) slp_in_deg, data_type);
else
- G_set_raster_value_d(slp_ptr,
+ Rast_set_raster_value_d(slp_ptr,
(DCELL) slp_in_perc, data_type);
}
- slp_ptr = G_incr_void_ptr(slp_ptr, G_raster_size(data_type));
+ slp_ptr = Rast_incr_void_ptr(slp_ptr, Rast_raster_size(data_type));
} /* computing slope */
if (aspect_fd > 0) {
@@ -870,12 +870,12 @@
if (out_type == CELL_TYPE)
*((CELL *) asp_ptr) = (CELL) (aspect + .5);
else
- G_set_raster_value_d(asp_ptr,
+ Rast_set_raster_value_d(asp_ptr,
(DCELL) aspect, data_type);
}
else
- G_set_null_value(asp_ptr, 1, data_type);
- asp_ptr = G_incr_void_ptr(asp_ptr, G_raster_size(data_type));
+ Rast_set_null_value(asp_ptr, 1, data_type);
+ asp_ptr = Rast_incr_void_ptr(asp_ptr, Rast_raster_size(data_type));
/* now update min and max */
if (min_asp > aspect)
@@ -888,16 +888,16 @@
if (out_type == CELL_TYPE)
*((CELL *) dx_ptr) = (CELL) (scik1 * dx);
else
- G_set_raster_value_d(dx_ptr, (DCELL) dx, data_type);
- dx_ptr = G_incr_void_ptr(dx_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dx_ptr, (DCELL) dx, data_type);
+ dx_ptr = Rast_incr_void_ptr(dx_ptr, Rast_raster_size(data_type));
}
if (dy_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) dy_ptr) = (CELL) (scik1 * dy);
else
- G_set_raster_value_d(dy_ptr, (DCELL) dy, data_type);
- dy_ptr = G_incr_void_ptr(dy_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dy_ptr, (DCELL) dy, data_type);
+ dy_ptr = Rast_incr_void_ptr(dy_ptr, Rast_raster_size(data_type));
}
if (dxx_fd <= 0 && dxy_fd <= 0 && dyy_fd <= 0 &&
@@ -918,24 +918,24 @@
if (out_type == CELL_TYPE)
*((CELL *) dxx_ptr) = (CELL) (scik1 * dxx);
else
- G_set_raster_value_d(dxx_ptr, (DCELL) dxx, data_type);
- dxx_ptr = G_incr_void_ptr(dxx_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dxx_ptr, (DCELL) dxx, data_type);
+ dxx_ptr = Rast_incr_void_ptr(dxx_ptr, Rast_raster_size(data_type));
}
if (dyy_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) dyy_ptr) = (CELL) (scik1 * dyy);
else
- G_set_raster_value_d(dyy_ptr, (DCELL) dyy, data_type);
- dyy_ptr = G_incr_void_ptr(dyy_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dyy_ptr, (DCELL) dyy, data_type);
+ dyy_ptr = Rast_incr_void_ptr(dyy_ptr, Rast_raster_size(data_type));
}
if (dxy_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) dxy_ptr) = (CELL) (scik1 * dxy);
else
- G_set_raster_value_d(dxy_ptr, (DCELL) dxy, data_type);
- dxy_ptr = G_incr_void_ptr(dxy_ptr, G_raster_size(data_type));
+ Rast_set_raster_value_d(dxy_ptr, (DCELL) dxy, data_type);
+ dxy_ptr = Rast_incr_void_ptr(dxy_ptr, Rast_raster_size(data_type));
}
/* compute curvature */
@@ -970,54 +970,54 @@
if (out_type == CELL_TYPE)
*((CELL *) pcurv_ptr) = (CELL) (scik1 * pcurv);
else
- G_set_raster_value_d(pcurv_ptr, (DCELL) pcurv, data_type);
+ Rast_set_raster_value_d(pcurv_ptr, (DCELL) pcurv, data_type);
pcurv_ptr =
- G_incr_void_ptr(pcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(pcurv_ptr, Rast_raster_size(data_type));
}
if (tcurv_fd > 0) {
if (out_type == CELL_TYPE)
*((CELL *) tcurv_ptr) = (CELL) (scik1 * tcurv);
else
- G_set_raster_value_d(tcurv_ptr, (DCELL) tcurv, data_type);
+ Rast_set_raster_value_d(tcurv_ptr, (DCELL) tcurv, data_type);
tcurv_ptr =
- G_incr_void_ptr(tcurv_ptr, G_raster_size(data_type));
+ Rast_incr_void_ptr(tcurv_ptr, Rast_raster_size(data_type));
}
} /* column for loop */
if (aspect_fd > 0)
- G_put_raster_row(aspect_fd, asp_raster, data_type);
+ Rast_put_raster_row(aspect_fd, asp_raster, data_type);
if (slope_fd > 0)
- G_put_raster_row(slope_fd, slp_raster, data_type);
+ Rast_put_raster_row(slope_fd, slp_raster, data_type);
if (pcurv_fd > 0)
- G_put_raster_row(pcurv_fd, pcurv_raster, data_type);
+ Rast_put_raster_row(pcurv_fd, pcurv_raster, data_type);
if (tcurv_fd > 0)
- G_put_raster_row(tcurv_fd, tcurv_raster, data_type);
+ Rast_put_raster_row(tcurv_fd, tcurv_raster, data_type);
if (dx_fd > 0)
- G_put_raster_row(dx_fd, dx_raster, data_type);
+ Rast_put_raster_row(dx_fd, dx_raster, data_type);
if (dy_fd > 0)
- G_put_raster_row(dy_fd, dy_raster, data_type);
+ Rast_put_raster_row(dy_fd, dy_raster, data_type);
if (dxx_fd > 0)
- G_put_raster_row(dxx_fd, dxx_raster, data_type);
+ Rast_put_raster_row(dxx_fd, dxx_raster, data_type);
if (dyy_fd > 0)
- G_put_raster_row(dyy_fd, dyy_raster, data_type);
+ Rast_put_raster_row(dyy_fd, dyy_raster, data_type);
if (dxy_fd > 0)
- G_put_raster_row(dxy_fd, dxy_raster, data_type);
+ Rast_put_raster_row(dxy_fd, dxy_raster, data_type);
} /* row loop */
G_percent(row, nrows, 2);
- G_close_cell(elevation_fd);
+ Rast_close_cell(elevation_fd);
G_message(_("Creating support files..."));
G_message(_("Elevation products for mapset [%s] in [%s]"),
@@ -1027,16 +1027,16 @@
DCELL min, max;
struct FPRange range;
- G_set_null_value(asp_raster, G_window_cols(), data_type);
- G_put_raster_row(aspect_fd, asp_raster, data_type);
- G_close_cell(aspect_fd);
+ Rast_set_null_value(asp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(aspect_fd, asp_raster, data_type);
+ Rast_close_cell(aspect_fd);
if (out_type != CELL_TYPE)
- G_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
+ Rast_quantize_fp_map_range(aspect_name, G_mapset(), 0., 360., 0,
360);
- G_read_raster_cats(aspect_name, G_mapset(), &cats);
- G_set_raster_cats_title
+ Rast_read_raster_cats(aspect_name, G_mapset(), &cats);
+ Rast_set_raster_cats_title
("Aspect counterclockwise in degrees from east", &cats);
G_message(_("Min computed aspect %.4f, max computed aspect %.4f"),
@@ -1068,80 +1068,80 @@
sprintf(buf, "%d degree%s ccw from east", i,
i == 1 ? "" : "s");
if (data_type == CELL_TYPE) {
- G_set_cat(i, buf, &cats);
+ Rast_set_cat(i, buf, &cats);
continue;
}
tmp1 = (double)i - .5;
tmp2 = (double)i + .5;
- G_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
}
if (data_type == CELL_TYPE)
- G_set_cat(0, "no aspect", &cats);
+ Rast_set_cat(0, "no aspect", &cats);
else {
tmp1 = 0.;
tmp2 = .5;
- G_set_d_raster_cat(&tmp1, &tmp2, "no aspect", &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, "no aspect", &cats);
}
- G_write_raster_cats(aspect_name, &cats);
- G_free_raster_cats(&cats);
+ Rast_write_raster_cats(aspect_name, &cats);
+ Rast_free_raster_cats(&cats);
/* write colors for aspect file */
- G_init_colors(&colors);
- G_read_fp_range(aspect_name, G_mapset(), &range);
- G_get_fp_range_min_max(&range, &min, &max);
- G_make_aspect_fp_colors(&colors, min, max);
- G_write_colors(aspect_name, G_mapset(), &colors);
+ Rast_init_colors(&colors);
+ Rast_read_fp_range(aspect_name, G_mapset(), &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
+ Rast_make_aspect_fp_colors(&colors, min, max);
+ Rast_write_colors(aspect_name, G_mapset(), &colors);
/* writing history file */
- G_short_history(aspect_name, "raster", &hist);
+ Rast_short_history(aspect_name, "raster", &hist);
sprintf(hist.edhist[0], "aspect map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(aspect_name, &hist);
+ Rast_write_history(aspect_name, &hist);
G_message(_("ASPECT [%s] COMPLETE"), aspect_name);
}
if (slope_fd >= 0) {
/* colortable for slopes */
- G_init_colors(&colors);
- G_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
- G_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
- G_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
- G_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
- G_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
- G_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
- G_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
+ Rast_init_colors(&colors);
+ Rast_add_color_rule(0, 255, 255, 255, 2, 255, 255, 0, &colors);
+ Rast_add_color_rule(2, 255, 255, 0, 5, 0, 255, 0, &colors);
+ Rast_add_color_rule(5, 0, 255, 0, 10, 0, 255, 255, &colors);
+ Rast_add_color_rule(10, 0, 255, 255, 15, 0, 0, 255, &colors);
+ Rast_add_color_rule(15, 0, 0, 255, 30, 255, 0, 255, &colors);
+ Rast_add_color_rule(30, 255, 0, 255, 50, 255, 0, 0, &colors);
+ Rast_add_color_rule(50, 255, 0, 0, 90, 0, 0, 0, &colors);
- G_set_null_value(slp_raster, G_window_cols(), data_type);
- G_put_raster_row(slope_fd, slp_raster, data_type);
- G_close_cell(slope_fd);
+ Rast_set_null_value(slp_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(slope_fd, slp_raster, data_type);
+ Rast_close_cell(slope_fd);
if (out_type != CELL_TYPE) {
/* INCR_BY_ONE
if(deg)
- G_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 1, 91);
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 1, 91);
else
- G_quantize_fp_map_range(slope_name, G_mapset(), min_slp, max_slp,
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), min_slp, max_slp,
(CELL) min_slp + 1, (CELL) ceil(max_slp) + 1);
*/
- G_write_colors(slope_name, G_mapset(), &colors);
+ Rast_write_colors(slope_name, G_mapset(), &colors);
if (deg)
- G_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 0,
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), 0., 90., 0,
90);
else /* percent */
- G_quantize_fp_map_range(slope_name, G_mapset(), min_slp,
+ Rast_quantize_fp_map_range(slope_name, G_mapset(), min_slp,
max_slp, (CELL) min_slp,
(CELL) ceil(max_slp));
}
- G_read_raster_cats(slope_name, G_mapset(), &cats);
+ Rast_read_raster_cats(slope_name, G_mapset(), &cats);
if (deg)
- G_set_raster_cats_title("slope in degrees", &cats);
+ Rast_set_raster_cats_title("slope in degrees", &cats);
else if (perc)
- G_set_raster_cats_title("percent slope", &cats);
+ Rast_set_raster_cats_title("percent slope", &cats);
G_message(_("Min computed slope %.4f, max computed slope %.4f"),
min_slp, max_slp);
@@ -1156,9 +1156,9 @@
sprintf(buf, "%d percent", i);
if (data_type == CELL_TYPE) {
/* INCR_BY_ONE
- G_set_cat(i+1, buf, &cats);
+ Rast_set_cat(i+1, buf, &cats);
*/
- G_set_cat(i, buf, &cats);
+ Rast_set_cat(i, buf, &cats);
continue;
}
/* INCR_BY_ONE
@@ -1167,70 +1167,70 @@
*/
tmp1 = (DCELL) i - .5;
tmp2 = (DCELL) i + .5;
- G_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, buf, &cats);
}
if (data_type == CELL_TYPE)
- G_set_cat(0, "zero slope", &cats);
+ Rast_set_cat(0, "zero slope", &cats);
/* INCR_BY_ONE
- G_set_cat(0, "no data", &cats);
+ Rast_set_cat(0, "no data", &cats);
*/
else {
tmp1 = 0;
tmp2 = 0.5;
- G_set_d_raster_cat(&tmp1, &tmp2, "zero slope", &cats);
+ Rast_set_d_raster_cat(&tmp1, &tmp2, "zero slope", &cats);
}
/* INCR_BY_ONE
- G_set_d_raster_cat (&tmp1, &tmp1, "no data", &cats);
+ Rast_set_d_raster_cat (&tmp1, &tmp1, "no data", &cats);
*/
- G_write_raster_cats(slope_name, &cats);
+ Rast_write_raster_cats(slope_name, &cats);
/* writing history file */
- G_short_history(slope_name, "raster", &hist);
+ Rast_short_history(slope_name, "raster", &hist);
sprintf(hist.edhist[0], "slope map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f format = %s", zfactor,
parm.slope_fmt->answer);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(slope_name, &hist);
+ Rast_write_history(slope_name, &hist);
G_message(_("SLOPE [%s] COMPLETE"), slope_name);
}
/* colortable for curvatures */
if (pcurv_fd >= 0 || tcurv_fd >= 0) {
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
if (c1min < c2min)
dat1 = (FCELL) c1min;
else
dat1 = (FCELL) c2min;
dat2 = (FCELL) - 0.01;
- G_add_f_raster_color_rule(&dat1, 127, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 127, 0, 255,
&dat2, 0, 0, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.001;
- G_add_f_raster_color_rule(&dat1, 0, 0, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 0, 255,
&dat2, 0, 127, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) - 0.00001;
- G_add_f_raster_color_rule(&dat1, 0, 127, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 127, 255,
&dat2, 0, 255, 255, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.0;
- G_add_f_raster_color_rule(&dat1, 0, 255, 255,
+ Rast_add_f_raster_color_rule(&dat1, 0, 255, 255,
&dat2, 200, 255, 200, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.00001;
- G_add_f_raster_color_rule(&dat1, 200, 255, 200,
+ Rast_add_f_raster_color_rule(&dat1, 200, 255, 200,
&dat2, 255, 255, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.001;
- G_add_f_raster_color_rule(&dat1, 255, 255, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 255, 0,
&dat2, 255, 127, 0, &colors);
dat1 = dat2;
dat2 = (FCELL) 0.01;
- G_add_f_raster_color_rule(&dat1, 255, 127, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 127, 0,
&dat2, 255, 0, 0, &colors);
dat1 = dat2;
if (c1max > c2max)
@@ -1238,178 +1238,178 @@
else
dat2 = (FCELL) c2max;
- G_add_f_raster_color_rule(&dat1, 255, 0, 0,
+ Rast_add_f_raster_color_rule(&dat1, 255, 0, 0,
&dat2, 255, 0, 200, &colors);
}
if (pcurv_fd >= 0) {
- G_set_null_value(pcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(pcurv_fd, pcurv_raster, data_type);
- G_close_cell(pcurv_fd);
+ Rast_set_null_value(pcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(pcurv_fd, pcurv_raster, data_type);
+ Rast_close_cell(pcurv_fd);
- G_write_colors(pcurv_name, G_mapset(), &colors);
+ Rast_write_colors(pcurv_name, G_mapset(), &colors);
if (out_type != CELL_TYPE)
- G_round_fp_map(pcurv_name, G_mapset());
+ Rast_round_fp_map(pcurv_name, G_mapset());
- G_read_cats(pcurv_name, G_mapset(), &cats);
- G_set_cats_title("profile curvature", &cats);
- G_set_cat((CELL) 0, "no profile curve", &cats);
+ Rast_read_cats(pcurv_name, G_mapset(), &cats);
+ Rast_set_cats_title("profile curvature", &cats);
+ Rast_set_cat((CELL) 0, "no profile curve", &cats);
/* writing history file */
- G_short_history(pcurv_name, "raster", &hist);
+ Rast_short_history(pcurv_name, "raster", &hist);
sprintf(hist.edhist[0], "profile curve map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(pcurv_name, &hist);
+ Rast_write_history(pcurv_name, &hist);
G_message(_("PROFILE CURVE [%s] COMPLETE"), pcurv_name);
}
if (tcurv_fd >= 0) {
- G_set_null_value(tcurv_raster, G_window_cols(), data_type);
- G_put_raster_row(tcurv_fd, tcurv_raster, data_type);
- G_close_cell(tcurv_fd);
+ Rast_set_null_value(tcurv_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(tcurv_fd, tcurv_raster, data_type);
+ Rast_close_cell(tcurv_fd);
- G_write_colors(tcurv_name, G_mapset(), &colors);
+ Rast_write_colors(tcurv_name, G_mapset(), &colors);
if (out_type != CELL_TYPE)
- G_round_fp_map(tcurv_name, G_mapset());
+ Rast_round_fp_map(tcurv_name, G_mapset());
- G_read_cats(tcurv_name, G_mapset(), &cats);
- G_set_cats_title("tangential curvature", &cats);
- G_set_cat((CELL) 0, "no tangential curve", &cats);
+ Rast_read_cats(tcurv_name, G_mapset(), &cats);
+ Rast_set_cats_title("tangential curvature", &cats);
+ Rast_set_cat((CELL) 0, "no tangential curve", &cats);
/* writing history file */
- G_short_history(tcurv_name, "raster", &hist);
+ Rast_short_history(tcurv_name, "raster", &hist);
sprintf(hist.edhist[0], "tangential curve map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(tcurv_name, &hist);
+ Rast_write_history(tcurv_name, &hist);
G_message(_("TANGENTIAL CURVE [%s] COMPLETE"), tcurv_name);
}
if (dx_fd >= 0) {
- G_set_null_value(dx_raster, G_window_cols(), data_type);
- G_put_raster_row(dx_fd, dx_raster, data_type);
- G_close_cell(dx_fd);
+ Rast_set_null_value(dx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dx_fd, dx_raster, data_type);
+ Rast_close_cell(dx_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dx_name, G_mapset());
+ Rast_round_fp_map(dx_name, G_mapset());
- G_read_cats(dx_name, G_mapset(), &cats);
- G_set_cats_title("E-W slope", &cats);
- G_set_cat((CELL) 0, "no E-W slope", &cats);
+ Rast_read_cats(dx_name, G_mapset(), &cats);
+ Rast_set_cats_title("E-W slope", &cats);
+ Rast_set_cat((CELL) 0, "no E-W slope", &cats);
/* writing history file */
- G_short_history(dx_name, "raster", &hist);
+ Rast_short_history(dx_name, "raster", &hist);
sprintf(hist.edhist[0], "E-W slope map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dx_name, &hist);
+ Rast_write_history(dx_name, &hist);
G_message(_("E-W SLOPE [%s] COMPLETE"), dx_name);
}
if (dy_fd >= 0) {
- G_set_null_value(dy_raster, G_window_cols(), data_type);
- G_put_raster_row(dy_fd, dy_raster, data_type);
- G_close_cell(dy_fd);
+ Rast_set_null_value(dy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dy_fd, dy_raster, data_type);
+ Rast_close_cell(dy_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dy_name, G_mapset());
+ Rast_round_fp_map(dy_name, G_mapset());
- G_read_cats(dy_name, G_mapset(), &cats);
- G_set_cats_title("N-S slope", &cats);
- G_set_cat((CELL) 0, "no N-S slope", &cats);
+ Rast_read_cats(dy_name, G_mapset(), &cats);
+ Rast_set_cats_title("N-S slope", &cats);
+ Rast_set_cat((CELL) 0, "no N-S slope", &cats);
/* writing history file */
- G_short_history(dy_name, "raster", &hist);
+ Rast_short_history(dy_name, "raster", &hist);
sprintf(hist.edhist[0], "N-S slope map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dy_name, &hist);
+ Rast_write_history(dy_name, &hist);
G_message(_("N-S SLOPE [%s] COMPLETE"), dy_name);
}
if (dxx_fd >= 0) {
- G_set_null_value(dxx_raster, G_window_cols(), data_type);
- G_put_raster_row(dxx_fd, dxx_raster, data_type);
- G_close_cell(dxx_fd);
+ Rast_set_null_value(dxx_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxx_fd, dxx_raster, data_type);
+ Rast_close_cell(dxx_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dxx_name, G_mapset());
+ Rast_round_fp_map(dxx_name, G_mapset());
- G_read_cats(dxx_name, G_mapset(), &cats);
- G_set_cats_title("DXX", &cats);
- G_set_cat((CELL) 0, "DXX", &cats);
+ Rast_read_cats(dxx_name, G_mapset(), &cats);
+ Rast_set_cats_title("DXX", &cats);
+ Rast_set_cat((CELL) 0, "DXX", &cats);
/* writing history file */
- G_short_history(dxx_name, "raster", &hist);
+ Rast_short_history(dxx_name, "raster", &hist);
sprintf(hist.edhist[0], "DXX map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dxx_name, &hist);
+ Rast_write_history(dxx_name, &hist);
G_message(_("DXX [%s] COMPLETE"), dxx_name);
}
if (dyy_fd >= 0) {
- G_set_null_value(dyy_raster, G_window_cols(), data_type);
- G_put_raster_row(dyy_fd, dyy_raster, data_type);
- G_close_cell(dyy_fd);
+ Rast_set_null_value(dyy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dyy_fd, dyy_raster, data_type);
+ Rast_close_cell(dyy_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dyy_name, G_mapset());
+ Rast_round_fp_map(dyy_name, G_mapset());
- G_read_cats(dyy_name, G_mapset(), &cats);
- G_set_cats_title("DYY", &cats);
- G_set_cat((CELL) 0, "DYY", &cats);
+ Rast_read_cats(dyy_name, G_mapset(), &cats);
+ Rast_set_cats_title("DYY", &cats);
+ Rast_set_cat((CELL) 0, "DYY", &cats);
/* writing history file */
- G_short_history(dyy_name, "raster", &hist);
+ Rast_short_history(dyy_name, "raster", &hist);
sprintf(hist.edhist[0], "DYY map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dyy_name, &hist);
+ Rast_write_history(dyy_name, &hist);
G_message(_("DYY [%s] COMPLETE"), dyy_name);
}
if (dxy_fd >= 0) {
- G_set_null_value(dxy_raster, G_window_cols(), data_type);
- G_put_raster_row(dxy_fd, dxy_raster, data_type);
- G_close_cell(dxy_fd);
+ Rast_set_null_value(dxy_raster, G_window_cols(), data_type);
+ Rast_put_raster_row(dxy_fd, dxy_raster, data_type);
+ Rast_close_cell(dxy_fd);
if (out_type != CELL_TYPE)
- G_round_fp_map(dxy_name, G_mapset());
+ Rast_round_fp_map(dxy_name, G_mapset());
- G_read_cats(dxy_name, G_mapset(), &cats);
- G_set_cats_title("DXY", &cats);
- G_set_cat((CELL) 0, "DXY", &cats);
+ Rast_read_cats(dxy_name, G_mapset(), &cats);
+ Rast_set_cats_title("DXY", &cats);
+ Rast_set_cat((CELL) 0, "DXY", &cats);
/* writing history file */
- G_short_history(dxy_name, "raster", &hist);
+ Rast_short_history(dxy_name, "raster", &hist);
sprintf(hist.edhist[0], "DXY map elev = %s", elev_name);
sprintf(hist.edhist[1], "zfactor = %.2f", zfactor);
sprintf(hist.edhist[2], "min_slp_allowed = %f", min_slp_allowed);
sprintf(hist.datsrc_1, "raster elevation file %s", elev_name);
hist.edlinecnt = 3;
- G_write_history(dxy_name, &hist);
+ Rast_write_history(dxy_name, &hist);
G_message(_("DXY [%s] COMPLETE"), dxy_name);
}
Modified: grass/trunk/vector/lidar/lidarlib/TcholBand.c
===================================================================
--- grass/trunk/vector/lidar/lidarlib/TcholBand.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/lidarlib/TcholBand.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/PolimiFunct.h>
/*--------------------------------------------------------------------------------------*/
Modified: grass/trunk/vector/lidar/lidarlib/raster.c
===================================================================
--- grass/trunk/vector/lidar/lidarlib/raster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/lidarlib/raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/lidar/lidarlib/zones.c
===================================================================
--- grass/trunk/vector/lidar/lidarlib/zones.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/lidarlib/zones.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
@@ -273,18 +274,18 @@
nrows = G_window_rows();
ncols = G_window_cols();
- raster = G_allocate_raster_buf(DCELL_TYPE);
+ raster = Rast_allocate_raster_buf(DCELL_TYPE);
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- G_set_d_null_value(raster, ncols);
+ Rast_set_d_null_value(raster, ncols);
for (col = 0, ptr = raster; col < ncols;
- col++, ptr = G_incr_void_ptr(ptr, G_raster_size(DCELL_TYPE))) {
- G_set_raster_value_d(ptr, (DCELL) (matrix[row][col]), DCELL_TYPE);
+ col++, ptr = Rast_incr_void_ptr(ptr, Rast_raster_size(DCELL_TYPE))) {
+ Rast_set_raster_value_d(ptr, (DCELL) (matrix[row][col]), DCELL_TYPE);
}
- G_put_d_raster_row(fd, raster);
+ Rast_put_d_raster_row(fd, raster);
}
}
Modified: grass/trunk/vector/lidar/v.lidar.correction/correction.c
===================================================================
--- grass/trunk/vector/lidar/v.lidar.correction/correction.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.lidar.correction/correction.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
Modified: grass/trunk/vector/lidar/v.lidar.correction/main.c
===================================================================
--- grass/trunk/vector/lidar/v.lidar.correction/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.lidar.correction/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,7 @@
#include <math.h>
#include <grass/config.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/lidar/v.lidar.edgedetection/edgedetection.c
===================================================================
--- grass/trunk/vector/lidar/v.lidar.edgedetection/edgedetection.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.lidar.edgedetection/edgedetection.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -28,6 +28,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
/* #include <grass/PolimiFunct.h> */
Modified: grass/trunk/vector/lidar/v.lidar.edgedetection/main.c
===================================================================
--- grass/trunk/vector/lidar/v.lidar.edgedetection/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.lidar.edgedetection/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -27,6 +27,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/lidar/v.lidar.growing/ConvexHull.c
===================================================================
--- grass/trunk/vector/lidar/v.lidar.growing/ConvexHull.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.lidar.growing/ConvexHull.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "growing.h"
Modified: grass/trunk/vector/lidar/v.lidar.growing/main.c
===================================================================
--- grass/trunk/vector/lidar/v.lidar.growing/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.lidar.growing/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -25,6 +25,7 @@
#include <math.h>
#include <grass/config.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/lidar/v.outlier/main.c
===================================================================
--- grass/trunk/vector/lidar/v.outlier/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.outlier/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,7 @@
#include <math.h>
#include <grass/config.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/lidar/v.outlier/outlier.c
===================================================================
--- grass/trunk/vector/lidar/v.outlier/outlier.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.outlier/outlier.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
Modified: grass/trunk/vector/lidar/v.surf.bspline/crosscorr.c
===================================================================
--- grass/trunk/vector/lidar/v.surf.bspline/crosscorr.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.surf.bspline/crosscorr.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/lidar/v.surf.bspline/main.c
===================================================================
--- grass/trunk/vector/lidar/v.surf.bspline/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/lidar/v.surf.bspline/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -22,6 +22,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
@@ -282,7 +283,7 @@
/* raster output */
raster = -1;
- G_set_fp_type(DCELL_TYPE);
+ Rast_set_fp_type(DCELL_TYPE);
if (!vector && map) {
grid = TRUE;
/*
@@ -290,7 +291,7 @@
G_fatal_error (_("Raster <%s> already exist."), out_map_opt->answer);
*/
- if ((raster = G_open_fp_cell_new(out_map_opt->answer)) < 0)
+ if ((raster = Rast_open_fp_cell_new(out_map_opt->answer)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
out_map_opt->answer);
}
@@ -344,7 +345,7 @@
Vect_close(&Out);
if (map)
- G_close_cell(raster);
+ Rast_close_cell(raster);
G_done_msg(_("Cross Validation was success!"));
exit(EXIT_SUCCESS);
@@ -729,16 +730,16 @@
Vect_close(&Out);
if (map) {
- G_close_cell(raster);
+ Rast_close_cell(raster);
/* set map title */
sprintf(title, "%s interpolation with Tykhonov regularization",
type->answer);
- G_put_cell_title(out_map_opt->answer, title);
+ Rast_put_cell_title(out_map_opt->answer, title);
/* write map history */
- G_short_history(out_map_opt->answer, "raster", &history);
- G_command_history(&history);
- G_write_history(out_map_opt->answer, &history);
+ Rast_short_history(out_map_opt->answer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out_map_opt->answer, &history);
}
G_done_msg(" ");
Modified: grass/trunk/vector/v.convert/att.c
===================================================================
--- grass/trunk/vector/v.convert/att.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.convert/att.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -37,7 +38,7 @@
return 0;
}
- if (G_read_vector_cats(in, mapset, &Cats) == -1) {
+ if (Rast_read_vector_cats(in, mapset, &Cats) == -1) {
G_warning(_("Unable to open dig_cats file"));
return -1;
}
Modified: grass/trunk/vector/v.convert/dist.c
===================================================================
--- grass/trunk/vector/v.convert/dist.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.convert/dist.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include "conv.h"
#include "local_proto.h"
Modified: grass/trunk/vector/v.convert/main.c
===================================================================
--- grass/trunk/vector/v.convert/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.convert/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
#include "conv.h"
Modified: grass/trunk/vector/v.convert/old2new.c
===================================================================
--- grass/trunk/vector/v.convert/old2new.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.convert/old2new.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
#include "conv.h"
Modified: grass/trunk/vector/v.convert/read.c
===================================================================
--- grass/trunk/vector/v.convert/read.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.convert/read.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
#include "conv.h"
Modified: grass/trunk/vector/v.drape/main.c
===================================================================
--- grass/trunk/vector/v.drape/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.drape/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
@@ -52,10 +53,10 @@
/* sample raster at this point, and update the z-coordinate
* (note that input vector should not be 3D!)
*/
- estimated_elevation = scale * G_get_raster_sample(
+ estimated_elevation = scale * Rast_get_raster_sample(
fdrast, &window, NULL, Points->y[0], Points->x[0], 0, method);
/* Elevation value has to be meaningfull */
- if (G_is_d_null_value(&estimated_elevation)) {
+ if (Rast_is_d_null_value(&estimated_elevation)) {
if (null_opt->answer) {
estimated_elevation = null_val;
}
@@ -75,10 +76,10 @@
/* loop through each point in a line */
for (j = 0; j < Points->n_points; j++) {
/* sample raster at this point, and update the z-coordinate (note that input vector should not be 3D!) */
- estimated_elevation = scale * G_get_raster_sample(
+ estimated_elevation = scale * Rast_get_raster_sample(
fdrast, &window, NULL, Points->y[j], Points->x[j], 0, method);
- if (G_is_d_null_value(&estimated_elevation)) {
+ if (Rast_is_d_null_value(&estimated_elevation)) {
if (null_opt->answer) {
estimated_elevation = null_val;
}
@@ -99,10 +100,10 @@
/* loop through each point in a line */
for (j = 0; j < Points->n_points; j++) {
/* sample raster at this point, and update the z-coordinate (note that input vector should not be 3D!) */
- estimated_elevation = scale * G_get_raster_sample(
+ estimated_elevation = scale * Rast_get_raster_sample(
fdrast, &window, NULL, Points->y[j], Points->x[j], 0, method);
- if (G_is_d_null_value(&estimated_elevation)) {
+ if (Rast_is_d_null_value(&estimated_elevation)) {
if (null_opt->answer) {
estimated_elevation = null_val;
}
@@ -223,7 +224,7 @@
otype = Vect_option_to_types(type_opt);
/* open the elev raster, and check for error condition */
- if ((fdrast = G_open_cell_old(rast_opt->answer, "")) < 0) {
+ if ((fdrast = Rast_open_cell_old(rast_opt->answer, "")) < 0) {
G_fatal_error(_("Unable to open raster map <%s>"), rast_opt->answer);
}
@@ -366,7 +367,7 @@
} /* end working on type=lines */
/* close elevation raster: */
- G_close_cell(fdrast);
+ Rast_close_cell(fdrast);
/* build topology for output vector */
if (out_num > 0) {
Modified: grass/trunk/vector/v.extrude/main.c
===================================================================
--- grass/trunk/vector/v.extrude/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.extrude/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
@@ -172,7 +173,7 @@
G_get_window(&window);
/* open the elev raster, and check for error condition */
- if ((fdrast = G_open_cell_old(elevation->answer, "")) < 0)
+ if ((fdrast = Rast_open_cell_old(elevation->answer, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"),
elevation->answer);
}
@@ -389,10 +390,10 @@
/* do not trace -> calculate minumum dem offset */
if (fdrast && !trace) {
for (k = 0; k < Points->n_points; k++) {
- voffset_curr = G_get_raster_sample(fdrast, &window, NULL,
+ voffset_curr = Rast_get_raster_sample(fdrast, &window, NULL,
Points->y[k], Points->x[k], 0,
NEAREST);
- if (G_is_d_null_value(&voffset_curr))
+ if (Rast_is_d_null_value(&voffset_curr))
continue;
if (k == 0) {
@@ -412,20 +413,20 @@
/* trace */
if (fdrast && trace) {
- voffset_curr = G_get_raster_sample(fdrast, &window, NULL,
+ voffset_curr = Rast_get_raster_sample(fdrast, &window, NULL,
Points->y[k], Points->x[k], 0,
NEAREST);
if (type != GV_POINT) {
- voffset_next = G_get_raster_sample(fdrast, &window, NULL,
+ voffset_next = Rast_get_raster_sample(fdrast, &window, NULL,
Points->y[k + 1],
Points->x[k + 1], 0,
NEAREST);
}
}
- if (G_is_d_null_value(&voffset_curr) ||
- G_is_d_null_value(&voffset_next)) {
+ if (Rast_is_d_null_value(&voffset_curr) ||
+ Rast_is_d_null_value(&voffset_next)) {
if (type == GV_POINT)
break;
else if (type == GV_LINE) {
Modified: grass/trunk/vector/v.kernel/function.c
===================================================================
--- grass/trunk/vector/v.kernel/function.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.kernel/function.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include "global.h"
Modified: grass/trunk/vector/v.kernel/main.c
===================================================================
--- grass/trunk/vector/v.kernel/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.kernel/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <float.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/gmath.h>
#include <grass/Vect.h>
@@ -237,19 +238,19 @@
else {
/* check and open the name of output map */
if (!flag_q->answer) {
- G_set_fp_type(DCELL_TYPE);
- if ((fdout = G_open_raster_new(out_opt->answer, DCELL_TYPE)) < 0)
+ Rast_set_fp_type(DCELL_TYPE);
+ if ((fdout = Rast_open_raster_new(out_opt->answer, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
out_opt->answer);
/* open mask file */
- if ((maskfd = G_maskfd()) >= 0)
- mask = G_allocate_cell_buf();
+ if ((maskfd = Rast_maskfd()) >= 0)
+ mask = Rast_allocate_cell_buf();
else
mask = NULL;
/* allocate output raster */
- output_cell = G_allocate_raster_buf(DCELL_TYPE);
+ output_cell = Rast_allocate_raster_buf(DCELL_TYPE);
}
}
@@ -396,14 +397,14 @@
for (row = 0; row < window.rows; row++) {
G_percent(row, window.rows, 2);
if (mask) {
- if (G_get_map_row(maskfd, mask, row) < 0)
+ if (Rast_get_map_row(maskfd, mask, row) < 0)
G_fatal_error(_("Unable to read MASK"));
}
for (col = 0; col < window.cols; col++) {
/* don't interpolate outside of the mask */
if (mask && mask[col] == 0) {
- G_set_d_null_value(&output_cell[col], 1);
+ Rast_set_d_null_value(&output_cell[col], 1);
continue;
}
@@ -415,10 +416,10 @@
if (gaussian > gausmax)
gausmax = gaussian;
}
- G_put_raster_row(fdout, output_cell, DCELL_TYPE);
+ Rast_put_raster_row(fdout, output_cell, DCELL_TYPE);
}
- G_close_cell(fdout);
+ Rast_close_cell(fdout);
}
G_message(_("Maximum value in output: %e."), gausmax);
Modified: grass/trunk/vector/v.neighbors/main.c
===================================================================
--- grass/trunk/vector/v.neighbors/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.neighbors/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -79,13 +80,13 @@
nrows = G_window_rows();
ncols = G_window_cols();
- result = G_allocate_raster_buf(CELL_TYPE);
+ result = Rast_allocate_raster_buf(CELL_TYPE);
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
List = Vect_new_list();
/*open the new cellfile */
- out_fd = G_open_raster_new(out_opt->answer, CELL_TYPE);
+ out_fd = Rast_open_raster_new(out_opt->answer, CELL_TYPE);
if (out_fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"), out_opt->answer);
@@ -101,7 +102,7 @@
box.N = y + radius;
box.S = y - radius;
- G_set_null_value(result, ncols, CELL_TYPE);
+ Rast_set_null_value(result, ncols, CELL_TYPE);
rp = result;
for (col = 0; col < ncols; col++) {
@@ -133,17 +134,17 @@
if (count > 0) {
value = count;
- G_set_raster_value_d(rp, value, CELL_TYPE);
+ Rast_set_raster_value_d(rp, value, CELL_TYPE);
}
- rp = G_incr_void_ptr(rp, G_raster_size(CELL_TYPE));
+ rp = Rast_incr_void_ptr(rp, Rast_raster_size(CELL_TYPE));
}
- G_put_raster_row(out_fd, result, CELL_TYPE);
+ Rast_put_raster_row(out_fd, result, CELL_TYPE);
}
G_percent(row, nrows, 1);
Vect_close(&In);
- G_close_cell(out_fd);
+ Rast_close_cell(out_fd);
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/vector/v.sample/main.c
===================================================================
--- grass/trunk/vector/v.sample/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.sample/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -43,6 +43,7 @@
#include <string.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
@@ -145,7 +146,7 @@
Vect_set_open_level(2);
Vect_open_old(&In, parm.input->answer, "");
- if ((fdrast = G_open_cell_old(parm.rast->answer, "")) < 0)
+ if ((fdrast = Rast_open_cell_old(parm.rast->answer, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), parm.rast->answer);
/* Read attributes */
@@ -255,9 +256,9 @@
G_debug(4, "actual = %e", actual);
/* find predicted value */
- predicted = G_get_raster_sample(fdrast, &window, NULL, Points->y[0],
+ predicted = Rast_get_raster_sample(fdrast, &window, NULL, Points->y[0],
Points->x[0], 0, method);
- if (G_is_d_null_value(&predicted))
+ if (Rast_is_d_null_value(&predicted))
continue;
predicted *= scale;
@@ -279,7 +280,7 @@
db_close_database_shutdown_driver(Driver);
- G_close_cell(fdrast);
+ Rast_close_cell(fdrast);
Vect_close(&In);
Modified: grass/trunk/vector/v.surf.idw/main.c
===================================================================
--- grass/trunk/vector/v.surf.idw/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.surf.idw/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
int search_points = 12;
@@ -238,15 +239,15 @@
/* allocate buffers, etc. */
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
- if ((maskfd = G_maskfd()) >= 0)
- mask = G_allocate_cell_buf();
+ if ((maskfd = Rast_maskfd()) >= 0)
+ mask = Rast_allocate_cell_buf();
else
mask = NULL;
- fd = G_open_raster_new(parm.output->answer, DCELL_TYPE);
+ fd = Rast_open_raster_new(parm.output->answer, DCELL_TYPE);
if (fd < 0)
G_fatal_error(_("Unable to create raster map <%s>"),
parm.output->answer);
@@ -259,7 +260,7 @@
G_percent(row, window.rows - 1, 1);
if (mask) {
- if (G_get_map_row(maskfd, mask, row) < 0)
+ if (Rast_get_map_row(maskfd, mask, row) < 0)
exit(1);
}
north -= window.ns_res;
@@ -268,7 +269,7 @@
east += window.ew_res;
/* don't interpolate outside of the mask */
if (mask && mask[col] == 0) {
- G_set_d_null_value(&dcell[col], 1);
+ Rast_set_d_null_value(&dcell[col], 1);
continue;
}
@@ -393,13 +394,13 @@
}
dcell[col] = (DCELL) interp_value;
}
- G_put_d_raster_row(fd, dcell);
+ Rast_put_d_raster_row(fd, dcell);
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
/* writing history file */
- G_short_history(parm.output->answer, "raster", &history);
- G_command_history(&history);
- G_write_history(parm.output->answer, &history);
+ Rast_short_history(parm.output->answer, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(parm.output->answer, &history);
G_done_msg(" ");
Modified: grass/trunk/vector/v.surf.idw/read_sites.c
===================================================================
--- grass/trunk/vector/v.surf.idw/read_sites.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.surf.idw/read_sites.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <grass/glocale.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include "proto.h"
Modified: grass/trunk/vector/v.to.rast/do_areas.c
===================================================================
--- grass/trunk/vector/v.to.rast/do_areas.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.to.rast/do_areas.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/v.to.rast/do_lines.c
===================================================================
--- grass/trunk/vector/v.to.rast/do_lines.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.to.rast/do_lines.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/v.to.rast/local.h
===================================================================
--- grass/trunk/vector/v.to.rast/local.h 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.to.rast/local.h 2009-06-20 22:03:23 UTC (rev 38003)
@@ -11,10 +11,10 @@
/* 2 * PI */
#define M_2PI 6.283185307179586232
-#define ISNULL(x) G_is_c_null_value (x)
-#define ISDNULL(x) G_is_d_null_value (x)
-#define SETNULL(x) G_set_c_null_value (x, 1)
-#define SETDNULL(x) G_set_d_null_value (x, 1)
+#define ISNULL(x) Rast_is_c_null_value (x)
+#define ISDNULL(x) Rast_is_d_null_value (x)
+#define SETNULL(x) Rast_set_c_null_value (x, 1)
+#define SETDNULL(x) Rast_set_d_null_value (x, 1)
/* cell type */
#define USE_CELL 1
Modified: grass/trunk/vector/v.to.rast/main.c
===================================================================
--- grass/trunk/vector/v.to.rast/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.to.rast/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Modified: grass/trunk/vector/v.to.rast/raster.c
===================================================================
--- grass/trunk/vector/v.to.rast/raster.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.to.rast/raster.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,4 +1,5 @@
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include "local.h"
@@ -143,16 +144,16 @@
cell = raster.cell[i];
/* insert the NULL values */
- G_insert_c_null_values(cell, null_flags[i], page.cols);
- if (G_put_c_raster_row(fd, cell) < 0)
+ Rast_insert_c_null_values(cell, null_flags[i], page.cols);
+ if (Rast_put_c_raster_row(fd, cell) < 0)
return -1;
break;
case USE_DCELL:
dcell = raster.dcell[i];
/* insert the NULL values */
- G_insert_d_null_values(dcell, null_flags[i], page.cols);
- if (G_put_d_raster_row(fd, dcell) < 0)
+ Rast_insert_d_null_values(dcell, null_flags[i], page.cols);
+ if (Rast_put_d_raster_row(fd, dcell) < 0)
return -1;
break;
}
Modified: grass/trunk/vector/v.to.rast/support.c
===================================================================
--- grass/trunk/vector/v.to.rast/support.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.to.rast/support.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -8,6 +8,7 @@
#include <string.h>
#include <stdio.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -21,7 +22,7 @@
if (raster_name == NULL)
return (-1);
- if (G_read_history(raster_name, G_mapset(), &hist) < 0)
+ if (Rast_read_history(raster_name, G_mapset(), &hist) < 0)
return -1;
strcpy(hist.title, raster_name);
@@ -31,9 +32,9 @@
sprintf(hist.datsrc_2, "Original scale from vector map: 1:%ld", scale); /* 4.0 */
/* store command line options */
- G_command_history(&hist);
+ Rast_command_history(&hist);
- return (G_write_history(raster_name, &hist));
+ return (Rast_write_history(raster_name, &hist));
}
@@ -43,10 +44,10 @@
struct Colors colors;
CELL min, max;
- G_read_range(raster_name, G_mapset(), &range);
- G_get_range_min_max(&range, &min, &max);
- G_make_rainbow_colors(&colors, min, max);
- G_write_colors(raster_name, G_mapset(), &colors);
+ Rast_read_range(raster_name, G_mapset(), &range);
+ Rast_get_range_min_max(&range, &min, &max);
+ Rast_make_rainbow_colors(&colors, min, max);
+ Rast_write_colors(raster_name, G_mapset(), &colors);
return 0;
}
@@ -58,10 +59,10 @@
struct Colors colors;
DCELL min, max;
- G_read_fp_range(raster_name, G_mapset(), &range);
- G_get_fp_range_min_max(&range, &min, &max);
- G_make_rainbow_colors(&colors, (CELL) min, (CELL) max);
- G_write_colors(raster_name, G_mapset(), &colors);
+ Rast_read_fp_range(raster_name, G_mapset(), &range);
+ Rast_get_fp_range_min_max(&range, &min, &max);
+ Rast_make_rainbow_colors(&colors, (CELL) min, (CELL) max);
+ Rast_write_colors(raster_name, G_mapset(), &colors);
return 0;
}
@@ -70,12 +71,12 @@
int update_cats(const char *raster_name)
{
/* TODO: maybe attribute transfer from vector map?
- Use G_set_raster_cat() somewhere */
+ Use Rast_set_raster_cat() somewhere */
struct Categories cats;
- G_init_cats((CELL) 0, raster_name, &cats);
- G_write_cats(raster_name, &cats);
+ Rast_init_cats((CELL) 0, raster_name, &cats);
+ Rast_write_cats(raster_name, &cats);
return 0;
}
@@ -113,7 +114,7 @@
int blu;
/* init colors structure */
- G_init_colors(&colors);
+ Rast_init_colors(&colors);
/* open vector map and database driver */
Vect_open_old(&Map, vector_map, "");
@@ -162,7 +163,7 @@
if (*colorstring != '\0') {
G_debug(3, "element colorstring: %s", colorstring);
- if (G_str_to_color(colorstring, &red, &grn, &blu) == 1) {
+ if (Rast_str_to_color(colorstring, &red, &grn, &blu) == 1) {
G_debug(3, "cat %d r:%d g:%d b:%d", cat, red, grn, blu);
}
else {
@@ -200,7 +201,7 @@
/* set the color rules: for each rule */
for (i = 0; i < colors_n_values - 1; i++) {
if (is_fp) { /* add floating point color rule */
- G_add_d_raster_color_rule(&my_color_rules[i].d,
+ Rast_add_d_raster_color_rule(&my_color_rules[i].d,
my_color_rules[i].red,
my_color_rules[i].green,
my_color_rules[i].blue,
@@ -210,7 +211,7 @@
my_color_rules[i + 1].blue, &colors);
}
else { /* add CELL color rule */
- G_add_color_rule((CELL) my_color_rules[i].i,
+ Rast_add_color_rule((CELL) my_color_rules[i].i,
my_color_rules[i].red, my_color_rules[i].green,
my_color_rules[i].blue,
(CELL) my_color_rules[i + 1].i,
@@ -221,7 +222,7 @@
}
/* write the rules */
- G_write_colors(rast_name, G_mapset(), &colors);
+ Rast_write_colors(rast_name, G_mapset(), &colors);
return 1;
}
@@ -256,16 +257,16 @@
} *my_labels_rules;
/* init raster categories */
- G_init_cats((CELL) 0, "Categories", &rast_cats);
+ Rast_init_cats((CELL) 0, "Categories", &rast_cats);
- if (!(fd = G_open_cell_old(rast_name, G_mapset())))
+ if (!(fd = Rast_open_cell_old(rast_name, G_mapset())))
G_fatal_error(_("Unable to open raster map <%s>"), rast_name);
switch (use) {
case USE_ATTR:
{
- G_set_raster_cats_title("Labels", &rast_cats);
- int is_fp = G_raster_map_is_fp(rast_name, G_mapset());
+ Rast_set_raster_cats_title("Labels", &rast_cats);
+ int is_fp = Rast_raster_map_is_fp(rast_name, G_mapset());
/* open vector map and database driver */
Vect_open_old(&Map, vector_map, G_find_vector2(vector_map, ""));
@@ -361,14 +362,14 @@
if (is_fp) {
/* add label */
for (i = 0; i < labels_n_values - 1; i++)
- G_set_raster_cat(&my_labels_rules[i].d,
+ Rast_set_raster_cat(&my_labels_rules[i].d,
&my_labels_rules[i + 1].d,
db_get_string(&my_labels_rules[i].label),
&rast_cats, DCELL_TYPE);
}
else {
for (i = 0; i < labels_n_values; i++)
- G_set_cat(my_labels_rules[i].i,
+ Rast_set_cat(my_labels_rules[i].i,
db_get_string(&my_labels_rules[i].label),
&rast_cats);
}
@@ -381,26 +382,26 @@
struct FPRange fprange;
struct Range range;
- map_type = G_raster_map_type(rast_name, G_mapset());
- G_set_raster_cats_title("Values", &rast_cats);
+ map_type = Rast_raster_map_type(rast_name, G_mapset());
+ Rast_set_raster_cats_title("Values", &rast_cats);
if (map_type == CELL_TYPE) {
CELL min, max;
- G_read_range(rast_name, G_mapset(), &range);
- G_get_range_min_max(&range, &min, &max);
+ Rast_read_range(rast_name, G_mapset(), &range);
+ Rast_get_range_min_max(&range, &min, &max);
sprintf(msg, "Value %d", val);
- G_set_raster_cat(&min, &max, msg, &rast_cats, map_type);
+ Rast_set_raster_cat(&min, &max, msg, &rast_cats, map_type);
}
else {
DCELL fmin, fmax;
- G_read_fp_range(rast_name, G_mapset(), &fprange);
- G_get_fp_range_min_max(&fprange, &fmin, &fmax);
+ Rast_read_fp_range(rast_name, G_mapset(), &fprange);
+ Rast_get_fp_range_min_max(&fprange, &fmin, &fmax);
sprintf(msg, "Value %.4f", (double)val);
- G_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
+ Rast_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
}
}
@@ -414,34 +415,34 @@
RASTER_MAP_TYPE map_type;
long count;
- if (!(fd = G_open_cell_old(rast_name, G_mapset())))
+ if (!(fd = Rast_open_cell_old(rast_name, G_mapset())))
G_fatal_error(_("Unable to open raster map <%s>"), rast_name);
- map_type = G_raster_map_type(rast_name, G_mapset());
+ map_type = Rast_raster_map_type(rast_name, G_mapset());
- if (!(rowbuf = G_allocate_raster_buf(map_type)))
+ if (!(rowbuf = Rast_allocate_raster_buf(map_type)))
G_fatal_error(_("Cannot allocate memory for row buffer"));
- G_init_cell_stats(&stats);
- G_set_raster_cats_title("Categories", &rast_cats);
+ Rast_init_cell_stats(&stats);
+ Rast_set_raster_cats_title("Categories", &rast_cats);
rows = G_window_rows();
for (row = 0; row < rows; row++) {
- if (G_get_raster_row(fd, rowbuf, row, map_type) < 0)
+ if (Rast_get_raster_row(fd, rowbuf, row, map_type) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
rast_name, row);
- G_update_cell_stats(rowbuf, G_window_cols(), &stats);
+ Rast_update_cell_stats(rowbuf, G_window_cols(), &stats);
}
- G_rewind_cell_stats(&stats);
+ Rast_rewind_cell_stats(&stats);
- while (G_next_cell_stat(&n, &count, &stats)) {
+ while (Rast_next_cell_stat(&n, &count, &stats)) {
char msg[80];
sprintf(msg, "Category %d", n);
- G_set_raster_cat(&n, &n, msg, &rast_cats, map_type);
+ Rast_set_raster_cat(&n, &n, msg, &rast_cats, map_type);
}
G_free(rowbuf);
@@ -454,8 +455,8 @@
int i;
char msg[64];
- map_type = G_raster_map_type(rast_name, G_mapset());
- G_set_raster_cats_title("Degrees", &rast_cats);
+ map_type = Rast_raster_map_type(rast_name, G_mapset());
+ Rast_set_raster_cats_title("Degrees", &rast_cats);
for (i = 1; i <= 360; i++) {
sprintf(msg, "%d degrees", i);
@@ -463,7 +464,7 @@
if (i == 360) {
fmin = 359.5;
fmax = 360.0;
- G_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
+ Rast_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
fmin = 0.0;
fmax = 0.5;
}
@@ -472,7 +473,7 @@
fmax = i + 0.5;
}
- G_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
+ Rast_set_raster_cat(&fmin, &fmax, msg, &rast_cats, map_type);
}
}
break;
@@ -484,11 +485,11 @@
break;
}
- G_close_cell(fd);
- if (G_write_cats(rast_name, &rast_cats) <= 0)
+ Rast_close_cell(fd);
+ if (Rast_write_cats(rast_name, &rast_cats) <= 0)
G_warning(_("Unable to write categories for raster map <%s>"),
rast_name);
- G_free_cats(&rast_cats);
+ Rast_free_cats(&rast_cats);
return 1;
}
Modified: grass/trunk/vector/v.to.rast/vect2rast.c
===================================================================
--- grass/trunk/vector/v.to.rast/vect2rast.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.to.rast/vect2rast.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -1,5 +1,6 @@
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -118,11 +119,11 @@
switch (format) {
case USE_CELL:
- if ((fd = G_open_cell_new(raster_map)) < 0)
+ if ((fd = Rast_open_cell_new(raster_map)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), raster_map);
break;
case USE_DCELL:
- if ((fd = G_open_raster_new(raster_map, DCELL_TYPE)) < 0)
+ if ((fd = Rast_open_raster_new(raster_map, DCELL_TYPE)) < 0)
G_fatal_error(_("Unable to create raster map <%s>"), raster_map);
break;
default:
@@ -186,7 +187,7 @@
Vect_destroy_line_struct(Points);
if (stat < 0) {
- G_unopen_cell(fd);
+ Rast_unopen_cell(fd);
return 1;
}
@@ -194,7 +195,7 @@
Vect_close(&Map);
G_verbose_message(_("Creating support files for raster map..."));
- G_close_cell(fd);
+ Rast_close_cell(fd);
update_hist(raster_map, vector_map, Map.head.orig_scale);
/* colors */
Modified: grass/trunk/vector/v.vol.rst/dataoct.c
===================================================================
--- grass/trunk/vector/v.vol.rst/dataoct.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/dataoct.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "dataoct.h"
#include "externs.h"
#include "user.h"
Modified: grass/trunk/vector/v.vol.rst/main.c
===================================================================
--- grass/trunk/vector/v.vol.rst/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/site.h>
#include <grass/Vect.h>
#include "userglobs.h"
@@ -642,10 +643,10 @@
mapset = G_find_cell2(cellinp, "");
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), cellinp);
- fdcell = G_open_cell_old(cellinp, mapset);
+ fdcell = Rast_open_cell_old(cellinp, mapset);
if (fdcell < 0)
G_fatal_error(_("Unable to open raster map <%s>"), cellinp);
- fdcout = G_open_fp_cell_new(cellout);
+ fdcout = Rast_open_fp_cell_new(cellout);
if (fdcout < 0)
G_fatal_error(_("Cannot open %s"), cellout);
zero_array_cell = (FCELL *) G_malloc(sizeof(FCELL) * n_cols);
@@ -842,9 +843,9 @@
OUTGR();
if ((cellinp != NULL)) {
- G_close_cell(fdcout);
+ Rast_close_cell(fdcout);
if ((cellout != NULL)) {
- G_short_history(cellout, "raster", &hist);
+ Rast_short_history(cellout, "raster", &hist);
/* TODO: next lines need to be verified! */
sprintf(hist.edhist[0], "tension=%f, smoothing=%f", fi,
rsm);
@@ -858,12 +859,12 @@
/* ? sprintf (hist.edhist[4], "wmin_int=%f, wmax_int=%f", wminac, wmaxac); */
hist.edlinecnt = 5;
- G_command_history(&hist);
- G_write_history(cellout, &hist);
+ Rast_command_history(&hist);
+ Rast_write_history(cellout, &hist);
fclose(Tmp_fd_cell);
unlink(Tmp_file_cell);
}
- G_close_cell(fdcell);
+ Rast_close_cell(fdcell);
}
if (outz != NULL) {
fclose(Tmp_fd_z);
Modified: grass/trunk/vector/v.vol.rst/oct.c
===================================================================
--- grass/trunk/vector/v.vol.rst/oct.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/oct.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "oct.h"
#include "externs.h"
Modified: grass/trunk/vector/v.vol.rst/user1.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user1.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/user1.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/G3d.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
@@ -363,13 +364,13 @@
clean_fatal_error(buf);
}
bitmask = BM_create(nsizc, nsizr);
- cellmask = G_allocate_cell_buf();
- cfmask = G_open_cell_old(maskmap, mapsetm);
+ cellmask = Rast_allocate_cell_buf();
+ cfmask = Rast_open_cell_old(maskmap, mapsetm);
for (i = 0; i < nsizr; i++) {
irev = nsizr - i - 1;
- G_get_map_row(cfmask, cellmask, i);
+ Rast_get_map_row(cfmask, cellmask, i);
for (j = 0; j < nsizc; j++) {
- if ((cellmask[j] == 0) || G_is_c_null_value(&cellmask[j]))
+ if ((cellmask[j] == 0) || Rast_is_c_null_value(&cellmask[j]))
BM_set(bitmask, j, irev, 0);
else
BM_set(bitmask, j, irev, 1);
@@ -398,7 +399,7 @@
float value;
if ((cellinp != NULL) && (cellout != NULL)) {
- cell = G_allocate_f_raster_buf();
+ cell = Rast_allocate_f_raster_buf();
for (i = 0; i < nsizr; i++) {
/* seek to the right row */
@@ -407,7 +408,7 @@
0) == -1)
G_fatal_error("cannot fseek to the right spot");
fread(cell, sizeof(FCELL), nsizc, Tmp_fd_cell);
- G_put_f_raster_row(fdcout, cell);
+ Rast_put_f_raster_row(fdcout, cell);
}
}
Modified: grass/trunk/vector/v.vol.rst/user2.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user2.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/user2.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -30,6 +30,7 @@
#include <math.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "oct.h"
#include "surf.h"
Modified: grass/trunk/vector/v.vol.rst/user3.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user3.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/user3.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
@@ -275,7 +276,7 @@
}
if (cell == NULL)
- cell = G_allocate_f_raster_buf();
+ cell = Rast_allocate_f_raster_buf();
for (i = 1; i <= n_points; i++) {
points[i - 1].x = (points[i - 1].x - x_or) / dnorm;
@@ -413,7 +414,7 @@
w2[m] = wm * wm;
}
if ((cellinp != NULL) && (cellout != NULL) && (i == ngstl)) {
- if (G_get_f_raster_row(fdcell, cell, n_rows_in - k) < 0) /* fix by JH 04/24/02 */
+ if (Rast_get_f_raster_row(fdcell, cell, n_rows_in - k) < 0) /* fix by JH 04/24/02 */
G_fatal_error
("Could not get row (eventually WIND3 does not match WIND)");
}
Modified: grass/trunk/vector/v.vol.rst/user4.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user4.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/user4.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -31,6 +31,7 @@
#include <math.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include "oct.h"
#include "surf.h"
Modified: grass/trunk/vector/v.vol.rst/vector.c
===================================================================
--- grass/trunk/vector/v.vol.rst/vector.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.vol.rst/vector.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/Vect.h>
#include <grass/dbmi.h>
Modified: grass/trunk/vector/v.what.rast/main.c
===================================================================
--- grass/trunk/vector/v.what.rast/main.c 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/vector/v.what.rast/main.c 2009-06-20 22:03:23 UTC (rev 38003)
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
@@ -130,14 +131,14 @@
}
/* Open raster */
- if ((fd = G_open_cell_old(rast_opt->answer, "")) < 0)
+ if ((fd = Rast_open_cell_old(rast_opt->answer, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), rast_opt->answer);
- out_type = G_get_raster_map_type(fd);
+ out_type = Rast_get_raster_map_type(fd);
/* TODO: Later possibly category labels */
/*
- if ( G_read_cats (name, "", &RCats) < 0 )
+ if ( Rast_read_cats (name, "", &RCats) < 0 )
G_fatal_error ( "Cannot read category file");
*/
@@ -245,9 +246,9 @@
/* Allocate space for raster row */
if (out_type == CELL_TYPE)
- cell = G_allocate_c_raster_buf();
+ cell = Rast_allocate_c_raster_buf();
else
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
/* Extract raster values from file and store in cache */
G_debug(1, "Extracting raster values");
@@ -260,12 +261,12 @@
if (cur_row != cache[point].row) {
if (out_type == CELL_TYPE) {
- if (G_get_c_raster_row(fd, cell, cache[point].row) < 0)
+ if (Rast_get_c_raster_row(fd, cell, cache[point].row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
cell, cache[point].row);
}
else {
- if (G_get_d_raster_row(fd, dcell, cache[point].row) < 0)
+ if (Rast_get_d_raster_row(fd, dcell, cache[point].row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
dcell, cache[point].row);
}
@@ -314,7 +315,7 @@
if (out_type == CELL_TYPE) {
if (cache[point].count > 1 ||
- G_is_c_null_value(&cache[point].value)) {
+ Rast_is_c_null_value(&cache[point].value)) {
sprintf(buf, "NULL");
}
else {
@@ -323,7 +324,7 @@
}
else { /* FCELL or DCELL */
if (cache[point].count > 1 ||
- G_is_d_null_value(&cache[point].dvalue)) {
+ Rast_is_d_null_value(&cache[point].dvalue)) {
sprintf(buf, "NULL");
}
else {
Modified: grass/trunk/visualization/xganim/main.cc
===================================================================
--- grass/trunk/visualization/xganim/main.cc 2009-06-20 21:39:23 UTC (rev 38002)
+++ grass/trunk/visualization/xganim/main.cc 2009-06-20 22:03:23 UTC (rev 38003)
@@ -30,6 +30,7 @@
extern "C" {
#include <grass/gis.h>
+#include <grass/Rast.h>
#include <grass/glocale.h>
}
@@ -185,7 +186,7 @@
const char *name;
struct Colors colors;
- dcell = G_allocate_d_raster_buf();
+ dcell = Rast_allocate_d_raster_buf();
tsiz = G_window_cols();
@@ -231,23 +232,23 @@
name = vfiles[vnum][cnt];
G_message(_("Reading file [%s]..."), name);
- fd = G_open_cell_old(name, "");
+ fd = Rast_open_cell_old(name, "");
if (fd < 0)
G_fatal_error(_("Unable to open raster map <%s>"), name);
/*
strcpy(title[cnt],G_get_cell_title(name, mapset));
*/
- ret = G_read_colors(name, "", &colors);
+ ret = Rast_read_colors(name, "", &colors);
if (ret < 0)
G_fatal_error(_("Unable to read color file"));
for (row = 0; row < vrows; row++) {
- if (G_get_d_raster_row(fd, dcell, (int)(row / vscale)) < 0)
+ if (Rast_get_d_raster_row(fd, dcell, (int)(row / vscale)) < 0)
G_fatal_error(_("Unable to read raster row"));
rowoff = (vyoff + row) * ncols;
- G_lookup_d_raster_colors(dcell, tr, tg, tb, tset, tsiz, &colors);
+ Rast_lookup_d_raster_colors(dcell, tr, tg, tb, tset, tsiz, &colors);
for (col = 0; col < vcols; col++) {
coff = (int)(col / vscale);
@@ -259,7 +260,7 @@
}
}
- G_close_cell(fd);
+ Rast_close_cell(fd);
}
wxBitmap *bmp = new wxBitmap(img);
More information about the grass-commit
mailing list