~ubuntu-branches/ubuntu/trusty/mapnik/trusty-proposed

« back to all changes in this revision

Viewing changes to plugins/input/occi/occi_datasource.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2009-08-27 00:28:37 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090827002837-ztqzfg2rmclfh4i9
Tags: 0.6.1-0ubuntu1
* New upstream release.
* Change usr/lib to usr/lib* to enable build on 64 bits systems due to new
  configuration in SConstruct in :
  - debian/libmapnik-dev.install
  - debian/libmapnik0.6.install
  - debian/mapnik-plugin-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
     geometry_field_(*params.get<std::string>("geometry_field","GEOLOC")),
98
98
     type_(datasource::Vector),
99
99
     extent_initialized_(false),
 
100
     row_limit_(*params_.get<int>("row_limit",0)),
 
101
     row_prefetch_(*params_.get<int>("row_prefetch",100)),
100
102
     desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")),
101
103
     pool_(0)
102
104
{
421
423
        s << " from ";
422
424
 
423
425
        std::string query (table_); 
424
 
        
 
426
        std::string table_name = table_from_sql(query);
 
427
 
425
428
        if (use_spatial_index_)
426
429
        {
427
 
           std::string table_name = table_from_sql(query);
428
430
           std::ostringstream spatial_sql;
429
431
           spatial_sql << std::setprecision(16);
430
432
           spatial_sql << " where sdo_filter(" << geometry_field_ << ",";
444
446
           }
445
447
        }
446
448
        
 
449
        if (row_limit_ > 0)
 
450
        {
 
451
           std::string row_limit_string = "rownum < " + row_limit_;
 
452
 
 
453
           if (boost::algorithm::ifind_first(query,"where"))
 
454
           {
 
455
              boost::algorithm::ireplace_first(query, "where", row_limit_string + " and");
 
456
           }
 
457
           else if (boost::algorithm::find_first(query,table_name))  
 
458
           {
 
459
              boost::algorithm::ireplace_first(query, table_name , table_name + " " + row_limit_string);
 
460
           }
 
461
        }
 
462
        
447
463
        s << query;
448
464
 
449
465
#ifdef MAPNIK_DEBUG
450
466
        clog << s.str() << endl;
451
467
#endif
452
468
        
453
 
        return featureset_ptr(new occi_featureset(pool_,s.str(),desc_.get_encoding(),multiple_geometries_,props.size()));
 
469
        return featureset_ptr (new occi_featureset (pool_,
 
470
                                                    s.str(),
 
471
                                                    desc_.get_encoding(),
 
472
                                                    multiple_geometries_,
 
473
                                                    row_prefetch_,
 
474
                                                    props.size()));
454
475
    }
455
476
    
456
477
    return featureset_ptr();
493
514
        {
494
515
           boost::algorithm::ireplace_first(query, table_name , table_name + " " + spatial_sql.str());
495
516
        }
 
517
 
 
518
        if (row_limit_ > 0)
 
519
        {
 
520
           std::string row_limit_string = "rownum < " + row_limit_;
 
521
 
 
522
           if (boost::algorithm::ifind_first(query,"where"))
 
523
           {
 
524
              boost::algorithm::ireplace_first(query, "where", row_limit_string + " and");
 
525
           }
 
526
           else if (boost::algorithm::find_first(query,table_name))  
 
527
           {
 
528
              boost::algorithm::ireplace_first(query, table_name , table_name + " " + row_limit_string);
 
529
           }
 
530
        }
496
531
        
497
532
        s << query;
498
533
 
500
535
        clog << s.str() << endl;
501
536
#endif
502
537
        
503
 
        return featureset_ptr(new occi_featureset(pool_,s.str(),desc_.get_encoding(),multiple_geometries_,size));
 
538
        return featureset_ptr (new occi_featureset (pool_,
 
539
                                                    s.str(),
 
540
                                                    desc_.get_encoding(),
 
541
                                                    multiple_geometries_,
 
542
                                                    row_prefetch_,
 
543
                                                    size));
504
544
    }
505
545
 
506
546
    return featureset_ptr();