From 2e0a0fa09e213aa6c6948258d62e0fb6a481dc4b Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Thu, 18 Feb 2016 16:02:38 +0000 Subject: [PATCH 01/70] First iOS client changes --- .../G3MiOSDemo.xcodeproj/project.pbxproj | 2 +- iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm | 137 ++++++++++++-- iOS/G3MiOSSDK/Commons/Basic/BilParser.cpp | 84 +++++++++ iOS/G3MiOSSDK/Commons/Basic/BilParser.hpp | 4 + .../Commons/Basic/DefaultTileTexturizer.cpp | 4 +- iOS/G3MiOSSDK/Commons/Basic/ElevationData.cpp | 2 + iOS/G3MiOSSDK/Commons/Basic/ElevationData.hpp | 2 + .../Commons/Basic/ElevationDataProvider.hpp | 8 +- iOS/G3MiOSSDK/Commons/Basic/MapBoo.cpp | 2 +- .../Commons/Basic/PlanetTileTessellator.cpp | 175 ++++++++++-------- .../Basic/ShortBufferElevationData.cpp | 44 +++++ .../Basic/ShortBufferElevationData.hpp | 17 ++ .../Basic/SingleBilElevationDataProvider.cpp | 9 + .../Basic/SingleBilElevationDataProvider.hpp | 6 + iOS/G3MiOSSDK/Commons/Basic/Tile.cpp | 7 +- .../Basic/TileElevationDataRequest.cpp | 4 + .../Commons/Mesh/AbstractGeometryMesh.hpp | 2 +- iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.cpp | 2 +- iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.hpp | 10 +- iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.cpp | 2 +- iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.hpp | 2 +- iOS/G3MiOSSDK/Commons/Mesh/IndexedMesh.hpp | 1 + .../Rendererers/VectorStreamingRenderer.cpp | 6 +- .../G3MiOSSDK.xcodeproj/project.pbxproj | 26 ++- .../PyramidElevationDataProvider.hpp | 78 ++++++++ iOS/G3MiOSSDK/PyramidElevationDataProvider.mm | 155 ++++++++++++++++ ...ionDataProvider_BufferDownloadListener.hpp | 50 +++++ ...tionDataProvider_BufferDownloadListener.mm | 91 +++++++++ 28 files changed, 809 insertions(+), 123 deletions(-) create mode 100644 iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp create mode 100644 iOS/G3MiOSSDK/PyramidElevationDataProvider.mm create mode 100644 iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp create mode 100644 iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm diff --git a/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj b/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj index 68948556a9..ab2423f2ed 100644 --- a/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj +++ b/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj @@ -186,7 +186,7 @@ D8EEF39A1577920B003FEB5E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; D8EEF39D1577920B003FEB5E /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = ""; }; D8EEF3A21577920B003FEB5E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - D8EEF3A31577920B003FEB5E /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ViewController.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + D8EEF3A31577920B003FEB5E /* ViewController.mm */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ViewController.mm; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; D8EEF40E1577AA61003FEB5E /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; D8EEF4101577AAE2003FEB5E /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; D8EEF4161577AEC8003FEB5E /* G3MiOSSDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = G3MiOSSDK.xcodeproj; path = ../G3MiOSSDK/G3MiOSSDK.xcodeproj; sourceTree = ""; }; diff --git a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm index 382d89ce64..a4a62445bb 100644 --- a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm +++ b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm @@ -147,6 +147,8 @@ #import #import +#import +#import #include @@ -163,7 +165,7 @@ //}; -Mesh* createSectorMesh(const Planet* planet, +/*Mesh* createSectorMesh(const Planet* planet, const int resolution, const Sector& sector, const Color& color, @@ -235,7 +237,7 @@ new Color(color), delete vertices; return result; -} +}*/ @implementation ViewController @@ -284,7 +286,8 @@ - (void)viewDidLoad //[[self G3MWidget] initSingletons]; // [self initWithoutBuilder]; - [self initCustomizedWithBuilder]; + //[self initCustomizedWithBuilder]; + [self initWithPyramidElevations]; //[self initTestingTileImageProvider]; @@ -322,13 +325,108 @@ - (void)viewDidLoad [[self G3MWidget] widget]->addPeriodicalTask(TimeInterval::fromMilliseconds(100), new CameraRollChangerTask([[self G3MWidget] widget])); */ - + + [[self G3MWidget] widget]->setCameraPitch(Angle::fromDegrees(-45)); + [[self G3MWidget] widget]->setCameraPosition(Geodetic3D::fromDegrees(28, -15.6, 10000)); +} + +-(void) initWithPyramidElevations +{ + G3MBuilder_iOS builder([self G3MWidget]); + + const Planet *planet = EllipsoidalPlanet::createEarth(); + LayerSet* layerSet = new LayerSet(); + layerSet->addLayer(new BingMapsLayer(BingMapType::Aerial(), + "AnU5uta7s5ql_HTrRZcPLI4_zotvNefEeSxIClF1Jf7eS-mLig1jluUdCoecV7jc", + TimeInterval::fromDays(30))); + MeshRenderer *_meshRenderer = new MeshRenderer(); + builder.addRenderer(_meshRenderer); + builder.getPlanetRendererBuilder()->setLayerSet(layerSet); + builder.getPlanetRendererBuilder()->setIncrementalTileQuality(true); + builder.getPlanetRendererBuilder()->setRenderDebug(true); + std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/result/"; + PyramidElevationDataProvider *edp = new PyramidElevationDataProvider(server,Sector::fullSphere(),true,false); + builder.getPlanetRendererBuilder()->setElevationDataProvider(edp); + + bool showPrimarySectors = false; + if (showPrimarySectors){ + addSectorMesh(_meshRenderer, Sector::fromDegrees(50, -180, 90, -90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(50, -90, 90, 0), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(50, 0, 90, 90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(50, 90, 90, 180), planet); + + addSectorMesh(_meshRenderer, Sector::fromDegrees(0, -180, 50, -90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(0, -90, 50, 0), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(0, 0, 50, 90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(0, 90, 50, 180), planet); + + addSectorMesh(_meshRenderer, Sector::fromDegrees(-50, -180, 0, -90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(-50, -90, 0, 0), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(-50, 0, 0, 90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(-50, 90, 0, 180), planet); + + addSectorMesh(_meshRenderer, Sector::fromDegrees(-90, -180, -50, -90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(-90, -90, -50, 0), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(-90, 0, -50, 90), planet); + addSectorMesh(_meshRenderer, Sector::fromDegrees(-90, 90, -50, 180), planet); + } + + builder.initializeWidget(); + //return _widget; +} + +void addSectorMesh(MeshRenderer *renderer, const Sector& sector, const Planet *planet){ + /* const double POINT_DIV = 100; + + FloatBufferBuilderFromGeodetic *fbb = FloatBufferBuilderFromGeodetic::builderWithFirstVertexAsCenter(planet); + fbb->add(sector._upper, 5); + //Delta instruction here + if (sector._upper._latitude._degrees != 90){ + double delta = (sector._upper._longitude._radians - sector._lower._longitude._radians) / POINT_DIV; + double lonRads = sector._upper._longitude._radians; + for (int i=0; iadd(sector._upper._latitude,Geodetic2D::fromRadians(sector._upper._latitude._radians,lonRads)._longitude, 5); + } + } + else fbb->add(sector._upper._latitude, sector._lower._longitude, 5); + + double delta = (sector._upper._latitude._radians - sector._lower._latitude._radians) / POINT_DIV; + double latRads = sector._upper._latitude._radians; + for (int i=0; iadd(Geodetic2D::fromRadians(latRads,sector._lower._longitude._radians)._latitude,sector._lower._longitude, 5); + } + + //Delta instruction here + if (sector._lower._latitude._degrees != -90){ + delta = (sector._upper._longitude._radians - sector._lower._longitude._radians) / POINT_DIV; + double lonRads = sector._lower._longitude._radians; + for (int i=0; iadd(sector._lower._latitude,Geodetic2D::fromRadians(sector._lower._latitude._radians,lonRads)._longitude, 5); + } + } + else fbb->add(sector._lower._latitude,sector._upper._longitude, 5); + + delta = (sector._upper._latitude._radians - sector._lower._latitude._radians) / POINT_DIV; + latRads = sector._lower._latitude._radians; + for (int i=0; iadd(Geodetic2D::fromRadians(latRads,sector._upper._longitude._radians)._latitude,sector._upper._longitude, 5); + } + + renderer->addMesh(new DirectMesh(GLPrimitive::lineStrip(), true, fbb->getCenter(), fbb->create(), 6.0f, 1.0f, + Color::yellow(), NULL, 0.0f, false));*/ } + + +/* - (void) initWithNonOverlappingMarks { G3MBuilder_iOS builder([self G3MWidget]); - + Vector2D::intersectionOfTwoLines(Vector2D(0,0), Vector2D(10,10), Vector2D(10,0), Vector2D(-10, 10)); @@ -433,7 +531,7 @@ new DownloaderImageBuilder(URL("file:///anchorWidget.png")), builder.initializeWidget(); } - +*/ class MoveCameraInitializationTask : public GInitializationTask { private: @@ -506,6 +604,7 @@ bool isDone(const G3MContext* context) { // //}; +/* #pragma testing tile image provider #warning working now - (void) initTestingTileImageProvider @@ -841,7 +940,7 @@ - (void) testContainsGEO2DPolygonDataWorld : (const GEOFeatureCollection*) fc } } - +*/ - (void) testContainsGEO2DPolygonData { std::vector* coordinates = new std::vector(); @@ -911,7 +1010,7 @@ - (void) testContainsGEO2DPolygonData } - +/* - (ShapesRenderer*) createShapesRendererForTestImageDrawingOfCanvas : (const Planet*) planet { ShapesRenderer* shapesRenderer = new ShapesRenderer(); @@ -1070,7 +1169,7 @@ - (void) initWithBuilderAndSegmentedWorld builder.initializeWidget(); } - +*/ - (void) initWithDefaultBuilder { @@ -1167,7 +1266,7 @@ void onAfterAddMesh(Mesh* mesh) { // } //}; - +/* - (void) initCustomizedWithBuilder { G3MBuilder_iOS builder([self G3MWidget]); @@ -1739,7 +1838,7 @@ bool onCameraChange(const Planet* planet, // [self testGenericQuadTree:geoVectorLayer]; } - +*/ - (void) testGenericQuadTree: (GEOVectorLayer*) geoVectorLayer { @@ -1851,7 +1950,7 @@ - (void) testGenericQuadTree: (GEOVectorLayer*) geoVectorLayer { } */ } - +/* - (void)createInterpolationTest: (MeshRenderer*) meshRenderer { @@ -1941,7 +2040,7 @@ - (void)createInterpolationTest: (MeshRenderer*) meshRenderer delete planet; } - +*/ - (Mesh*) createPointsMesh: (const Planet*)planet { @@ -2273,7 +2372,7 @@ static GEO2DSurfaceRasterStyle createPointSurfaceRasterStyle(const GEOGeometry* } }; - +/* - (LayerSet*) createLayerSet { @@ -2901,7 +3000,7 @@ - (PlanetRenderer*) createPlanetRenderer: (TilesRenderParameters*) parameters return planetRenderer; } - +*/ - (MarksRenderer*) createMarksRenderer { @@ -2984,7 +3083,7 @@ - (MarksRenderer*) createMarksRenderer return marksRenderer; } - +/* - (ShapesRenderer*) createShapesRenderer: (const Planet*) planet { ShapesRenderer* shapesRenderer = new ShapesRenderer(); @@ -3232,7 +3331,7 @@ void imageCreated(const IImage* image) { return shapesRenderer; } - +*/ class SampleSymbolizer : public GEOSymbolizer { private: mutable int _colorIndex = 0; @@ -3562,7 +3661,7 @@ - (GEORenderer*) createGEORendererMeshRenderer: (MeshRenderer*) meshRenderer // } //}; - +/* class Bil16Parser_IBufferDownloadListener : public IBufferDownloadListener { private: ShapesRenderer* _shapesRenderer; @@ -3669,7 +3768,7 @@ void onCanceledDownload(const URL& url, } }; - +*/ class RadarParser_BufferDownloadListener : public IBufferDownloadListener { private: diff --git a/iOS/G3MiOSSDK/Commons/Basic/BilParser.cpp b/iOS/G3MiOSSDK/Commons/Basic/BilParser.cpp index 642b39f284..13277a4e31 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/BilParser.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/BilParser.cpp @@ -56,3 +56,87 @@ ShortBufferElevationData* BilParser::parseBil16(const Sector& sector, size, deltaHeight); } + +ShortBufferElevationData* BilParser::parseBil16MaxMin(const Sector& sector, const Vector2I &extent, IByteBuffer *buffer, double deltaHeight) +{ + const int size = extent._x * extent._y; + + const int expectedSizeInBytes = (size * 2) + 8; + if (buffer->size() != expectedSizeInBytes) + { + ILogger::instance()->logError("Invalid buffer size, expected %d bytes, but got %d", expectedSizeInBytes, buffer->size()); + return NULL; + } + + ByteBufferIterator *iterator = new ByteBufferIterator(buffer); + + const short minValue = IMathUtils::instance()->minInt16(); + + short* shortBuffer = new short[size]; + for (int i = 0; i < size; i++) + { + short height = iterator->nextInt16(); + + if (height == 15000) //Our own NODATA, since -9999 is a valid height. + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + else if (height == minValue) + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + + shortBuffer[i] = height; + } + + short max = iterator->nextInt16(); + short min = iterator->nextInt16(); + short children = iterator->nextInt16(); + short similarity = iterator->nextInt16(); + + return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, + size, deltaHeight,max,min,children,similarity); +} + +ShortBufferElevationData* BilParser::parseBil16Redim (const Sector& sector, IByteBuffer *buffer, double deltaHeight) +{ + ByteBufferIterator *iterator = new ByteBufferIterator(buffer); + + const short size = iterator->nextInt16(); + + const int expectedSizeInBytes = (size * size * 2) + 10; + if (buffer->size() != expectedSizeInBytes) + { + ILogger::instance()->logError("Invalid buffer size, expected %d bytes, but got %d", expectedSizeInBytes, buffer->size()); + return NULL; + } + + const short minValue = IMathUtils::instance()->minInt16(); + + short* shortBuffer = new short[size*size]; + for (int i = 0; i < size*size; i++) + { + short height = iterator->nextInt16(); + + if (height == 15000) //Our own NODATA, since -9999 is a valid height. + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + else if (height == minValue) + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + + shortBuffer[i] = height; + } + + short max = iterator->nextInt16(); + short min = iterator->nextInt16(); + short children = iterator->nextInt16(); + short similarity = iterator->nextInt16(); + + Vector2I extent = Vector2I(size,size); + + return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, + size*size, deltaHeight,max,min,children,similarity); +} diff --git a/iOS/G3MiOSSDK/Commons/Basic/BilParser.hpp b/iOS/G3MiOSSDK/Commons/Basic/BilParser.hpp index dcc7cf2bc6..ee7ba01aa0 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/BilParser.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/BilParser.hpp @@ -25,6 +25,10 @@ class BilParser { const Vector2I& extent, const IByteBuffer* buffer, double deltaHeight = 0); + + static ShortBufferElevationData* parseBil16MaxMin(const Sector& sector, const Vector2I &extent, IByteBuffer *buffer, double deltaHeight = 0); + + static ShortBufferElevationData* parseBil16Redim (const Sector& sector, IByteBuffer *buffer, double deltaHeight); }; #endif diff --git a/iOS/G3MiOSSDK/Commons/Basic/DefaultTileTexturizer.cpp b/iOS/G3MiOSSDK/Commons/Basic/DefaultTileTexturizer.cpp index 5a54175f5a..2a0a12fbe9 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/DefaultTileTexturizer.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/DefaultTileTexturizer.cpp @@ -28,6 +28,7 @@ #include "IImageBuilderListener.hpp" #include "PlanetRenderContext.hpp" #include "TilesRenderParameters.hpp" +#include "ElevationData.hpp" class DTT_LTMInitializer : public LazyTextureMappingInitializer { private: @@ -188,7 +189,7 @@ class DTT_TileTextureBuilder : public RCObject { const bool transparent, const bool generateMipmap) { std::vector* mappings = new std::vector(); - + Tile* ancestor = tile; bool fallbackSolved = false; while (ancestor != NULL && !fallbackSolved) { @@ -669,6 +670,7 @@ Mesh* DefaultTileTexturizer::texturize(const G3MRenderContext* rc, : prc->_tileDownloadPriority + tile->_level); builder = new DTT_TileTextureBuilder(rc, + //Vector2I(8,8), prc->_layerTilesRenderParameters, tileImageProvider, tile, diff --git a/iOS/G3MiOSSDK/Commons/Basic/ElevationData.cpp b/iOS/G3MiOSSDK/Commons/Basic/ElevationData.cpp index 8e2562bb9c..e5dc3b4e77 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/ElevationData.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/ElevationData.cpp @@ -26,6 +26,8 @@ _resolution(sector._deltaLatitude.div(extent._y), sector._deltaLongitude.div(extent._x)), _interpolator(NULL) { + _children = IMathUtils::instance()->minInt16(); + _similarity = IMathUtils::instance()->minInt16(); } ElevationData::~ElevationData() { diff --git a/iOS/G3MiOSSDK/Commons/Basic/ElevationData.hpp b/iOS/G3MiOSSDK/Commons/Basic/ElevationData.hpp index 8d516bc0b3..2a47bf22d3 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/ElevationData.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/ElevationData.hpp @@ -31,6 +31,8 @@ class ElevationData { const int _height; const Geodetic2D _resolution; + + short _children, _similarity; public: ElevationData(const Sector& sector, diff --git a/iOS/G3MiOSSDK/Commons/Basic/ElevationDataProvider.hpp b/iOS/G3MiOSSDK/Commons/Basic/ElevationDataProvider.hpp index 12ffafae1a..5891754a76 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/ElevationDataProvider.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/ElevationDataProvider.hpp @@ -68,7 +68,13 @@ class ElevationDataProvider { const Vector2I& extent, IElevationDataListener* listener, bool autodeleteListener) = 0; - + + virtual const long long requestElevationData(const Sector& sector, + int level, int row, int column, + const Vector2I& extent, + IElevationDataListener* listener, + bool autodeleteListener) = 0; + virtual void cancelRequest(const long long requestId) = 0; virtual std::vector getSectors() const = 0; diff --git a/iOS/G3MiOSSDK/Commons/Basic/MapBoo.cpp b/iOS/G3MiOSSDK/Commons/Basic/MapBoo.cpp index 4e0bbcdb4e..0d20fc6b49 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/MapBoo.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/MapBoo.cpp @@ -585,7 +585,7 @@ void MapBoo::MBVectorSymbology::apply(const URL& true, // readExpired true, // verbose false, // haltOnError - VectorStreamingRenderer::Format::SERVER); + VectorStreamingRenderer::SERVER); } void MapBoo::MBSymbolizedDataset::apply(const URL& serverURL, diff --git a/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp b/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp index 0404d2d364..970516a5aa 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp @@ -58,7 +58,18 @@ Vector2I PlanetTileTessellator::calculateResolution(const PlanetRenderContext* p const Tile* tile, const Sector& renderedSector) const { Sector sector = tile->_sector; - const Vector2I resolution = prc->_layerTilesRenderParameters->_tileMeshResolution; +#warning Chano_changed_behaviour: Cambio clave: resolución general sólo si no tenemos elevaciones en el tile. Si las tenemos, entonces la malla será acorde a esas elevaciones dadas, tengan el extent que tengan. + + MutableVector2I mutableResolution = prc->_layerTilesRenderParameters->_tileMeshResolution.asMutableVector2I(); + + if (tile->getElevationData() != NULL) { + mutableResolution = tile->getElevationData()->getExtent().asMutableVector2I(); + ILogger::instance()->logInfo(tile->description()+": From elev"); + } + else ILogger::instance()->logInfo(tile->description()+": No elev"); + + const Vector2I resolution = mutableResolution.asVector2I(); + ILogger::instance()->logInfo(resolution.description()); const double latRatio = sector._deltaLatitude._degrees / renderedSector._deltaLatitude._degrees; const double lonRatio = sector._deltaLongitude._degrees / renderedSector._deltaLongitude._degrees; @@ -76,6 +87,7 @@ Vector2I PlanetTileTessellator::calculateResolution(const PlanetRenderContext* p } const Vector2I meshRes = Vector2I(resX, resY); + ILogger::instance()->logInfo("Calculated meshRes:"+meshRes.description()); return meshRes; @@ -239,90 +251,89 @@ IFloatBuffer* PlanetTileTessellator::createTextCoords(const Vector2I& rawResolut Mesh* PlanetTileTessellator::createTileDebugMesh(const G3MRenderContext* rc, const PlanetRenderContext* prc, const Tile* tile) const { - #warning TODO for JM! return NULL; -// const Sector meshSector = getRenderedSectorForTile(tile); -// const Vector2I meshResolution = calculateResolution(prc, tile, meshSector); -// const short rx = (short)meshResolution._x; -// const short ry = (short)meshResolution._y; -// -// AbstractGeometryMesh* mesh = ((AbstractGeometryMesh*)tile->getTessellatorMesh()); -// const IFloatBuffer* vertices = mesh->getVertices(); -// -// //INDEX OF BORDER/////////////////////////////////////////////////////////////// -// ShortBufferBuilder indicesBorder; -// for (short j = 0; j < rx; j++) { -// indicesBorder.add(j); -// } -// -// for (short i = 2; i < ry+1; i++) { -// indicesBorder.add((short)((i * rx)-1)); -// } -// -// for (short j = (short)(rx*ry-2); j >= (short)(rx*(ry-1)); j--) { -// indicesBorder.add(j); -// } -// -// for (short j = (short)(rx*(ry-1)-rx); j >= 0; j-=rx) { -// indicesBorder.add(j); -// } -// -// //INDEX OF GRID -// ShortBufferBuilder indicesGrid; -// for (short i = 0; i < ry-1; i++) { -// short rowOffset = (short)(i * rx); -// -// for (short j = 0; j < rx; j++) { -// indicesGrid.add((short)(rowOffset + j)); -// indicesGrid.add((short)(rowOffset + j+rx)); -// } -// for (short j = (short)((2*rx)-1); j >= rx; j--) { -// indicesGrid.add((short)(rowOffset + j)); -// } -// -// } -// -// const Color levelColor = Color::blue().wheelStep(5, tile->_level % 5); -// const float gridLineWidth = tile->isElevationDataSolved() || (tile->getElevationData() == NULL) ? 1.0f : 3.0f; -// -// -// IndexedMesh* border = new IndexedMesh(GLPrimitive::lineStrip(), -// mesh->getCenter(), -// (IFloatBuffer*)vertices, -// false, -// indicesBorder.create(), -// true, -// 2.0f, -// 1.0f, -// Color::newFromRGBA(1.0f, 0.0f, 0.0f, 1.0f), -// NULL, -// 1.0f, -// false, -// NULL, -// true, 1.0f, 1.0f); -// -// IndexedMesh* grid = new IndexedMesh(GLPrimitive::lineStrip(), -// mesh->getCenter(), -// (IFloatBuffer*)vertices, -// false, -// indicesGrid.create(), -// true, -// gridLineWidth, -// 1.0f, -// new Color(levelColor), -// NULL, -// 1.0f, -// false, -// NULL, -// true, 1.0f, 1.0f); -// -// CompositeMesh* c = new CompositeMesh(); -// c->addMesh(grid); -// c->addMesh(border); -// -// return c; + /*const Sector meshSector = getRenderedSectorForTile(tile); + const Vector2I meshResolution = calculateResolution(prc, tile, meshSector); + const short rx = (short)meshResolution._x; + const short ry = (short)meshResolution._y; + + AbstractGeometryMesh* mesh = ((AbstractGeometryMesh*)tile->getTessellatorMesh()); + const IFloatBuffer* vertices = mesh->getVertices(); + + //INDEX OF BORDER/////////////////////////////////////////////////////////////// + ShortBufferBuilder indicesBorder; + for (short j = 0; j < rx; j++) { + indicesBorder.add(j); + } + + for (short i = 2; i < ry+1; i++) { + indicesBorder.add((short)((i * rx)-1)); + } + + for (short j = (short)(rx*ry-2); j >= (short)(rx*(ry-1)); j--) { + indicesBorder.add(j); + } + + for (short j = (short)(rx*(ry-1)-rx); j >= 0; j-=rx) { + indicesBorder.add(j); + } + + //INDEX OF GRID + ShortBufferBuilder indicesGrid; + for (short i = 0; i < ry-1; i++) { + short rowOffset = (short)(i * rx); + + for (short j = 0; j < rx; j++) { + indicesGrid.add((short)(rowOffset + j)); + indicesGrid.add((short)(rowOffset + j+rx)); + } + for (short j = (short)((2*rx)-1); j >= rx; j--) { + indicesGrid.add((short)(rowOffset + j)); + } + + } + + const Color levelColor = Color::blue().wheelStep(5, tile->_level % 5); + const float gridLineWidth = tile->isElevationDataSolved() || (tile->getElevationData() == NULL) ? 1.0f : 3.0f; + + + IndexedMesh* border = new IndexedMesh(GLPrimitive::lineStrip(), + mesh->getCenter(), + (IFloatBuffer*)vertices, + false, + indicesBorder.create(), + true, + 2.0f, + 1.0f, + Color::newFromRGBA(1.0f, 0.0f, 0.0f, 1.0f), + NULL, + 1.0f, + false, + NULL, + true, 1.0f, 1.0f); + + IndexedMesh* grid = new IndexedMesh(GLPrimitive::lineStrip(), + mesh->getCenter(), + (IFloatBuffer*)vertices, + false, + indicesGrid.create(), + true, + gridLineWidth, + 1.0f, + new Color(levelColor), + NULL, + 1.0f, + false, + NULL, + true, 1.0f, 1.0f); + + CompositeMesh* c = new CompositeMesh(); + c->addMesh(grid); + c->addMesh(border); + + return c;*/ } Sector PlanetTileTessellator::getRenderedSectorForTile(const Tile* tile) const { diff --git a/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp b/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp index 9d622a85b0..c6623111ac 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp @@ -37,6 +37,45 @@ _buffer(buffer) break; } } + + + _max = IMathUtils::instance()->minInt16(); + _min = IMathUtils::instance()->maxInt16(); + _children = IMathUtils::instance()->minInt16(); + _similarity = IMathUtils::instance()->minInt16(); +} + +ShortBufferElevationData::ShortBufferElevationData(const Sector& sector, + const Vector2I& extent, + const Sector& realSector, + const Vector2I& realExtent, + short* buffer, + int bufferSize, + double deltaHeight, + short max, + short min, + short children, + short similarity) : +BufferElevationData(sector, extent, realSector, realExtent, bufferSize, deltaHeight), +_buffer(buffer) +{ + if (_bufferSize != (_width * _height) ) { + ILogger::instance()->logError("Invalid buffer size"); + } + + const size_t size = _bufferSize; + _hasNoData = false; + for (size_t i = 0; i < size; i++) { + if (buffer[i] == NO_DATA_VALUE) { + _hasNoData = true; + break; + } + } + + _max = max; + _min = min; + _children = children; + _similarity = similarity; } ShortBufferElevationData::~ShortBufferElevationData() { @@ -106,6 +145,11 @@ Vector3D ShortBufferElevationData::getMinMaxAverageElevations() const { if (maxHeight == mu->minInt16()) { maxHeight = 0; } + + if (_max > mu->minInt16() && _min < mu->maxInt16()){ + minHeight = _min; + maxHeight = _max; + } return Vector3D(minHeight, maxHeight, diff --git a/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.hpp b/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.hpp index 00dadf5a11..7c6ca16b57 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.hpp @@ -16,6 +16,8 @@ class ShortBufferElevationData : public BufferElevationData { private: short* _buffer; bool _hasNoData; + + short _max, _min; protected: double getValueInBufferAt(int index) const; @@ -31,6 +33,18 @@ class ShortBufferElevationData : public BufferElevationData { short* buffer, int bufferSize, double deltaHeight); + + ShortBufferElevationData(const Sector& sector, + const Vector2I& extent, + const Sector& realSector, + const Vector2I& realExtent, + short* buffer, + int bufferSize, + double deltaHeight, + short max, + short min, + short children, + short similarity); virtual ~ShortBufferElevationData(); @@ -40,6 +54,9 @@ class ShortBufferElevationData : public BufferElevationData { bool hasNoData() const { return _hasNoData;} + bool hasChildren() const { if (_children > 0) return true; return false; } + int getSimilarity() const {return _similarity; } + }; #endif diff --git a/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.cpp b/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.cpp index c5eccaf5a1..8a04f15d15 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.cpp @@ -228,3 +228,12 @@ void SingleBilElevationDataProvider::removeQueueRequest(const long long requestI _requestsQueue.remove(requestId); #endif } + +const long long SingleBilElevationDataProvider::requestElevationData(const Sector& sector, + int level, int row, int column, + const Vector2I& extent, + IElevationDataListener* listener, + bool autodeleteListener){ + return requestElevationData(sector, extent, listener, autodeleteListener); +} + diff --git a/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.hpp b/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.hpp index 196a6e580e..6209971aae 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/SingleBilElevationDataProvider.hpp @@ -101,6 +101,12 @@ class SingleBilElevationDataProvider : public ElevationDataProvider { const Vector2I& extent, IElevationDataListener* listener, bool autodeleteListener); + + const long long requestElevationData(const Sector& sector, + int level, int row, int column, + const Vector2I& extent, + IElevationDataListener* listener, + bool autodeleteListener); void cancelRequest(const long long requestId); diff --git a/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp b/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp index 59a9f6edeb..14ddfb2abf 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp @@ -23,7 +23,7 @@ #include "TilesRenderParameters.hpp" #include "MercatorUtils.hpp" #include "LayerTilesRenderParameters.hpp" -#include "DecimatedSubviewElevationData.hpp" +#include "InterpolatedSubviewElevationData.hpp" std::string Tile::createTileId(int level, @@ -178,7 +178,6 @@ Mesh* Tile::getTessellatorMesh(const G3MRenderContext* rc, if ( (_tessellatorMesh == NULL) || _mustActualizeMeshDueToNewElevationData ) { _mustActualizeMeshDueToNewElevationData = false; - _planetRenderer->onTileHasChangedMesh(this); if (_debugMesh != NULL) { @@ -653,7 +652,9 @@ ElevationData* Tile::createElevationDataSubviewFromAncestor(Tile* ancestor) cons if ((_lastElevationDataProvider != NULL) && (_lastTileMeshResolutionX > 0) && (_lastTileMeshResolutionY > 0)) { - return new DecimatedSubviewElevationData(ed, + + //return ed; + return new InterpolatedSubviewElevationData(ed, _sector, Vector2I(_lastTileMeshResolutionX, _lastTileMeshResolutionY)); } diff --git a/iOS/G3MiOSSDK/Commons/Basic/TileElevationDataRequest.cpp b/iOS/G3MiOSSDK/Commons/Basic/TileElevationDataRequest.cpp index 4c3bdc28e4..89a50f1edd 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/TileElevationDataRequest.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/TileElevationDataRequest.cpp @@ -50,7 +50,11 @@ void TileElevationDataRequest::cancelRequest() { void TileElevationDataRequest::sendRequest() { _listener = new TileElevationDataRequestListener(this); +#warning chano_changed_behaviour: Ahora se llama siempre a la nueva versión de request. En la versión piramidal cargará tiles por lrc. En el resto se llamará indirectamente a la antigua versión de request. _requestID = _provider->requestElevationData(_tile->_sector, + _tile->_level, + _tile->_row, + _tile->_column, _resolution, _listener, true); } diff --git a/iOS/G3MiOSSDK/Commons/Mesh/AbstractGeometryMesh.hpp b/iOS/G3MiOSSDK/Commons/Mesh/AbstractGeometryMesh.hpp index 849fc9ad2b..bfe70b8bff 100644 --- a/iOS/G3MiOSSDK/Commons/Mesh/AbstractGeometryMesh.hpp +++ b/iOS/G3MiOSSDK/Commons/Mesh/AbstractGeometryMesh.hpp @@ -24,7 +24,7 @@ class AbstractGeometryMesh : public Mesh { const int _primitive; const Vector3D _center; const MutableMatrix44D* _translationMatrix; - const IFloatBuffer* _vertices; + IFloatBuffer* _vertices; const bool _ownsVertices; const IFloatBuffer* _normals; const bool _ownsNormals; diff --git a/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.cpp b/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.cpp index c00d21cd22..ca054db840 100644 --- a/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.cpp +++ b/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.cpp @@ -47,7 +47,7 @@ AbstractMesh::~AbstractMesh() { AbstractMesh::AbstractMesh(const int primitive, bool owner, const Vector3D& center, - const IFloatBuffer* vertices, + IFloatBuffer* vertices, float lineWidth, float pointSize, const Color* flatColor, diff --git a/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.hpp b/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.hpp index 163013e7ba..db1ca98f72 100644 --- a/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.hpp +++ b/iOS/G3MiOSSDK/Commons/Mesh/AbstractMesh.hpp @@ -24,7 +24,7 @@ class AbstractMesh : public Mesh { const bool _owner; const Vector3D _center; const MutableMatrix44D* _translationMatrix; - const IFloatBuffer* _vertices; + IFloatBuffer* _vertices; const Color* _flatColor; const IFloatBuffer* _colors; const float _colorsIntensity; @@ -43,7 +43,7 @@ class AbstractMesh : public Mesh { AbstractMesh(const int primitive, bool owner, const Vector3D& center, - const IFloatBuffer* vertices, + IFloatBuffer* vertices, float lineWidth, float pointSize, const Color* flatColor, @@ -83,8 +83,10 @@ class AbstractMesh : public Mesh { void showNormals(bool v) const { _showNormals = v; } + +#warning Chano_at_work: Como quiero poder actualizar el tile mesh, conviene que vértices sea no const. Al ser una ñapa, recuerda que JM y Agustín la vean antes de subirla. - const IFloatBuffer* getVertices() const { + IFloatBuffer* getVertices() const { return _vertices; } @@ -92,6 +94,8 @@ class AbstractMesh : public Mesh { return _center; } + + }; #endif diff --git a/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.cpp b/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.cpp index a00bc8ace7..a171498021 100644 --- a/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.cpp +++ b/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.cpp @@ -12,7 +12,7 @@ DirectMesh::DirectMesh(const int primitive, bool owner, const Vector3D& center, - const IFloatBuffer* vertices, + IFloatBuffer* vertices, float lineWidth, float pointSize, const Color* flatColor, diff --git a/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.hpp b/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.hpp index 3b9191afbc..3a239b4151 100644 --- a/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.hpp +++ b/iOS/G3MiOSSDK/Commons/Mesh/DirectMesh.hpp @@ -26,7 +26,7 @@ class DirectMesh : public AbstractMesh { DirectMesh(const int primitive, bool owner, const Vector3D& center, - const IFloatBuffer* vertices, + IFloatBuffer* vertices, float lineWidth, float pointSize, const Color* flatColor = NULL, diff --git a/iOS/G3MiOSSDK/Commons/Mesh/IndexedMesh.hpp b/iOS/G3MiOSSDK/Commons/Mesh/IndexedMesh.hpp index 5aa867abf5..68dc87b379 100644 --- a/iOS/G3MiOSSDK/Commons/Mesh/IndexedMesh.hpp +++ b/iOS/G3MiOSSDK/Commons/Mesh/IndexedMesh.hpp @@ -44,6 +44,7 @@ class IndexedMesh : public AbstractMesh { const IShortBuffer* getIndices() const { return _indices; } + }; #endif diff --git a/iOS/G3MiOSSDK/Commons/Rendererers/VectorStreamingRenderer.cpp b/iOS/G3MiOSSDK/Commons/Rendererers/VectorStreamingRenderer.cpp index b87e8548db..375367df04 100644 --- a/iOS/G3MiOSSDK/Commons/Rendererers/VectorStreamingRenderer.cpp +++ b/iOS/G3MiOSSDK/Commons/Rendererers/VectorStreamingRenderer.cpp @@ -956,7 +956,7 @@ void VectorStreamingRenderer::VectorSet::parsedMetadata(Sector* sector, } const URL VectorStreamingRenderer::VectorSet::getMetadataURL() const { - if (_format == VectorStreamingRenderer::Format::SERVER) { + if (_format == VectorStreamingRenderer::SERVER) { return URL(_serverURL, _name); } return URL(_serverURL, _name + "/metadata.json"); @@ -978,7 +978,7 @@ const std::string VectorStreamingRenderer::VectorSet::toNodesDirectories(const s } const URL VectorStreamingRenderer::VectorSet::getNodeFeaturesURL(const std::string& nodeID) const { - if (_format == VectorStreamingRenderer::Format::SERVER) { + if (_format == VectorStreamingRenderer::SERVER) { return URL(_serverURL, _name + "/features" + "?node=" + nodeID + @@ -991,7 +991,7 @@ const URL VectorStreamingRenderer::VectorSet::getNodeFeaturesURL(const std::stri const URL VectorStreamingRenderer::VectorSet::getNodeChildrenURL(const std::string& nodeID, const std::vector& childrenIDs) const { - if (_format == VectorStreamingRenderer::Format::SERVER) { + if (_format == VectorStreamingRenderer::SERVER) { std::string nodes = ""; const size_t childrenIDsSize = childrenIDs.size(); diff --git a/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj b/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj index 945e46e449..ac32a232f9 100644 --- a/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj +++ b/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj @@ -467,6 +467,10 @@ CFFAFD73169F2E3000BCE129 /* TextUtils_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFFAFD71169F2E3000BCE129 /* TextUtils_iOS.mm */; }; CFFEC12315C2EA5F003FA986 /* Downloader_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFFEC12215C2EA5F003FA986 /* Downloader_iOS.mm */; }; CFFEC12615C2EBA6003FA986 /* URL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CFFEC12515C2EBA6003FA986 /* URL.cpp */; }; + D0E1E2341C75CECA00C37DA0 /* PyramidElevationDataProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = D0E1E22C1C75C16300C37DA0 /* PyramidElevationDataProvider.mm */; }; + D0E1E2351C75CECA00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = D0E1E22F1C75C7C100C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm */; }; + D0E1E2391C75D04600C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0E1E2311C75C80F00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */; }; + D0E1E23A1C75D04600C37DA0 /* PyramidElevationDataProvider.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0E1E2321C75CD6F00C37DA0 /* PyramidElevationDataProvider.hpp */; }; D8019FF01C11D91800784287 /* TileLODTester.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D8019FEE1C11D91800784287 /* TileLODTester.cpp */; }; D8019FF21C11DFCF00784287 /* TileLODTester.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8019FEF1C11D91800784287 /* TileLODTester.hpp */; }; D80270BE17B3AADF0029F0BE /* CameraDoubleDragHandler.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = FBBDBCDD17AB983200077004 /* CameraDoubleDragHandler.hpp */; }; @@ -762,6 +766,8 @@ dstPath = "include/${PRODUCT_NAME}"; dstSubfolderSpec = 16; files = ( + D0E1E2391C75D04600C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */, + D0E1E23A1C75D04600C37DA0 /* PyramidElevationDataProvider.hpp in CopyFiles */, CFE50D251C6669160002EFD5 /* GradualSplitsTileLODTester.hpp in CopyFiles */, CFE50D261C6669160002EFD5 /* PlanetRenderContext.hpp in CopyFiles */, CF75396B1C5C0501006CE697 /* OrTileLODTester.hpp in CopyFiles */, @@ -1319,7 +1325,7 @@ CF2412AE191FE3D100B796FB /* GEO2DCoordinatesArrayData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = GEO2DCoordinatesArrayData.hpp; path = Commons/GEO/GEO2DCoordinatesArrayData.hpp; sourceTree = ""; }; CF27B15E16D93DC90000A415 /* BufferElevationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BufferElevationData.cpp; path = Commons/Basic/BufferElevationData.cpp; sourceTree = ""; }; CF27B15F16D93DC90000A415 /* BufferElevationData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = BufferElevationData.hpp; path = Commons/Basic/BufferElevationData.hpp; sourceTree = ""; }; - CF27B16216D93F2B0000A415 /* ShortBufferElevationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ShortBufferElevationData.cpp; path = Commons/Basic/ShortBufferElevationData.cpp; sourceTree = ""; }; + CF27B16216D93F2B0000A415 /* ShortBufferElevationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = ShortBufferElevationData.cpp; path = Commons/Basic/ShortBufferElevationData.cpp; sourceTree = ""; tabWidth = 2; }; CF27B16316D93F2C0000A415 /* ShortBufferElevationData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ShortBufferElevationData.hpp; path = Commons/Basic/ShortBufferElevationData.hpp; sourceTree = ""; }; CF290D4B187F149D000BE644 /* SimpleTextureMapping.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SimpleTextureMapping.cpp; path = Commons/Mesh/SimpleTextureMapping.cpp; sourceTree = ""; }; CF290D4C187F149D000BE644 /* SimpleTextureMapping.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = SimpleTextureMapping.hpp; path = Commons/Mesh/SimpleTextureMapping.hpp; sourceTree = ""; }; @@ -1345,7 +1351,7 @@ CF31CBF215878AF90085E8F1 /* ITimer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = ITimer.hpp; path = Commons/Interfaces/ITimer.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; CF31CBF315878BE40085E8F1 /* Timer_iOS.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Timer_iOS.hpp; path = Specific/Derived/Timer_iOS.hpp; sourceTree = ""; }; CF35A20516D3D44E00D795D8 /* BilParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BilParser.cpp; path = Commons/Basic/BilParser.cpp; sourceTree = ""; }; - CF35A20616D3D44E00D795D8 /* BilParser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = BilParser.hpp; path = Commons/Basic/BilParser.hpp; sourceTree = ""; }; + CF35A20616D3D44E00D795D8 /* BilParser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.h; name = BilParser.hpp; path = Commons/Basic/BilParser.hpp; sourceTree = ""; tabWidth = 2; }; CF35DD4A16C6995C002EFC96 /* Vector3F.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vector3F.cpp; path = Commons/Geometry/Vector3F.cpp; sourceTree = ""; }; CF35DD4B16C6995C002EFC96 /* Vector3F.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Vector3F.hpp; path = Commons/Geometry/Vector3F.hpp; sourceTree = ""; }; CF35DD4E16C69B08002EFC96 /* Vector2F.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vector2F.cpp; path = Commons/Geometry/Vector2F.cpp; sourceTree = ""; }; @@ -1556,7 +1562,7 @@ CF94EB931669307700F2283C /* GEO2DLineStringGeometry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = GEO2DLineStringGeometry.hpp; path = Commons/GEO/GEO2DLineStringGeometry.hpp; sourceTree = ""; }; CF9592AC1652E28500CB7AC8 /* OrderedRenderable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OrderedRenderable.cpp; path = Commons/Basic/OrderedRenderable.cpp; sourceTree = ""; }; CF9592AD1652E28500CB7AC8 /* OrderedRenderable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = OrderedRenderable.hpp; path = Commons/Basic/OrderedRenderable.hpp; sourceTree = ""; }; - CF9AEBBD159B3B95004C3558 /* TileTessellator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = TileTessellator.hpp; path = Commons/Basic/TileTessellator.hpp; sourceTree = ""; }; + CF9AEBBD159B3B95004C3558 /* TileTessellator.hpp */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.cpp.h; name = TileTessellator.hpp; path = Commons/Basic/TileTessellator.hpp; sourceTree = ""; tabWidth = 2; }; CF9AEBC0159B3FDD004C3558 /* PlanetTileTessellator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = PlanetTileTessellator.hpp; path = Commons/Basic/PlanetTileTessellator.hpp; sourceTree = ""; }; CF9AEBC1159B3FEA004C3558 /* PlanetTileTessellator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlanetTileTessellator.cpp; path = Commons/Basic/PlanetTileTessellator.cpp; sourceTree = ""; }; CF9CD89815DBE2C800C6FD7E /* CachedDownloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = CachedDownloader.cpp; path = Commons/Interfaces/CachedDownloader.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; @@ -1711,7 +1717,7 @@ CFDDDF9A17F8C9E100DD3499 /* URLTemplateLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLTemplateLayer.cpp; sourceTree = ""; }; CFDDDF9B17F8C9E100DD3499 /* URLTemplateLayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = URLTemplateLayer.hpp; sourceTree = ""; }; CFDFC05B166AB22A0065BC1F /* AbstractMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = AbstractMesh.cpp; path = Commons/Mesh/AbstractMesh.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; - CFDFC05C166AB22A0065BC1F /* AbstractMesh.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = AbstractMesh.hpp; path = Commons/Mesh/AbstractMesh.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; + CFDFC05C166AB22A0065BC1F /* AbstractMesh.hpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = AbstractMesh.hpp; path = Commons/Mesh/AbstractMesh.hpp; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; CFE029531601367100D1E75B /* IImageDownloadListener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = IImageDownloadListener.hpp; path = Commons/Downloader/IImageDownloadListener.hpp; sourceTree = ""; }; CFE0844015E27A310004EC0E /* LayerTouchEventListener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = LayerTouchEventListener.hpp; path = Commons/Basic/LayerTouchEventListener.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; CFE3B577164AE32E009975A5 /* SceneJSShapesParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SceneJSShapesParser.cpp; path = Commons/Rendererers/SceneJSShapesParser.cpp; sourceTree = ""; }; @@ -1753,6 +1759,10 @@ CFFEC12215C2EA5F003FA986 /* Downloader_iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Downloader_iOS.mm; path = Specific/Derived/Downloader_iOS.mm; sourceTree = ""; }; CFFEC12415C2EB96003FA986 /* URL.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = URL.hpp; path = Commons/Basic/URL.hpp; sourceTree = ""; }; CFFEC12515C2EBA6003FA986 /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = URL.cpp; path = Commons/Basic/URL.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; + D0E1E22C1C75C16300C37DA0 /* PyramidElevationDataProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PyramidElevationDataProvider.mm; sourceTree = ""; }; + D0E1E22F1C75C7C100C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PyramidElevationDataProvider_BufferDownloadListener.mm; sourceTree = ""; }; + D0E1E2311C75C80F00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PyramidElevationDataProvider_BufferDownloadListener.hpp; sourceTree = ""; }; + D0E1E2321C75CD6F00C37DA0 /* PyramidElevationDataProvider.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PyramidElevationDataProvider.hpp; sourceTree = ""; }; D8019FEE1C11D91800784287 /* TileLODTester.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = TileLODTester.cpp; path = Commons/Rendererers/TileLODTester.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; D8019FEF1C11D91800784287 /* TileLODTester.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = TileLODTester.hpp; path = Commons/Rendererers/TileLODTester.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; D802448B177B314800F58D0D /* TransformedTexCoorTexturedMesh.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = TransformedTexCoorTexturedMesh.fsh; sourceTree = ""; }; @@ -1834,7 +1844,7 @@ D892FBCB15C930CC00E69254 /* NativeGL2_iOS.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = NativeGL2_iOS.hpp; path = Specific/GL/NativeGL2_iOS.hpp; sourceTree = ""; }; D895CA1C1861C32300AE8291 /* IImageUtils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = IImageUtils.hpp; path = Commons/Basic/IImageUtils.hpp; sourceTree = ""; }; D895CA1D1861C33A00AE8291 /* IImageUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IImageUtils.cpp; path = Commons/Basic/IImageUtils.cpp; sourceTree = ""; }; - D89D9CC6172E95370058CA9D /* TileElevationDataRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileElevationDataRequest.cpp; path = Commons/Basic/TileElevationDataRequest.cpp; sourceTree = ""; }; + D89D9CC6172E95370058CA9D /* TileElevationDataRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = TileElevationDataRequest.cpp; path = Commons/Basic/TileElevationDataRequest.cpp; sourceTree = ""; tabWidth = 2; }; D89D9CC7172E95370058CA9D /* TileElevationDataRequest.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = TileElevationDataRequest.hpp; path = Commons/Basic/TileElevationDataRequest.hpp; sourceTree = ""; }; D89D9CC8172E95370058CA9D /* CompositeElevationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = CompositeElevationData.cpp; path = Commons/Basic/CompositeElevationData.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; D89D9CC9172E95370058CA9D /* CompositeElevationData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = CompositeElevationData.hpp; path = Commons/Basic/CompositeElevationData.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; @@ -2039,6 +2049,10 @@ CF4027D11770DD5C00D5A80C /* WebSocket_iOS.hpp */, CF4F78481804ADFC00550409 /* DeviceInfo_iOS.mm */, CF4F78491804ADFC00550409 /* DeviceInfo_iOS.hpp */, + D0E1E22C1C75C16300C37DA0 /* PyramidElevationDataProvider.mm */, + D0E1E22F1C75C7C100C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm */, + D0E1E2311C75C80F00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */, + D0E1E2321C75CD6F00C37DA0 /* PyramidElevationDataProvider.hpp */, ); name = Derived; sourceTree = ""; @@ -3013,6 +3027,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D0E1E2341C75CECA00C37DA0 /* PyramidElevationDataProvider.mm in Sources */, + D0E1E2351C75CECA00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm in Sources */, CCF45F551743AE620037CA28 /* SphericalPlanet.cpp in Sources */, CF67D9C31C5A90BB00873661 /* TileVisibilityTester.cpp in Sources */, 383BD37D1577EDC00012AC53 /* Logger_iOS.mm in Sources */, diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp b/iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp new file mode 100644 index 0000000000..d23b47abea --- /dev/null +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp @@ -0,0 +1,78 @@ +// +// PyramidElevationDataProvider.h +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 18/2/16. +// +// + +#ifndef G3MiOSSDK_PyramidElevationDataProvider_h +#define G3MiOSSDK_PyramidElevationDataProvider_h + +#include +#include "ElevationDataProvider.hpp" +#include "IDownloader.hpp" +#include "Sector.hpp" +#include "URL.hpp" + +class PyramidElevationDataProvider : public ElevationDataProvider { +private: + IDownloader * _downloader; + const Sector _sector; + double _deltaHeight; + bool _isMercator, _variableSized; + const std::string _layer; + + class MetadataListener; + + class PyramidComposition { + public: + double _upperLat, _upperLon, _lowerLat, _lowerLon; + int _pyramidLevel; + + PyramidComposition(double lowerLat, double lowerLon, double upperLat, double upperLon, const int pyramidLevel){ + _lowerLat = lowerLat; + _lowerLon = lowerLon; + _upperLat = upperLat; + _upperLon = upperLon; + _pyramidLevel = pyramidLevel; + } + + std::string description(){ + //TODO: implement this better. + return ""; + //return _sector.description() + ", pyramidLevel: "+_pyramidLevel; + } + + Sector getSector() { + return Sector::fromDegrees(_lowerLat, _lowerLon, _upperLat, _upperLon); + } + }; + + std::vector *_pyrComposition; + + bool aboveLevel(const Sector §or, int level); +public: + + PyramidElevationDataProvider(const std::string &layer, const Sector& sector, bool isMercator, bool variableSized, double deltaHeight = 0); + + ~PyramidElevationDataProvider(); + + bool isReadyToRender (const G3MRenderContext *rc) {return true;} + void getMetadata() const; + + void initialize(const G3MContext* context); + const long long requestElevationData(const Sector §or, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener); + const long long requestElevationData(const Sector §or, int level, int row, int column, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener); + + std::string requestStringPath(const Sector §or, const Vector2I &extent); + std::string requestStringPath(const std::string & layer, int level, int row, int column); + std::string requestMetadataPath() const; + + void cancelRequest(const long long requestId); + std::vector getSectors() const; + const Vector2I getMinResolution() const; + +}; + +#endif diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm b/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm new file mode 100644 index 0000000000..cc06dec800 --- /dev/null +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm @@ -0,0 +1,155 @@ +// +// PyramidElevationDataProvider.m +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 18/2/16. +// +// + +#import + +#import "PyramidElevationDataProvider.hpp" +#include "PyramidElevationDataProvider_BufferDownloadListener.hpp" +#include "DownloadPriority.hpp" +#include "JSONParser_iOS.hpp" +#include "JSONObject.hpp" +#include "JSONInteger.hpp" +#include "JSONDouble.hpp" +#include "JSONArray.hpp" +#include "Context.hpp" +#include + +class PyramidElevationDataProvider::MetadataListener : public IBufferDownloadListener { +public: + MetadataListener(std::vector* itself): _itself(itself) {} + + void onDownload(const URL& url, + IByteBuffer* buffer, + bool expired) { + + JSONParser_iOS *parser = new JSONParser_iOS(); + const JSONArray *array = parser->parse(buffer->getAsString(), true)->asArray(); + delete parser; + + for (unsigned int i=0; isize(); i++){ + _itself->push_back(PyramidComposition(getLowerLat(array,i),getLowerLon(array,i),getUpperLat(array,i),getUpperLon(array,i),getLevel(array,i))); + } + } + void onError(const URL& url) {} + void onCancel(const URL& url) {} + + void onCanceledDownload(const URL& url, + IByteBuffer* data, + bool expired) {} + +private: + std::vector* _itself; + + double getUpperLat(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lat"); + return doble->value(); + } + + double getLowerLat(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lat"); + return doble->value(); + } + + double getUpperLon(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lon"); + return doble->value(); + } + + double getLowerLon(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*)array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lon"); + return doble->value(); + } + + int getLevel(const JSONArray *array,int index){ + JSONInteger *integer = (JSONInteger *) array->getAsObject(index)->getAsNumber("pyrLevel"); + return integer->intValue(); + } +}; + +PyramidElevationDataProvider::PyramidElevationDataProvider(const std::string &layer, const Sector& sector, bool isMercator, bool variableSized, double deltaHeight): _sector(sector), _layer(layer){ + _pyrComposition = new std::vector(); + _deltaHeight = deltaHeight; + _isMercator = isMercator; + _variableSized = variableSized; +} + +PyramidElevationDataProvider::~PyramidElevationDataProvider(){ + _pyrComposition->clear(); + delete _pyrComposition; + _pyrComposition = NULL; +} + +void PyramidElevationDataProvider::getMetadata() const{ + _downloader->requestBuffer(URL(requestMetadataPath(),false), DownloadPriority::HIGHER, TimeInterval::fromDays(30), true, new MetadataListener(_pyrComposition), true); +} + +void PyramidElevationDataProvider::initialize(const G3MContext* context ){ + _downloader = context->getDownloader(); + getMetadata(); +} + +const long long PyramidElevationDataProvider::requestElevationData(const Sector §or, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener){ + //This requester is not necessary, but we are forced to implement it, so -1. + return -1; +} + +const long long PyramidElevationDataProvider::requestElevationData(const Sector §or, int level, int row, int column, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener){ + + if ((_downloader == NULL) || (aboveLevel(sector, level))){ + return -1; + } + + std::string path = requestStringPath(_layer,level,row,column); + + return _downloader->requestBuffer(URL(path,false), DownloadPriority::HIGHEST - level, TimeInterval::fromDays(30), true, new PyramidElevationDataProvider_BufferDownloadListener(sector, extent,_variableSized, listener, autodeleteListener, _deltaHeight), true ); +} + +std::string PyramidElevationDataProvider::requestStringPath(const Sector §or, const Vector2I &extent){ + // TODO: Esta en principio no debería usarse, pero ... + ILogger::instance()->logError("BAD STRING PATH REQUESTED!"); + return ""; +} + +std::string PyramidElevationDataProvider::requestStringPath(const std::string & layer, int level, int row, int column){ + std::ostringstream strs; + strs << _layer << level << "/" << column << "/" << row << ".bil"; + std::string res = strs.str(); + ILogger::instance()->logInfo(res); + return res; +} + +std::string PyramidElevationDataProvider::requestMetadataPath() const{ + return _layer + "/meta.json"; +} + +void PyramidElevationDataProvider::cancelRequest(const long long requestId){ + _downloader->cancelRequest(requestId); +} + +std::vector PyramidElevationDataProvider::getSectors() const{ + std::vector sectors; + sectors.push_back(&_sector); + return sectors; +} + +const Vector2I PyramidElevationDataProvider::getMinResolution() const{ + // int WORKING_JM; + return Vector2I::zero(); +} + +bool PyramidElevationDataProvider::aboveLevel(const Sector §or, int level){ + int maxLevel = 0; + for (unsigned int i=0; i< _pyrComposition->size(); i++) + if (sector.touchesWith(_pyrComposition->at(i).getSector())) + maxLevel = fmax(maxLevel,_pyrComposition->at(i)._pyramidLevel); + + if (level > maxLevel) return true; + else return false; +} + + diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp new file mode 100644 index 0000000000..d60a9729f9 --- /dev/null +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp @@ -0,0 +1,50 @@ +// +// PyramidElevationDataProvider_BufferDownloadListener.hpp +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 18/2/16. +// +// + +#ifndef G3MiOSSDK_PyramidElevationDataProvider_BufferDownloadListener_hpp +#define G3MiOSSDK_PyramidElevationDataProvider_BufferDownloadListener_hpp + +#include +#include "IBufferDownloadListener.hpp" +#include "ElevationDataProvider.hpp" +#include "ShortBufferElevationData.hpp" +#include "Sector.hpp" +#include "BilParser.hpp" + + +class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownloadListener { +private: + + const Sector &_sector; + int _width, _height; + IElevationDataListener *_listener; + bool _autodeleteListener; + double _deltaHeight; + bool _variableSized; + +public: + PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, + const Vector2I& extent, + bool variableSized, + IElevationDataListener *listener, + bool autodeleteListener, + double deltaHeight); + + void onDownload(const URL& url, + IByteBuffer* buffer, + bool expired); + void onError(const URL& url); + void onCancel(const URL& url); + + void onCanceledDownload(const URL& url, + IByteBuffer* data, + bool expired); + +}; + +#endif diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm new file mode 100644 index 0000000000..7947ef79e9 --- /dev/null +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm @@ -0,0 +1,91 @@ +// +// PyramidElevationDataProvider_BufferDownloadListener.m +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 18/2/16. +// +// + +#import +#import "PyramidElevationDataProvider_BufferDownloadListener.hpp" + +PyramidElevationDataProvider_BufferDownloadListener::PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, + const Vector2I& extent, + bool variableSized, + IElevationDataListener *listener, + bool autodeleteListener, + double deltaHeight) : _sector(sector){ + //_sector = Sector(sector); + _width = extent._x; + _height = extent._y; + _listener = listener; + _autodeleteListener = autodeleteListener; + _deltaHeight = deltaHeight; + _variableSized = variableSized; +} + +void PyramidElevationDataProvider_BufferDownloadListener::onDownload(const URL& url,IByteBuffer* buffer,bool expired){ + + Vector2I *resolution = NULL; + ShortBufferElevationData *elevationData; + if (!_variableSized) { +#warning Chano_at_work: Si bien la resolución está fijada a 8 porque la pirámide que sirvo la tiene, debo encontrar una forma de no fijarla por hardcoding. + resolution = new Vector2I(8, 8); + elevationData = BilParser::parseBil16MaxMin(_sector, *resolution, buffer, _deltaHeight); + } + else { + elevationData = BilParser::parseBil16Redim(_sector, buffer, _deltaHeight); + resolution = new Vector2I(elevationData->getExtent()); + } + + if (buffer != NULL) delete buffer; + + if (elevationData == NULL) + { + _listener->onError(_sector, *resolution); + } + else + { + _listener->onData(_sector, *resolution, elevationData); + //elevationData->_release(); + } + + + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } +} +void PyramidElevationDataProvider_BufferDownloadListener::onError(const URL& url){ + const Vector2I resolution = Vector2I(_width, _height); + + _listener->onError(_sector, resolution); + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } +} +void PyramidElevationDataProvider_BufferDownloadListener::onCancel(const URL& url){ + if (_listener != NULL) + { + const Vector2I resolution = Vector2I(_width, _height); + _listener->onCancel(_sector, resolution); + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } + } +} + +void PyramidElevationDataProvider_BufferDownloadListener::onCanceledDownload(const URL& url, + IByteBuffer* data, + bool expired){ + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } +} From baf9b10f6cf04161b224339232cbb0b89a9079b6 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 29 Feb 2016 16:15:22 +0000 Subject: [PATCH 02/70] Updating client so geojson-formatted DEM can be read --- iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm | 23 +++++---- .../Commons/Basic/PlanetTileTessellator.cpp | 5 +- .../Basic/ShortBufferElevationData.cpp | 2 +- iOS/G3MiOSSDK/Commons/Basic/Tile.cpp | 2 +- .../LayerTilesRenderParameters.hpp | 4 +- iOS/G3MiOSSDK/PyramidElevationDataProvider.mm | 7 +-- ...ionDataProvider_BufferDownloadListener.hpp | 8 ++- ...tionDataProvider_BufferDownloadListener.mm | 50 +++++++++++++++++-- 8 files changed, 75 insertions(+), 26 deletions(-) diff --git a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm index a4a62445bb..c10e6218cf 100644 --- a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm +++ b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm @@ -93,7 +93,7 @@ #import #import #import -#import +//#import #import #import #import @@ -111,7 +111,7 @@ #import #import #import -#import +//#import #import #import #import @@ -133,7 +133,7 @@ #import #import #import -#import +//#import #import #import #import @@ -326,8 +326,8 @@ - (void)viewDidLoad new CameraRollChangerTask([[self G3MWidget] widget])); */ - [[self G3MWidget] widget]->setCameraPitch(Angle::fromDegrees(-45)); - [[self G3MWidget] widget]->setCameraPosition(Geodetic3D::fromDegrees(28, -15.6, 10000)); + //[[self G3MWidget] widget]->setCameraPitch(Angle::fromDegrees(-45)); + [[self G3MWidget] widget]->setCameraPosition(Geodetic3D::fromDegrees(28, -15.6, 500000)); } -(void) initWithPyramidElevations @@ -342,9 +342,10 @@ -(void) initWithPyramidElevations MeshRenderer *_meshRenderer = new MeshRenderer(); builder.addRenderer(_meshRenderer); builder.getPlanetRendererBuilder()->setLayerSet(layerSet); - builder.getPlanetRendererBuilder()->setIncrementalTileQuality(true); + //builder.getPlanetRendererBuilder()->setIncrementalTileQuality(true); builder.getPlanetRendererBuilder()->setRenderDebug(true); - std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/result/"; + builder.getPlanetRendererBuilder()->setVerticalExaggeration(2.0f); + std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fusion/"; PyramidElevationDataProvider *edp = new PyramidElevationDataProvider(server,Sector::fullSphere(),true,false); builder.getPlanetRendererBuilder()->setElevationDataProvider(edp); @@ -532,7 +533,7 @@ new DownloaderImageBuilder(URL("file:///anchorWidget.png")), builder.initializeWidget(); } */ - +/* class MoveCameraInitializationTask : public GInitializationTask { private: G3MWidget_iOS* _iosWidget; @@ -547,13 +548,13 @@ new DownloaderImageBuilder(URL("file:///anchorWidget.png")), { } - void run(const G3MContext* context) { + void run(const G3MContext* context) {*/ // const std::string cartoCSS = "/* coment */ // comment\n @water: #C0E0F8; [zoom > 1] { line-color:@waterline; line-width:1.6; ::newSymbolizer { line-width:2; } } #world .class [level == 5] { background-color: black; } "; // const std::string cartoCSS = "@water: #ddeeff;\n#lakes[ScaleRank<3][zoom=3],\n#lakes[ScaleRank<4][zoom=4],\n#lakes[ScaleRank<5][zoom=5],\n#lakes[ScaleRank<6][zoom>=6] {\n polygon-fill:@water;\n line-color:darken(@water, 20%);\n line-width:0.3;\n }\n"; // const std::string cartoCSS = "/* coment */ // comment\n @water: #C0E0F8; [zoom > 1] { line-color:@waterline; line-width:1.6; ::newSymbolizer { line-width:2; } } #world .class [level == 5] { background-color: black; } \n@water: #ddeeff;\n#lakes[ScaleRank<3][zoom=3],\n#lakes[ScaleRank<4][zoom=4],\n#lakes[ScaleRank<5][zoom=5],\n#lakes[ScaleRank<6][zoom>=6] {\n polygon-fill:@water;\n line-color:darken(@water, 20%);\n line-width:0.3;\n }\n.class1.class2{} ::anotherSymbolizer {background-color: black;} * {line-color:white;} "; - const std::string cartoCSS = "@water: #C0E0F8; #id { a:1; b:2; .class {a:2;} [level > 2] {b:3; [COUNTRY=US][COUNTRY=AR] { d:33;} } }"; + /* const std::string cartoCSS = "@water: #C0E0F8; #id { a:1; b:2; .class {a:2;} [level > 2] {b:3; [COUNTRY=US][COUNTRY=AR] { d:33;} } }"; CartoCSSResult* result = CartoCSSParser::parse(cartoCSS); @@ -585,7 +586,7 @@ bool isDone(const G3MContext* context) { return true; } }; - +*/ //class ToggleGEORendererTask: public GTask { //private: diff --git a/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp b/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp index 970516a5aa..59377ccbdb 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PlanetTileTessellator.cpp @@ -64,12 +64,9 @@ Vector2I PlanetTileTessellator::calculateResolution(const PlanetRenderContext* p if (tile->getElevationData() != NULL) { mutableResolution = tile->getElevationData()->getExtent().asMutableVector2I(); - ILogger::instance()->logInfo(tile->description()+": From elev"); } - else ILogger::instance()->logInfo(tile->description()+": No elev"); const Vector2I resolution = mutableResolution.asVector2I(); - ILogger::instance()->logInfo(resolution.description()); const double latRatio = sector._deltaLatitude._degrees / renderedSector._deltaLatitude._degrees; const double lonRatio = sector._deltaLongitude._degrees / renderedSector._deltaLongitude._degrees; @@ -87,7 +84,7 @@ Vector2I PlanetTileTessellator::calculateResolution(const PlanetRenderContext* p } const Vector2I meshRes = Vector2I(resX, resY); - ILogger::instance()->logInfo("Calculated meshRes:"+meshRes.description()); + //ILogger::instance()->logInfo("Calculated meshRes:"+meshRes.description()); return meshRes; diff --git a/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp b/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp index c6623111ac..0c6b5bc526 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/ShortBufferElevationData.cpp @@ -79,7 +79,7 @@ _buffer(buffer) } ShortBufferElevationData::~ShortBufferElevationData() { - delete [] _buffer; + delete [] _buffer; #ifdef JAVA_CODE super.dispose(); diff --git a/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp b/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp index 14ddfb2abf..c552d62766 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp @@ -87,7 +87,7 @@ _dataSize(0) Tile::~Tile() { // prune(NULL, NULL); - + ILogger::instance()->logInfo("Destroying:"+_id); delete _debugMesh; _debugMesh = NULL; diff --git a/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp b/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp index 39418acfa5..c1e5fd5081 100644 --- a/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp +++ b/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp @@ -56,7 +56,9 @@ class LayerTilesRenderParameters { } static const Vector2I defaultTileMeshResolution() { - return Vector2I(16, 16); +#warning ChanoAtWork - Hay que cambiar esto! + return Vector2I(8,8); + //return Vector2I(16, 16); } static const Vector2I defaultTileTextureResolution () { diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm b/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm index cc06dec800..4cd53d48dd 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm @@ -16,7 +16,8 @@ #include "JSONInteger.hpp" #include "JSONDouble.hpp" #include "JSONArray.hpp" -#include "Context.hpp" +#include "G3MContext.hpp" +#include "TimeInterval.hpp" #include class PyramidElevationDataProvider::MetadataListener : public IBufferDownloadListener { @@ -117,9 +118,9 @@ int getLevel(const JSONArray *array,int index){ std::string PyramidElevationDataProvider::requestStringPath(const std::string & layer, int level, int row, int column){ std::ostringstream strs; - strs << _layer << level << "/" << column << "/" << row << ".bil"; + strs << _layer << level << "/" << column << "/" << row << ".json"; //".bil"; std::string res = strs.str(); - ILogger::instance()->logInfo(res); + //ILogger::instance()->logInfo(res); return res; } diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp index d60a9729f9..e4a5148e97 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp @@ -15,7 +15,7 @@ #include "ShortBufferElevationData.hpp" #include "Sector.hpp" #include "BilParser.hpp" - +#include "JSONObject.hpp" class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownloadListener { private: @@ -27,6 +27,12 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo double _deltaHeight; bool _variableSized; + const Vector2I* getResolution(const JSONObject *data); + ShortBufferElevationData* getElevationData(Sector sector, + Vector2I extent, + const JSONObject *data, + double deltaHeight); + public: PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, const Vector2I& extent, diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm index 7947ef79e9..cdd4f70e92 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm @@ -8,6 +8,8 @@ #import #import "PyramidElevationDataProvider_BufferDownloadListener.hpp" +#include "JSONParser_iOS.hpp" +#include "JSONArray.hpp" PyramidElevationDataProvider_BufferDownloadListener::PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, const Vector2I& extent, @@ -26,17 +28,20 @@ void PyramidElevationDataProvider_BufferDownloadListener::onDownload(const URL& url,IByteBuffer* buffer,bool expired){ - Vector2I *resolution = NULL; + //Vector2I *resolution = NULL; ShortBufferElevationData *elevationData; - if (!_variableSized) { -#warning Chano_at_work: Si bien la resolución está fijada a 8 porque la pirámide que sirvo la tiene, debo encontrar una forma de no fijarla por hardcoding. + /*if (!_variableSized) { resolution = new Vector2I(8, 8); elevationData = BilParser::parseBil16MaxMin(_sector, *resolution, buffer, _deltaHeight); } else { elevationData = BilParser::parseBil16Redim(_sector, buffer, _deltaHeight); resolution = new Vector2I(elevationData->getExtent()); - } + }*/ + std::string contents = buffer->getAsString(); + const JSONObject *jsonContent = JSONParser_iOS::instance()->parse(contents)->asObject(); + const Vector2I *resolution = getResolution(jsonContent); + elevationData = getElevationData(_sector, *resolution, jsonContent, _deltaHeight); if (buffer != NULL) delete buffer; @@ -89,3 +94,40 @@ _listener = NULL; } } + +const Vector2I* PyramidElevationDataProvider_BufferDownloadListener::getResolution(const JSONObject *data){ + return new Vector2I((int) data->getAsNumber("width",0),(int) data->getAsNumber("height",0)); +} + +ShortBufferElevationData* PyramidElevationDataProvider_BufferDownloadListener::getElevationData(Sector sector, + Vector2I extent, + const JSONObject *data, + double deltaHeight){ + const short minValue = IMathUtils::instance()->minInt16(); + const int size = extent._x * extent._y; + const JSONArray *dataArray = data->getAsArray("data"); + short *shortBuffer = new short[size]; + for (int i = 0; i < size; i++) + { + short height = (short) dataArray->getAsNumber(i, minValue); + + if (height == 15000) //Our own NODATA, since -9999 is a valid height. + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + else if (height == minValue) + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + + shortBuffer[i] = height; + } + + short max = (short) data->getAsNumber("max",IMathUtils::instance()->minInt16()); + short min = (short) data->getAsNumber("min",IMathUtils::instance()->maxInt16()); + short children = (short) data->getAsNumber("withChildren",0); + short similarity = (short) data->getAsNumber("similarity",0); + + return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, + size, deltaHeight,max,min,children,similarity); +} From 0503d20603057ad46961e9abbbc4732e535dc7ee Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Wed, 2 Mar 2016 15:52:10 +0000 Subject: [PATCH 03/70] Pointing at server, restoring default mesh res --- iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm | 2 +- iOS/G3MiOSSDK/Commons/Basic/Tile.cpp | 1 - .../Commons/Rendererers/LayerTilesRenderParameters.hpp | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm index c10e6218cf..ca6a388404 100644 --- a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm +++ b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm @@ -345,7 +345,7 @@ -(void) initWithPyramidElevations //builder.getPlanetRendererBuilder()->setIncrementalTileQuality(true); builder.getPlanetRendererBuilder()->setRenderDebug(true); builder.getPlanetRendererBuilder()->setVerticalExaggeration(2.0f); - std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fusion/"; + std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fix-16/"; PyramidElevationDataProvider *edp = new PyramidElevationDataProvider(server,Sector::fullSphere(),true,false); builder.getPlanetRendererBuilder()->setElevationDataProvider(edp); diff --git a/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp b/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp index c552d62766..be52488f2f 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/Tile.cpp @@ -87,7 +87,6 @@ _dataSize(0) Tile::~Tile() { // prune(NULL, NULL); - ILogger::instance()->logInfo("Destroying:"+_id); delete _debugMesh; _debugMesh = NULL; diff --git a/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp b/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp index c1e5fd5081..39418acfa5 100644 --- a/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp +++ b/iOS/G3MiOSSDK/Commons/Rendererers/LayerTilesRenderParameters.hpp @@ -56,9 +56,7 @@ class LayerTilesRenderParameters { } static const Vector2I defaultTileMeshResolution() { -#warning ChanoAtWork - Hay que cambiar esto! - return Vector2I(8,8); - //return Vector2I(16, 16); + return Vector2I(16, 16); } static const Vector2I defaultTileTextureResolution () { From 9fb04d18fc5d5574ff2cc111c5f1379a4419daaa Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Fri, 4 Mar 2016 13:16:54 +0100 Subject: [PATCH 04/70] Generated --- .../generated/AbstractGeometryMesh.java | 2 +- .../glob3/mobile/generated/AbstractMesh.java | 7 +- .../org/glob3/mobile/generated/BilParser.java | 86 +++++++++ .../CompositeElevationDataProvider.java | 2 +- .../generated/DefaultTileTexturizer.java | 1 + .../glob3/mobile/generated/ElevationData.java | 5 + .../generated/ElevationDataProvider.java | 2 + .../glob3/mobile/generated/IndexedMesh.java | 1 + .../generated/PlanetTileTessellator.java | 174 +++++++++--------- .../generated/ShortBufferElevationData.java | 54 +++++- .../SingleBilElevationDataProvider.java | 5 + .../src/org/glob3/mobile/generated/Tile.java | 6 +- .../generated/TileElevationDataRequest.java | 4 +- .../WMSBilElevationDataProvider.java | 2 +- 14 files changed, 260 insertions(+), 91 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractGeometryMesh.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractGeometryMesh.java index ed5d5a5762..f4e4649271 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractGeometryMesh.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractGeometryMesh.java @@ -28,7 +28,7 @@ public abstract class AbstractGeometryMesh extends Mesh protected final int _primitive; protected final Vector3D _center ; protected final MutableMatrix44D _translationMatrix; - protected final IFloatBuffer _vertices; + protected IFloatBuffer _vertices; protected final boolean _ownsVertices; protected final IFloatBuffer _normals; protected final boolean _ownsNormals; diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractMesh.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractMesh.java index 8b4de12c98..606fc6602d 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractMesh.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/AbstractMesh.java @@ -28,7 +28,7 @@ public abstract class AbstractMesh extends Mesh protected final boolean _owner; protected final Vector3D _center ; protected final MutableMatrix44D _translationMatrix; - protected final IFloatBuffer _vertices; + protected IFloatBuffer _vertices; protected final Color _flatColor; protected final IFloatBuffer _colors; protected final float _colorsIntensity; @@ -283,6 +283,9 @@ public final void showNormals(boolean v) _showNormals = v; } +//C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: +//#warning Chano_at_work: Como quiero poder actualizar el tile mesh, conviene que vértices sea no const.Al ser una ñapa, recuerda que JM y Agustín la vean antes de subirla. + public final IFloatBuffer getVertices() { return _vertices; @@ -293,4 +296,6 @@ public final Vector3D getCenter() return _center; } + + } \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BilParser.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BilParser.java index 87e5affd43..6ab35246af 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BilParser.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/BilParser.java @@ -67,4 +67,90 @@ else if (height == minValue) return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, size, deltaHeight); } + + public static ShortBufferElevationData parseBil16MaxMin(Sector sector, Vector2I extent, IByteBuffer buffer) + { + return parseBil16MaxMin(sector, extent, buffer, 0); + } + public static ShortBufferElevationData parseBil16MaxMin(Sector sector, Vector2I extent, IByteBuffer buffer, double deltaHeight) + { + final int size = extent._x * extent._y; + + final int expectedSizeInBytes = (size * 2) + 8; + if (buffer.size() != expectedSizeInBytes) + { + ILogger.instance().logError("Invalid buffer size, expected %d bytes, but got %d", expectedSizeInBytes, buffer.size()); + return null; + } + + ByteBufferIterator iterator = new ByteBufferIterator(buffer); + + final short minValue = IMathUtils.instance().minInt16(); + + short[] shortBuffer = new short[size]; + for (int i = 0; i < size; i++) + { + short height = iterator.nextInt16(); + + if (height == 15000) //Our own NODATA, since -9999 is a valid height. + { + height = ShortBufferElevationData.NO_DATA_VALUE; + } + else if (height == minValue) + { + height = ShortBufferElevationData.NO_DATA_VALUE; + } + + shortBuffer[i] = height; + } + + short max = iterator.nextInt16(); + short min = iterator.nextInt16(); + short children = iterator.nextInt16(); + short similarity = iterator.nextInt16(); + + return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, size, deltaHeight,max,min,children,similarity); + } + + public static ShortBufferElevationData parseBil16Redim (Sector sector, IByteBuffer buffer, double deltaHeight) + { + ByteBufferIterator iterator = new ByteBufferIterator(buffer); + + final short size = iterator.nextInt16(); + + final int expectedSizeInBytes = (size * size * 2) + 10; + if (buffer.size() != expectedSizeInBytes) + { + ILogger.instance().logError("Invalid buffer size, expected %d bytes, but got %d", expectedSizeInBytes, buffer.size()); + return null; + } + + final short minValue = IMathUtils.instance().minInt16(); + + short[] shortBuffer = new short[size *size]; + for (int i = 0; i < size *size; i++) + { + short height = iterator.nextInt16(); + + if (height == 15000) //Our own NODATA, since -9999 is a valid height. + { + height = ShortBufferElevationData.NO_DATA_VALUE; + } + else if (height == minValue) + { + height = ShortBufferElevationData.NO_DATA_VALUE; + } + + shortBuffer[i] = height; + } + + short max = iterator.nextInt16(); + short min = iterator.nextInt16(); + short children = iterator.nextInt16(); + short similarity = iterator.nextInt16(); + + Vector2I extent = new Vector2I(size,size); + + return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, size *size, deltaHeight,max,min,children,similarity); + } } \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CompositeElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CompositeElevationDataProvider.java index d49426575f..510e859187 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CompositeElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/CompositeElevationDataProvider.java @@ -21,7 +21,7 @@ //class CompositeElevationData; -public class CompositeElevationDataProvider extends ElevationDataProvider +public abstract class CompositeElevationDataProvider extends ElevationDataProvider { private G3MContext _context; diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/DefaultTileTexturizer.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/DefaultTileTexturizer.java index 83a708ed43..ae47955913 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/DefaultTileTexturizer.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/DefaultTileTexturizer.java @@ -100,6 +100,7 @@ public final Mesh texturize(G3MRenderContext rc, PlanetRenderContext prc, Tile t final long tileTexturePriority = (prc._tilesRenderParameters._incrementalTileQuality ? prc._tileDownloadPriority + prc._layerTilesRenderParameters._maxLevel - tile._level : prc._tileDownloadPriority + tile._level); builder = new DTT_TileTextureBuilder(rc, prc._layerTilesRenderParameters, tileImageProvider, tile, tessellatorMesh, prc._tessellator, tileTexturePriority, prc._logTilesPetitions, rc.getFrameTasksExecutor(), _defaultBackgroundImage, _defaultBackgroundImageName); + //Vector2I(8,8), builderHolder = new DTT_TileTextureBuilderHolder(builder); tile.setTexturizerData(builderHolder); } diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationData.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationData.java index 0feba8cf23..2812db7a73 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationData.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationData.java @@ -41,6 +41,9 @@ private Interpolator getInterpolator() protected final Geodetic2D _resolution ; + protected short _children; + protected short _similarity; + public ElevationData(Sector sector, Vector2I extent) { _sector = new Sector(sector); @@ -48,6 +51,8 @@ public ElevationData(Sector sector, Vector2I extent) _height = extent._y; _resolution = new Geodetic2D(sector._deltaLatitude.div(extent._y), sector._deltaLongitude.div(extent._x)); _interpolator = null; + _children = IMathUtils.instance().minInt16(); + _similarity = IMathUtils.instance().minInt16(); } public void dispose() diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationDataProvider.java index ac465da36f..73bf54414b 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ElevationDataProvider.java @@ -24,6 +24,8 @@ public void dispose() public abstract long requestElevationData(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener); + public abstract long requestElevationData(Sector sector, int level, int row, int column, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener); + public abstract void cancelRequest(long requestId); public abstract java.util.ArrayList getSectors(); diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/IndexedMesh.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/IndexedMesh.java index d1a8a41ca0..49453af05e 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/IndexedMesh.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/IndexedMesh.java @@ -91,4 +91,5 @@ public final IShortBuffer getIndices() { return _indices; } + } \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PlanetTileTessellator.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PlanetTileTessellator.java index 2e3251bd41..f60b092247 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PlanetTileTessellator.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PlanetTileTessellator.java @@ -7,7 +7,17 @@ public class PlanetTileTessellator extends TileTessellator private Vector2I calculateResolution(PlanetRenderContext prc, Tile tile, Sector renderedSector) { Sector sector = tile._sector; - final Vector2I resolution = prc._layerTilesRenderParameters._tileMeshResolution; +//C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: +//#warning Chano_changed_behaviour: Cambio clave: resolución general sólo si no tenemos elevaciones en el tile.Si las tenemos, entonces la malla será acorde a esas elevaciones dadas, tengan el extent que tengan. + + MutableVector2I mutableResolution = prc._layerTilesRenderParameters._tileMeshResolution.asMutableVector2I(); + + if (tile.getElevationData() != null) + { + mutableResolution = tile.getElevationData().getExtent().asMutableVector2I(); + } + + final Vector2I resolution = mutableResolution.asVector2I(); final double latRatio = sector._deltaLatitude._degrees / renderedSector._deltaLatitude._degrees; final double lonRatio = sector._deltaLongitude._degrees / renderedSector._deltaLongitude._degrees; @@ -27,6 +37,7 @@ private Vector2I calculateResolution(PlanetRenderContext prc, Tile tile, Sector } final Vector2I meshRes = new Vector2I(resX, resY); + //ILogger::instance()->logInfo("Calculated meshRes:"+meshRes.description()); return meshRes; @@ -435,91 +446,90 @@ public final Mesh createTileMesh(G3MRenderContext rc, PlanetRenderContext prc, T public final Mesh createTileDebugMesh(G3MRenderContext rc, PlanetRenderContext prc, Tile tile) { - //C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: //#warning TODO for JM! return null; - // const Sector meshSector = getRenderedSectorForTile(tile); - // const Vector2I meshResolution = calculateResolution(prc, tile, meshSector); - // const short rx = (short)meshResolution._x; - // const short ry = (short)meshResolution._y; - // - // AbstractGeometryMesh* mesh = ((AbstractGeometryMesh*)tile->getTessellatorMesh()); - // const IFloatBuffer* vertices = mesh->getVertices(); - // - // //INDEX OF BORDER/////////////////////////////////////////////////////////////// - // ShortBufferBuilder indicesBorder; - // for (short j = 0; j < rx; j++) { - // indicesBorder.add(j); - // } - // - // for (short i = 2; i < ry+1; i++) { - // indicesBorder.add((short)((i * rx)-1)); - // } - // - // for (short j = (short)(rx*ry-2); j >= (short)(rx*(ry-1)); j--) { - // indicesBorder.add(j); - // } - // - // for (short j = (short)(rx*(ry-1)-rx); j >= 0; j-=rx) { - // indicesBorder.add(j); - // } - // - // //INDEX OF GRID - // ShortBufferBuilder indicesGrid; - // for (short i = 0; i < ry-1; i++) { - // short rowOffset = (short)(i * rx); - // - // for (short j = 0; j < rx; j++) { - // indicesGrid.add((short)(rowOffset + j)); - // indicesGrid.add((short)(rowOffset + j+rx)); - // } - // for (short j = (short)((2*rx)-1); j >= rx; j--) { - // indicesGrid.add((short)(rowOffset + j)); - // } - // - // } - // - // const Color levelColor = Color::blue().wheelStep(5, tile->_level % 5); - // const float gridLineWidth = tile->isElevationDataSolved() || (tile->getElevationData() == NULL) ? 1.0f : 3.0f; - // - // - // IndexedMesh* border = new IndexedMesh(GLPrimitive::lineStrip(), - // mesh->getCenter(), - // (IFloatBuffer*)vertices, - // false, - // indicesBorder.create(), - // true, - // 2.0f, - // 1.0f, - // Color::newFromRGBA(1.0f, 0.0f, 0.0f, 1.0f), - // NULL, - // 1.0f, - // false, - // NULL, - // true, 1.0f, 1.0f); - // - // IndexedMesh* grid = new IndexedMesh(GLPrimitive::lineStrip(), - // mesh->getCenter(), - // (IFloatBuffer*)vertices, - // false, - // indicesGrid.create(), - // true, - // gridLineWidth, - // 1.0f, - // new Color(levelColor), - // NULL, - // 1.0f, - // false, - // NULL, - // true, 1.0f, 1.0f); - // - // CompositeMesh* c = new CompositeMesh(); - // c->addMesh(grid); - // c->addMesh(border); - // - // return c; + /*const Sector meshSector = getRenderedSectorForTile(tile); + const Vector2I meshResolution = calculateResolution(prc, tile, meshSector); + const short rx = (short)meshResolution._x; + const short ry = (short)meshResolution._y; + + AbstractGeometryMesh* mesh = ((AbstractGeometryMesh*)tile->getTessellatorMesh()); + const IFloatBuffer* vertices = mesh->getVertices(); + + //INDEX OF BORDER/////////////////////////////////////////////////////////////// + ShortBufferBuilder indicesBorder; + for (short j = 0; j < rx; j++) { + indicesBorder.add(j); + } + + for (short i = 2; i < ry+1; i++) { + indicesBorder.add((short)((i * rx)-1)); + } + + for (short j = (short)(rx*ry-2); j >= (short)(rx*(ry-1)); j--) { + indicesBorder.add(j); + } + + for (short j = (short)(rx*(ry-1)-rx); j >= 0; j-=rx) { + indicesBorder.add(j); + } + + //INDEX OF GRID + ShortBufferBuilder indicesGrid; + for (short i = 0; i < ry-1; i++) { + short rowOffset = (short)(i * rx); + + for (short j = 0; j < rx; j++) { + indicesGrid.add((short)(rowOffset + j)); + indicesGrid.add((short)(rowOffset + j+rx)); + } + for (short j = (short)((2*rx)-1); j >= rx; j--) { + indicesGrid.add((short)(rowOffset + j)); + } + + } + + const Color levelColor = Color::blue().wheelStep(5, tile->_level % 5); + const float gridLineWidth = tile->isElevationDataSolved() || (tile->getElevationData() == NULL) ? 1.0f : 3.0f; + + + IndexedMesh* border = new IndexedMesh(GLPrimitive::lineStrip(), + mesh->getCenter(), + (IFloatBuffer*)vertices, + false, + indicesBorder.create(), + true, + 2.0f, + 1.0f, + Color::newFromRGBA(1.0f, 0.0f, 0.0f, 1.0f), + NULL, + 1.0f, + false, + NULL, + true, 1.0f, 1.0f); + + IndexedMesh* grid = new IndexedMesh(GLPrimitive::lineStrip(), + mesh->getCenter(), + (IFloatBuffer*)vertices, + false, + indicesGrid.create(), + true, + gridLineWidth, + 1.0f, + new Color(levelColor), + NULL, + 1.0f, + false, + NULL, + true, 1.0f, 1.0f); + + CompositeMesh* c = new CompositeMesh(); + c->addMesh(grid); + c->addMesh(border); + + return c;*/ } public final IFloatBuffer createTextCoords(Vector2I rawResolution, Tile tile) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ShortBufferElevationData.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ShortBufferElevationData.java index 1bb747b19f..62f22b3e07 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ShortBufferElevationData.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/ShortBufferElevationData.java @@ -23,6 +23,9 @@ public class ShortBufferElevationData extends BufferElevationData private short[] _buffer; private boolean _hasNoData; + private short _max; + private short _min; + protected final double getValueInBufferAt(int index) { final short value = _buffer[index]; @@ -55,11 +58,43 @@ public ShortBufferElevationData(Sector sector, Vector2I extent, Sector realSecto break; } } + + + _max = IMathUtils.instance().minInt16(); + _min = IMathUtils.instance().maxInt16(); + _children = IMathUtils.instance().minInt16(); + _similarity = IMathUtils.instance().minInt16(); + } + + public ShortBufferElevationData(Sector sector, Vector2I extent, Sector realSector, Vector2I realExtent, short[] buffer, int bufferSize, double deltaHeight, short max, short min, short children, short similarity) + { + super(sector, extent, realSector, realExtent, bufferSize, deltaHeight); + _buffer = buffer; + if (_bufferSize != (_width * _height)) + { + ILogger.instance().logError("Invalid buffer size"); + } + + final int size = _bufferSize; + _hasNoData = false; + for (int i = 0; i < size; i++) + { + if (buffer[i] == NO_DATA_VALUE) + { + _hasNoData = true; + break; + } + } + + _max = max; + _min = min; + _children = children; + _similarity = similarity; } public void dispose() { - _buffer = null; + _buffer = null; super.dispose(); } @@ -128,6 +163,12 @@ public final Vector3D getMinMaxAverageElevations() maxHeight = 0; } + if (_max > mu.minInt16() && _min < mu.maxInt16()) + { + minHeight = _min; + maxHeight = _max; + } + return new Vector3D(minHeight, maxHeight, sumHeight / (_width * _height)); } @@ -136,4 +177,15 @@ public final boolean hasNoData() return _hasNoData; } + public final boolean hasChildren() + { + if (_children > 0) + return true; + return false; + } + public final int getSimilarity() + { + return _similarity; + } + } \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/SingleBilElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/SingleBilElevationDataProvider.java index fb33b8095e..5e98effa52 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/SingleBilElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/SingleBilElevationDataProvider.java @@ -131,6 +131,11 @@ public final long requestElevationData(Sector sector, Vector2I extent, IElevatio return -1; } + public final long requestElevationData(Sector sector, int level, int row, int column, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener) + { + return requestElevationData(sector, extent, listener, autodeleteListener); + } + public final void cancelRequest(long requestId) { if (requestId >= 0) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Tile.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Tile.java index 8b5c98cfc9..5f7f62aadc 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Tile.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/Tile.java @@ -241,7 +241,6 @@ public Tile(TileTexturizer texturizer, Tile parent, Sector sector, boolean merca public void dispose() { // prune(NULL, NULL); - if (_debugMesh != null) _debugMesh.dispose(); _debugMesh = null; @@ -728,7 +727,9 @@ public final ElevationData createElevationDataSubviewFromAncestor(Tile ancestor) if ((_lastElevationDataProvider != null) && (_lastTileMeshResolutionX > 0) && (_lastTileMeshResolutionY > 0)) { - return new DecimatedSubviewElevationData(ed, _sector, new Vector2I(_lastTileMeshResolutionX, _lastTileMeshResolutionY)); + + //return ed; + return new InterpolatedSubviewElevationData(ed, _sector, new Vector2I(_lastTileMeshResolutionX, _lastTileMeshResolutionY)); } ILogger.instance().logError("Can't create subview of elevation data from ancestor"); @@ -809,7 +810,6 @@ public final Mesh getTessellatorMesh(G3MRenderContext rc, PlanetRenderContext pr if ((_tessellatorMesh == null) || _mustActualizeMeshDueToNewElevationData) { _mustActualizeMeshDueToNewElevationData = false; - _planetRenderer.onTileHasChangedMesh(this); if (_debugMesh != null) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/TileElevationDataRequest.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/TileElevationDataRequest.java index 2b1423b5cb..33b2c9cdf0 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/TileElevationDataRequest.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/TileElevationDataRequest.java @@ -45,7 +45,9 @@ public final void onCancel(Sector sector, Vector2I resolution) public final void sendRequest() { _listener = new TileElevationDataRequestListener(this); - _requestID = _provider.requestElevationData(_tile._sector, _resolution, _listener, true); +//C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: +//#warning chano_changed_behaviour: Ahora se llama siempre a la nueva versión de request.En la versión piramidal cargará tiles por lrc.En el resto se llamará indirectamente a la antigua versión de request. + _requestID = _provider.requestElevationData(_tile._sector, _tile._level, _tile._row, _tile._column, _resolution, _listener, true); } public final void cancelRequest() diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/WMSBilElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/WMSBilElevationDataProvider.java index 30ec1e3890..e21fccf919 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/WMSBilElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/WMSBilElevationDataProvider.java @@ -20,7 +20,7 @@ //class IDownloader; -public class WMSBilElevationDataProvider extends ElevationDataProvider +public abstract class WMSBilElevationDataProvider extends ElevationDataProvider { private IDownloader _downloader; private URL _url = new URL(); From db17f6d5cc7bc2cdbbf300a1572b40cfd7ff8bb3 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Fri, 4 Mar 2016 15:13:12 +0000 Subject: [PATCH 05/70] changing pyramid classes --- .../G3MiOSDemo.xcodeproj/project.pbxproj | 4 +- iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm | 16 +++++++- .../G3MiOSSDK.xcodeproj/project.pbxproj | 32 ++++++++-------- ...er.mm => PyramidElevationDataProvider.cpp} | 27 ++++++++------ .../PyramidElevationDataProvider.hpp | 8 ++-- ...onDataProvider_BufferDownloadListener.cpp} | 37 +++++++------------ ...ionDataProvider_BufferDownloadListener.hpp | 13 +++---- 7 files changed, 71 insertions(+), 66 deletions(-) rename iOS/G3MiOSSDK/{PyramidElevationDataProvider.mm => PyramidElevationDataProvider.cpp} (89%) rename iOS/G3MiOSSDK/{PyramidElevationDataProvider_BufferDownloadListener.mm => PyramidElevationDataProvider_BufferDownloadListener.cpp} (80%) diff --git a/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj b/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj index ab2423f2ed..9ac1011857 100644 --- a/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj +++ b/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj @@ -406,7 +406,7 @@ LastUpgradeCheck = 0700; TargetAttributes = { D8EEF3851577920A003FEB5E = { - DevelopmentTeam = N847RXR927; + DevelopmentTeam = CTLLY45L74; }; }; }; @@ -659,6 +659,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_BITCODE = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Glob3iOSDemo/G3MiOSDemo-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -688,6 +689,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_BITCODE = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Glob3iOSDemo/G3MiOSDemo-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = C_CODE; diff --git a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm index ca6a388404..d560211a0e 100644 --- a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm +++ b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm @@ -345,8 +345,20 @@ -(void) initWithPyramidElevations //builder.getPlanetRendererBuilder()->setIncrementalTileQuality(true); builder.getPlanetRendererBuilder()->setRenderDebug(true); builder.getPlanetRendererBuilder()->setVerticalExaggeration(2.0f); - std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fix-16/"; - PyramidElevationDataProvider *edp = new PyramidElevationDataProvider(server,Sector::fullSphere(),true,false); + + //Tamaño fijo, 16x16 + //std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fix-16/"; + //Tamaño variable, 2 a 16 + //std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/var-16/"; + //Europa, fijo, 16 + //std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fix-euro-16/"; + //Europa, variable, 2 a 16 + std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/var-euro-16/"; + //Tierra + //Sector sector = Sector::fullSphere(); + //Solo Europa continental + Sector sector = Sector::fromDegrees(34,-10,72,50); + PyramidElevationDataProvider *edp = new PyramidElevationDataProvider(server,sector,true); builder.getPlanetRendererBuilder()->setElevationDataProvider(edp); bool showPrimarySectors = false; diff --git a/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj b/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj index ac32a232f9..b76bb5fbf7 100644 --- a/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj +++ b/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj @@ -467,10 +467,10 @@ CFFAFD73169F2E3000BCE129 /* TextUtils_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFFAFD71169F2E3000BCE129 /* TextUtils_iOS.mm */; }; CFFEC12315C2EA5F003FA986 /* Downloader_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFFEC12215C2EA5F003FA986 /* Downloader_iOS.mm */; }; CFFEC12615C2EBA6003FA986 /* URL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CFFEC12515C2EBA6003FA986 /* URL.cpp */; }; - D0E1E2341C75CECA00C37DA0 /* PyramidElevationDataProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = D0E1E22C1C75C16300C37DA0 /* PyramidElevationDataProvider.mm */; }; - D0E1E2351C75CECA00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = D0E1E22F1C75C7C100C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm */; }; - D0E1E2391C75D04600C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0E1E2311C75C80F00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */; }; - D0E1E23A1C75D04600C37DA0 /* PyramidElevationDataProvider.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0E1E2321C75CD6F00C37DA0 /* PyramidElevationDataProvider.hpp */; }; + D0D4E56C1C89BFC800B87B11 /* PyramidElevationDataProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0D4E56A1C89BFC800B87B11 /* PyramidElevationDataProvider.cpp */; }; + D0D4E56F1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0D4E56D1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.cpp */; }; + D0D4E5701C89C9CE00B87B11 /* PyramidElevationDataProvider.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0D4E56B1C89BFC800B87B11 /* PyramidElevationDataProvider.hpp */; }; + D0D4E5711C89C9DD00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0D4E56E1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */; }; D8019FF01C11D91800784287 /* TileLODTester.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D8019FEE1C11D91800784287 /* TileLODTester.cpp */; }; D8019FF21C11DFCF00784287 /* TileLODTester.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8019FEF1C11D91800784287 /* TileLODTester.hpp */; }; D80270BE17B3AADF0029F0BE /* CameraDoubleDragHandler.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = FBBDBCDD17AB983200077004 /* CameraDoubleDragHandler.hpp */; }; @@ -766,8 +766,8 @@ dstPath = "include/${PRODUCT_NAME}"; dstSubfolderSpec = 16; files = ( - D0E1E2391C75D04600C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */, - D0E1E23A1C75D04600C37DA0 /* PyramidElevationDataProvider.hpp in CopyFiles */, + D0D4E5711C89C9DD00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */, + D0D4E5701C89C9CE00B87B11 /* PyramidElevationDataProvider.hpp in CopyFiles */, CFE50D251C6669160002EFD5 /* GradualSplitsTileLODTester.hpp in CopyFiles */, CFE50D261C6669160002EFD5 /* PlanetRenderContext.hpp in CopyFiles */, CF75396B1C5C0501006CE697 /* OrTileLODTester.hpp in CopyFiles */, @@ -1759,10 +1759,10 @@ CFFEC12215C2EA5F003FA986 /* Downloader_iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Downloader_iOS.mm; path = Specific/Derived/Downloader_iOS.mm; sourceTree = ""; }; CFFEC12415C2EB96003FA986 /* URL.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = URL.hpp; path = Commons/Basic/URL.hpp; sourceTree = ""; }; CFFEC12515C2EBA6003FA986 /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = URL.cpp; path = Commons/Basic/URL.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; - D0E1E22C1C75C16300C37DA0 /* PyramidElevationDataProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PyramidElevationDataProvider.mm; sourceTree = ""; }; - D0E1E22F1C75C7C100C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PyramidElevationDataProvider_BufferDownloadListener.mm; sourceTree = ""; }; - D0E1E2311C75C80F00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PyramidElevationDataProvider_BufferDownloadListener.hpp; sourceTree = ""; }; - D0E1E2321C75CD6F00C37DA0 /* PyramidElevationDataProvider.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PyramidElevationDataProvider.hpp; sourceTree = ""; }; + D0D4E56A1C89BFC800B87B11 /* PyramidElevationDataProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PyramidElevationDataProvider.cpp; sourceTree = ""; }; + D0D4E56B1C89BFC800B87B11 /* PyramidElevationDataProvider.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PyramidElevationDataProvider.hpp; sourceTree = ""; }; + D0D4E56D1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PyramidElevationDataProvider_BufferDownloadListener.cpp; sourceTree = ""; }; + D0D4E56E1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PyramidElevationDataProvider_BufferDownloadListener.hpp; sourceTree = ""; }; D8019FEE1C11D91800784287 /* TileLODTester.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = TileLODTester.cpp; path = Commons/Rendererers/TileLODTester.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; D8019FEF1C11D91800784287 /* TileLODTester.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = TileLODTester.hpp; path = Commons/Rendererers/TileLODTester.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; D802448B177B314800F58D0D /* TransformedTexCoorTexturedMesh.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = TransformedTexCoorTexturedMesh.fsh; sourceTree = ""; }; @@ -2049,10 +2049,6 @@ CF4027D11770DD5C00D5A80C /* WebSocket_iOS.hpp */, CF4F78481804ADFC00550409 /* DeviceInfo_iOS.mm */, CF4F78491804ADFC00550409 /* DeviceInfo_iOS.hpp */, - D0E1E22C1C75C16300C37DA0 /* PyramidElevationDataProvider.mm */, - D0E1E22F1C75C7C100C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm */, - D0E1E2311C75C80F00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */, - D0E1E2321C75CD6F00C37DA0 /* PyramidElevationDataProvider.hpp */, ); name = Derived; sourceTree = ""; @@ -2286,6 +2282,10 @@ CF75A9FB1B87E2750033DA25 /* MapBoo.hpp */, CF36233E1B97AFA400824932 /* CircleImageBuilder.cpp */, CF36233F1B97AFA400824932 /* CircleImageBuilder.hpp */, + D0D4E56A1C89BFC800B87B11 /* PyramidElevationDataProvider.cpp */, + D0D4E56B1C89BFC800B87B11 /* PyramidElevationDataProvider.hpp */, + D0D4E56D1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.cpp */, + D0D4E56E1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */, ); name = Basic; sourceTree = ""; @@ -3027,8 +3027,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D0E1E2341C75CECA00C37DA0 /* PyramidElevationDataProvider.mm in Sources */, - D0E1E2351C75CECA00C37DA0 /* PyramidElevationDataProvider_BufferDownloadListener.mm in Sources */, CCF45F551743AE620037CA28 /* SphericalPlanet.cpp in Sources */, CF67D9C31C5A90BB00873661 /* TileVisibilityTester.cpp in Sources */, 383BD37D1577EDC00012AC53 /* Logger_iOS.mm in Sources */, @@ -3326,6 +3324,7 @@ CF4027CF1770DCB400D5A80C /* IWebSocket.cpp in Sources */, CF4027D21770DD5C00D5A80C /* WebSocket_iOS.mm in Sources */, CF4027DD1770E7B900D5A80C /* base64.c in Sources */, + D0D4E56F1C89C1BC00B87B11 /* PyramidElevationDataProvider_BufferDownloadListener.cpp in Sources */, CF4027DE1770E7B900D5A80C /* NSData+SRB64Additions.m in Sources */, CF4027DF1770E7B900D5A80C /* SRWebSocket.m in Sources */, CF60500317724C5C00EB48A6 /* JSONNull.cpp in Sources */, @@ -3343,6 +3342,7 @@ 4436A82018ED518100CB6792 /* ChangedInfoListener.cpp in Sources */, 349B218A19615EBA00F3397C /* GEORectangleRasterSymbol.cpp in Sources */, FBBDBCDC17AB940C00077004 /* FlatPlanet.cpp in Sources */, + D0D4E56C1C89BFC800B87B11 /* PyramidElevationDataProvider.cpp in Sources */, CF5C1195178C76F2000ED715 /* BoundingArea.cpp in Sources */, CFCBA3BE1906F3C200FD2A2F /* RasterLayer.cpp in Sources */, CF5C1199178C7E33000ED715 /* GEOGeometry2D.cpp in Sources */, diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm b/iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp similarity index 89% rename from iOS/G3MiOSSDK/PyramidElevationDataProvider.mm rename to iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp index 4cd53d48dd..fea89e28a0 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp @@ -1,17 +1,15 @@ // -// PyramidElevationDataProvider.m +// PyramidElevationDataProvider.cpp // G3MiOSSDK // -// Created by Sebastian Ortega Trujillo on 18/2/16. +// Created by Sebastian Ortega Trujillo on 4/3/16. // // -#import - #import "PyramidElevationDataProvider.hpp" #include "PyramidElevationDataProvider_BufferDownloadListener.hpp" +#include "IJSONParser.hpp" #include "DownloadPriority.hpp" -#include "JSONParser_iOS.hpp" #include "JSONObject.hpp" #include "JSONInteger.hpp" #include "JSONDouble.hpp" @@ -28,9 +26,10 @@ void onDownload(const URL& url, IByteBuffer* buffer, bool expired) { - JSONParser_iOS *parser = new JSONParser_iOS(); - const JSONArray *array = parser->parse(buffer->getAsString(), true)->asArray(); - delete parser; + const std::string str = buffer->getAsString(); + + IJSONParser* parser = IJSONParser::instance(); + const JSONArray* array = parser->parse(str)->asObject()->getAsArray("sectors"); for (unsigned int i=0; isize(); i++){ _itself->push_back(PyramidComposition(getLowerLat(array,i),getLowerLon(array,i),getUpperLat(array,i),getUpperLon(array,i),getLevel(array,i))); @@ -45,6 +44,7 @@ void onCanceledDownload(const URL& url, private: std::vector* _itself; + const G3MContext *_context; double getUpperLat(const JSONArray *array, int index){ JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lat"); @@ -72,20 +72,22 @@ int getLevel(const JSONArray *array,int index){ } }; -PyramidElevationDataProvider::PyramidElevationDataProvider(const std::string &layer, const Sector& sector, bool isMercator, bool variableSized, double deltaHeight): _sector(sector), _layer(layer){ +PyramidElevationDataProvider::PyramidElevationDataProvider(const std::string &layer, const Sector& sector, + bool isMercator,double deltaHeight): _sector(sector), _layer(layer){ _pyrComposition = new std::vector(); _deltaHeight = deltaHeight; _isMercator = isMercator; - _variableSized = variableSized; } PyramidElevationDataProvider::~PyramidElevationDataProvider(){ _pyrComposition->clear(); delete _pyrComposition; _pyrComposition = NULL; + } void PyramidElevationDataProvider::getMetadata() const{ + _downloader->requestBuffer(URL(requestMetadataPath(),false), DownloadPriority::HIGHER, TimeInterval::fromDays(30), true, new MetadataListener(_pyrComposition), true); } @@ -107,7 +109,7 @@ int getLevel(const JSONArray *array,int index){ std::string path = requestStringPath(_layer,level,row,column); - return _downloader->requestBuffer(URL(path,false), DownloadPriority::HIGHEST - level, TimeInterval::fromDays(30), true, new PyramidElevationDataProvider_BufferDownloadListener(sector, extent,_variableSized, listener, autodeleteListener, _deltaHeight), true ); + return _downloader->requestBuffer(URL(path,false), DownloadPriority::HIGHEST - level, TimeInterval::fromDays(30), true, new PyramidElevationDataProvider_BufferDownloadListener(sector, extent, listener, autodeleteListener, _deltaHeight), true ); } std::string PyramidElevationDataProvider::requestStringPath(const Sector §or, const Vector2I &extent){ @@ -125,7 +127,7 @@ int getLevel(const JSONArray *array,int index){ } std::string PyramidElevationDataProvider::requestMetadataPath() const{ - return _layer + "/meta.json"; + return _layer + "meta.json"; } void PyramidElevationDataProvider::cancelRequest(const long long requestId){ @@ -154,3 +156,4 @@ int getLevel(const JSONArray *array,int index){ } + diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp b/iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp index d23b47abea..cdf5dcefd8 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider.hpp @@ -1,8 +1,8 @@ // -// PyramidElevationDataProvider.h +// PyramidElevationDataProvider.hpp // G3MiOSSDK // -// Created by Sebastian Ortega Trujillo on 18/2/16. +// Created by Sebastian Ortega Trujillo on 4/3/16. // // @@ -20,7 +20,7 @@ class PyramidElevationDataProvider : public ElevationDataProvider { IDownloader * _downloader; const Sector _sector; double _deltaHeight; - bool _isMercator, _variableSized; + bool _isMercator; const std::string _layer; class MetadataListener; @@ -54,7 +54,7 @@ class PyramidElevationDataProvider : public ElevationDataProvider { bool aboveLevel(const Sector §or, int level); public: - PyramidElevationDataProvider(const std::string &layer, const Sector& sector, bool isMercator, bool variableSized, double deltaHeight = 0); + PyramidElevationDataProvider(const std::string &layer, const Sector& sector, bool isMercator, double deltaHeight = 0); ~PyramidElevationDataProvider(); diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.cpp similarity index 80% rename from iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm rename to iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.cpp index cdd4f70e92..f77b29137a 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.mm +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.cpp @@ -1,45 +1,34 @@ // -// PyramidElevationDataProvider_BufferDownloadListener.m +// PyramidElevationDataProvider_BufferDownloadListener.cpp // G3MiOSSDK // -// Created by Sebastian Ortega Trujillo on 18/2/16. +// Created by Sebastian Ortega Trujillo on 4/3/16. // // -#import #import "PyramidElevationDataProvider_BufferDownloadListener.hpp" -#include "JSONParser_iOS.hpp" +#include "G3MContext.hpp" +#include "IJSONParser.hpp" #include "JSONArray.hpp" PyramidElevationDataProvider_BufferDownloadListener::PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, - const Vector2I& extent, - bool variableSized, - IElevationDataListener *listener, - bool autodeleteListener, - double deltaHeight) : _sector(sector){ - //_sector = Sector(sector); + const Vector2I& extent, + IElevationDataListener *listener, + bool autodeleteListener, + double deltaHeight) : _sector(sector){ _width = extent._x; _height = extent._y; _listener = listener; _autodeleteListener = autodeleteListener; _deltaHeight = deltaHeight; - _variableSized = variableSized; } void PyramidElevationDataProvider_BufferDownloadListener::onDownload(const URL& url,IByteBuffer* buffer,bool expired){ - //Vector2I *resolution = NULL; ShortBufferElevationData *elevationData; - /*if (!_variableSized) { - resolution = new Vector2I(8, 8); - elevationData = BilParser::parseBil16MaxMin(_sector, *resolution, buffer, _deltaHeight); - } - else { - elevationData = BilParser::parseBil16Redim(_sector, buffer, _deltaHeight); - resolution = new Vector2I(elevationData->getExtent()); - }*/ + std::string contents = buffer->getAsString(); - const JSONObject *jsonContent = JSONParser_iOS::instance()->parse(contents)->asObject(); + const JSONObject *jsonContent = IJSONParser::instance()->parse(contents)->asObject(); const Vector2I *resolution = getResolution(jsonContent); elevationData = getElevationData(_sector, *resolution, jsonContent, _deltaHeight); @@ -86,8 +75,8 @@ } void PyramidElevationDataProvider_BufferDownloadListener::onCanceledDownload(const URL& url, - IByteBuffer* data, - bool expired){ + IByteBuffer* data, + bool expired){ if (_autodeleteListener) { if (_listener != NULL) delete _listener; @@ -130,4 +119,4 @@ return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, size, deltaHeight,max,min,children,similarity); -} +} \ No newline at end of file diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp index e4a5148e97..2130130485 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider_BufferDownloadListener.hpp @@ -2,7 +2,7 @@ // PyramidElevationDataProvider_BufferDownloadListener.hpp // G3MiOSSDK // -// Created by Sebastian Ortega Trujillo on 18/2/16. +// Created by Sebastian Ortega Trujillo on 4/3/16. // // @@ -25,7 +25,7 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo IElevationDataListener *_listener; bool _autodeleteListener; double _deltaHeight; - bool _variableSized; + G3MContext *_context; const Vector2I* getResolution(const JSONObject *data); ShortBufferElevationData* getElevationData(Sector sector, @@ -35,11 +35,10 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo public: PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, - const Vector2I& extent, - bool variableSized, - IElevationDataListener *listener, - bool autodeleteListener, - double deltaHeight); + const Vector2I& extent, + IElevationDataListener *listener, + bool autodeleteListener, + double deltaHeight); void onDownload(const URL& url, IByteBuffer* buffer, From a49e9a7c48a05cd8d615c512b7eeebc7dbab76fc Mon Sep 17 00:00:00 2001 From: amazingsmash Date: Fri, 4 Mar 2016 16:14:40 +0100 Subject: [PATCH 06/70] minor change on PyramidElevationDataProvider --- .../G3MiOSDemo.xcodeproj/project.pbxproj | 4 +- iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm | 2 +- iOS/G3MiOSSDK/PyramidElevationDataProvider.mm | 175 +++++++++--------- 3 files changed, 94 insertions(+), 87 deletions(-) diff --git a/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj b/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj index ab2423f2ed..9ac1011857 100644 --- a/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj +++ b/iOS/G3MiOSDemo/G3MiOSDemo.xcodeproj/project.pbxproj @@ -406,7 +406,7 @@ LastUpgradeCheck = 0700; TargetAttributes = { D8EEF3851577920A003FEB5E = { - DevelopmentTeam = N847RXR927; + DevelopmentTeam = CTLLY45L74; }; }; }; @@ -659,6 +659,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_BITCODE = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Glob3iOSDemo/G3MiOSDemo-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -688,6 +689,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_BITCODE = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Glob3iOSDemo/G3MiOSDemo-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = C_CODE; diff --git a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm index ca6a388404..22b0677f73 100644 --- a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm +++ b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm @@ -345,7 +345,7 @@ -(void) initWithPyramidElevations //builder.getPlanetRendererBuilder()->setIncrementalTileQuality(true); builder.getPlanetRendererBuilder()->setRenderDebug(true); builder.getPlanetRendererBuilder()->setVerticalExaggeration(2.0f); - std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fix-16/"; + std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fusion"; PyramidElevationDataProvider *edp = new PyramidElevationDataProvider(server,Sector::fullSphere(),true,false); builder.getPlanetRendererBuilder()->setElevationDataProvider(edp); diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm b/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm index 4cd53d48dd..72d7158e98 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider.mm @@ -19,138 +19,143 @@ #include "G3MContext.hpp" #include "TimeInterval.hpp" #include +#include "ErrorHandling.hpp" class PyramidElevationDataProvider::MetadataListener : public IBufferDownloadListener { public: - MetadataListener(std::vector* itself): _itself(itself) {} + MetadataListener(std::vector* itself): _itself(itself) {} + + void onDownload(const URL& url, + IByteBuffer* buffer, + bool expired) { - void onDownload(const URL& url, - IByteBuffer* buffer, - bool expired) { - - JSONParser_iOS *parser = new JSONParser_iOS(); - const JSONArray *array = parser->parse(buffer->getAsString(), true)->asArray(); - delete parser; - - for (unsigned int i=0; isize(); i++){ - _itself->push_back(PyramidComposition(getLowerLat(array,i),getLowerLon(array,i),getUpperLat(array,i),getUpperLon(array,i),getLevel(array,i))); - } + JSONParser_iOS *parser = new JSONParser_iOS(); + const JSONArray *array = parser->parse(buffer->getAsString(), true)->asArray(); + if (array == NULL){ + THROW_EXCEPTION("Problem parsing JSON on PyramidElevationDataProvider::MetadataListener::onDownload()"); } - void onError(const URL& url) {} - void onCancel(const URL& url) {} - void onCanceledDownload(const URL& url, - IByteBuffer* data, - bool expired) {} + delete parser; -private: - std::vector* _itself; - - double getUpperLat(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lat"); - return doble->value(); - } - - double getLowerLat(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lat"); - return doble->value(); - } - - double getUpperLon(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lon"); - return doble->value(); - } - - double getLowerLon(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*)array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lon"); - return doble->value(); - } - - int getLevel(const JSONArray *array,int index){ - JSONInteger *integer = (JSONInteger *) array->getAsObject(index)->getAsNumber("pyrLevel"); - return integer->intValue(); + for (unsigned int i=0; isize(); i++){ + _itself->push_back(PyramidComposition(getLowerLat(array,i),getLowerLon(array,i),getUpperLat(array,i),getUpperLon(array,i),getLevel(array,i))); } + } + void onError(const URL& url) {} + void onCancel(const URL& url) {} + + void onCanceledDownload(const URL& url, + IByteBuffer* data, + bool expired) {} + +private: + std::vector* _itself; + + double getUpperLat(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lat"); + return doble->value(); + } + + double getLowerLat(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lat"); + return doble->value(); + } + + double getUpperLon(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lon"); + return doble->value(); + } + + double getLowerLon(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*)array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lon"); + return doble->value(); + } + + int getLevel(const JSONArray *array,int index){ + JSONInteger *integer = (JSONInteger *) array->getAsObject(index)->getAsNumber("pyrLevel"); + return integer->intValue(); + } }; PyramidElevationDataProvider::PyramidElevationDataProvider(const std::string &layer, const Sector& sector, bool isMercator, bool variableSized, double deltaHeight): _sector(sector), _layer(layer){ - _pyrComposition = new std::vector(); - _deltaHeight = deltaHeight; - _isMercator = isMercator; - _variableSized = variableSized; + _pyrComposition = new std::vector(); + _deltaHeight = deltaHeight; + _isMercator = isMercator; + _variableSized = variableSized; } PyramidElevationDataProvider::~PyramidElevationDataProvider(){ - _pyrComposition->clear(); - delete _pyrComposition; - _pyrComposition = NULL; + _pyrComposition->clear(); + delete _pyrComposition; + _pyrComposition = NULL; } void PyramidElevationDataProvider::getMetadata() const{ - _downloader->requestBuffer(URL(requestMetadataPath(),false), DownloadPriority::HIGHER, TimeInterval::fromDays(30), true, new MetadataListener(_pyrComposition), true); + _downloader->requestBuffer(URL(requestMetadataPath(),false), DownloadPriority::HIGHER, TimeInterval::fromDays(30), true, new MetadataListener(_pyrComposition), true); } void PyramidElevationDataProvider::initialize(const G3MContext* context ){ - _downloader = context->getDownloader(); - getMetadata(); + _downloader = context->getDownloader(); + getMetadata(); } const long long PyramidElevationDataProvider::requestElevationData(const Sector §or, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener){ - //This requester is not necessary, but we are forced to implement it, so -1. - return -1; + //This requester is not necessary, but we are forced to implement it, so -1. + return -1; } const long long PyramidElevationDataProvider::requestElevationData(const Sector §or, int level, int row, int column, const Vector2I &extent, IElevationDataListener *listener, bool autodeleteListener){ - - if ((_downloader == NULL) || (aboveLevel(sector, level))){ - return -1; - } - - std::string path = requestStringPath(_layer,level,row,column); - - return _downloader->requestBuffer(URL(path,false), DownloadPriority::HIGHEST - level, TimeInterval::fromDays(30), true, new PyramidElevationDataProvider_BufferDownloadListener(sector, extent,_variableSized, listener, autodeleteListener, _deltaHeight), true ); + + if ((_downloader == NULL) || (aboveLevel(sector, level))){ + return -1; + } + + std::string path = requestStringPath(_layer,level,row,column); + + return _downloader->requestBuffer(URL(path,false), DownloadPriority::HIGHEST - level, TimeInterval::fromDays(30), true, new PyramidElevationDataProvider_BufferDownloadListener(sector, extent,_variableSized, listener, autodeleteListener, _deltaHeight), true ); } std::string PyramidElevationDataProvider::requestStringPath(const Sector §or, const Vector2I &extent){ - // TODO: Esta en principio no debería usarse, pero ... - ILogger::instance()->logError("BAD STRING PATH REQUESTED!"); - return ""; + // TODO: Esta en principio no debería usarse, pero ... + ILogger::instance()->logError("BAD STRING PATH REQUESTED!"); + return ""; } std::string PyramidElevationDataProvider::requestStringPath(const std::string & layer, int level, int row, int column){ - std::ostringstream strs; - strs << _layer << level << "/" << column << "/" << row << ".json"; //".bil"; - std::string res = strs.str(); - //ILogger::instance()->logInfo(res); - return res; + std::ostringstream strs; + strs << _layer << level << "/" << column << "/" << row << ".json"; //".bil"; + std::string res = strs.str(); + //ILogger::instance()->logInfo(res); + return res; } std::string PyramidElevationDataProvider::requestMetadataPath() const{ - return _layer + "/meta.json"; + return _layer + "/meta.json"; } void PyramidElevationDataProvider::cancelRequest(const long long requestId){ - _downloader->cancelRequest(requestId); + _downloader->cancelRequest(requestId); } std::vector PyramidElevationDataProvider::getSectors() const{ - std::vector sectors; - sectors.push_back(&_sector); - return sectors; + std::vector sectors; + sectors.push_back(&_sector); + return sectors; } const Vector2I PyramidElevationDataProvider::getMinResolution() const{ - // int WORKING_JM; - return Vector2I::zero(); + // int WORKING_JM; + return Vector2I::zero(); } bool PyramidElevationDataProvider::aboveLevel(const Sector §or, int level){ - int maxLevel = 0; - for (unsigned int i=0; i< _pyrComposition->size(); i++) - if (sector.touchesWith(_pyrComposition->at(i).getSector())) - maxLevel = fmax(maxLevel,_pyrComposition->at(i)._pyramidLevel); - - if (level > maxLevel) return true; - else return false; + int maxLevel = 0; + for (unsigned int i=0; i< _pyrComposition->size(); i++) + if (sector.touchesWith(_pyrComposition->at(i).getSector())) + maxLevel = fmax(maxLevel,_pyrComposition->at(i)._pyramidLevel); + + if (level > maxLevel) return true; + else return false; } From 883a42bfa3aa5191867717625e0330f7ed313d4b Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Fri, 4 Mar 2016 15:27:46 +0000 Subject: [PATCH 07/70] Avoiding unnecesary elevation requests --- iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm | 6 +++--- iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm index d560211a0e..e6d325bc60 100644 --- a/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm +++ b/iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm @@ -327,7 +327,7 @@ - (void)viewDidLoad */ //[[self G3MWidget] widget]->setCameraPitch(Angle::fromDegrees(-45)); - [[self G3MWidget] widget]->setCameraPosition(Geodetic3D::fromDegrees(28, -15.6, 500000)); + //[[self G3MWidget] widget]->setCameraPosition(Geodetic3D::fromDegrees(28, -15.6, 500000)); } -(void) initWithPyramidElevations @@ -343,8 +343,8 @@ -(void) initWithPyramidElevations builder.addRenderer(_meshRenderer); builder.getPlanetRendererBuilder()->setLayerSet(layerSet); //builder.getPlanetRendererBuilder()->setIncrementalTileQuality(true); - builder.getPlanetRendererBuilder()->setRenderDebug(true); - builder.getPlanetRendererBuilder()->setVerticalExaggeration(2.0f); + //builder.getPlanetRendererBuilder()->setRenderDebug(true); + builder.getPlanetRendererBuilder()->setVerticalExaggeration(2.0f); //Tamaño fijo, 16x16 //std::string server = "http://193.145.147.50:8080/DemoElevs/elevs/fix-16/"; diff --git a/iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp b/iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp index fea89e28a0..6aa92b0217 100644 --- a/iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp +++ b/iOS/G3MiOSSDK/PyramidElevationDataProvider.cpp @@ -149,10 +149,13 @@ bool PyramidElevationDataProvider::aboveLevel(const Sector §or, int level){ int maxLevel = 0; for (unsigned int i=0; i< _pyrComposition->size(); i++) if (sector.touchesWith(_pyrComposition->at(i).getSector())) - maxLevel = fmax(maxLevel,_pyrComposition->at(i)._pyramidLevel); + maxLevel = IMathUtils::instance()->max(maxLevel,_pyrComposition->at(i)._pyramidLevel); if (level > maxLevel) return true; - else return false; + else { + if (!sector.touchesWith(_sector)) return true; + return false; + } } From e7bc6d4b31fc5369d197f4dba107c076fd18f44b Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Fri, 4 Mar 2016 16:57:28 +0100 Subject: [PATCH 08/70] Generated --- .../mobile/generated/MetadataListener.java | 80 ++++++++++++++++ .../PyramidElevationDataProvider.java | 92 +++++++++++++++++++ ...onDataProvider_BufferDownloadListener.java | 41 +++++++++ 3 files changed, 213 insertions(+) create mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java create mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java create mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java new file mode 100644 index 0000000000..b714b9f417 --- /dev/null +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java @@ -0,0 +1,80 @@ +package org.glob3.mobile.generated; +// +// PyramidElevationDataProvider.cpp +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 4/3/16. +// +// + +//C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: +//#import "PyramidElevationDataProvider.hpp" + +public class MetadataListener extends IBufferDownloadListener +{ + public MetadataListener(java.util.ArrayList itself) + { + _itself = itself; + } + + public final void onDownload(URL url, IByteBuffer buffer, boolean expired) + { + + final String str = buffer.getAsString(); + + IJSONParser parser = IJSONParser.instance(); + final JSONArray array = parser.parse(str).asObject().getAsArray("sectors"); + if (array == null) + { + throw new RuntimeException("Problem parsing at PyramidElevationDataProvider::MetadataListener::onDownload()."); + } + + for (int i = 0; i _itself; + private final G3MContext _context; + + private double getUpperLat(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("upper").getAsNumber("lat"); + return doble.value(); + } + + private double getLowerLat(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("lower").getAsNumber("lat"); + return doble.value(); + } + + private double getUpperLon(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("upper").getAsNumber("lon"); + return doble.value(); + } + + private double getLowerLon(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble)array.getAsObject(index).getAsObject("sector").getAsObject("lower").getAsNumber("lon"); + return doble.value(); + } + + private int getLevel(JSONArray array, int index) + { + JSONInteger integer = (JSONInteger) array.getAsObject(index).getAsNumber("pyrLevel"); + return integer.intValue(); + } +} \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java new file mode 100644 index 0000000000..faf9ae0593 --- /dev/null +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java @@ -0,0 +1,92 @@ +package org.glob3.mobile.generated; +// +// PyramidElevationDataProvider.hpp +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 4/3/16. +// +// + + + +public class PyramidElevationDataProvider extends ElevationDataProvider +{ + private IDownloader _downloader; + private final Sector _sector ; + private double _deltaHeight; + private boolean _isMercator; + private final String _layer; + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following type could not be found. +// class MetadataListener; + + private static class PyramidComposition + { + public double _upperLat; + public double _upperLon; + public double _lowerLat; + public double _lowerLon; + public int _pyramidLevel; + + public PyramidComposition(double lowerLat, double lowerLon, double upperLat, double upperLon, int pyramidLevel) + { + _lowerLat = lowerLat; + _lowerLon = lowerLon; + _upperLat = upperLat; + _upperLon = upperLon; + _pyramidLevel = pyramidLevel; + } + + public final String description() + { + //TODO: implement this better. + return ""; + //return _sector.description() + ", pyramidLevel: "+_pyramidLevel; + } + + public final Sector getSector() + { + return Sector.fromDegrees(_lowerLat, _lowerLon, _upperLat, _upperLon); + } + } + + private java.util.ArrayList _pyrComposition; + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// boolean aboveLevel(Sector sector, int level); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// PyramidElevationDataProvider(String layer, Sector sector, boolean isMercator, double deltaHeight); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// public void dispose() + + public final boolean isReadyToRender (G3MRenderContext rc) + { + return true; + } +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// void getMetadata(); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// void initialize(G3MContext context); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// long requestElevationData(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// long requestElevationData(Sector sector, int level, int row, int column, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// String requestStringPath(Sector sector, Vector2I extent); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// String requestStringPath(String layer, int level, int row, int column); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// String requestMetadataPath(); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// void cancelRequest(long requestId); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// java.util.ArrayList getSectors(); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// Vector2I getMinResolution(); + +} \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java new file mode 100644 index 0000000000..0d75272697 --- /dev/null +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java @@ -0,0 +1,41 @@ +package org.glob3.mobile.generated; +// +// PyramidElevationDataProvider_BufferDownloadListener.hpp +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 4/3/16. +// +// + + + +public class PyramidElevationDataProvider_BufferDownloadListener extends IBufferDownloadListener +{ + + private final Sector _sector; + private int _width; + private int _height; + private IElevationDataListener _listener; + private boolean _autodeleteListener; + private double _deltaHeight; + private G3MContext _context; + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// Vector2I getResolution(JSONObject data); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// ShortBufferElevationData getElevationData(Sector sector, Vector2I extent, JSONObject data, double deltaHeight); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// PyramidElevationDataProvider_BufferDownloadListener(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener, double deltaHeight); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// void onDownload(URL url, IByteBuffer buffer, boolean expired); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// void onError(URL url); +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// void onCancel(URL url); + +//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: +// void onCanceledDownload(URL url, IByteBuffer data, boolean expired); + +} \ No newline at end of file From c23f5140a89b44830beae32eb8450d3e83940e43 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 09:02:59 +0000 Subject: [PATCH 09/70] Changing initialization in Pyramid Listener to help conversion --- ...vationDataProvider_BufferDownloadListener.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp index f77b29137a..d492689730 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp @@ -15,12 +15,14 @@ PyramidElevationDataProvider_BufferDownloadListener::PyramidElevationDataProvide const Vector2I& extent, IElevationDataListener *listener, bool autodeleteListener, - double deltaHeight) : _sector(sector){ - _width = extent._x; - _height = extent._y; - _listener = listener; - _autodeleteListener = autodeleteListener; - _deltaHeight = deltaHeight; + double deltaHeight) : +_sector(sector), +_width(extent._x), +_height(extent._y), +_listener(listener), +_autodeleteListener(autodeleteListener), +_deltaHeight(deltaHeight){ + } void PyramidElevationDataProvider_BufferDownloadListener::onDownload(const URL& url,IByteBuffer* buffer,bool expired){ @@ -119,4 +121,4 @@ ShortBufferElevationData* PyramidElevationDataProvider_BufferDownloadListener::g return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, size, deltaHeight,max,min,children,similarity); -} \ No newline at end of file +} From 5b098ac63e268a0f7f0913f924d3f02395d01fd0 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 09:47:29 +0000 Subject: [PATCH 10/70] Adding virtual to headers --- ...yramidElevationDataProvider_BufferDownloadListener.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp index 2130130485..92f719f6c4 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp @@ -40,13 +40,13 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo bool autodeleteListener, double deltaHeight); - void onDownload(const URL& url, + virtual void onDownload(const URL& url, IByteBuffer* buffer, bool expired); - void onError(const URL& url); - void onCancel(const URL& url); + virtual void onError(const URL& url); + virtual void onCancel(const URL& url); - void onCanceledDownload(const URL& url, + virtual void onCanceledDownload(const URL& url, IByteBuffer* data, bool expired); From 06dcf7cd58ce4b2579d088273c337080768856d6 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Mon, 7 Mar 2016 10:51:16 +0100 Subject: [PATCH 11/70] Generated --- ...ramidElevationDataProvider_BufferDownloadListener.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java index 0d75272697..f28d14ccd2 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java @@ -29,13 +29,13 @@ public class PyramidElevationDataProvider_BufferDownloadListener extends IBuffer // PyramidElevationDataProvider_BufferDownloadListener(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener, double deltaHeight); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onDownload(URL url, IByteBuffer buffer, boolean expired); +// virtual void onDownload(URL url, IByteBuffer buffer, boolean expired); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onError(URL url); +// virtual void onError(URL url); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onCancel(URL url); +// virtual void onCancel(URL url); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onCanceledDownload(URL url, IByteBuffer data, boolean expired); +// virtual void onCanceledDownload(URL url, IByteBuffer data, boolean expired); } \ No newline at end of file From 7a9151a4b2ebd43535e76cc3f852b9bf85441216 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 10:08:10 +0000 Subject: [PATCH 12/70] Reverting last change, adding java_code macros --- ...ElevationDataProvider_BufferDownloadListener.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp index 92f719f6c4..f99b2ab484 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp @@ -27,7 +27,12 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo double _deltaHeight; G3MContext *_context; +#ifdef C_CODE const Vector2I* getResolution(const JSONObject *data); +#endif +#ifdef JAVA_CODE + private Vector2I getResolution(const JSONObject data); +#endif ShortBufferElevationData* getElevationData(Sector sector, Vector2I extent, const JSONObject *data, @@ -40,13 +45,13 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo bool autodeleteListener, double deltaHeight); - virtual void onDownload(const URL& url, + void onDownload(const URL& url, IByteBuffer* buffer, bool expired); - virtual void onError(const URL& url); - virtual void onCancel(const URL& url); + void onError(const URL& url); + void onCancel(const URL& url); - virtual void onCanceledDownload(const URL& url, + void onCanceledDownload(const URL& url, IByteBuffer* data, bool expired); From 9e111dc2edc08ee1d03af0bed8a0ef4df8e26a68 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Mon, 7 Mar 2016 11:14:34 +0100 Subject: [PATCH 13/70] Generated --- ...dElevationDataProvider_BufferDownloadListener.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java index f28d14ccd2..04551f115d 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java @@ -20,8 +20,7 @@ public class PyramidElevationDataProvider_BufferDownloadListener extends IBuffer private double _deltaHeight; private G3MContext _context; -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// Vector2I getResolution(JSONObject data); + private Vector2I getResolution(const JSONObject data); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: // ShortBufferElevationData getElevationData(Sector sector, Vector2I extent, JSONObject data, double deltaHeight); @@ -29,13 +28,13 @@ public class PyramidElevationDataProvider_BufferDownloadListener extends IBuffer // PyramidElevationDataProvider_BufferDownloadListener(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener, double deltaHeight); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// virtual void onDownload(URL url, IByteBuffer buffer, boolean expired); +// void onDownload(URL url, IByteBuffer buffer, boolean expired); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// virtual void onError(URL url); +// void onError(URL url); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// virtual void onCancel(URL url); +// void onCancel(URL url); //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// virtual void onCanceledDownload(URL url, IByteBuffer data, boolean expired); +// void onCanceledDownload(URL url, IByteBuffer data, boolean expired); } \ No newline at end of file From 154119c7d6c3a02b1f57ea5b9eb0ff5114995bad Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 11:00:02 +0000 Subject: [PATCH 14/70] replacing classes --- .../mobile/generated/MetadataListener.java | 80 -------- .../PyramidElevationDataProvider.java | 3 +- ...onDataProvider_BufferDownloadListener.java | 40 ---- .../Basic/PyramidElevationDataProvider.cpp | 192 +++++++++++++----- .../Basic/PyramidElevationDataProvider.hpp | 69 ++++++- ...ionDataProvider_BufferDownloadListener.cpp | 124 ----------- ...ionDataProvider_BufferDownloadListener.hpp | 60 ------ .../G3MiOSSDK.xcodeproj/project.pbxproj | 8 - 8 files changed, 203 insertions(+), 373 deletions(-) delete mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java delete mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java delete mode 100644 iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp delete mode 100644 iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java deleted file mode 100644 index b714b9f417..0000000000 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/MetadataListener.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.glob3.mobile.generated; -// -// PyramidElevationDataProvider.cpp -// G3MiOSSDK -// -// Created by Sebastian Ortega Trujillo on 4/3/16. -// -// - -//C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: -//#import "PyramidElevationDataProvider.hpp" - -public class MetadataListener extends IBufferDownloadListener -{ - public MetadataListener(java.util.ArrayList itself) - { - _itself = itself; - } - - public final void onDownload(URL url, IByteBuffer buffer, boolean expired) - { - - final String str = buffer.getAsString(); - - IJSONParser parser = IJSONParser.instance(); - final JSONArray array = parser.parse(str).asObject().getAsArray("sectors"); - if (array == null) - { - throw new RuntimeException("Problem parsing at PyramidElevationDataProvider::MetadataListener::onDownload()."); - } - - for (int i = 0; i _itself; - private final G3MContext _context; - - private double getUpperLat(JSONArray array, int index) - { - JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("upper").getAsNumber("lat"); - return doble.value(); - } - - private double getLowerLat(JSONArray array, int index) - { - JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("lower").getAsNumber("lat"); - return doble.value(); - } - - private double getUpperLon(JSONArray array, int index) - { - JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("upper").getAsNumber("lon"); - return doble.value(); - } - - private double getLowerLon(JSONArray array, int index) - { - JSONDouble doble = (JSONDouble)array.getAsObject(index).getAsObject("sector").getAsObject("lower").getAsNumber("lon"); - return doble.value(); - } - - private int getLevel(JSONArray array, int index) - { - JSONInteger integer = (JSONInteger) array.getAsObject(index).getAsNumber("pyrLevel"); - return integer.intValue(); - } -} \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java index faf9ae0593..a7b3bd0e59 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java @@ -17,8 +17,7 @@ public class PyramidElevationDataProvider extends ElevationDataProvider private boolean _isMercator; private final String _layer; -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following type could not be found. -// class MetadataListener; + private static class PyramidComposition { diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java deleted file mode 100644 index 04551f115d..0000000000 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.glob3.mobile.generated; -// -// PyramidElevationDataProvider_BufferDownloadListener.hpp -// G3MiOSSDK -// -// Created by Sebastian Ortega Trujillo on 4/3/16. -// -// - - - -public class PyramidElevationDataProvider_BufferDownloadListener extends IBufferDownloadListener -{ - - private final Sector _sector; - private int _width; - private int _height; - private IElevationDataListener _listener; - private boolean _autodeleteListener; - private double _deltaHeight; - private G3MContext _context; - - private Vector2I getResolution(const JSONObject data); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// ShortBufferElevationData getElevationData(Sector sector, Vector2I extent, JSONObject data, double deltaHeight); - -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// PyramidElevationDataProvider_BufferDownloadListener(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener, double deltaHeight); - -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onDownload(URL url, IByteBuffer buffer, boolean expired); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onError(URL url); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onCancel(URL url); - -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void onCanceledDownload(URL url, IByteBuffer data, boolean expired); - -} \ No newline at end of file diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp index ae0eede3d4..4941b62a34 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp @@ -7,75 +7,155 @@ // #import "PyramidElevationDataProvider.hpp" -#include "PyramidElevationDataProvider_BufferDownloadListener.hpp" -#include "IJSONParser.hpp" +#include "ShortBufferElevationData.hpp" + #include "DownloadPriority.hpp" -#include "JSONObject.hpp" -#include "JSONInteger.hpp" -#include "JSONDouble.hpp" -#include "JSONArray.hpp" #include "G3MContext.hpp" #include "TimeInterval.hpp" #include -#include "ErrorHandling.hpp" -class PyramidElevationDataProvider::MetadataListener : public IBufferDownloadListener { + +class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownloadListener { +private: + + const Sector &_sector; + int _width, _height; + IElevationDataListener *_listener; + bool _autodeleteListener; + double _deltaHeight; + G3MContext *_context; + +#ifdef C_CODE + const Vector2I* getResolution(const JSONObject *data){ + return new Vector2I((int) data->getAsNumber("width",0),(int) data->getAsNumber("height",0)); + } +#endif +#ifdef JAVA_CODE + private Vector2I getResolution(const JSONObject data){ + return new Vector2I((int) data.getAsNumber("width",0),(int) data.getAsNumber("height",0)); + } +#endif + + ShortBufferElevationData* getElevationData(Sector sector, + Vector2I extent, + const JSONObject *data, + double deltaHeight){ + const short minValue = IMathUtils::instance()->minInt16(); + const int size = extent._x * extent._y; + const JSONArray *dataArray = data->getAsArray("data"); + short *shortBuffer = new short[size]; + for (int i = 0; i < size; i++) + { + short height = (short) dataArray->getAsNumber(i, minValue); + + if (height == 15000) //Our own NODATA, since -9999 is a valid height. + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + else if (height == minValue) + { + height = ShortBufferElevationData::NO_DATA_VALUE; + } + + shortBuffer[i] = height; + } + + short max = (short) data->getAsNumber("max",IMathUtils::instance()->minInt16()); + short min = (short) data->getAsNumber("min",IMathUtils::instance()->maxInt16()); + short children = (short) data->getAsNumber("withChildren",0); + short similarity = (short) data->getAsNumber("similarity",0); + + return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, + size, deltaHeight,max,min,children,similarity); + } + public: - MetadataListener(std::vector* itself): _itself(itself) {} - - void onDownload(const URL& url, - IByteBuffer* buffer, - bool expired) { + PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, + const Vector2I& extent, + IElevationDataListener *listener, + bool autodeleteListener, + double deltaHeight): + _sector(sector), + _width(extent._x), + _height(extent._y), + _listener(listener), + _autodeleteListener(autodeleteListener), + _deltaHeight(deltaHeight){ + + } - const std::string str = buffer->getAsString(); + void onDownload(const URL& url, + IByteBuffer* buffer, + bool expired){ + + ShortBufferElevationData *elevationData; + + std::string contents = buffer->getAsString(); + const JSONObject *jsonContent = IJSONParser::instance()->parse(contents)->asObject(); + const Vector2I *resolution = getResolution(jsonContent); + elevationData = getElevationData(_sector, *resolution, jsonContent, _deltaHeight); + + if (buffer != NULL) delete buffer; + + if (elevationData == NULL) + { + _listener->onError(_sector, *resolution); + } + else + { + _listener->onData(_sector, *resolution, elevationData); + //elevationData->_release(); + } + + + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } + } - IJSONParser* parser = IJSONParser::instance(); - const JSONArray* array = parser->parse(str)->asObject()->getAsArray("sectors"); - if (array == NULL){ - THROW_EXCEPTION("Problem parsing at PyramidElevationDataProvider::MetadataListener::onDownload()."); + void onError(const URL& url){ + const Vector2I resolution = Vector2I(_width, _height); + + _listener->onError(_sector, resolution); + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } } + + void onCancel(const URL& url){ + if (_listener != NULL) + { + const Vector2I resolution = Vector2I(_width, _height); + _listener->onCancel(_sector, resolution); + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } + } + } + - for (unsigned int i=0; isize(); i++){ - _itself->push_back(PyramidComposition(getLowerLat(array,i),getLowerLon(array,i),getUpperLat(array,i),getUpperLon(array,i),getLevel(array,i))); + void onCanceledDownload(const URL& url, + IByteBuffer* data, + bool expired){ + if (_autodeleteListener) + { + if (_listener != NULL) delete _listener; + _listener = NULL; + } } - } - void onError(const URL& url) {} - void onCancel(const URL& url) {} - - void onCanceledDownload(const URL& url, - IByteBuffer* data, - bool expired) {} - -private: - std::vector* _itself; - const G3MContext *_context; - - double getUpperLat(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lat"); - return doble->value(); - } - - double getLowerLat(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lat"); - return doble->value(); - } - - double getUpperLon(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lon"); - return doble->value(); - } - - double getLowerLon(const JSONArray *array, int index){ - JSONDouble *doble = (JSONDouble*)array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lon"); - return doble->value(); - } - - int getLevel(const JSONArray *array,int index){ - JSONInteger *integer = (JSONInteger *) array->getAsObject(index)->getAsNumber("pyrLevel"); - return integer->intValue(); - } + + }; + + + PyramidElevationDataProvider::PyramidElevationDataProvider(const std::string &layer, const Sector& sector, bool isMercator,double deltaHeight): _sector(sector), _layer(layer){ _pyrComposition = new std::vector(); diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp index cdf5dcefd8..51a526049f 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp @@ -12,8 +12,15 @@ #include #include "ElevationDataProvider.hpp" #include "IDownloader.hpp" +#include "IJSONParser.hpp" #include "Sector.hpp" +#include "JSONArray.hpp" +#include "JSONObject.hpp" +#include "JSONInteger.hpp" +#include "JSONDouble.hpp" #include "URL.hpp" +#include "ErrorHandling.hpp" +#include "IBufferDownloadListener.hpp" class PyramidElevationDataProvider : public ElevationDataProvider { private: @@ -22,9 +29,7 @@ class PyramidElevationDataProvider : public ElevationDataProvider { double _deltaHeight; bool _isMercator; const std::string _layer; - - class MetadataListener; - + class PyramidComposition { public: double _upperLat, _upperLon, _lowerLat, _lowerLon; @@ -49,6 +54,64 @@ class PyramidElevationDataProvider : public ElevationDataProvider { } }; + class MetadataListener : public IBufferDownloadListener { + public: + MetadataListener(std::vector* itself): _itself(itself) {} + + void onDownload(const URL& url, + IByteBuffer* buffer, + bool expired) { + + const std::string str = buffer->getAsString(); + + IJSONParser* parser = IJSONParser::instance(); + const JSONArray* array = parser->parse(str)->asObject()->getAsArray("sectors"); + if (array == NULL){ + THROW_EXCEPTION("Problem parsing at PyramidElevationDataProvider::MetadataListener::onDownload()."); + } + + for (unsigned int i=0; isize(); i++){ + _itself->push_back(PyramidComposition(getLowerLat(array,i),getLowerLon(array,i),getUpperLat(array,i),getUpperLon(array,i),getLevel(array,i))); + } + } + void onError(const URL& url) {} + void onCancel(const URL& url) {} + + void onCanceledDownload(const URL& url, + IByteBuffer* data, + bool expired) {} + + private: + std::vector* _itself; + const G3MContext *_context; + + double getUpperLat(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lat"); + return doble->value(); + } + + double getLowerLat(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lat"); + return doble->value(); + } + + double getUpperLon(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lon"); + return doble->value(); + } + + double getLowerLon(const JSONArray *array, int index){ + JSONDouble *doble = (JSONDouble*)array->getAsObject(index)->getAsObject("sector")->getAsObject("lower")->getAsNumber("lon"); + return doble->value(); + } + + int getLevel(const JSONArray *array,int index){ + JSONInteger *integer = (JSONInteger *) array->getAsObject(index)->getAsNumber("pyrLevel"); + return integer->intValue(); + } + + }; + std::vector *_pyrComposition; bool aboveLevel(const Sector §or, int level); diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp deleted file mode 100644 index d492689730..0000000000 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// -// PyramidElevationDataProvider_BufferDownloadListener.cpp -// G3MiOSSDK -// -// Created by Sebastian Ortega Trujillo on 4/3/16. -// -// - -#import "PyramidElevationDataProvider_BufferDownloadListener.hpp" -#include "G3MContext.hpp" -#include "IJSONParser.hpp" -#include "JSONArray.hpp" - -PyramidElevationDataProvider_BufferDownloadListener::PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, - const Vector2I& extent, - IElevationDataListener *listener, - bool autodeleteListener, - double deltaHeight) : -_sector(sector), -_width(extent._x), -_height(extent._y), -_listener(listener), -_autodeleteListener(autodeleteListener), -_deltaHeight(deltaHeight){ - -} - -void PyramidElevationDataProvider_BufferDownloadListener::onDownload(const URL& url,IByteBuffer* buffer,bool expired){ - - ShortBufferElevationData *elevationData; - - std::string contents = buffer->getAsString(); - const JSONObject *jsonContent = IJSONParser::instance()->parse(contents)->asObject(); - const Vector2I *resolution = getResolution(jsonContent); - elevationData = getElevationData(_sector, *resolution, jsonContent, _deltaHeight); - - if (buffer != NULL) delete buffer; - - if (elevationData == NULL) - { - _listener->onError(_sector, *resolution); - } - else - { - _listener->onData(_sector, *resolution, elevationData); - //elevationData->_release(); - } - - - if (_autodeleteListener) - { - if (_listener != NULL) delete _listener; - _listener = NULL; - } -} -void PyramidElevationDataProvider_BufferDownloadListener::onError(const URL& url){ - const Vector2I resolution = Vector2I(_width, _height); - - _listener->onError(_sector, resolution); - if (_autodeleteListener) - { - if (_listener != NULL) delete _listener; - _listener = NULL; - } -} -void PyramidElevationDataProvider_BufferDownloadListener::onCancel(const URL& url){ - if (_listener != NULL) - { - const Vector2I resolution = Vector2I(_width, _height); - _listener->onCancel(_sector, resolution); - if (_autodeleteListener) - { - if (_listener != NULL) delete _listener; - _listener = NULL; - } - } -} - -void PyramidElevationDataProvider_BufferDownloadListener::onCanceledDownload(const URL& url, - IByteBuffer* data, - bool expired){ - if (_autodeleteListener) - { - if (_listener != NULL) delete _listener; - _listener = NULL; - } -} - -const Vector2I* PyramidElevationDataProvider_BufferDownloadListener::getResolution(const JSONObject *data){ - return new Vector2I((int) data->getAsNumber("width",0),(int) data->getAsNumber("height",0)); -} - -ShortBufferElevationData* PyramidElevationDataProvider_BufferDownloadListener::getElevationData(Sector sector, - Vector2I extent, - const JSONObject *data, - double deltaHeight){ - const short minValue = IMathUtils::instance()->minInt16(); - const int size = extent._x * extent._y; - const JSONArray *dataArray = data->getAsArray("data"); - short *shortBuffer = new short[size]; - for (int i = 0; i < size; i++) - { - short height = (short) dataArray->getAsNumber(i, minValue); - - if (height == 15000) //Our own NODATA, since -9999 is a valid height. - { - height = ShortBufferElevationData::NO_DATA_VALUE; - } - else if (height == minValue) - { - height = ShortBufferElevationData::NO_DATA_VALUE; - } - - shortBuffer[i] = height; - } - - short max = (short) data->getAsNumber("max",IMathUtils::instance()->minInt16()); - short min = (short) data->getAsNumber("min",IMathUtils::instance()->maxInt16()); - short children = (short) data->getAsNumber("withChildren",0); - short similarity = (short) data->getAsNumber("similarity",0); - - return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, - size, deltaHeight,max,min,children,similarity); -} diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp deleted file mode 100644 index f99b2ab484..0000000000 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// -// PyramidElevationDataProvider_BufferDownloadListener.hpp -// G3MiOSSDK -// -// Created by Sebastian Ortega Trujillo on 4/3/16. -// -// - -#ifndef G3MiOSSDK_PyramidElevationDataProvider_BufferDownloadListener_hpp -#define G3MiOSSDK_PyramidElevationDataProvider_BufferDownloadListener_hpp - -#include -#include "IBufferDownloadListener.hpp" -#include "ElevationDataProvider.hpp" -#include "ShortBufferElevationData.hpp" -#include "Sector.hpp" -#include "BilParser.hpp" -#include "JSONObject.hpp" - -class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownloadListener { -private: - - const Sector &_sector; - int _width, _height; - IElevationDataListener *_listener; - bool _autodeleteListener; - double _deltaHeight; - G3MContext *_context; - -#ifdef C_CODE - const Vector2I* getResolution(const JSONObject *data); -#endif -#ifdef JAVA_CODE - private Vector2I getResolution(const JSONObject data); -#endif - ShortBufferElevationData* getElevationData(Sector sector, - Vector2I extent, - const JSONObject *data, - double deltaHeight); - -public: - PyramidElevationDataProvider_BufferDownloadListener(const Sector& sector, - const Vector2I& extent, - IElevationDataListener *listener, - bool autodeleteListener, - double deltaHeight); - - void onDownload(const URL& url, - IByteBuffer* buffer, - bool expired); - void onError(const URL& url); - void onCancel(const URL& url); - - void onCanceledDownload(const URL& url, - IByteBuffer* data, - bool expired); - -}; - -#endif diff --git a/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj b/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj index aee4af2745..bcdcb1432c 100644 --- a/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj +++ b/iOS/G3MiOSSDK/G3MiOSSDK.xcodeproj/project.pbxproj @@ -488,9 +488,7 @@ D824A8591C296381002C84AA /* MaxFrameTimeTileLODTester.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D824A8571C296381002C84AA /* MaxFrameTimeTileLODTester.cpp */; }; D842D9AF1A727FAF008D55E4 /* NonOverlappingMarksRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D842D9AD1A727FAF008D55E4 /* NonOverlappingMarksRenderer.cpp */; }; D842D9B01A72906A008D55E4 /* NonOverlappingMarksRenderer.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D842D9AE1A727FAF008D55E4 /* NonOverlappingMarksRenderer.hpp */; }; - D84824AD1C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D84824A91C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.cpp */; }; D84824AE1C89E155007F41D1 /* PyramidElevationDataProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D84824AB1C89E155007F41D1 /* PyramidElevationDataProvider.cpp */; }; - D84824AF1C89E345007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D84824AA1C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */; }; D84824B01C89E345007F41D1 /* PyramidElevationDataProvider.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D84824AC1C89E155007F41D1 /* PyramidElevationDataProvider.hpp */; }; D84D5A31157E0EAA000C5E35 /* MutableVector3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D84D5A2F157E0EAA000C5E35 /* MutableVector3D.cpp */; }; D856FBFD189BB5610053F514 /* CoordinateSystem.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8F2EBAC18994A7B001B6103 /* CoordinateSystem.hpp */; }; @@ -766,7 +764,6 @@ dstPath = "include/${PRODUCT_NAME}"; dstSubfolderSpec = 16; files = ( - D84824AF1C89E345007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.hpp in CopyFiles */, D84824B01C89E345007F41D1 /* PyramidElevationDataProvider.hpp in CopyFiles */, CFE50D251C6669160002EFD5 /* GradualSplitsTileLODTester.hpp in CopyFiles */, CFE50D261C6669160002EFD5 /* PlanetRenderContext.hpp in CopyFiles */, @@ -1805,8 +1802,6 @@ D84625D61777291F00FC4862 /* TexturedMesh.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = TexturedMesh.vsh; sourceTree = ""; }; D84625DD177732A900FC4862 /* ColorMesh.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ColorMesh.fsh; sourceTree = ""; }; D84625DE177732A900FC4862 /* ColorMesh.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ColorMesh.vsh; sourceTree = ""; }; - D84824A91C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PyramidElevationDataProvider_BufferDownloadListener.cpp; path = Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.cpp; sourceTree = ""; }; - D84824AA1C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = PyramidElevationDataProvider_BufferDownloadListener.hpp; path = Commons/Basic/PyramidElevationDataProvider_BufferDownloadListener.hpp; sourceTree = ""; }; D84824AB1C89E155007F41D1 /* PyramidElevationDataProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PyramidElevationDataProvider.cpp; path = Commons/Basic/PyramidElevationDataProvider.cpp; sourceTree = ""; }; D84824AC1C89E155007F41D1 /* PyramidElevationDataProvider.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = PyramidElevationDataProvider.hpp; path = Commons/Basic/PyramidElevationDataProvider.hpp; sourceTree = ""; }; D84D5A2F157E0EAA000C5E35 /* MutableVector3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MutableVector3D.cpp; path = Commons/Geometry/MutableVector3D.cpp; sourceTree = ""; }; @@ -2086,8 +2081,6 @@ 383BD3891577EDF40012AC53 /* Basic */ = { isa = PBXGroup; children = ( - D84824A91C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.cpp */, - D84824AA1C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.hpp */, D84824AB1C89E155007F41D1 /* PyramidElevationDataProvider.cpp */, D84824AC1C89E155007F41D1 /* PyramidElevationDataProvider.hpp */, CF02302619119B1E00FD85E0 /* TiledVectorLayerTileImageProvider.cpp */, @@ -3195,7 +3188,6 @@ CFDAE7AC16684929006F6A00 /* GEOFeature.cpp in Sources */, CF906EF8191D79DC00EFB950 /* TimeInterval.cpp in Sources */, CFDAE7B016691982006F6A00 /* GEOGeometry.cpp in Sources */, - D84824AD1C89E155007F41D1 /* PyramidElevationDataProvider_BufferDownloadListener.cpp in Sources */, CF94EB941669307700F2283C /* GEO2DLineStringGeometry.cpp in Sources */, CFBF0D16166946350045B882 /* GEO2DMultiLineStringGeometry.cpp in Sources */, CFC54E0F1669766C00E1CD15 /* GEORenderer.cpp in Sources */, From 64b7370121b77d57f75629c208171bb098361bd6 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Mon, 7 Mar 2016 12:03:34 +0100 Subject: [PATCH 15/70] Generated --- .../PyramidElevationDataProvider.java | 72 ++++++++- ...onDataProvider_BufferDownloadListener.java | 148 ++++++++++++++++++ 2 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java index a7b3bd0e59..227df42954 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java @@ -17,8 +17,6 @@ public class PyramidElevationDataProvider extends ElevationDataProvider private boolean _isMercator; private final String _layer; - - private static class PyramidComposition { public double _upperLat; @@ -49,6 +47,76 @@ public final Sector getSector() } } + private static class MetadataListener extends IBufferDownloadListener + { + public MetadataListener(java.util.ArrayList itself) + { + _itself = itself; + } + + public final void onDownload(URL url, IByteBuffer buffer, boolean expired) + { + + final String str = buffer.getAsString(); + + IJSONParser parser = IJSONParser.instance(); + final JSONArray array = parser.parse(str).asObject().getAsArray("sectors"); + if (array == null) + { + throw new RuntimeException("Problem parsing at PyramidElevationDataProvider::MetadataListener::onDownload()."); + } + + for (int i = 0; i _itself; + private final G3MContext _context; + + private double getUpperLat(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("upper").getAsNumber("lat"); + return doble.value(); + } + + private double getLowerLat(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("lower").getAsNumber("lat"); + return doble.value(); + } + + private double getUpperLon(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble) array.getAsObject(index).getAsObject("sector").getAsObject("upper").getAsNumber("lon"); + return doble.value(); + } + + private double getLowerLon(JSONArray array, int index) + { + JSONDouble doble = (JSONDouble)array.getAsObject(index).getAsObject("sector").getAsObject("lower").getAsNumber("lon"); + return doble.value(); + } + + private int getLevel(JSONArray array, int index) + { + JSONInteger integer = (JSONInteger) array.getAsObject(index).getAsNumber("pyrLevel"); + return integer.intValue(); + } + + } + private java.util.ArrayList _pyrComposition; //C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java new file mode 100644 index 0000000000..ed5f0eccb6 --- /dev/null +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java @@ -0,0 +1,148 @@ +package org.glob3.mobile.generated; +// +// PyramidElevationDataProvider.cpp +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 4/3/16. +// +// + +//C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: +//#import "PyramidElevationDataProvider.hpp" + + + +public class PyramidElevationDataProvider_BufferDownloadListener extends IBufferDownloadListener +{ + + private final Sector _sector; + private int _width; + private int _height; + private IElevationDataListener _listener; + private boolean _autodeleteListener; + private double _deltaHeight; + private G3MContext _context; + + private Vector2I getResolution(const JSONObject data){ + return new Vector2I((int) data.getAsNumber("width",0),(int) data.getAsNumber("height",0)); + } + + private ShortBufferElevationData getElevationData(Sector sector, Vector2I extent, JSONObject data, double deltaHeight) + { + final short minValue = IMathUtils.instance().minInt16(); + final int size = extent._x * extent._y; + final JSONArray dataArray = data.getAsArray("data"); + short[] shortBuffer = new short[size]; + for (int i = 0; i < size; i++) + { + short height = (short) dataArray.getAsNumber(i, minValue); + + if (height == 15000) //Our own NODATA, since -9999 is a valid height. + { + height = ShortBufferElevationData.NO_DATA_VALUE; + } + else if (height == minValue) + { + height = ShortBufferElevationData.NO_DATA_VALUE; + } + + shortBuffer[i] = height; + } + + short max = (short) data.getAsNumber("max", IMathUtils.instance().minInt16()); + short min = (short) data.getAsNumber("min", IMathUtils.instance().maxInt16()); + short children = (short) data.getAsNumber("withChildren", 0); + short similarity = (short) data.getAsNumber("similarity", 0); + + return new ShortBufferElevationData(sector, extent, sector, extent, shortBuffer, size, deltaHeight,max,min,children,similarity); + } + + public PyramidElevationDataProvider_BufferDownloadListener(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener, double deltaHeight) + { + _sector = new Sector(sector); + _width = extent._x; + _height = extent._y; + _listener = listener; + _autodeleteListener = autodeleteListener; + _deltaHeight = deltaHeight; + + } + + public final void onDownload(URL url, IByteBuffer buffer, boolean expired) + { + + ShortBufferElevationData elevationData; + + String contents = buffer.getAsString(); + final JSONObject jsonContent = IJSONParser.instance().parse(contents).asObject(); + final Vector2I resolution = getResolution(jsonContent); + elevationData = getElevationData(_sector, resolution, jsonContent, _deltaHeight); + + if (buffer != null) + if (buffer != null) + buffer.dispose(); + + if (elevationData == null) + { + _listener.onError(_sector, resolution); + } + else + { + _listener.onData(_sector, resolution, elevationData); + //elevationData->_release(); + } + + + if (_autodeleteListener) + { + if (_listener != null) + if (_listener != null) + _listener.dispose(); + _listener = null; + } + } + + public final void onError(URL url) + { + final Vector2I resolution = new Vector2I(_width, _height); + + _listener.onError(_sector, resolution); + if (_autodeleteListener) + { + if (_listener != null) + if (_listener != null) + _listener.dispose(); + _listener = null; + } + } + + public final void onCancel(URL url) + { + if (_listener != null) + { + final Vector2I resolution = new Vector2I(_width, _height); + _listener.onCancel(_sector, resolution); + if (_autodeleteListener) + { + if (_listener != null) + if (_listener != null) + _listener.dispose(); + _listener = null; + } + } + } + + + public final void onCanceledDownload(URL url, IByteBuffer data, boolean expired) + { + if (_autodeleteListener) + { + if (_listener != null) + if (_listener != null) + _listener.dispose(); + _listener = null; + } + } + + +} \ No newline at end of file From 627aeb8b6515657dae00b856b5ee36bfeb809362 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 11:16:22 +0000 Subject: [PATCH 16/70] Changing import to include --- iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp index 4941b62a34..2838ff7c7d 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp @@ -6,7 +6,7 @@ // // -#import "PyramidElevationDataProvider.hpp" +#include "PyramidElevationDataProvider.hpp" #include "ShortBufferElevationData.hpp" #include "DownloadPriority.hpp" From f2159b91449a475981a4b17e82f09adb14fc2d4b Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Mon, 7 Mar 2016 12:19:49 +0100 Subject: [PATCH 17/70] Generated --- .../PyramidElevationDataProvider.java | 135 ++++++++++++++---- ...onDataProvider_BufferDownloadListener.java | 13 -- 2 files changed, 106 insertions(+), 42 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java index 227df42954..d4c068be4d 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java @@ -1,4 +1,12 @@ package org.glob3.mobile.generated; +// +// PyramidElevationDataProvider.cpp +// G3MiOSSDK +// +// Created by Sebastian Ortega Trujillo on 4/3/16. +// +// + // // PyramidElevationDataProvider.hpp // G3MiOSSDK @@ -119,41 +127,110 @@ private int getLevel(JSONArray array, int index) private java.util.ArrayList _pyrComposition; -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// boolean aboveLevel(Sector sector, int level); + private boolean aboveLevel(Sector sector, int level) + { + int maxLevel = 0; + for (int i = 0; i< _pyrComposition.size(); i++) + if (sector.touchesWith(_pyrComposition.get(i).getSector())) + maxLevel = IMathUtils.instance().max(maxLevel, _pyrComposition.get(i)._pyramidLevel); + + if (level > maxLevel) + return true; + else + { + if (!sector.touchesWith(_sector)) + return true; + return false; + } + } -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// PyramidElevationDataProvider(String layer, Sector sector, boolean isMercator, double deltaHeight); + public PyramidElevationDataProvider(String layer, Sector sector, boolean isMercator) + { + this(layer, sector, isMercator, 0); + } + public PyramidElevationDataProvider(String layer, Sector sector, boolean isMercator, double deltaHeight) + { + _sector = new Sector(sector); + _layer = layer; + _pyrComposition = new java.util.ArrayList(); + _deltaHeight = deltaHeight; + _isMercator = isMercator; + } -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// public void dispose() + public void dispose() + { + _pyrComposition.clear(); + _pyrComposition = null; + _pyrComposition = null; + + } public final boolean isReadyToRender (G3MRenderContext rc) { return true; } -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void getMetadata(); - -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void initialize(G3MContext context); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// long requestElevationData(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// long requestElevationData(Sector sector, int level, int row, int column, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener); - -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// String requestStringPath(Sector sector, Vector2I extent); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// String requestStringPath(String layer, int level, int row, int column); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// String requestMetadataPath(); - -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// void cancelRequest(long requestId); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// java.util.ArrayList getSectors(); -//C++ TO JAVA CONVERTER TODO TASK: The implementation of the following method could not be found: -// Vector2I getMinResolution(); + public final void getMetadata() + { + + _downloader.requestBuffer(new URL(requestMetadataPath(),false), DownloadPriority.HIGHER, TimeInterval.fromDays(30), true, new MetadataListener(_pyrComposition), true); + } + + public final void initialize(G3MContext context) + { + _downloader = context.getDownloader(); + getMetadata(); + } + public final long requestElevationData(Sector sector, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener) + { + //This requester is not necessary, but we are forced to implement it, so -1. + return -1; + } + public final long requestElevationData(Sector sector, int level, int row, int column, Vector2I extent, IElevationDataListener listener, boolean autodeleteListener) + { + + if ((_downloader == null) || (aboveLevel(sector, level))) + { + return -1; + } + + String path = requestStringPath(_layer, level, row, column); + + return _downloader.requestBuffer(new URL(path,false), DownloadPriority.HIGHEST - level, TimeInterval.fromDays(30), true, new PyramidElevationDataProvider_BufferDownloadListener(sector, extent, listener, autodeleteListener, _deltaHeight), true); + } + + public final String requestStringPath(Sector sector, Vector2I extent) + { + // TODO: Esta en principio no debería usarse, pero ... + ILogger.instance().logError("BAD STRING PATH REQUESTED!"); + return ""; + } + public final String requestStringPath(String layer, int level, int row, int column) + { + std.ostringstream strs = new std.ostringstream(); + strs << _layer.compareTo() < 0< < level << "/" << column << "/" << row << ".json"; //".bil"; + String res = strs.str(); + //ILogger::instance()->logInfo(res); + return res; + } + public final String requestMetadataPath() + { + return _layer + "meta.json"; + } + + public final void cancelRequest(long requestId) + { + _downloader.cancelRequest(requestId); + } + public final java.util.ArrayList getSectors() + { + final java.util.ArrayList sectors = new java.util.ArrayList(); + sectors.add(_sector); + return sectors; + } + public final Vector2I getMinResolution() + { + // int WORKING_JM; + return Vector2I.zero(); + } } \ No newline at end of file diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java index ed5f0eccb6..a6b3c22df5 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java @@ -1,17 +1,4 @@ package org.glob3.mobile.generated; -// -// PyramidElevationDataProvider.cpp -// G3MiOSSDK -// -// Created by Sebastian Ortega Trujillo on 4/3/16. -// -// - -//C++ TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: -//#import "PyramidElevationDataProvider.hpp" - - - public class PyramidElevationDataProvider_BufferDownloadListener extends IBufferDownloadListener { From 0ccfb3c5f1a767ad53cb817d20b6490a76dd7cc9 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 11:38:38 +0000 Subject: [PATCH 18/70] Fixing conversion issues on Pytamid requestStringPath --- .../Basic/PyramidElevationDataProvider.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp index 2838ff7c7d..2843200bd8 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp @@ -8,7 +8,7 @@ #include "PyramidElevationDataProvider.hpp" #include "ShortBufferElevationData.hpp" - +#include "IStringBuilder.hpp" #include "DownloadPriority.hpp" #include "G3MContext.hpp" #include "TimeInterval.hpp" @@ -203,11 +203,18 @@ std::string PyramidElevationDataProvider::requestStringPath(const Sector §or } std::string PyramidElevationDataProvider::requestStringPath(const std::string & layer, int level, int row, int column){ - std::ostringstream strs; - strs << _layer << level << "/" << column << "/" << row << ".json"; //".bil"; - std::string res = strs.str(); - //ILogger::instance()->logInfo(res); - return res; + + IStringBuilder *istr = IStringBuilder::newStringBuilder(); + istr->addString(_layer); + istr->addInt(level); + istr->addString("/"); + istr->addInt(column); + istr->addString("/"); + istr->addInt(row); + istr->addString(".json"); + std::string res = istr->getString(); + delete istr; + return res; } std::string PyramidElevationDataProvider::requestMetadataPath() const{ From 593d7a559e990b06d607de5d28b04ce3107b1118 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Mon, 7 Mar 2016 12:42:05 +0100 Subject: [PATCH 19/70] Generated --- .../PyramidElevationDataProvider.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java index d4c068be4d..8dcebde4ff 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java @@ -206,11 +206,19 @@ public final String requestStringPath(Sector sector, Vector2I extent) } public final String requestStringPath(String layer, int level, int row, int column) { - std.ostringstream strs = new std.ostringstream(); - strs << _layer.compareTo() < 0< < level << "/" << column << "/" << row << ".json"; //".bil"; - String res = strs.str(); - //ILogger::instance()->logInfo(res); - return res; + + IStringBuilder istr = IStringBuilder.newStringBuilder(); + istr.addString(_layer); + istr.addInt(level); + istr.addString("/"); + istr.addInt(column); + istr.addString("/"); + istr.addInt(row); + istr.addString(".json"); + String res = istr.getString(); + if (istr != null) + istr.dispose(); + return res; } public final String requestMetadataPath() { From a985ec8832a39a8e1f2696e2a6dabf4915655ce6 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 12:36:19 +0000 Subject: [PATCH 20/70] Fixing conversion issues, adding references to getElevationData --- .../Commons/Basic/PyramidElevationDataProvider.cpp | 7 +++---- .../Commons/Basic/PyramidElevationDataProvider.hpp | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp index 2843200bd8..7ff48c960e 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.cpp @@ -23,7 +23,6 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo IElevationDataListener *_listener; bool _autodeleteListener; double _deltaHeight; - G3MContext *_context; #ifdef C_CODE const Vector2I* getResolution(const JSONObject *data){ @@ -31,13 +30,13 @@ class PyramidElevationDataProvider_BufferDownloadListener : public IBufferDownlo } #endif #ifdef JAVA_CODE - private Vector2I getResolution(const JSONObject data){ + private Vector2I getResolution(JSONObject data){ return new Vector2I((int) data.getAsNumber("width",0),(int) data.getAsNumber("height",0)); } #endif - ShortBufferElevationData* getElevationData(Sector sector, - Vector2I extent, + ShortBufferElevationData* getElevationData(const Sector& sector, + const Vector2I& extent, const JSONObject *data, double deltaHeight){ const short minValue = IMathUtils::instance()->minInt16(); diff --git a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp index 51a526049f..938210b458 100644 --- a/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp +++ b/iOS/G3MiOSSDK/Commons/Basic/PyramidElevationDataProvider.hpp @@ -83,7 +83,6 @@ class PyramidElevationDataProvider : public ElevationDataProvider { private: std::vector* _itself; - const G3MContext *_context; double getUpperLat(const JSONArray *array, int index){ JSONDouble *doble = (JSONDouble*) array->getAsObject(index)->getAsObject("sector")->getAsObject("upper")->getAsNumber("lat"); From 3d167495502d4e7e7f419170e4057634622a1d02 Mon Sep 17 00:00:00 2001 From: aldeanueva Date: Mon, 7 Mar 2016 13:40:07 +0100 Subject: [PATCH 21/70] Generated --- .../glob3/mobile/generated/PyramidElevationDataProvider.java | 1 - .../PyramidElevationDataProvider_BufferDownloadListener.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java index 8dcebde4ff..5b4e650c58 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider.java @@ -91,7 +91,6 @@ public final void onCanceledDownload(URL url, IByteBuffer data, boolean expired) } private java.util.ArrayList _itself; - private final G3MContext _context; private double getUpperLat(JSONArray array, int index) { diff --git a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java index a6b3c22df5..ba6e965034 100644 --- a/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java +++ b/Commons/G3MSharedSDK/src/org/glob3/mobile/generated/PyramidElevationDataProvider_BufferDownloadListener.java @@ -8,9 +8,8 @@ public class PyramidElevationDataProvider_BufferDownloadListener extends IBuffer private IElevationDataListener _listener; private boolean _autodeleteListener; private double _deltaHeight; - private G3MContext _context; - private Vector2I getResolution(const JSONObject data){ + private Vector2I getResolution(JSONObject data){ return new Vector2I((int) data.getAsNumber("width",0),(int) data.getAsNumber("height",0)); } From 6d0f1e4f04c28f3e07e96cc04aa15c7762b21f99 Mon Sep 17 00:00:00 2001 From: ChanoOT Date: Mon, 7 Mar 2016 14:24:47 +0000 Subject: [PATCH 22/70] Removing not needed functions and variables, adding demo for Android --- .../res/layout/goto_dialog.xml | 50 +++ .../res/layout/loader_dialog.xml | 38 +++ .../res/menu/main.xml | 21 +- .../res/values/strings.xml | 21 +- .../MainActivity.java | 288 +++++++++++++++++- .../PointCloudActivity.java | 2 +- .../PyramidElevationDataProvider.java | 43 +-- iOS/G3MiOSDemo/Glob3iOSDemo/ViewController.mm | 5 +- iOS/G3MiOSSDK/Commons/Basic/BilParser.cpp | 84 ----- iOS/G3MiOSSDK/Commons/Basic/BilParser.hpp | 4 - .../Basic/PyramidElevationDataProvider.cpp | 9 +- .../Basic/PyramidElevationDataProvider.hpp | 22 +- 12 files changed, 434 insertions(+), 153 deletions(-) create mode 100644 Android/G3MAndroidTestingApplication/res/layout/goto_dialog.xml create mode 100644 Android/G3MAndroidTestingApplication/res/layout/loader_dialog.xml diff --git a/Android/G3MAndroidTestingApplication/res/layout/goto_dialog.xml b/Android/G3MAndroidTestingApplication/res/layout/goto_dialog.xml new file mode 100644 index 0000000000..a340eca12a --- /dev/null +++ b/Android/G3MAndroidTestingApplication/res/layout/goto_dialog.xml @@ -0,0 +1,50 @@ + + + + + + + + + + +
+ Go to: lat: + + lon: + + hgt: + + pitch: + + +
+
+
+ + + + + \ No newline at end of file diff --git a/WebGL/G3MWebGLTestingApplication/war/org.glob3.mobile.G3MWebGLTestingApplication/org.glob3.mobile.G3MWebGLTestingApplication.nocache.js b/WebGL/G3MWebGLTestingApplication/war/org.glob3.mobile.G3MWebGLTestingApplication/org.glob3.mobile.G3MWebGLTestingApplication.nocache.js index 397bf3c6e5..4fa4630fca 100644 --- a/WebGL/G3MWebGLTestingApplication/war/org.glob3.mobile.G3MWebGLTestingApplication/org.glob3.mobile.G3MWebGLTestingApplication.nocache.js +++ b/WebGL/G3MWebGLTestingApplication/war/org.glob3.mobile.G3MWebGLTestingApplication/org.glob3.mobile.G3MWebGLTestingApplication.nocache.js @@ -1,67 +1,346 @@ -/* - * Copyright 2014 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -/** - * This startup script is used when we run superdevmode from an app server. - */ -(function($wnd, $doc){ - // document.head does not exist in IE8 - var $head = $doc.head || $doc.getElementsByTagName('head')[0]; - // Compute some codeserver urls so as the user does not need bookmarklets - var hostName = $wnd.location.hostname; - var serverUrl = 'http://' + hostName + ':9876'; - var module = 'org.glob3.mobile.G3MWebGLTestingApplication'; - var nocacheUrl = serverUrl + '/recompile-requester/' + module; - - // Insert the superdevmode nocache script in the first position of the head - var devModeScript = $doc.createElement('script'); - devModeScript.src = nocacheUrl; - - // Everybody except IE8 does fire an error event - // This means that we do not detect a non running SDM with IE8. - if (devModeScript.addEventListener) { - var callback = function() { - // Don't show the confirmation dialogue twice (multimodule) - if (!$wnd.__gwt__sdm__confirmed && - (!$wnd.__gwt_sdm__recompiler || !$wnd.__gwt_sdm__recompiler.loaded)) { - $wnd.__gwt__sdm__confirmed = true; - if ($wnd.confirm( - "Couldn't load " + module + " from Super Dev Mode\n" + - "server at " + serverUrl + ".\n" + - "Please make sure this server is ready.\n" + - "Do you want to try again?")) { - $wnd.location.reload(); +function org_glob3_mobile_G3MWebGLTestingApplication(){ + var $intern_0 = '', $intern_36 = '" for "gwt:onLoadErrorFn"', $intern_34 = '" for "gwt:onPropertyErrorFn"', $intern_21 = '"><\/script>', $intern_10 = '#', $intern_60 = '.cache.html', $intern_12 = '/', $intern_24 = '//', $intern_54 = '22CDE9B982629CB436D4E35F5A97C21B', $intern_59 = ':', $intern_28 = '::', $intern_62 = '