Beispiel #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();
    }
    geometry_type* poly = new geometry_type(mapnik::Polygon);
    poly->move_to(exterior->getX(0), exterior->getY(0));
    for (int i = 1; i < num_points; ++i)
    {
        poly->line_to(exterior->getX(i), exterior->getY(i));
    }
    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; ++i)
        {
            poly->line_to(interior->getX(i), interior->getY(i));
        }
    }
    feature->add_geometry(poly);
}
Beispiel #2
0
void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature)
{
    int num_points = geom->getNumPoints();
    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->add_geometry(line);
}
Beispiel #3
0
void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature)
{
    int gtype = (int)geom->getSdo_gtype();
    int dimensions = gtype / 1000;
    int lrsvalue = (gtype - dimensions * 1000) / 100;
    int geomtype = (gtype - dimensions * 1000 - lrsvalue * 100);

    const std::vector<Number>& elem_info = geom->getSdo_elem_info();
    const std::vector<Number>& ordinates = geom->getSdo_ordinates();
    const int ordinates_size = (int)ordinates.size();

    switch (geomtype)
    {
    case SDO_GTYPE_POINT:
    {
        SDOPointType* sdopoint = geom->getSdo_point();
        if (sdopoint && ! sdopoint->isNull())
        {
            std::unique_ptr<geometry_type> point = std::make_unique<geometry_type>(mapnik::geometry_type::types::Point);
            point->move_to(sdopoint->getX(), sdopoint->getY());
            feature->add_geometry(point.release());
        }
    }
    break;
    case SDO_GTYPE_LINE:
    {
        if (ordinates_size >= dimensions)
        {
            const bool is_single_geom = true;
            const bool is_point_type = false;
            convert_ordinates(feature,
                              mapnik::geometry_type::types::LineString,
                              elem_info,
                              ordinates,
                              dimensions,
                              is_single_geom,
                              is_point_type);
        }
    }
    break;
    case SDO_GTYPE_POLYGON:
    {
        if (ordinates_size >= dimensions)
        {
            const bool is_single_geom = true;
            const bool is_point_type = false;
            convert_ordinates(feature,
                              mapnik::geometry_type::types::Polygon,
                              elem_info,
                              ordinates,
                              dimensions,
                              is_single_geom,
                              is_point_type);
        }
    }
    break;
    case SDO_GTYPE_MULTIPOINT:
    {
        if (ordinates_size >= dimensions)
        {
            const bool is_single_geom = false;
            const bool is_point_type = true;
            convert_ordinates(feature,
                              mapnik::geometry_type::types::Point,
                              elem_info,
                              ordinates,
                              dimensions,
                              is_single_geom,
                              is_point_type);
        }
    }
    break;
    case SDO_GTYPE_MULTILINE:
    {
        if (ordinates_size >= dimensions)
        {
            const bool is_single_geom = false;
            const bool is_point_type = false;

            convert_ordinates(feature,
                              mapnik::geometry_type::types::LineString,
                              elem_info,
                              ordinates,
                              dimensions,
                              is_single_geom,
                              is_point_type);
        }
    }
    break;
    case SDO_GTYPE_MULTIPOLYGON:
    {
        if (ordinates_size >= dimensions)
        {
            const bool is_single_geom = false;
            const bool is_point_type = false;

            convert_ordinates(feature,
                              mapnik::geometry_type::types::Polygon,
                              elem_info,
                              ordinates,
                              dimensions,
                              is_single_geom,
                              is_point_type);
        }

    }
    break;
    case SDO_GTYPE_COLLECTION:
    {
        if (ordinates_size >= dimensions)
        {
            const bool is_single_geom = false;
            const bool is_point_type = false;

            convert_ordinates(feature,
                              mapnik::geometry_type::types::Polygon,
                              elem_info,
                              ordinates,
                              dimensions,
                              is_single_geom,
                              is_point_type);
        }
    }
    break;
    case SDO_GTYPE_UNKNOWN:
    default:
    {
        MAPNIK_LOG_WARN(occi) << "occi_featureset: Unknown oracle enum "
                              << occi_enums::resolve_gtype(geomtype)
                              << "(gtype=" << gtype << ")";
    }
    break;
    }
}
Beispiel #4
0
void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature)
{
    geometry_type * point = new geometry_type(mapnik::Point);
    point->move_to(geom->getX(), geom->getY());
    feature->add_geometry(point);
}