예제 #1
0
void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
{
    OGRLinearRing* exterior = geom->getExteriorRing();
    int num_points = exterior->getNumPoints();
    int num_interior = geom->getNumInteriorRings();
    int capacity = 0;
    for (int r = 0; r < num_interior; ++r)
    {
        OGRLinearRing* interior = geom->getInteriorRing(r);
        capacity += interior->getNumPoints();
    }

    std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));

    poly->move_to(exterior->getX(0), exterior->getY(0));
    for (int i = 1; i < num_points - 1; ++i)
    {
        poly->line_to(exterior->getX(i), exterior->getY(i));
    }
    poly->close(exterior->getX(num_points-1), exterior->getY(num_points-1));
    for (int r = 0; r < num_interior; ++r)
    {
        OGRLinearRing* interior = geom->getInteriorRing(r);
        num_points = interior->getNumPoints();
        poly->move_to(interior->getX(0), interior->getY(0));
        for (int i = 1; i < num_points - 1; ++i)
        {
            poly->line_to(interior->getX(i), interior->getY(i));
        }
        poly->close(interior->getX(num_points-1), interior->getY(num_points-1));
    }
    feature->paths().push_back(poly);
}
예제 #2
0
void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature)
{
    int num_points = geom->getNumPoints();
    std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
    line->move_to(geom->getX(0), geom->getY(0));
    for (int i = 1; i < num_points; ++i)
    {
        line->line_to (geom->getX(i), geom->getY(i));
    }
    feature->paths().push_back(line);
}
예제 #3
0
void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature)
{
    std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
    point->move_to(geom->getX(), geom->getY());
    feature->paths().push_back(point);
}