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(); }
void testTruncate() { printf( "testTruncate\n" ); char buffer[20]; getLineString( buffer, "123456789012345" ); assert( !strcmp( buffer, "123456789012" ) ); printf( "." ); printf( "\ntestTruncate successful.\n" ); }
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; }
LineString getLineString(const uint32 quality = 24) const { return getLineString(0.0, 1.0, quality); }
const Bezier2& Bezier2::draw(const double thickness, const ColorF& color) const { getLineString().draw(thickness, color); return *this; }
void Bezier3::draw(const double thickness, const ColorF& color) const { getLineString().draw(thickness, color); }