Exemplo n.º 1
0
geos::geom::MultiLineString* GeoJSONReader::getMultiLineString(Handle<Value> coords) {

    if (coords->IsArray()) {

        Handle<Array> array = Handle<Array>::Cast(coords);
        uint32_t length = array->Length();
        std::vector<geos::geom::Geometry*>* geoms = new std::vector<geos::geom::Geometry*>();
        try {
            for (uint32_t i = 0; i < length; i++) {
                geos::geom::LineString* g = getLineString(array->Get(i));
                geoms->push_back(g);
            }
        }
        catch (...) {
            unsigned size = geoms->size();
            for (unsigned int i = 0; i < size; i++)
                delete (*geoms)[i];
            delete geoms;
            throw;
        }


        return geometryFactory->createMultiLineString(geoms);
    }


    return geometryFactory->createMultiLineString();
}
Exemplo n.º 2
0
void testTruncate() {
	printf( "testTruncate\n" );
	char buffer[20];
	getLineString( buffer, "123456789012345" );
	assert( !strcmp( buffer, "123456789012" ) );
	printf( "." );
	printf( "\ntestTruncate successful.\n" );
}
Exemplo n.º 3
0
geos::geom::Geometry* GeoJSONReader::read(Handle<Value> value) {

    if (!value->IsObject()) {
        throw "GeoJSON must be an instance of Object";
    }

    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);


    Handle<Object> obj = Handle<Object>::Cast(value);

    Handle<String> typeKey = String::NewFromUtf8(isolate, "type");

    if (!obj->HasOwnProperty(typeKey)) {
        throw "Property \"type\" is missing";
    }

    std::string string = *String::Utf8Value(obj->Get(typeKey)->ToString());

    geos::geom::Geometry* g;

    try {
        if (string == "Point") {
            g = getPoint(getCoordsArray(obj));
        } else if (string == "LineString") {
            g = getLineString(getCoordsArray(obj));
        } else if (string == "Polygon") {
            g = getPolygon(getCoordsArray(obj));
        } else if (string == "MultiPoint") {
            g = getMultiPoint(getCoordsArray(obj));
        } else if (string == "MultiLineString") {
            g = getMultiLineString(getCoordsArray(obj));
        } else if (string == "MultiPolygon") {
            g = getMultiPolygon(getCoordsArray(obj));
        } else if (string == "GeometryCollection") {
            g = getGeometryCollection(getGeomsArray(obj));
        }
        else {
            throw "Property \"type\" has a value that is not supported or allowed";
        }
    }
    catch (...) {
        throw;
    }

    return g;
}
Exemplo n.º 4
0
		LineString getLineString(const uint32 quality = 24) const
		{
			return getLineString(0.0, 1.0, quality);
		}
Exemplo n.º 5
0
	const Bezier2& Bezier2::draw(const double thickness, const ColorF& color) const
	{
		getLineString().draw(thickness, color);

		return *this;
	}
Exemplo n.º 6
0
	void Bezier3::draw(const double thickness, const ColorF& color) const
	{
		getLineString().draw(thickness, color);
	}