Giter Site home page Giter Site logo

Comments (5)

artemp avatar artemp commented on September 24, 2024

@Wingong - I'm assuming you're trying to access Feature attributes. If so, you can use feature_kv_iterator

#include <mapnik/feature_kv_iterator.hpp>
.....

while (auto feature = features->next())
{
   feature_kv_iterator itr(*feature, true);
   feature_kv_iterator end(*feature); 
   for (; itr != end; ++itr)
   {
      std::cerr << std::get<0>(*itr) << ":" << std::get<1>(*itr).to_string() << std::endl;
   }
}

or

auto itr = feature->begin();
auto end = feature->end();
for (; itr != end; ++itr) { ... }

or

for (auto const& kv : feature)
{
        std::cerr << std::get<0>(kv) << ":" << std::get<1>(kv).to_string();
}

HTH

from mapnik.

Wingong avatar Wingong commented on September 24, 2024

@artemp I tried feature_kv_iterator, but it seems not working. itr is equal to end, so nothing was iterate. Besides, I read the code of the input file shape.input, exactly dbf.hpp and dbf.cpp in it. When reading dBase file, it doesn't load records, but only the header (using read_header() function). I thought if it could cause the problem?

from mapnik.

artemp avatar artemp commented on September 24, 2024

@Wingong Could you share your shapefile if it's not too large?

from mapnik.

Wingong avatar Wingong commented on September 24, 2024

@artemp Of course, but i don't know how to upload file - however, it is just the demo shapefile in mapnik source code, like src/demo/data/boundaries and others. Thanks very much!

from mapnik.

Wingong avatar Wingong commented on September 24, 2024

@artemp update: using mapnik::rule and add rules to style can filter the write shape (like r.set_filter(parse_expression("[NAME_EN] = 'Ontario'"));). I tried using map.query_point(index, x, y), and features in it contain correct context.

from mapnik.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.