Esempio n. 1
0
File: wkb.cpp Progetto: rjw57/mapnik
    void read(boost::ptr_vector<geometry_type> & paths)
    {
        int type = read_integer();

#ifdef MAPNIK_LOG
        MAPNIK_LOG_DEBUG(wkb_reader) << "wkb_reader: Read=" << wkb_geometry_type_string(type) << "," << type;
#endif
        switch (type)
        {
        case wkbPoint:
            read_point(paths);
            break;
        case wkbLineString:
            read_linestring(paths);
            break;
        case wkbPolygon:
            read_polygon(paths);
            break;
        case wkbMultiPoint:
            read_multipoint(paths);
            break;
        case wkbMultiLineString:
            read_multilinestring(paths);
            break;
        case wkbMultiPolygon:
            read_multipolygon(paths);
            break;
        case wkbGeometryCollection:
            read_collection(paths);
            break;
        case wkbPointZ:
            read_point_xyz(paths);
            break;
        case wkbLineStringZ:
            read_linestring_xyz(paths);
            break;
        case wkbPolygonZ:
            read_polygon_xyz(paths);
            break;
        case wkbMultiPointZ:
            read_multipoint_xyz(paths);
            break;
        case wkbMultiLineStringZ:
            read_multilinestring_xyz(paths);
            break;
        case wkbMultiPolygonZ:
            read_multipolygon_xyz(paths);
            break;
        case wkbGeometryCollectionZ:
            read_collection(paths);
            break;
        default:
            break;
        }
    }
Esempio n. 2
0
    void read(boost::ptr_vector<geometry_type> & paths)
    {
        int type = read_integer();

        switch (type)
        {
        case wkbPoint:
            read_point(paths);
            break;
        case wkbLineString:
            read_linestring(paths);
            break;
        case wkbPolygon:
            read_polygon(paths);
            break;
        case wkbMultiPoint:
            read_multipoint(paths);
            break;
        case wkbMultiLineString:
            read_multilinestring(paths);
            break;
        case wkbMultiPolygon:
            read_multipolygon(paths);
            break;
        case wkbGeometryCollection:
            read_collection(paths);
            break;
        case wkbPointZ:
            read_point_xyz(paths);
            break;
        case wkbLineStringZ:
            read_linestring_xyz(paths);
            break;
        case wkbPolygonZ:
            read_polygon_xyz(paths);
            break;
        case wkbMultiPointZ:
            read_multipoint_xyz(paths);
            break;
        case wkbMultiLineStringZ:
            read_multilinestring_xyz(paths);
            break;
        case wkbMultiPolygonZ:
            read_multipolygon_xyz(paths);
            break;
        case wkbGeometryCollectionZ:
            read_collection(paths);
            break;
        default:
            break;
        }
    }
Esempio n. 3
0
static bool
read_blank(SerdReader* reader, ReadContext ctx, bool subject, Ref* dest, bool* ate_dot)
{
	const SerdStatementFlags old_flags = *ctx.flags;
	bool empty;
	switch (peek_byte(reader)) {
	case '_':
		return (*dest = read_BLANK_NODE_LABEL(reader, ate_dot));
	case '[':
		eat_byte_safe(reader, '[');
		if ((empty = peek_delim(reader, ']'))) {
			*ctx.flags |= (subject) ? SERD_EMPTY_S : SERD_EMPTY_O;
		} else {
			*ctx.flags |= (subject) ? SERD_ANON_S_BEGIN : SERD_ANON_O_BEGIN;
			if (peek_delim(reader, '=')) {
				if (!(*dest = read_blankName(reader)) ||
				    !eat_delim(reader, ';')) {
					return false;
				}
			}
		}

		if (!*dest) {
			*dest = blank_id(reader);
		}
		if (ctx.subject) {
			TRY_RET(emit_statement(reader, ctx, *dest, 0, 0));
		}

		ctx.subject = *dest;
		if (!empty) {
			*ctx.flags &= ~(SERD_LIST_CONT);
			if (!subject) {
				*ctx.flags |= SERD_ANON_CONT;
			}
			bool ate_dot_in_list = false;
			read_predicateObjectList(reader, ctx, &ate_dot_in_list);
			if (ate_dot_in_list) {
				return r_err(reader, SERD_ERR_BAD_SYNTAX, "`.' inside blank\n");
			}
			read_ws_star(reader);
			if (reader->end_sink) {
				reader->end_sink(reader->handle, deref(reader, *dest));
			}
			*ctx.flags = old_flags;
		}
		return (eat_byte_check(reader, ']') == ']');
	case '(':
		return read_collection(reader, ctx, dest);
	default: return false;  // never reached
	}
}
Esempio n. 4
0
ReaderCollection
ReaderMapping::read_collection(const char* key) const
{
  if (!m_impl)
  {
    return {};
  }
  {
    ReaderCollection result;
    read_collection(key, result);
    return result;
  }
}
Esempio n. 5
0
static Ref
read_subject(SerdReader* reader, ReadContext ctx, bool* nested)
{
	Ref  subject = 0;
	bool ate_dot = false;
	switch (peek_byte(reader)) {
	case '[':
		*nested = true;
		read_anon(reader, ctx, true, &subject);
		break;
	case '(':
		*nested = true;
		read_collection(reader, ctx, &subject);
		break;
	case '_':
		*nested = false;
		subject = read_BLANK_NODE_LABEL(reader, &ate_dot);
		break;
	default:
		read_iri(reader, &subject, &ate_dot);
	}
	return ate_dot ? pop_node(reader, subject) : subject;
}
Esempio n. 6
0
File: wkb.cpp Progetto: bblu/mapnik
 mapnik::geometry::geometry<double> read()
 {
     mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty();
     int type = read_integer();
     switch (type)
     {
     case wkbPoint:
         geom = std::move(read_point());
         break;
     case wkbLineString:
         geom = std::move(read_linestring());
         break;
     case wkbPolygon:
         geom = std::move(read_polygon());
         break;
     case wkbMultiPoint:
         geom = std::move(read_multipoint());
         break;
     case wkbMultiLineString:
         geom = std::move(read_multilinestring());
         break;
     case wkbMultiPolygon:
         geom = std::move(read_multipolygon());
         break;
     case wkbGeometryCollection:
         geom = std::move(read_collection());
         break;
     case wkbPointZ:
     case wkbPointM:
         geom = std::move(read_point<true>());
         break;
     case wkbPointZM:
         geom = std::move(read_point<true,true>());
         break;
     case wkbLineStringZ:
     case wkbLineStringM:
         geom = std::move(read_linestring<true>());
         break;
     case wkbLineStringZM:
         geom = std::move(read_linestring<true,true>());
         break;
     case wkbPolygonZ:
     case wkbPolygonM:
         geom = std::move(read_polygon<true>());
         break;
     case wkbPolygonZM:
         geom = std::move(read_polygon<true,true>());
         break;
     case wkbMultiPointZ:
     case wkbMultiPointM:
         geom = std::move(read_multipoint<true>());
         break;
     case wkbMultiPointZM:
         geom = std::move(read_multipoint<true,true>());
         break;
     case wkbMultiLineStringZ:
     case wkbMultiLineStringM:
         geom = std::move(read_multilinestring<true>());
         break;
     case wkbMultiLineStringZM:
         geom = std::move(read_multilinestring<true,true>());
         break;
     case wkbMultiPolygonZ:
     case wkbMultiPolygonM:
         geom = std::move(read_multipolygon<true>());
         break;
     case wkbMultiPolygonZM:
         geom = std::move(read_multipolygon<true,true>());
         break;
     case wkbGeometryCollectionZ:
     case wkbGeometryCollectionM:
     case wkbGeometryCollectionZM:
         geom = std::move(read_collection());
         break;
     default:
         break;
     }
     return geom;
 }
Esempio n. 7
0
// Recurses, calling statement_sink for every statement encountered.
// Leaves stack in original calling state (i.e. pops everything it pushes).
static bool
read_object(SerdReader* reader, ReadContext ctx, bool* ate_dot)
{
	static const char* const XSD_BOOLEAN     = NS_XSD "boolean";
	static const size_t      XSD_BOOLEAN_LEN = 40;

#ifndef NDEBUG
	const size_t orig_stack_size = reader->stack.size;
#endif

	bool          ret      = false;
	bool          emit     = (ctx.subject != 0);
	SerdNode*     node     = NULL;
	Ref           o        = 0;
	Ref           datatype = 0;
	Ref           lang     = 0;
	uint32_t      flags    = 0;
	const uint8_t c        = peek_byte(reader);
	switch (c) {
	case '\0':
	case ')':
		return false;
	case '[':
		emit = false;
		TRY_THROW(ret = read_anon(reader, ctx, false, &o));
		break;
	case '(':
		emit = false;
		TRY_THROW(ret = read_collection(reader, ctx, &o));
		break;
	case '_':
		TRY_THROW(ret = (o = read_BLANK_NODE_LABEL(reader, ate_dot)));
		break;
	case '<': case ':':
		TRY_THROW(ret = read_iri(reader, &o, ate_dot));
		break;
	case '+': case '-': case '.': case '0': case '1': case '2': case '3':
	case '4': case '5': case '6': case '7': case '8': case '9':
		TRY_THROW(ret = read_number(reader, &o, &datatype, ate_dot));
		break;
	case '\"':
	case '\'':
		TRY_THROW(ret = read_literal(reader, &o, &datatype, &lang, &flags, ate_dot));
		break;
	default:
		/* Either a boolean literal, or a qname.  Read the prefix first, and if
		   it is in fact a "true" or "false" literal, produce that instead.
		*/
		node = deref(reader, o = push_node(reader, SERD_CURIE, "", 0));
		while (read_PN_CHARS_BASE(reader, o)) {}
		if ((node->n_bytes == 4 && !memcmp(node->buf, "true", 4)) ||
		    (node->n_bytes == 5 && !memcmp(node->buf, "false", 5))) {
			node->type = SERD_LITERAL;
			datatype   = push_node(
				reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN);
			ret = true;
		} else if (read_PN_PREFIX_tail(reader, o) > SERD_FAILURE) {
			ret = false;
		} else {
			ret = read_PrefixedName(reader, o, false, ate_dot);
		}
	}

	if (ret && emit) {
		deref(reader, o)->flags = flags;
		ret = emit_statement(reader, ctx, o, datatype, lang);
	}

except:
	pop_node(reader, lang);
	pop_node(reader, datatype);
	pop_node(reader, o);
#ifndef NDEBUG
	assert(reader->stack.size == orig_stack_size);
#endif
	return ret;
}