35 #include "graph/graphic.hh"
52 GColor
_bg( 0, 140, 150 );
75 main(
int argc,
char **argv )
89 int show_map = strcmp( argv[1],
"-r" );
90 char *request = (show_map ? argv[1] : argv[2]);
109 vector<string> mapfile = fp.
getAll(
"Map" );
111 for (
int i = 0; i <
_nmap; i++ ) {
124 string result = fp.
get(
"Output file" );
126 if ( result.empty() ) {
137 Coord xmin, ymin, xmax, ymax;
142 int dimy = int( dimx * (ymax - ymin) / (xmax - xmin) );
146 dimx = int( dimy * (xmax - xmin) / (ymax - ymin) );
152 string oc_cs = fp.
get(
"WKT Coord System" );
153 string oc_file = fp.
get(
"Occurrences source" );
155 if ( oc_file.empty() ) {
157 string oc_file = fp.
get(
"Species file" );
160 string oc_name = fp.
get(
"Occurrences group" );
162 if ( oc_name.empty() ) {
164 string oc_name = fp.
get(
"Species" );
167 if ( ! oc_cs.empty() && ! oc_file.empty() ) {
169 _occurs =
readOccurrences( oc_file.c_str(), oc_name.c_str(), oc_cs.c_str() );
173 if ( oc_file.empty() )
181 GFrame *frame = createFrame(
"openModeller Viewer", 1, dimx, dimy );
182 _cnv = frame->newCanvas( 0, 0, dimx, dimy );
183 _pm = frame->newPixmap(
_cnv, dimx, dimy );
187 _graph->scale(
float(xmin),
float(ymin),
float(xmax),
197 frame->funcShow(
draw );
206 catch ( std::exception& e ) {
223 for (
int i = 0; i <
_nmap; i++ )
242 Coord xmin = graph->minX();
243 Coord ymin = graph->minY();
244 Coord xmax = graph->maxX();
245 Coord ymax = graph->maxY();
246 Coord xstep = graph->stepX();
247 Coord ystep = graph->stepY();
253 for (
Coord y = ymin; y < ymax; y += ystep )
255 for (
Coord x = xmin; x < xmax; x += xstep )
256 if ( map->
get( x, y, val ) )
259 graph->pixel(
float(x),
float(y), color );
280 for( ; oc != occurs->end(); ++oc ) {
282 x = float( (*oc)->x() );
283 y = float( (*oc)->y() );
284 abundance = int( (*oc)->abundance() );
286 color = ( abundance == 1 ) ? GColor::Green : GColor::Red;
288 graph->markAxe( x, y, 1, color);
298 map[0]->
getExtent( xmin, ymin, xmax, ymax );
313 if ( absences->numOccurrences() ) {
315 occurrences->appendFrom( absences );
int count(const std::string &key) const
void draw_occur(GGraph *graph, Map *map, const OccurrencesPtr &)
void warn(const char *format,...)
'Warn' level.
void setPrefix(const char *pref)
int get(Coord x, Coord y, Scalar *val) const
double Scalar
Type of map values.
static Log * instance()
Returns the instance pointer, creating the object on the first call.
static OccurrencesFactory & instance()
virtual OccurrencesPtr getAbsences(const char *groupId)
void setLevel(Level level)
void draw_map(GGraph *graph, Map *map)
void error(const char *format,...)
'Error' level.
virtual OccurrencesPtr getPresences(const char *groupId)
OccurrencesPtr readOccurrences(char const *source, char const *name, char const *coord_system)
int getExtent(Coord *xmin, Coord *ymin, Coord *xmax, Coord *ymax) const
std::vector< std::string > getAll(const std::string &key) const
static RasterFactory & instance()
void findRegion(int nmap, Map **map, Coord *xmin, Coord *ymin, Coord *xmax, Coord *ymax)
void info(const char *format,...)
'Info' level.
double Coord
Type of map coordinates.
std::vector< OccurrencePtr >::const_iterator const_iterator
int main(int argc, char **argv)
std::string get(const std::string &key) const
OccurrencesReader * create(const char *source, const char *coordSystem)