OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ossimGpkgWriter Class Reference

#include <ossimGpkgWriter.h>

Inheritance diagram for ossimGpkgWriter:
ossimImageFileWriter ossimGpkgWriterInterface ossimImageWriter ossimProcessInterface ossimConnectableObjectListener ossimOutputSource ossimListener ossimSource ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Types

enum  { DEFAULT_JPEG_QUALITY = 75 }
 
enum  ossimGpkgWriterMode {
  OSSIM_GPGK_WRITER_MODE_UNKNOWN = 0, OSSIM_GPGK_WRITER_MODE_JPEG = 1, OSSIM_GPGK_WRITER_MODE_PNG = 2, OSSIM_GPGK_WRITER_MODE_PNGA = 3,
  OSSIM_GPGK_WRITER_MODE_MIXED = 4
}
 
- Public Types inherited from ossimConnectableObject
enum  ossimConnectableObjectDirectionType { CONNECTABLE_DIRECTION_NONE = 0, CONNECTABLE_DIRECTION_INPUT = 1, CONNECTABLE_DIRECTION_OUTPUT = 2 }
 
typedef std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
 
- Public Types inherited from ossimProcessInterface
enum  ossimProcessStatus {
  PROCESS_STATUS_UNKNOWN = 0, PROCESS_STATUS_EXECUTING = 1, PROCESS_STATUS_ABORTED = 2, PROCESS_STATUS_ABORT_REQUEST = 3,
  PROCESS_STATUS_NOT_EXECUTING = 4
}
 

Public Member Functions

 ossimGpkgWriter ()
 
virtual ~ossimGpkgWriter ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getClassName () const
 
virtual ossimString getExtension () const
 Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for image file extensions. More...
 
virtual void getImageTypeList (std::vector< ossimString > &imageTypeList) const
 void getImageTypeList(std::vector<ossimString>& imageTypeList)const More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 saves the state of the object. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of an object from a keyword list. More...
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 Will set the property whose name matches the argument "property->getName()". More...
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 Pushes this's names onto the list of property names. More...
 
bool hasImageType (const ossimString &imageType) const
 bool hasImageType(const ossimString& imageType) const More...
 
ossimString getCompressionLevel () const
 Get the gpkg compression level as a string. More...
 
bool setCompressionLevel (const ossimString &level)
 Set the gpkg compression level from a string. More...
 
virtual bool isOpen () const
 
virtual bool open ()
 
virtual bool openFile (const ossimKeywordlist &options)
 Opens file for writing, appending, merging without an input connection. More...
 
virtual void close ()
 
ossimGpkgWriterMode getWriterMode () const
 Gets the writer mode. More...
 
std::string getWriterModeString (ossimGpkgWriterMode mode) const
 Gets the writer mode as string. More...
 
void setCompressionQuality (const std::string &quality)
 
ossim_uint32 getCompressionQuality () const
 Gets the compression quality. More...
 
virtual ossim_int32 beginTileProcessing ()
 Calls initial sqlite3_prepare_v2 statement. More...
 
virtual bool writeTile (ossimRefPtr< ossimImageData > &tile, ossim_int32 zoomLevel, ossim_int64 row, ossim_int64 col)
 Direct interface to writing a tile to database. More...
 
virtual bool writeCodecTile (ossim_uint8 *codecTile, ossim_int32 codecTileSize, ossim_int32 zoomLevel, ossim_int64 row, ossim_int64 col)
 Direct interface to writing a Codec tile to database. More...
 
virtual void finalizeTileProcessing ()
 Calls sqlite3_finalize(pStmt) terminating tile processing. More...
 
- Public Member Functions inherited from ossimImageFileWriter
 ossimImageFileWriter (const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
 The writer will own the sequencer. More...
 
virtual ~ossimImageFileWriter ()
 
virtual ossimObjectgetObject ()
 
virtual const ossimObjectgetObject () const
 
virtual bool getOutputHasInternalOverviews (void) const
 Examples of writers that always generate internal overviews are ossim_kakadu_jp2 and ossim_kakadu_nitf_j2k. More...
 
virtual void setTileSize (const ossimIpt &tileSize)
 Sets the output image tiling size if supported by the writer. More...
 
virtual bool writeEnviHeaderFile ()
 Will write an envi header file. More...
 
virtual bool writeErsHeaderFile ()
 Will write an ER Mapper header file. More...
 
virtual bool writeExternalGeometryFile ()
 Will write an external geometry file. More...
 
virtual bool writeFgdcFile ()
 Will write an fgdc file. More...
 
virtual bool writeHistogramFile ()
 Returns true on success, false on error. More...
 
virtual bool writeJpegWorldFile ()
 Will write a jpeg world file. More...
 
virtual bool writeOverviewFile (ossim_uint16 tiff_compress_type=1, ossim_int32 jpeg_compress_quality=75, bool includeR0=false)
 Write out an ossim overview file from the source_file. More...
 
virtual bool writeReadmeFile ()
 Will write a readme file. More...
 
virtual bool writeTiffWorldFile ()
 Will write a world file. More...
 
virtual bool writeWorldFile ()
 Will write a world file. More...
 
virtual bool writeMetaDataFiles ()
 Convenience method that calls meta data write methods that are flagged to be called. More...
 
virtual void setAreaOfInterest (const ossimIrect &inputRect)
 
virtual void changeSequencer (ossimImageSourceSequencer *sequencer)
 Sets the sequencer and connects it to the input of this. More...
 
virtual ossimImageSourceSequencergetSequencer ()
 
virtual void initialize ()
 Initialize method. More...
 
virtual bool execute ()
 Calls: writeFile() writeMetaDataFiles() More...
 
virtual bool writeStream ()
 Method to write the image to a stream. More...
 
virtual bool setOutputStream (ossimRefPtr< ossimOStream > stream)
 Sets the output stream to write to. More...
 
virtual bool setOutputStream (std::ostream &str)
 tmp drb More...
 
virtual ossimRefPtr< ossimOStreamgetOutputStream () const
 Method to return the stream attached to output. More...
 
virtual void setPercentComplete (double percentComplete)
 
virtual void setOutputImageType (ossim_int32 type)
 
virtual void setOutputImageType (const ossimString &type)
 
virtual ossim_int32 getOutputImageType () const
 
virtual ossimString getOutputImageTypeString () const
 
virtual void setOutputName (const ossimString &outputName)
 
virtual void setFilename (const ossimFilename &file)
 
virtual const ossimFilenamegetFilename () const
 
virtual bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 required to be overriden by derived classes More...
 
virtual void disconnectInputEvent (ossimConnectionEvent &event)
 
virtual void connectInputEvent (ossimConnectionEvent &event)
 
virtual void propertyEvent (ossimPropertyEvent &event)
 
virtual bool getWriteImageFlag () const
 Control flags... More...
 
virtual bool getWriteHistogramFlag () const
 
virtual bool getWriteOverviewFlag () const
 
virtual bool getScaleToEightBitFlag () const
 
virtual bool getWriteEnviHeaderFlag () const
 
virtual bool getWriteErsHeaderFlag () const
 
virtual bool getWriteExternalGeometryFlag () const
 
virtual bool getWriteFgdcFlag () const
 
virtual bool getWriteJpegWorldFileFlag () const
 
virtual bool getWriteReadmeFlag () const
 
virtual bool getWriteTiffWorldFileFlag () const
 
virtual bool getWriteWorldFileFlag () const
 
virtual void setWriteImageFlag (bool flag)
 
virtual void setWriteOverviewFlag (bool flag)
 
virtual void setWriteHistogramFlag (bool flag)
 
virtual void setScaleToEightBitFlag (bool flag)
 
virtual void setWriteEnviHeaderFlag (bool flag)
 
virtual void setWriteErsHeaderFlag (bool flag)
 
virtual void setWriteExternalGeometryFlag (bool flag)
 
virtual void setWriteFgdcFlag (bool flag)
 
virtual void setWriteJpegWorldFile (bool flag)
 
virtual void setWriteReadme (bool flag)
 
virtual void setWriteTiffWorldFile (bool flag)
 
virtual void setWriteWorldFile (bool flag)
 
virtual ossim_uint16 getOverviewCompressType () const
 
virtual ossim_int32 getOverviewJpegCompressQuality () const
 
virtual void setOverviewCompressType (ossim_uint16 type)
 
virtual void setOverviewJpegCompressQuality (ossim_int32 quality)
 
virtual bool addListener (ossimListener *listener)
 Overrides base "addListener" this will capture the pointer and then call the base class "addListener". More...
 
virtual bool removeListener (ossimListener *listener)
 Overrides base "removeListener". More...
 
virtual void setPixelType (ossimPixelType type)
 If "point" the coordinate tie points are relative to the center of the pixel. More...
 
virtual void setPixelType (const ossimString &type)
 If "point" the coordinate tie points are relative to the center of the pixel. More...
 
virtual ossimPixelType getPixelType () const
 
virtual void getPixelTypeString (ossimString &type) const
 
- Public Member Functions inherited from ossimImageWriter
 ossimImageWriter (ossimObject *owner=NULL)
 
 ossimImageWriter (ossimObject *owner, ossim_uint32 numberOfInputs, ossim_uint32 numberOfOutputs, bool inputListIsFixed, bool outputListIsFixed)
 
virtual ~ossimImageWriter ()
 
virtual bool setViewingRect (const ossimIrect &aRect)
 
virtual ossimIrect getAreaOfInterest () const
 
- Public Member Functions inherited from ossimOutputSource
 ossimOutputSource (ossimObject *owner=NULL)
 
 ossimOutputSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimOutputSource ()
 
virtual bool open (const ossimString &outputName)
 
virtual const ossimStringgetOutputName ()
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual void enableSource ()
 
virtual void disableSource ()
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
- Public Member Functions inherited from ossimConnectableObject
 ossimConnectableObject (ossimObject *owner=0)
 Base constructor of this object. More...
 
 ossimConnectableObject (ossimObject *owner, ossim_int32 inputListSize, ossim_int32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimConnectableObject ()
 
void setId (const ossimId &id)
 All connectable objects will have id's. More...
 
const ossimIdgetId () const
 Will allow us to get this object's id. More...
 
const ossimObjectgetOwner () const
 Fetches the current owner, most likely a container but not limited to one. More...
 
virtual void changeOwner (ossimObject *owner)
 Permits changing the object's owner. More...
 
virtual void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual bool isConnected (ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
 will check the direction specified to see if all slots are full. More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findConnectableObject(const ossimId &id))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(RTTItypeid typeId, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(const ossimString &obj, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findInputObjectOfType(const ossimString &className))
 
virtual ossim_int32 findInputIndex (const ossimConnectableObject *object)
 Return a valid index of the input list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findInputIndex (const ossimId &id)
 Return a valid index of the input list if the passed id is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimConnectableObject *object)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimId &id)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 getMyInputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual ossim_int32 getMyOutputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual bool canConnectMyOutputTo (ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
 default implementation is to allow anyone to connect to us. More...
 
virtual void disconnect (ossimConnectableObject *object=0)
 Will disconnect the object passed in. More...
 
virtual void disconnect (const ossimId &id)
 Will disconnect the object passed in. More...
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyInput (ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given input index and generate a connection event. More...
 
virtual void disconnectMyInput (ossimConnectableObject *input, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Finds the index of the passed in input and calls disconnectMyInput(inputIndex, disconnectOutputFlag, createEventFlag);. More...
 
virtual void disconnectMyInputs (ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyOutput (ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given output index and generate a connection event. More...
 
virtual void disconnectMyOutput (ossimConnectableObject *output, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the output object. More...
 
virtual void disconnectMyOutputs (ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual void disconnectAllInputs ()
 Will disconnect all of the input objects. More...
 
virtual void disconnectAllOutputs ()
 Will disconnect all of the output objects. More...
 
virtual ossim_int32 connectMyInputTo (ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will try to connect this objects input to the passed in object. More...
 
virtual ossim_int32 connectMyInputTo (ossim_int32 inputIndex, ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will connect the specified input to the passed in object. More...
 
virtual bool connectMyInputTo (ConnectableObjectList &inputList, bool makeOutputConnection=true, bool createEventFlag=true)
 
virtual ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Will try to connect this objects output to the passed in object. More...
 
virtual bool connectMyOutputTo (ConnectableObjectList &outputList, bool makeInputConnection=true, bool createEventFlag=true)
 
virtual bool connectInputList (ConnectableObjectList &inputList)
 Will disconnect itself from all inputs and reset to the passed in input list. More...
 
virtual bool connectOutputList (ConnectableObjectList &outputList)
 Will disconnect itself from all outputs and reset to the passed in output list. More...
 
virtual ossim_uint32 getNumberOfInputs () const
 Returns the number of input objects. More...
 
virtual ossim_uint32 getNumberOfOutputs () const
 Return the number of output objects. More...
 
ossimConnectableObjectgetInput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetInput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
ossimConnectableObjectgetOutput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetOutput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
virtual void setNumberOfInputs (ossim_int32 numberOfInputs)
 Will set the number of inputs. More...
 
virtual bool getInputListIsFixedFlag () const
 
virtual bool getOutputListIsFixedFlag () const
 
virtual void setNumberOfOutputs (ossim_int32 numberOfInputs)
 Will set the number of outputs. More...
 
const ConnectableObjectListgetInputList () const
 
const ConnectableObjectListgetOutputList () const
 
ConnectableObjectListgetInputList ()
 
ConnectableObjectListgetOutputList ()
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const ossimString &className, bool recurse=true))
 
virtual void propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossim_uint32 saveStateOfAllInputs (ossimKeywordlist &kwl, bool saveThisStateFlag=true, ossim_uint32 objectIndex=1, const char *prefix=0) const
 Save the state of all inputs to a keyword list. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 Inserts this object and all of its children and inputs into the container provided. More...
 
bool moveInputUp (const ossimId &id)
 Moves the input connection matching id up one in the connection list. More...
 
bool moveInputDown (const ossimId &id)
 Moves the input connection matching id down one in the connection list. More...
 
bool moveInputToTop (const ossimId &id)
 Moves the input connection matching id to the top of the connection list. More...
 
bool moveInputToBottom (const ossimId &id)
 Moves the input connection matching id to the bottom of the connection list. More...
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool findListener (ossimListener *listener)
 
- Public Member Functions inherited from ossimPropertyInterface
 ossimPropertyInterface ()
 
virtual ~ossimPropertyInterface ()
 
virtual ossimString getPropertyValueAsString (const ossimString &name) const
 
void getPropertyList (std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
 
void setProperties (std::vector< ossimRefPtr< ossimProperty > > &propertyList)
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
- Public Member Functions inherited from ossimProcessInterface
 ossimProcessInterface ()
 
virtual ~ossimProcessInterface ()
 
virtual void abort ()
 
bool needsAborting () const
 
bool isAbortRequested () const
 
bool isAborted () const
 
bool isExecuting () const
 
ossimProcessStatus getProcessStatus () const
 
virtual void setProcessStatus (ossimProcessStatus processStatus)
 
virtual double getPercentComplete () const
 
virtual ossimListenerManagergetManager ()
 
void enableEvents ()
 
void disableEvents ()
 
void setCurrentMessage (const ossimString &message)
 
virtual std::ostream & print (std::ostream &out) const
 
- Public Member Functions inherited from ossimConnectableObjectListener
 ossimConnectableObjectListener ()
 
virtual ~ossimConnectableObjectListener ()
 
virtual void processEvent (ossimEvent &event)
 ProcessEvent. More...
 
virtual void objectDestructingEvent (ossimObjectDestructingEvent &)
 
virtual void connectionEvent (ossimConnectionEvent &)
 
virtual void disconnectOutputEvent (ossimConnectionEvent &)
 
virtual void connectOutputEvent (ossimConnectionEvent &)
 
virtual void addObjectEvent (ossimContainerEvent &)
 
virtual void removeObjectEvent (ossimContainerEvent &)
 
virtual void containerEvent (ossimContainerEvent &)
 
virtual void refreshEvent (ossimRefreshEvent &)
 
- Public Member Functions inherited from ossimListener
 ossimListener ()
 
virtual ~ossimListener ()
 
void enableListener ()
 
void disableListener ()
 
void setListenerEnableFlag (bool flag)
 
bool isListenerEnabled () const
 
bool getListenerEnableFlag () const
 
- Public Member Functions inherited from ossimGpkgWriterInterface
 ossimGpkgWriterInterface ()
 GP: I had to add this or windows would not link with the latest compiler. More...
 

Private Member Functions

virtual bool writeFile ()
 Writes the file to disk or a stream. More...
 
bool writeEntry ()
 Writes an entry to gpkg. More...
 
bool addLevels ()
 Adds levels to an existing an gpkg. More...
 
bool createTables (sqlite3 *db)
 
ossim_int32 writeGpkgSpatialRefSysTable (sqlite3 *db, const ossimMapProjection *proj)
 
bool writeGpkgContentsTable (sqlite3 *db, const ossimDrect &boundingRect)
 
bool writeGpkgTileMatrixSetTable (sqlite3 *db, const ossimDrect &boundingRect)
 
bool writeGpkgTileMatrixTable (sqlite3 *db, ossim_int32 zoom_level, const ossimIpt &matrixSize, const ossimDpt &gsd)
 Initialize method. More...
 
bool writeGpkgNsgTileMatrixExtentTable (sqlite3 *db, ossim_int32 zoom_level, const ossimIrect &expandedAoi, const ossimIrect &clippedAoi)
 
void writeZoomLevels (sqlite3 *db, ossimMapProjection *proj, const std::vector< ossim_int32 > &zoomLevels)
 
void writeTiles (sqlite3 *db, const ossimIrect &aoi, ossim_int32 zoomLevel, const ossim_float64 &totalTiles, ossim_float64 &tilesWritten)
 
void writeTile (sqlite3_stmt *pStmt, sqlite3 *db, ossimRefPtr< ossimImageData > &tile, ossim_int32 zoomLevel, ossim_int64 row, ossim_int64 col)
 
void writeCodecTile (sqlite3_stmt *pStmt, sqlite3 *db, ossim_uint8 *codecTile, ossim_int32 codecTileSize, ossim_int32 zoomLevel, ossim_int64 row, ossim_int64 col)
 
void getGsd (const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
 
void getGsd (const ossimMapProjection *proj, ossimDpt &gsd) const
 Get the gsd. More...
 
void getGsd (const ossimImageGeometry *geom, ossimDpt &gsd) const
 Get the gsd. More...
 
void getGsd (const ossimMapProjection *proj, ossim_int32 zoomLevel, ossimDpt &gsd) const
 Get the gsd. More...
 
bool alignToGrid () const
 
bool append () const
 Check if file is to be open new or appended. More...
 
bool addLevels () const
 
bool addEntry () const
 
ossimRefPtr< ossimMapProjectiongetNewOutputProjection (ossimImageGeometry *geom) const
 Get the output projection. More...
 
ossimRefPtr< ossimMapProjectiongetNewOutputProjection () const
 Gets projection from "epsg" code if in options list. More...
 
ossimRefPtr< ossimMapProjectiongetNewGeographicProjection () const
 
ossimRefPtr< ossimMapProjectiongetNewWorldMercatorProjection () const
 
void setView (ossimMapProjection *proj)
 
void reInitializeCombiners ()
 Finds all combiners and calls initialize to reset the bounding box after a view change. More...
 
void reInitializeCutters (const ossimMapProjection *proj)
 Finds all ossimRectangleCutter and calls setRectangle with a nan rect to reset the bounding box after a view change. More...
 
bool keyIsTrue (const std::string &key) const
 
void getTileSize (ossimIpt &tileSize) const
 
ossim_uint64 getBatchSize () const
 This is the number of transactions batched before being executed. More...
 
ossim_int32 getNumberOfZoomLevels (const ossimIrect &aoi) const
 Zoom levels needed to get AOI down to one tile. More...
 
void getZoomLevels (std::vector< ossim_int32 > &zoomLevels) const
 Gets zoom levels from options keyword list if set. More...
 
void getZoomLevels (const ossimMapProjection *proj, const ossimIrect &aoi, const ossimDpt &sourceGsd, std::vector< ossim_int32 > &zoomLevels, ossimDpt &fullResGsd) const
 Computes start and stop level. More...
 
void getAoiFromRect (const ossimMapProjection *proj, const ossimDrect &rect, ossimIrect &aoi)
 Get the view coordinates for edge to edge rect. More...
 
void getExpandedAoi (const ossimIrect &aoi, ossimIrect &expandedAoi) const
 Gets aoi expanded to tile boundaries. More...
 
void getMatrixSize (const ossimIrect &rect, ossimIpt &matrixSize) const
 
void setProjectionTie (ossimMapProjection *proj) const
 
bool requiresEightBit () const
 
ossim_uint32 getEpsgCode () const
 
void getProjectionDimensionsInMeters (const ossimMapProjection *proj, ossimDpt &dims) const
 Gets the projection dimensions in meters. More...
 
void initializeProjectionRect (const ossimMapProjection *productProj)
 
void initializeRect (const ossimMapProjection *proj, const ossimIrect &aoi, ossimDrect &rect)
 
void getTileTableName (std::string &tileTableName) const
 Gets the tile table name. More...
 
bool getFilename (ossimFilename &file) const
 
void initializeCodec ()
 Initializes m_fullTileCodec and m_partialTileCodec. More...
 
bool initializeGpkg ()
 Initializes the output gpkg file. More...
 
bool getWmsCutBox (ossimDrect &rect) const
 Get rectangle in projected space from key: cut_wms_bbox key:value form: cut_wms_bbox: <minx>,<miny>,<maxx>,<maxy> More...
 
bool getClipExtents (ossimDrect &rect, bool &alignToGridFlag) const
 Get clip rectangle in projected space from key: clip_extents key:value form: clip_extents: <minx>,<miny>,<maxx>,<maxy> More...
 
bool getRect (const std::string &key, ossimDrect &rect) const
 Gets rectangle. More...
 
void checkLevels (const std::vector< ossim_int32 > &currentZoomLevels, const std::vector< ossim_int32 > &newZoomLevels) const
 Checks for: new level lower then existing. More...
 
bool isValidZoomLevelRowCol (ossim_int32 level, ossim_int32 row, ossim_int32 col) const
 Checks to see if level, row, column are within range of existing gpkg. More...
 
void applyScaleToProjection (ossimMapProjection *proj, const ossimDpt &desiredGsd) const
 Get the current gsd from projection. More...
 

Private Attributes

sqlite3 * m_db
 database connection More...
 
ossim_uint64 m_batchCount
 Working variable for holding the current batch count. More...
 
ossim_uint64 m_batchSize
 Number of transactions batched before being executed. More...
 
ossimDrect m_projectionBoundingRect
 Holds the bounding rect of the output projection edges either in decimal degrees for geographic projection or Easting/Northings(meters) for map projection. More...
 
ossimDrect m_sceneBoundingRect
 Holds the bounding rect of the scene edges either in decimal degrees for geographic projection or Easting/Northings(meters) for map projection. More...
 
ossimDrect m_clipRect
 AOI clipped to projection rect. More...
 
ossimDrect m_outputRect
 Expanded(final) AOI clipped to projection rect. More...
 
ossimIpt m_tileSize
 
std::string m_tileTableName
 
ossim_int32 m_srs_id
 
ossimRefPtr< ossimKeywordlistm_kwl
 Hold all options. More...
 
ossimRefPtr< ossimCodecBasem_fullTileCodec
 Will cache and hold the allocated codecs to use for the encoding. More...
 
ossimRefPtr< ossimCodecBasem_partialTileCodec
 
bool m_fullTileCodecAlpha
 true if codec requires alpha channel. More...
 
bool m_partialTileCodecAlpha
 
std::vector< ossim_int32m_zoomLevels
 Holds zoom level indexes for connectionless write tile. More...
 
std::vector< ossimIptm_zoomLevelMatrixSizes
 Hold zoom level matrix sizes for connectionless write tile. More...
 
sqlite3_stmt * m_pStmt
 Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile. More...
 
bool m_writeBlanks
 Controlled by option key: "include_blank_tiles". More...
 

Additional Inherited Members

- Protected Member Functions inherited from ossimImageFileWriter
bool writeWorldFile (const ossimFilename &file)
 Common world file writer method. More...
 
- Protected Member Functions inherited from ossimSource
 ossimSource (const ossimSource &rhs)
 
const ossimSourceoperator= (const ossimSource &rhs)
 
- Protected Member Functions inherited from ossimConnectableObject
ossimConnectableObjectfindObjectOfType (ConnectableObjectList *connectableList, ossimVisitor &visitor)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 
- Protected Attributes inherited from ossimImageFileWriter
ossimRefPtr< ossimImageSourceSequencertheInputConnection
 
ossimRefPtr< ossimViewControllertheViewController
 
ossimListenertheProgressListener
 
ossimFilename theFilename
 
ossimString theOutputImageType
 
bool theWriteImageFlag
 
bool theWriteOverviewFlag
 
bool theWriteHistogramFlag
 
bool theScaleToEightBitFlag
 
ossim_uint16 theOverviewCompressType
 
ossim_int32 theOverviewJpegCompressQuality
 
bool theWriteEnviHeaderFlag
 External meta data writer flags. More...
 
bool theWriteErsHeaderFlag
 
bool theWriteExternalGeometryFlag
 
bool theWriteFgdcFlag
 
bool theWriteJpegWorldFileFlag
 
bool theWriteReadmeFlag
 
bool theWriteTiffWorldFileFlag
 
bool theWriteWorldFileFlag
 
bool theAutoCreateDirectoryFlag
 
ossimUnitType theLinearUnits
 If not a geographic projection this allows the user to set the linear units of the output tag to be: More...
 
ossimPixelType thePixelType
 OSSIM_PIXEL_IS_POINT = 0, OSSIM_PIXEL_IS_AREA = 1. More...
 
- Protected Attributes inherited from ossimImageWriter
ossimIrect theAreaOfInterest
 
- Protected Attributes inherited from ossimOutputSource
ossimString theOutputName
 
- Protected Attributes inherited from ossimSource
bool theEnableFlag
 
bool theInitializedFlag
 
- Protected Attributes inherited from ossimConnectableObject
ossimId theId
 
ossimString theDescription
 
ossimObjecttheOwner
 
bool theInputListIsFixedFlag
 Indicates whether the theInputObjectList is fixed. More...
 
bool theOutputListIsFixedFlag
 Indicates whether the theOutputObjectList is fixed. More...
 
ConnectableObjectList theInputObjectList
 Holds a list of input objects. More...
 
ConnectableObjectList theOutputObjectList
 Holds a list of output objects. More...
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 
- Protected Attributes inherited from ossimProcessInterface
double thePercentComplete
 
ossimProcessStatus theProcessStatus
 
ossimString theMessage
 
bool theEventFlag
 
- Protected Attributes inherited from ossimListener
bool theListenerEnableFlag
 

Detailed Description

Definition at line 37 of file ossimGpkgWriter.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEFAULT_JPEG_QUALITY 

Definition at line 43 of file ossimGpkgWriter.h.

◆ ossimGpkgWriterMode

Enumerator
OSSIM_GPGK_WRITER_MODE_UNKNOWN 
OSSIM_GPGK_WRITER_MODE_JPEG 
OSSIM_GPGK_WRITER_MODE_PNG 
OSSIM_GPGK_WRITER_MODE_PNGA 
OSSIM_GPGK_WRITER_MODE_MIXED 

Definition at line 48 of file ossimGpkgWriter.h.

Constructor & Destructor Documentation

◆ ossimGpkgWriter()

ossimGpkgWriter::ossimGpkgWriter ( )

Definition at line 97 of file ossimGpkgWriter.cpp.

98  :
100  m_db(0),
101  m_batchCount(0),
102  m_batchSize(32),
103  m_projectionBoundingRect(0.0, 0.0, 0.0, 0.0, OSSIM_RIGHT_HANDED),
104  m_sceneBoundingRect(0.0, 0.0, 0.0, 0.0, OSSIM_RIGHT_HANDED),
105  m_clipRect(0.0, 0.0, 0.0, 0.0, OSSIM_RIGHT_HANDED),
106  m_outputRect(0.0, 0.0, 0.0, 0.0, OSSIM_RIGHT_HANDED),
107  m_tileSize(0,0),
108  m_tileTableName(),
109  m_srs_id(-1),
110  m_kwl(new ossimKeywordlist()),
111  m_fullTileCodec(0),
113  m_fullTileCodecAlpha(false),
115  m_zoomLevels(),
117  m_pStmt(0),
118  m_writeBlanks(false)
119 {
120  //---
121  // Uncomment for debug mode:
122  // traceDebug.setTraceFlag(true);
123  //---
124 
125  if (traceDebug())
126  {
128  << "ossimGpkgWriter::ossimGpkgWriter entered" << std::endl;
129 #if OSSIM_ID_ENABLED
131  << "OSSIM_ID: "
132  << OSSIM_ID
133  << std::endl;
134 #endif
135  }
136 
137  theOutputImageType = "ossim_gpkg"; // ossimImageFileWriter attribute.
138 
139  // Set default options:
140  m_kwl->addPair( ALIGN_TO_GRID_KW, TRUE_KW );
141  m_kwl->addPair( TILE_SIZE_KW, std::string("( 256, 256 )") );
142  m_kwl->addPair( WRITER_MODE_KW, std::string("mixed") );
143 
144  // Note batch size dramatically effects speed.
145  m_kwl->addPair( BATCH_SIZE_KW, "32" );
146 }
std::vector< ossim_int32 > m_zoomLevels
Holds zoom level indexes for connectionless write tile.
ossimRefPtr< ossimCodecBase > m_partialTileCodec
Represents serializable keyword/value map.
ossim_int32 m_srs_id
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
ossimImageFileWriter(const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
The writer will own the sequencer.
ossimDrect m_clipRect
AOI clipped to projection rect.
ossim_uint64 m_batchSize
Number of transactions batched before being executed.
std::vector< ossimIpt > m_zoomLevelMatrixSizes
Hold zoom level matrix sizes for connectionless write tile.
bool m_writeBlanks
Controlled by option key: "include_blank_tiles".
sqlite3_stmt * m_pStmt
Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile.
std::string m_tileTableName
ossimRefPtr< ossimCodecBase > m_fullTileCodec
Will cache and hold the allocated codecs to use for the encoding.
ossimDrect m_sceneBoundingRect
Holds the bounding rect of the scene edges either in decimal degrees for geographic projection or Eas...
ossimDrect m_outputRect
Expanded(final) AOI clipped to projection rect.
sqlite3 * m_db
database connection
ossimDrect m_projectionBoundingRect
Holds the bounding rect of the output projection edges either in decimal degrees for geographic proje...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_uint64 m_batchCount
Working variable for holding the current batch count.
bool m_fullTileCodecAlpha
true if codec requires alpha channel.

◆ ~ossimGpkgWriter()

ossimGpkgWriter::~ossimGpkgWriter ( )
virtual

Definition at line 148 of file ossimGpkgWriter.cpp.

References close(), and m_kwl.

149 {
150  close();
151 
152  // Not a leak, ref ptr.
153  m_kwl = 0;
154 }
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
virtual void close()

Member Function Documentation

◆ addEntry()

bool ossimGpkgWriter::addEntry ( ) const
private
Returns
true if "add_entry" key is set to true; false, if not.

◆ addLevels() [1/2]

bool ossimGpkgWriter::addLevels ( )
private

Adds levels to an existing an gpkg.

Returns
true on success, false on error.

Definition at line 849 of file ossimGpkgWriter.cpp.

References alignToGrid(), ossimRefPtr< T >::get(), ossimImageWriter::getAreaOfInterest(), ossimImageGeometry::getAsMapProjection(), ossimObject::getClassName(), getGsd(), ossimImageSource::getImageGeometry(), getNewOutputProjection(), ossimMapProjection::getPcsCode(), ossimGpkgTileEntry::getSrs(), ossim_gpkg::getTileEntry(), getTileTableName(), ossimIrect::hasNans(), m_db, ossimGpkgSpatialRefSysRecord::m_organization_coordsys_id, status, ossimImageFileWriter::theInputConnection, and ossimRefPtr< T >::valid().

850 {
851  static const char MODULE[] = "ossimGpkgWriter::addLevels";
852 
853  bool status = false;
854 
855  // Get the image geometry from the input.
857 
858  // Input projection:
860 
861  // Raw area of interest:
862  ossimIrect sourceAoi = getAreaOfInterest();
863 
864  if ( geom.valid() && sourceProj.valid() && (sourceAoi.hasNans() == false) )
865  {
866  ossimRefPtr<ossimMapProjection> productProjection =
867  getNewOutputProjection( geom.get() );
868 
869  if ( productProjection.valid() )
870  {
871  std::string tileTableName;
872  getTileTableName( tileTableName );
873 
874  ossimGpkgTileEntry entry;
875  if ( ossim_gpkg::getTileEntry( m_db, tileTableName, entry ) )
876  {
877  // productProjection must match what's already in there.
878  if ( entry.getSrs().m_organization_coordsys_id ==
879  (ossim_int32)productProjection->getPcsCode() )
880  {
881  ossimDpt sourceGsd;
882  getGsd( productProjection.get(), sourceGsd );
883 
884  bool gridAligned = alignToGrid();
885 
886  if ( gridAligned &&
887  ( productProjection->getClassName() == "ossimUtmProjection" ) )
888  {
889  // Turn off grid alignment for utm.
890  if (traceDebug())
891  {
893  << MODULE << " WARNING!"
894  << "\"align_to_grid\" option is invalid a UTM projection and is "
895  << "being disabled..."
896  << std::endl;
897  }
898 
899  m_kwl->addPair( ALIGN_TO_GRID_KW, std::string("0"), true );
900  gridAligned = false;
901  }
902 
903  // Initialize m_sceneBoundingRect:
904  initializeRect( sourceProj.get(), sourceAoi, m_sceneBoundingRect );
905 
906  if ( gridAligned )
907  {
908  // Initialize m_projectionBoundingRect. Only used if grid aligned.
909  initializeProjectionRect( productProjection.get() );
910  }
911 
912  //---
913  // Set the initial tie point. Requires m_sceneBoundingRect or
914  // m_projectionBoundingRect(grid aligned).
915  //---
916  setProjectionTie( productProjection.get() );
917 
918  // Pull the output rect from the existing entry.
920 
921  if ( gridAligned )
922  {
923  // Set the clip rect.
925  }
926  else
927  {
929  }
930 
931  // Final clip rect to existing entry.
933 
934  // Set tile size:
936 
937  // Set the sequence tile size:
939 
940  // Get the first aoi from the clip rect.
941  ossimIrect aoi;
942  getAoiFromRect( productProjection.get(), m_clipRect, aoi );
943 
944  // Get the current(existing) zoom levels from the entry.
945  std::vector<ossim_int32> currentZoomLevels;
946  entry.getZoomLevels( currentZoomLevels );
947  std::sort( currentZoomLevels.begin(), currentZoomLevels.end() );
948 
949  // Get the zoom levels to write:
950  ossimDpt fullResGsd;
951  std::vector<ossim_int32> zoomLevels;
952  getZoomLevels( productProjection.get(),
953  aoi,
954  sourceGsd,
955  zoomLevels,
956  fullResGsd );
957 
958  // Sanity check. Throws exception:
959  checkLevels( currentZoomLevels, zoomLevels );
960 
961  if ( zoomLevels.size() )
962  {
963  //---
964  // Start zoom level is full res.
965  // Stop zoom level is overview.
966  //---
967 
968  //---
969  // Set the initial full res scale:
970  // Must do this before the below call to
971  // "ossimMapProjection::applyScale"
972  //---
973  bool isGeographic = productProjection->isGeographic();
974  if ( isGeographic )
975  {
976  productProjection->setDecimalDegreesPerPixel( fullResGsd );
977  }
978  else
979  {
980  productProjection->setMetersPerPixel( fullResGsd );
981  }
982 
983  // Recenter tie point after resolution change.
984  setProjectionTie( productProjection.get() );
985 
986  // Stop gsd:
987  ossimDpt stopGsd;
988  getGsd( fullResGsd,
989  zoomLevels[zoomLevels.size()-1],
990  zoomLevels[0],
991  stopGsd );
992 
993  //---
994  // Set the scale of projection to the largest gsd before
995  // expanding AOI. This will also recenter projection tie
996  // for new gsd.
997  //---
998  applyScaleToProjection( productProjection.get(), stopGsd );
999 
1000  // propagate to chains.
1001  setView( productProjection.get() );
1002 
1003  if (traceDebug())
1004  {
1006  << "source aoi: " << sourceAoi
1007  << "\nproduct aoi: " << aoi
1008  // << "\nexpanded aoi(last zoom level): " << expandedAoi
1009  << "\ngsd: " << fullResGsd
1010  << "\nstop gsd: " << stopGsd
1011  << "\ntile size: " << m_tileSize
1012  << "\nscene rect: " << m_sceneBoundingRect
1013  << "\nclip rect: " << m_clipRect
1014  << "\noutput rect: " << m_outputRect
1015  << "\n";
1016 
1017  if ( gridAligned )
1018  {
1020  << "\nproj rect: " << m_projectionBoundingRect << "\n";
1021  }
1022  }
1023 
1024  //---
1025  // Note:
1026  // Writer starts at "stop" zoom level(low res) and goes
1027  // to "start"(high res). I know naming is confusing!
1028  //---
1030  productProjection.get(),
1031  zoomLevels );
1032  status = true;
1033 
1034  } // Matches: if ( zoomLevels.size() )
1035 
1036  } // Matches: if ( entry.getSrs() ...
1037 
1038  } // Matches: if ( productProjection.valid() )
1039 
1040  } // Matches: if ( ossim_gpkg::getTileEntry( m_db, ... )
1041 
1042  } // Matches: if ( geom.valid() && ... )
1043 
1044  return status;
1045 
1046 } // End: ossimGpkgWriter::addLevels()
void checkLevels(const std::vector< ossim_int32 > &currentZoomLevels, const std::vector< ossim_int32 > &newZoomLevels) const
Checks for: new level lower then existing.
void getTileSize(ossimIpt &tileSize) const
bool valid() const
Definition: ossimRefPtr.h:75
const ossimGpkgTileMatrixSetRecord & getTileMatrixSet() const
const ossimMapProjection * getAsMapProjection() const
virtual ossim_uint32 getPcsCode() const
Returns the EPSG PCS code or 32767 if the projection is a custom (non-EPSG) projection.
void setProjectionTie(ossimMapProjection *proj) const
virtual bool isGeographic() const
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
bool getTileEntry(sqlite3 *db, const std::string &tileTableName, ossimGpkgTileEntry &entry)
Gets tile entry whos table_name field matches tileTableName.
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
void getAoiFromRect(const ossimMapProjection *proj, const ossimDrect &rect, ossimIrect &aoi)
Get the view coordinates for edge to edge rect.
virtual void setMetersPerPixel(const ossimDpt &gsd)
ossimDrect m_clipRect
AOI clipped to projection rect.
ossimDrect clipToRect(const ossimDrect &rect) const
Definition: ossimDrect.cpp:769
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
void setView(ossimMapProjection *proj)
void initializeRect(const ossimMapProjection *proj, const ossimIrect &aoi, ossimDrect &rect)
const ossimGpkgSpatialRefSysRecord & getSrs() const
Spatial ref sys.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
void applyScaleToProjection(ossimMapProjection *proj, const ossimDpt &desiredGsd) const
Get the current gsd from projection.
void getTileTableName(std::string &tileTableName) const
Gets the tile table name.
return status
bool alignToGrid() const
void getZoomLevels(std::vector< ossim_int32 > &zoomLevels) const
Gets zoom levels from options keyword list if set.
ossimDrect m_sceneBoundingRect
Holds the bounding rect of the scene edges either in decimal degrees for geographic projection or Eas...
ossimDrect m_outputRect
Expanded(final) AOI clipped to projection rect.
void initializeProjectionRect(const ossimMapProjection *productProj)
void getRect(ossimDrect &rect) const
Gets the rectangle from bounds.
ossimRefPtr< ossimMapProjection > getNewOutputProjection() const
Gets projection from "epsg" code if in options list.
void writeZoomLevels(sqlite3 *db, ossimMapProjection *proj, const std::vector< ossim_int32 > &zoomLevels)
sqlite3 * m_db
database connection
bool hasNans() const
Definition: ossimIrect.h:337
void getZoomLevels(std::vector< ossim_int32 > &zoomLevels) const
Gets zoom levels of all tile matrixes.
virtual ossimIrect getAreaOfInterest() const
virtual void setTileSize(const ossimIpt &tileSize)
ossimDrect m_projectionBoundingRect
Holds the bounding rect of the output projection edges either in decimal degrees for geographic proje...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ addLevels() [2/2]

bool ossimGpkgWriter::addLevels ( ) const
private
Returns
true if "add_levels" key is set to true; false, if not.

◆ alignToGrid()

bool ossimGpkgWriter::alignToGrid ( ) const
private
Returns
true if align to grid option is set; false, if not.

Definition at line 1950 of file ossimGpkgWriter.cpp.

References keyIsTrue().

Referenced by addLevels(), getGsd(), getNewOutputProjection(), getZoomLevels(), setProjectionTie(), and writeEntry().

1951 {
1952  return keyIsTrue( ALIGN_TO_GRID_KW );
1953 }
bool keyIsTrue(const std::string &key) const

◆ append()

bool ossimGpkgWriter::append ( ) const
private

Check if file is to be open new or appended.

Checks for keywords: add_entry, add_levels

Returns
true if any append option is set; false, if not.

Definition at line 1955 of file ossimGpkgWriter.cpp.

References keyIsTrue().

Referenced by open().

1956 {
1957  return ( keyIsTrue( ADD_ENTRY_KW ) || keyIsTrue( ADD_LEVELS_KW ) || keyIsTrue( APPEND_KW ) );
1958 }
bool keyIsTrue(const std::string &key) const

◆ applyScaleToProjection()

void ossimGpkgWriter::applyScaleToProjection ( ossimMapProjection proj,
const ossimDpt desiredGsd 
) const
private

Get the current gsd from projection.

Computes the scale, and calls proj->applyScale(...) recentering tie point.

Parameters
proj
desiredGsdDesired gsd after scale change.

Please leave for debug. (drb)

Definition at line 3105 of file ossimGpkgWriter.cpp.

References ossimMapProjection::applyScale(), getGsd(), ossimDpt::hasNans(), ossimDpt::x, and ossimDpt::y.

3107 {
3108  if ( proj )
3109  {
3110  if ( desiredGsd.hasNans() == false )
3111  {
3112  // Current projection gsd:
3113  ossimDpt currentGsd;
3114  getGsd( proj, currentGsd );
3115 
3116  //---
3117  // Set the scale of projection to the stop gsd:
3118  // True on applyScale is to recenter tie.
3119  //---
3120  ossimDpt scale;
3121  scale.x = desiredGsd.x / currentGsd.x;
3122  scale.y = desiredGsd.y / currentGsd.y;
3123  proj->applyScale( scale, true );
3124 
3125 #if 0
3126  cout << "ossimGpkgWriter::applyScaleToProjection DEBUG:"
3127  << "\nproj gsd: " << currentGsd
3128  << "\ndesired gsd: " << desiredGsd
3129  << "\nscale: " << scale
3130  << "\n";
3131 #endif
3132  }
3133  }
3134 }
double y
Definition: ossimDpt.h:165
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
virtual void applyScale(const ossimDpt &scale, bool recenterTiePoint)
Applies scale to theDeltaLonPerPixel, theDeltaLatPerPixel and theMetersPerPixel data members (eg: the...
bool hasNans() const
Definition: ossimDpt.h:67
double x
Definition: ossimDpt.h:164

◆ beginTileProcessing()

ossim_int32 ossimGpkgWriter::beginTileProcessing ( )
virtual

Calls initial sqlite3_prepare_v2 statement.

Must be called prior to calling writeTile.

Returns
SQLITE_OK(0) on success, something other(non-zero) on failure.

Implements ossimGpkgWriterInterface.

Definition at line 1415 of file ossimGpkgWriter.cpp.

References m_tileTableName.

1416 {
1417  std::ostringstream sql;
1418  sql << "INSERT INTO " << m_tileTableName << "( zoom_level, tile_column, tile_row, tile_data ) VALUES ( "
1419  << "?, " // 1: zoom level
1420  << "?, " // 2: col
1421  << "?, " // 3: row
1422  << "?" // 4: blob
1423  << " )";
1424 
1425  if (traceDebug())
1426  {
1428  << "sql:\n" << sql.str() << "\n";
1429  }
1430 
1431  return sqlite3_prepare_v2(m_db, // Database handle
1432  sql.str().c_str(), // SQL statement, UTF-8 encoded
1433  -1, // Maximum length of zSql in bytes.
1434  &m_pStmt, // OUT: Statement handle
1435  NULL);
1436 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
sqlite3_stmt * m_pStmt
Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile.
std::string m_tileTableName
sqlite3 * m_db
database connection
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ checkLevels()

void ossimGpkgWriter::checkLevels ( const std::vector< ossim_int32 > &  currentZoomLevels,
const std::vector< ossim_int32 > &  newZoomLevels 
) const
private

Checks for: new level lower then existing.

new level already present

Throws exception on error.

Definition at line 3026 of file ossimGpkgWriter.cpp.

3029 {
3030  static const char MODULE[] = "ossimGpkgWriter::checkLevels";
3031 
3032  // Assuming sorted, low to high arrays.
3033  if ( currentZoomLevels.size() )
3034  {
3035  if ( newZoomLevels.size() )
3036  {
3037  // Check for new level lower then existing.
3038  if ( newZoomLevels[0] < currentZoomLevels[0] )
3039  {
3040  std::ostringstream errMsg;
3041  errMsg << MODULE
3042  << " ERROR:\n"
3043  << "New level[" << newZoomLevels[0]
3044  << "] will not fit in existing extents of level["
3045  << currentZoomLevels[0] << "].\n";
3046  throw ossimException( errMsg.str() );
3047  }
3048 
3049  // 2) level already present
3050  std::vector<ossim_int32>::const_iterator newIdx = newZoomLevels.begin();
3051  while ( newIdx < newZoomLevels.end() )
3052  {
3053  std::vector<ossim_int32>::const_iterator currentIdx = currentZoomLevels.begin();
3054  while ( currentIdx != currentZoomLevels.end() )
3055  {
3056  if ( (*newIdx) == (*currentIdx) )
3057  {
3058  std::ostringstream errMsg;
3059  errMsg << MODULE
3060  << " ERROR:\n"
3061  << "New level[" << (*newIdx)
3062  << "] already exists in current matrix set.\n";
3063  throw ossimException( errMsg.str() );
3064  }
3065  ++currentIdx;
3066  }
3067  ++newIdx;
3068  }
3069  }
3070  }
3071 
3072 } // End: ossimGpkgWriter::checkLevels
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35

◆ close()

void ossimGpkgWriter::close ( )
virtual

Generic interface to allow one to close a consumer. For displays this might minimize the window and free up internal pointers for file writers it will make sure the file stream is closed and flushed.

Implements ossimOutputSource.

Definition at line 520 of file ossimGpkgWriter.cpp.

References m_batchCount, m_db, m_fullTileCodec, m_partialTileCodec, and m_pStmt.

Referenced by open(), and ~ossimGpkgWriter().

521 {
522  if ( m_db )
523  {
524  sqlite3_close( m_db );
525  m_db = 0;
526  }
527  m_fullTileCodec = 0;
528  m_partialTileCodec = 0;
529 
530  // ??? : if ( m_pStmt ) finalizeTileProcessing()
531 
532  m_pStmt = 0;
533  m_batchCount = 0;
534 }
ossimRefPtr< ossimCodecBase > m_partialTileCodec
sqlite3_stmt * m_pStmt
Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile.
ossimRefPtr< ossimCodecBase > m_fullTileCodec
Will cache and hold the allocated codecs to use for the encoding.
sqlite3 * m_db
database connection
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

◆ createTables()

bool ossimGpkgWriter::createTables ( sqlite3 *  db)
private

Definition at line 1521 of file ossimGpkgWriter.cpp.

References ossimGpkgTileRecord::createTable(), ossimGpkgNsgTileMatrixExtentRecord::createTable(), ossimGpkgContentsRecord::createTable(), ossimGpkgTileMatrixSetRecord::createTable(), ossimGpkgSpatialRefSysRecord::createTable(), ossimGpkgTileMatrixRecord::createTable(), getTileTableName(), m_tileTableName, and status.

1522 {
1523  bool status = false;
1525  {
1527  {
1529  {
1531  {
1533  {
1536  }
1537  }
1538  }
1539  }
1540  }
1541  return status;
1542 }
static bool createTable(sqlite3 *db, const std::string &tableName)
Creates table in database.
static bool createTable(sqlite3 *db)
Creates table in database.
static bool createTable(sqlite3 *db)
Creates table in database.
static bool createTable(sqlite3 *db)
Creates table in database.
static bool createTable(sqlite3 *db)
Creates gpkg_contents table in database.
std::string m_tileTableName
void getTileTableName(std::string &tileTableName) const
Gets the tile table name.
return status
static bool createTable(sqlite3 *db)
Creates table in database.

◆ finalizeTileProcessing()

void ossimGpkgWriter::finalizeTileProcessing ( )
virtual

Calls sqlite3_finalize(pStmt) terminating tile processing.

Implements ossimGpkgWriterInterface.

Definition at line 1508 of file ossimGpkgWriter.cpp.

References m_batchCount, m_db, and m_pStmt.

1509 {
1510  if ( m_batchCount )
1511  {
1512  char* sErrMsg = 0;
1513  sqlite3_exec(m_db, "END TRANSACTION", NULL, NULL, &sErrMsg);
1514  m_batchCount = 0;
1515  }
1516 
1517  sqlite3_finalize(m_pStmt);
1518  m_pStmt = 0;
1519 }
sqlite3_stmt * m_pStmt
Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile.
sqlite3 * m_db
database connection
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

◆ getAoiFromRect()

void ossimGpkgWriter::getAoiFromRect ( const ossimMapProjection proj,
const ossimDrect rect,
ossimIrect aoi 
)
private

Get the view coordinates for edge to edge rect.

Definition at line 2449 of file ossimGpkgWriter.cpp.

Referenced by reInitializeCutters().

2452 {
2453  static const char MODULE[] = "ossimGpkgWriter::getAoi";
2454 
2455  if (traceDebug())
2456  {
2457  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
2458  }
2459 
2460  // Take the aoi edges(minPt, maxPt), shift to center pixel and return the aoi.
2461  if ( proj )
2462  {
2463  ossimDpt gsd;
2464  getGsd( proj, gsd );
2465  ossimDpt halfGsd = gsd/2.0;
2466 
2467  if (traceDebug())
2468  {
2469  ossimNotify(ossimNotifyLevel_DEBUG) << "gsd: " << gsd << "\n";
2470  }
2471 
2472  ossimDpt ulDpt;
2473  ossimDpt lrDpt;
2474 
2475  if ( proj->isGeographic() )
2476  {
2477  // Convert the ground points to view space.
2478  ossimGpt ulGpt( rect.ul().y-halfGsd.y, rect.ul().x+halfGsd.x, 0.0 );
2479  ossimGpt lrGpt( rect.lr().y+halfGsd.y, rect.lr().x-halfGsd.x, 0.0 );
2480 
2481  // Get the view coords of the aoi.
2482  proj->worldToLineSample(ulGpt, ulDpt);
2483  proj->worldToLineSample(lrGpt, lrDpt);
2484 
2485  if (traceDebug())
2486  {
2488  << "\nulGpt: " << ulGpt
2489  << "\nlrGpt: " << lrGpt
2490  << "\nulDpt: " << ulDpt
2491  << "\nlrDpt: " << lrDpt
2492  << "\n";
2493  }
2494  }
2495  else
2496  {
2497  ossimDpt ulEnPt( rect.ul().x+halfGsd.x, rect.ul().y-halfGsd.y );
2498  ossimDpt lrEnPt( rect.lr().x-halfGsd.x, rect.lr().y+halfGsd.y );
2499 
2500  // Get the view coords of the aoi.
2501  proj->eastingNorthingToLineSample( ulEnPt, ulDpt );
2502  proj->eastingNorthingToLineSample( lrEnPt, lrDpt );
2503  }
2504 
2505  // Area of interest in view space on point boundaries.
2506  aoi = ossimIrect( ossimIpt(ulDpt), ossimIpt(lrDpt) );
2507 
2508  if (traceDebug())
2509  {
2511  << "aoi: " << aoi << "\n"
2512  << MODULE << " exited...\n";
2513  }
2514  }
2515 
2516 } // End: ossimGpkgWriter::getAoiFromRect( ... )
virtual ossimDpt worldToLineSample(const ossimGpt &worldPoint) const
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
virtual bool isGeographic() const
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
double x
Definition: ossimDpt.h:164
virtual void eastingNorthingToLineSample(const ossimDpt &eastingNorthing, ossimDpt &lineSample) const
const ossimDpt & lr() const
Definition: ossimDrect.h:341
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getBatchSize()

ossim_uint64 ossimGpkgWriter::getBatchSize ( ) const
private

This is the number of transactions batched before being executed.

Returns
sqlite transaction batch size.

Definition at line 2243 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::findKey(), m_kwl, and size.

2244 {
2245  ossim_uint64 size = 32; // ???
2246  std::string value = m_kwl->findKey( BATCH_SIZE_KW );
2247  if ( value.size() )
2248  {
2249  size = ossimString(value).toUInt64();
2250  }
2251  return size;
2252 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
yy_size_t size
unsigned long long ossim_uint64
ossim_uint64 toUInt64() const

◆ getClassName()

ossimString ossimGpkgWriter::getClassName ( ) const
virtual
Returns
"ossimGpkgReader"

Reimplemented from ossimObject.

Definition at line 166 of file ossimGpkgWriter.cpp.

167 {
168  return ossimString("ossimGpkgWriter");
169 }

◆ getClipExtents()

bool ossimGpkgWriter::getClipExtents ( ossimDrect rect,
bool &  alignToGridFlag 
) const
private

Get clip rectangle in projected space from key: clip_extents key:value form: clip_extents: <minx>,<miny>,<maxx>,<maxy>

Parameters
rectInitialized by this. This is in output projection coordinate space.
alignToGridFlag.Indicates if the clip extents need to be aligned. The flag will be defaulted to true.
Returns
true on success; false, on error.

Definition at line 2992 of file ossimGpkgWriter.cpp.

References getRect().

2993 {
2994  bool result = getRect( CLIP_EXTENTS_KW, rect );
2995  alignToGridFlag = true;
2996  ossimString value = m_kwl->findKey( CLIP_EXTENTS_ALIGN_TO_GRID_KW );
2997  if(!value.empty()) alignToGridFlag = value.toBool();
2998 
2999  return result;
3000 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
bool toBool() const
String to numeric methods.
bool getRect(const std::string &key, ossimDrect &rect) const
Gets rectangle.
bool empty() const
Definition: ossimString.h:411

◆ getCompressionLevel()

ossimString ossimGpkgWriter::getCompressionLevel ( ) const

Get the gpkg compression level as a string.

Returns
The level which will be one of: z_no_compression z_best_speed z_best_compression z_default_compression

Definition at line 1785 of file ossimGpkgWriter.cpp.

1786 {
1787  ossimString result = ossimString("z_default_compression");
1788 #if 0
1789  switch (theCompressionLevel)
1790  {
1791  case Z_NO_COMPRESSION:
1792  result = ossimString("z_no_compression");
1793  break;
1794 
1795  case Z_BEST_SPEED:
1796  result = ossimString("z_best_speed");
1797  break;
1798 
1799  case Z_BEST_COMPRESSION:
1800  result = ossimString("z_best_compression");
1801  break;
1802 
1803  default:
1804  break;
1805  }
1806 #endif
1807  return result;
1808 }

◆ getCompressionQuality()

ossim_uint32 ossimGpkgWriter::getCompressionQuality ( ) const

Gets the compression quality.

Result is pulled from options keyword list where key=compression_quality.

Returns
Compression quality.or 0 if not found.

Definition at line 1774 of file ossimGpkgWriter.cpp.

References ossimKeywordNames::COMPRESSION_QUALITY_KW, ossimKeywordlist::findKey(), m_kwl, and ossimString::toUInt32().

Referenced by initializeCodec().

1775 {
1776  ossim_uint32 quality = 0;
1777  std::string value = m_kwl->findKey( std::string(ossimKeywordNames::COMPRESSION_QUALITY_KW) );
1778  if ( value.size() )
1779  {
1780  quality = ossimString(value).toUInt32();
1781  }
1782  return quality;
1783 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
unsigned int ossim_uint32
static const char * COMPRESSION_QUALITY_KW

◆ getEpsgCode()

ossim_uint32 ossimGpkgWriter::getEpsgCode ( ) const
private

Definition at line 2672 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

Referenced by getNewOutputProjection().

2673 {
2674  ossim_uint32 result = 0;
2675  std::string value = m_kwl->findKey( EPSG_KW );
2676  if ( value.size() )
2677  {
2678  result = ossimString(value).toUInt32();
2679  }
2680  return result;
2681 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossim_uint32 toUInt32() const
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
unsigned int ossim_uint32

◆ getExpandedAoi()

void ossimGpkgWriter::getExpandedAoi ( const ossimIrect aoi,
ossimIrect expandedAoi 
) const
private

Gets aoi expanded to tile boundaries.

This initializes expandedAoi with the aoi expanded to tile boundaries.

Parameters
aoiArea of interest.
expandedAoiInitialized by this.

Definition at line 2518 of file ossimGpkgWriter.cpp.

References m_tileSize, and ossimIrect::stretchToTileBoundary().

2520 {
2521  expandedAoi = aoi;
2522  expandedAoi.stretchToTileBoundary( m_tileSize );
2523 }
void stretchToTileBoundary(const ossimIpt &tileWidthHeight)
Definition: ossimIrect.cpp:212

◆ getExtension()

ossimString ossimGpkgWriter::getExtension ( ) const
virtual

Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for image file extensions.

Parameters
imageTypestring representing image type.
Returns
the 3-letter string extension.

Reimplemented from ossimImageFileWriter.

Definition at line 1694 of file ossimGpkgWriter.cpp.

1695 {
1696  return ossimString("gpkg");
1697 }

◆ getFilename()

bool ossimGpkgWriter::getFilename ( ossimFilename file) const
private

Definition at line 2916 of file ossimGpkgWriter.cpp.

References ossimKeywordNames::FILENAME_KW, ossimKeywordlist::findKey(), m_kwl, ossimString::size(), status, and ossimString::string().

2917 {
2918  bool status = false;
2919  file.string() = m_kwl->findKey( std::string(ossimKeywordNames::FILENAME_KW) );
2920  if ( file.size() > 0 )
2921  {
2922  status = true;
2923  }
2924  return status;
2925 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
std::string::size_type size() const
Definition: ossimString.h:405
return status
static const char * FILENAME_KW
const std::string & string() const
Definition: ossimString.h:414

◆ getGsd() [1/4]

void ossimGpkgWriter::getGsd ( const ossimDpt fullResGsd,
ossim_int32  fullResZoomLevel,
ossim_int32  currentZoomLevel,
ossimDpt gsd 
)
private

Definition at line 1851 of file ossimGpkgWriter.cpp.

References ossimDpt::hasNans().

Referenced by addLevels(), applyScaleToProjection(), getNewOutputProjection(), initializeRect(), setProjectionTie(), and writeEntry().

1855 {
1856  if ( fullResGsd.hasNans() == false )
1857  {
1858  double delta = fullResZoomLevel - currentZoomLevel;
1859  if ( delta > 0 )
1860  {
1861  gsd = fullResGsd * ( std::pow( 2.0, delta ) );
1862  }
1863  else if ( delta < 0 )
1864  {
1865  gsd = fullResGsd / ( std::pow( 2, std::fabs(delta) ) );
1866  }
1867  else
1868  {
1869  gsd = fullResGsd;
1870  }
1871  }
1872 }
bool hasNans() const
Definition: ossimDpt.h:67

◆ getGsd() [2/4]

void ossimGpkgWriter::getGsd ( const ossimMapProjection proj,
ossimDpt gsd 
) const
private

Get the gsd.

Gets gsd in either meters or decimal degrees dependent on if the projection is "geographic" or not.

Parameters
proj
gsdInitialized by this.

Definition at line 1874 of file ossimGpkgWriter.cpp.

References ossimMapProjection::getDecimalDegreesPerPixel(), ossimMapProjection::getMetersPerPixel(), and ossimMapProjection::isGeographic().

1876 {
1877  if ( proj )
1878  {
1879  if ( proj->isGeographic() )
1880  {
1881  gsd = proj->getDecimalDegreesPerPixel();
1882  }
1883  else
1884  {
1885  gsd = proj->getMetersPerPixel();
1886  }
1887  }
1888 }
virtual const ossimDpt & getDecimalDegreesPerPixel() const
Returns decimal degrees per pixel as an ossimDpt with "x" representing longitude and "y" representing...
virtual bool isGeographic() const
virtual ossimDpt getMetersPerPixel() const

◆ getGsd() [3/4]

void ossimGpkgWriter::getGsd ( const ossimImageGeometry geom,
ossimDpt gsd 
) const
private

Get the gsd.

Gets gsd in either meters or decimal degrees dependent on if the projection is "geographic" or not.

Parameters
geom
gsdInitialized by this.

Definition at line 1890 of file ossimGpkgWriter.cpp.

References ossimImageGeometry::getAsMapProjection(), ossimImageGeometry::getDegreesPerPixel(), ossimImageGeometry::getMetersPerPixel(), and ossimMapProjection::isGeographic().

1892 {
1893  if ( geom )
1894  {
1895  const ossimMapProjection* proj = geom->getAsMapProjection();
1896  if ( proj )
1897  {
1898  if ( proj->isGeographic() )
1899  {
1900  geom->getDegreesPerPixel( gsd );
1901  }
1902  else
1903  {
1904  geom->getMetersPerPixel( gsd );
1905  }
1906  }
1907  }
1908 }
const ossimMapProjection * getAsMapProjection() const
virtual bool isGeographic() const
ossimDpt getDegreesPerPixel() const
Returns the resolution of this image in degrees/pixel.
ossimDpt getMetersPerPixel() const
Returns the GSD associated with this image in the active projection.

◆ getGsd() [4/4]

void ossimGpkgWriter::getGsd ( const ossimMapProjection proj,
ossim_int32  zoomLevel,
ossimDpt gsd 
) const
private

Get the gsd.

Gets gsd in either meters or decimal degrees dependent on if the projection is "geographic" or not.

This method assumes zoom level are aligned to the projection grid. If align_to_grid==false gsd will be "nan"ed.

Parameters
projOutput projection.
zoomLevel
gsdInitialized by this.

Definition at line 1910 of file ossimGpkgWriter.cpp.

References alignToGrid(), getProjectionDimensionsInMeters(), ossimMapProjection::isGeographic(), m_tileSize, ossimDpt::makeNan(), ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

1912 {
1913  if ( proj )
1914  {
1915  if ( alignToGrid() )
1916  {
1917  ossimDpt dims;
1918  if ( proj->isGeographic() )
1919  {
1920  dims.x = 360.0;
1921  dims.y = 180.0;
1922 
1923  gsd.x = 360.0/(m_tileSize.x*2);
1924  gsd.y = 180.0/m_tileSize.y;
1925 
1926  }
1927  else
1928  {
1929  getProjectionDimensionsInMeters( proj, dims );
1930 
1931  // Gsd that puts Earth in one tile:
1932  gsd.x = dims.x/m_tileSize.x;
1933  gsd.y = dims.y/m_tileSize.y;
1934  }
1935 
1936  if ( zoomLevel )
1937  {
1938  gsd = gsd / ( std::pow( 2.0, zoomLevel ) );
1939  }
1940  }
1941  else
1942  {
1943  gsd.makeNan();
1944 
1945  // Error message??? (drb)
1946  }
1947  }
1948 }
double y
Definition: ossimDpt.h:165
virtual bool isGeographic() const
bool alignToGrid() const
ossim_int32 y
Definition: ossimIpt.h:142
double x
Definition: ossimDpt.h:164
ossim_int32 x
Definition: ossimIpt.h:141
void makeNan()
Definition: ossimDpt.h:65
void getProjectionDimensionsInMeters(const ossimMapProjection *proj, ossimDpt &dims) const
Gets the projection dimensions in meters.

◆ getImageTypeList()

void ossimGpkgWriter::getImageTypeList ( std::vector< ossimString > &  imageTypeList) const
virtual

void getImageTypeList(std::vector<ossimString>& imageTypeList)const

Appends this writer image types to list "imageTypeList".

This writer only has one type "gpkg".

Parameters
imageTypeListstl::vector<ossimString> list to append to.

Implements ossimImageFileWriter.

Definition at line 1689 of file ossimGpkgWriter.cpp.

Referenced by ossimSqliteWriterFactory::getImageTypeList().

1690 {
1691  imageTypeList.push_back(ossimString("ossim_gpkg"));
1692 }

◆ getLongName()

ossimString ossimGpkgWriter::getLongName ( ) const
virtual
Returns
"ossim gpkg writer"

Reimplemented from ossimObject.

Definition at line 161 of file ossimGpkgWriter.cpp.

162 {
163  return ossimString("ossim gpkg writer");
164 }

◆ getMatrixSize()

void ossimGpkgWriter::getMatrixSize ( const ossimIrect rect,
ossimIpt matrixSize 
) const
private

Definition at line 2525 of file ossimGpkgWriter.cpp.

References ossimIrect::height(), m_tileSize, ossimIrect::width(), ossimIpt::x, and ossimIpt::y.

2527 {
2528  matrixSize.x = rect.width()/m_tileSize.x;
2529  if ( rect.width() % m_tileSize.x )
2530  {
2531  ++matrixSize.x;
2532  }
2533  matrixSize.y = rect.height()/m_tileSize.y;
2534  if ( rect.height() % m_tileSize.y )
2535  {
2536  ++matrixSize.y;
2537  }
2538 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141

◆ getNewGeographicProjection()

ossimRefPtr< ossimMapProjection > ossimGpkgWriter::getNewGeographicProjection ( ) const
private

Definition at line 2206 of file ossimGpkgWriter.cpp.

References ossimDatumFactory::instance().

Referenced by getNewOutputProjection().

2207 {
2208  // Geographic, WGS 84, with origin at 0,0 for square pixels in decimal degrees.
2211  ossimEllipsoid(),
2212  ossimGpt(0.0, 0.0, 0.0, ossimDatumFactory::instance()->wgs84()) );
2213  return result;
2214 }
static ossimDatumFactory * instance()

◆ getNewOutputProjection() [1/2]

ossimRefPtr< ossimMapProjection > ossimGpkgWriter::getNewOutputProjection ( ossimImageGeometry geom) const
private

Get the output projection.

Output projection type is determined in this order: 1) User set epsg code, e.g. "3395". 2) Input projection. 3) Default output (currently geographic.

Returns
Projection wrapped in ref pointer.

Definition at line 2064 of file ossimGpkgWriter.cpp.

References alignToGrid(), ossimProjection::dup(), ossimImageGeometry::getAsMapProjection(), ossimObject::getClassName(), getGsd(), getNewGeographicProjection(), getNewOutputProjection(), getNewWorldMercatorProjection(), ossimMapProjection::isGeographic(), ossimMapProjection::setDecimalDegreesPerPixel(), ossimMapProjection::setMetersPerPixel(), ossimRefPtr< T >::valid(), ossimDpt::x, and ossimDpt::y.

2066 {
2068 
2069  if ( geom )
2070  {
2071  // "epsg" is a writer prop so check for it. This overrides the input projection.
2072  proj = getNewOutputProjection();
2073 
2074  if ( proj.valid() == false )
2075  {
2077  if ( sourceProj.valid() )
2078  {
2079  // Check the input projection. This could have been set by the caller.
2080  if ( sourceProj->getClassName() == "ossimEquDistCylProjection" )
2081  {
2082  // This will be an equdist with origin at 0, 0.
2083  proj = getNewGeographicProjection();
2084  }
2085  else if ( sourceProj->getClassName() == "ossimMercatorProjection" )
2086  {
2087  // WGS 84 / World Mercator:
2089  }
2090  else if ( sourceProj->getClassName() == "ossimGoogleProjection" )
2091  {
2092  proj = new ossimGoogleProjection(); // sourceProj;
2093  }
2094  else if ( sourceProj->getClassName() == "ossimUtmProjection" )
2095  {
2096  proj = dynamic_cast<ossimMapProjection*>(sourceProj->dup());
2097  }
2098  }
2099 
2100  // Final default:
2101  if ( proj.valid() == false )
2102  {
2103  //---
2104  // DEFAULT: Geographic, WGS 84
2105  // Note: May need to switch default to ossimMercatorProjection:
2106  //---
2107  proj = getNewGeographicProjection();
2108  }
2109  }
2110 
2111  if ( proj.valid() )
2112  {
2113  bool isGeographic = proj->isGeographic();
2114  bool gridAligned = alignToGrid();
2115 
2116  // Set the gsd:
2117  ossimDpt fullResGsd;
2118  getGsd( geom, fullResGsd );
2119 
2120  if ( isGeographic )
2121  {
2122  if ( gridAligned )
2123  {
2124  // Make pixels square if not already.
2125  if ( fullResGsd.y < fullResGsd.x )
2126  {
2127  fullResGsd.x = fullResGsd.y;
2128  }
2129  else if ( fullResGsd.x < fullResGsd.y )
2130  {
2131  fullResGsd.y = fullResGsd.x;
2132  }
2133  }
2134  proj->setDecimalDegreesPerPixel( fullResGsd );
2135  }
2136  else
2137  {
2138  if ( gridAligned && (proj->getClassName() == "ossimUtmProjection" ) )
2139  {
2140  // Turn off grid alignment for utm.
2141  gridAligned = false;
2142  }
2143 
2144  if ( gridAligned )
2145  {
2146  // Make pixels square if not already.
2147  if ( fullResGsd.y < fullResGsd.x )
2148  {
2149  fullResGsd.x = fullResGsd.y;
2150  }
2151  else if ( fullResGsd.x < fullResGsd.y )
2152  {
2153  fullResGsd.y = fullResGsd.x;
2154  }
2155  }
2156  proj->setMetersPerPixel( fullResGsd );
2157  }
2158  }
2159 
2160  } // Matches: if ( geom )
2161 
2162  return proj;
2163 
2164 } // End: ossimGpkgWriter::getNewOutputProjection( geom )
virtual ossimObject * dup() const =0
ossimRefPtr< ossimMapProjection > getNewWorldMercatorProjection() const
bool valid() const
Definition: ossimRefPtr.h:75
const ossimMapProjection * getAsMapProjection() const
double y
Definition: ossimDpt.h:165
virtual bool isGeographic() const
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
virtual void setMetersPerPixel(const ossimDpt &gsd)
ossimRefPtr< ossimMapProjection > getNewGeographicProjection() const
bool alignToGrid() const
ossimRefPtr< ossimMapProjection > getNewOutputProjection() const
Gets projection from "epsg" code if in options list.
double x
Definition: ossimDpt.h:164

◆ getNewOutputProjection() [2/2]

ossimRefPtr< ossimMapProjection > ossimGpkgWriter::getNewOutputProjection ( ) const
private

Gets projection from "epsg" code if in options list.

Definition at line 2166 of file ossimGpkgWriter.cpp.

References ossimEpsgProjectionFactory::createProjection(), ossimRefPtr< T >::get(), getEpsgCode(), getNewGeographicProjection(), getNewWorldMercatorProjection(), ossimEpsgProjectionFactory::instance(), ossimString::toString(), and ossimRefPtr< T >::valid().

Referenced by addLevels(), getNewOutputProjection(), and writeEntry().

2167 {
2169 
2170  // "epsg" is a writer prop so check for it. This overrides the input projection.
2171  ossim_uint32 epsgCode = getEpsgCode();
2172  if ( epsgCode )
2173  {
2174  if ( epsgCode == 4326 )
2175  {
2176  // Geographic, WGS 84
2177  proj = getNewGeographicProjection();
2178  }
2179  else if ( epsgCode == 3395 )
2180  {
2181  // WGS 84 / World Mercator:
2183  }
2184  else if ( ( epsgCode == 3857 ) || ( epsgCode == 900913) )
2185  {
2186  proj = new ossimGoogleProjection();
2187  }
2188  else
2189  {
2190  // Go to the factory:
2191  ossimString name = "EPSG:";
2192  name += ossimString::toString(epsgCode);
2195  if ( proj.valid() )
2196  {
2197  proj = dynamic_cast<ossimMapProjection*>( proj.get() );
2198  }
2199  }
2200  }
2201 
2202  return proj;
2203 
2204 } // End: ossimGpkgWriter::getNewOutputProjection()
ossimRefPtr< ossimMapProjection > getNewWorldMercatorProjection() const
bool valid() const
Definition: ossimRefPtr.h:75
static ossimString toString(bool aValue)
Numeric to string methods.
ossimRefPtr< ossimMapProjection > getNewGeographicProjection() const
unsigned int ossim_uint32
ossim_uint32 getEpsgCode() const
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
STUB. Not implemented.
static ossimEpsgProjectionFactory * instance()
Implements singleton pattern.

◆ getNewWorldMercatorProjection()

ossimRefPtr< ossimMapProjection > ossimGpkgWriter::getNewWorldMercatorProjection ( ) const
private

Definition at line 2216 of file ossimGpkgWriter.cpp.

References ossimDatumFactory::instance(), and ossimMapProjection::setPcsCode().

Referenced by getNewOutputProjection().

2217 {
2218  // EPSG: 3395, "WGS 84 / World Mercator", with origin at 0,0.
2221  ossimEllipsoid(),
2222  ossimGpt(0.0, 0.0, 0.0, ossimDatumFactory::instance()->wgs84()) );
2223 
2224  // Set the pcs(epsg) code:
2225  result->setPcsCode( 3395 );
2226 
2227  return result;
2228 }
virtual void setPcsCode(ossim_uint32 pcsCode)
static ossimDatumFactory * instance()

◆ getNumberOfZoomLevels()

ossim_int32 ossimGpkgWriter::getNumberOfZoomLevels ( const ossimIrect aoi) const
private

Zoom levels needed to get AOI down to one tile.

Parameters
aoiArea of Interest.

Definition at line 2415 of file ossimGpkgWriter.cpp.

References ossimIrect::hasNans(), ossimIrect::height(), m_tileSize, ossimIrect::width(), ossimIpt::x, and ossimIpt::y.

Referenced by getZoomLevels().

2416 {
2417  ossim_int32 result = 0;
2418 
2419  if ( aoi.hasNans() == false )
2420  {
2421  ossim_float64 w = aoi.width();
2422  ossim_float64 h = aoi.height();
2423 
2424  // Take it down to at least a quarter of a tile.
2425  const ossim_float64 TW = m_tileSize.x/4;
2426  const ossim_float64 TH = m_tileSize.y/4;
2427  if ( w && h )
2428  {
2429  ++result; // At least one level.
2430  while ( ( TW < w ) && ( TH < h ) )
2431  {
2432  w /= 2.0;
2433  h /= 2.0;
2434  ++result;
2435  }
2436  }
2437  }
2438 
2439  if (traceDebug())
2440  {
2442  << "ossimGpkgWriter::getNumberOfZoomLevels DEBUG"
2443  << "\nlevels: " << result << "\n";
2444  }
2445 
2446  return result;
2447 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
double ossim_float64
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossim_int32 y
Definition: ossimIpt.h:142
bool hasNans() const
Definition: ossimIrect.h:337
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ getProjectionDimensionsInMeters()

void ossimGpkgWriter::getProjectionDimensionsInMeters ( const ossimMapProjection proj,
ossimDpt dims 
) const
private

Gets the projection dimensions in meters.

Parameters
projProjection
dimsInitialized by this.

Definition at line 2683 of file ossimGpkgWriter.cpp.

References ossimMapProjection::getOrigin(), ossimMapProjection::getPcsCode(), ossimGpt::lat, ossimDpt::x, and ossimDpt::y.

Referenced by getGsd(), and getZoomLevels().

2685 {
2686  if ( proj )
2687  {
2688  ossim_uint32 epsgCode = proj->getPcsCode();
2689 
2690  switch( epsgCode )
2691  {
2692  case 4326:
2693  {
2694  if ( proj->getOrigin().lat == 0.0 )
2695  {
2696  // 20015110.0 * 2 = 40030220.0;
2697  dims.x = 40030220.0;
2698 
2699  // 10007555.0 * 2 = 20015110;
2700  dims.y = 20015110;
2701  }
2702  else
2703  {
2704  std::ostringstream errMsg;
2705  errMsg << "ossimGpkgWriter::getProjectionDimensionsInMeters ERROR:\n"
2706  << "EPSG 4326 Origin latitude is not at 0.\n";
2707  throw ossimException( errMsg.str() );
2708  }
2709  break;
2710  }
2711  case 3395:
2712  {
2713  //---
2714  // http://spatialreference.org/ref/epsg/3395/
2715  // WGS84 Bounds: -180.0000, -80.0000, 180.0000, 84.0000
2716  // Projected Bounds: -20037508.3428, -15496570.7397, 20037508.3428, 18764656.2314
2717  //---
2718  dims.x = 40075016.6856;
2719  dims.y = 34261226.9711;
2720 
2721  break;
2722  }
2723  case 3857:
2724  {
2725  // Bounds:
2726  // -20037508.342789244,-20037508.342789244,20037508.342789244,20037508.342789244
2727  //
2728  dims.x = 40075016.685578488;//40075016.6856;
2729  dims.y = 40075016.685578488;//40075016.6856;
2730  break;
2731  }
2732  default:
2733  {
2734  std::ostringstream errMsg;
2735  errMsg << "ossimGpkgWriter::getProjectionDimensionsInMeters ERROR:\n"
2736  << "Unhandled espg code: " << epsgCode << "\n";
2737  throw ossimException( errMsg.str() );
2738  }
2739  }
2740  }
2741 
2742 } // End: ossimGpkgWriter::getProjectionDimensionsInMeters
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
virtual ossim_uint32 getPcsCode() const
Returns the EPSG PCS code or 32767 if the projection is a custom (non-EPSG) projection.
double y
Definition: ossimDpt.h:165
unsigned int ossim_uint32
const ossimGpt & getOrigin() const
double x
Definition: ossimDpt.h:164
ossim_float64 lat
Definition: ossimGpt.h:265

◆ getProperty()

ossimRefPtr< ossimProperty > ossimGpkgWriter::getProperty ( const ossimString name) const
virtual
Parameters
nameName of property to return.
Returns
A pointer to a property object which matches "name".

Reimplemented from ossimImageFileWriter.

Definition at line 1741 of file ossimGpkgWriter.cpp.

References ossimImageFileWriter::getProperty().

1742 {
1743  ossimRefPtr<ossimProperty> prop = 0;
1744  prop = ossimImageFileWriter::getProperty(name);
1745  return prop;
1746 }
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const

◆ getPropertyNames()

void ossimGpkgWriter::getPropertyNames ( std::vector< ossimString > &  propertyNames) const
virtual

Pushes this's names onto the list of property names.

Parameters
propertyNamesarray to add this's property names to.

Reimplemented from ossimImageFileWriter.

Definition at line 1748 of file ossimGpkgWriter.cpp.

1749 {
1750  propertyNames.push_back(ossimString(ADD_ALPHA_CHANNEL_KW));
1751  propertyNames.push_back(ossimString(ADD_ENTRY_KW));
1752  propertyNames.push_back(ossimString(ADD_LEVELS_KW));
1753  propertyNames.push_back(ossimString(ALIGN_TO_GRID_KW));
1754  propertyNames.push_back(ossimString(APPEND_KW));
1755  propertyNames.push_back(ossimString(BATCH_SIZE_KW));
1756  propertyNames.push_back(ossimString(COMPRESSION_LEVEL_KW));
1757  propertyNames.push_back(ossimString(ossimKeywordNames::COMPRESSION_QUALITY_KW));
1758  propertyNames.push_back(ossimString(EPSG_KW));
1759  propertyNames.push_back(ossimString(INCLUDE_BLANK_TILES_KW));
1760  propertyNames.push_back(ossimString(TILE_SIZE_KW));
1761  propertyNames.push_back(ossimString(TILE_TABLE_NAME_KW));
1762  propertyNames.push_back(ossimString(WRITER_MODE_KW));
1763  propertyNames.push_back(ossimString(ZOOM_LEVELS_KW));
1764 
1766 }
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
static const char * COMPRESSION_QUALITY_KW

◆ getRect()

bool ossimGpkgWriter::getRect ( const std::string &  key,
ossimDrect rect 
) const
private

Gets rectangle.

Method assumes form of: key: <minx>,<miny>,<maxx>,<maxy> e.g. "clip_extents: <minx>,<miny>,<maxx>,<maxy>"

Parameters
rectInitialized by this. This is in output projection coordinate space.
Returns
true on success; false, on error.

Definition at line 3002 of file ossimGpkgWriter.cpp.

References ossimString::downcase(), ossimKeywordlist::findKey(), m_kwl, ossimString::replaceAllThatMatch(), ossimString::size(), ossimString::split(), status, and ossimString::string().

Referenced by getClipExtents(), and getWmsCutBox().

3003 {
3004  bool status = false;
3005  ossimString value;
3006  value.string() = m_kwl->findKey( key );
3007  if ( value.size() )
3008  {
3009  std::string replacementPattern = value.string() + std::string(":");
3010  ossimString bbox = value.downcase().replaceAllThatMatch(replacementPattern.c_str(),"");
3011  std::vector<ossimString> cutBox;
3012  bbox.split( cutBox, "," );
3013  if( cutBox.size() == 4 )
3014  {
3015  ossim_float64 minx = cutBox[0].toFloat64();
3016  ossim_float64 miny = cutBox[1].toFloat64();
3017  ossim_float64 maxx = cutBox[2].toFloat64();
3018  ossim_float64 maxy = cutBox[3].toFloat64();
3019  rect = ossimDrect( minx, maxy, maxx, miny );
3020  status = true;
3021  }
3022  }
3023  return status;
3024 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
double ossim_float64
ossimString replaceAllThatMatch(const char *regularExpressionPattern, const char *value="") const
std::string::size_type size() const
Definition: ossimString.h:405
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
return status
const std::string & string() const
Definition: ossimString.h:414

◆ getShortName()

ossimString ossimGpkgWriter::getShortName ( ) const
virtual
Returns
"gpkg writer"

Reimplemented from ossimObject.

Definition at line 156 of file ossimGpkgWriter.cpp.

157 {
158  return ossimString("ossim_gpkg_writer");
159 }

◆ getTileSize()

void ossimGpkgWriter::getTileSize ( ossimIpt tileSize) const
private

Definition at line 2230 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

2231 {
2232  std::string value = m_kwl->findKey( TILE_SIZE_KW );
2233  if ( value.size() )
2234  {
2235  tileSize.toPoint( value );
2236  }
2237  else
2238  {
2239  ossim::defaultTileSize( tileSize );
2240  }
2241 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
void toPoint(const std::string &s)
Initializes this point from string.
Definition: ossimIpt.cpp:170

◆ getTileTableName()

void ossimGpkgWriter::getTileTableName ( std::string &  tileTableName) const
private

Gets the tile table name.

Looks for "tile_table_name" and returns value if found; else, default="tiles".

Returns
tile table name.

Definition at line 2906 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

Referenced by addLevels(), and createTables().

2907 {
2908  std::string key = "tile_table_name";
2909  tileTableName = m_kwl->findKey( key );
2910  if ( tileTableName.empty() )
2911  {
2912  tileTableName = "tiles";
2913  }
2914 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.

◆ getWmsCutBox()

bool ossimGpkgWriter::getWmsCutBox ( ossimDrect rect) const
private

Get rectangle in projected space from key: cut_wms_bbox key:value form: cut_wms_bbox: <minx>,<miny>,<maxx>,<maxy>

Parameters
rectInitialized by this. This is in output projection coordinate space.
Returns
true on success; false on error.

Definition at line 2986 of file ossimGpkgWriter.cpp.

References getRect().

2987 {
2988  const std::string KEY = "cut_wms_bbox";
2989  return getRect( KEY, rect );
2990 }
bool getRect(const std::string &key, ossimDrect &rect) const
Gets rectangle.

◆ getWriterMode()

ossimGpkgWriter::ossimGpkgWriterMode ossimGpkgWriter::getWriterMode ( ) const

Gets the writer mode.

Default mode = jpeg.

Potential mode are: jpeg png pnga

Returns
Writer mode. Default mode = jpeg.

Definition at line 2599 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::findKey(), m_kwl, and OSSIM_GPGK_WRITER_MODE_MIXED.

Referenced by initializeCodec(), requiresEightBit(), and writeTile().

2600 {
2601  // Default to mixed.
2603 
2604  std::string value = m_kwl->findKey( WRITER_MODE_KW );
2605  if ( value.size() )
2606  {
2607  ossimString os(value);
2608  os.downcase();
2609 
2610  if ( os == "jpeg" )
2611  {
2613  }
2614  else if ( os == "png" )
2615  {
2617  }
2618  else if ( os == "pnga" )
2619  {
2621  }
2622  }
2623  return mode;
2624 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.

◆ getWriterModeString()

std::string ossimGpkgWriter::getWriterModeString ( ossimGpkgWriterMode  mode) const

Gets the writer mode as string.

Default mode = jpeg.

Potential mode are: jpeg png pnga

Returns
Writer mode. Default mode = jpeg.

Definition at line 2626 of file ossimGpkgWriter.cpp.

References OSSIM_GPGK_WRITER_MODE_JPEG, OSSIM_GPGK_WRITER_MODE_MIXED, OSSIM_GPGK_WRITER_MODE_PNG, OSSIM_GPGK_WRITER_MODE_PNGA, and OSSIM_GPGK_WRITER_MODE_UNKNOWN.

Referenced by initializeCodec().

2627 {
2628  std::string result;
2629  switch ( mode )
2630  {
2632  {
2633  result = "jpeg";
2634  break;
2635  }
2637  {
2638  result = "mixed";
2639  break;
2640  }
2642  {
2643  result = "png";
2644  break;
2645  }
2647  {
2648  result = "pnga";
2649  break;
2650  }
2652  default:
2653  {
2654  result = "unknown";
2655  break;
2656  }
2657  }
2658  return result;
2659 }

◆ getZoomLevels() [1/2]

void ossimGpkgWriter::getZoomLevels ( std::vector< ossim_int32 > &  zoomLevels) const
private

Gets zoom levels from options keyword list if set.

Keyword: "zoom_levels"

Splits comma separated list, e.g. "(8,9,10,11)"

If align to grid is on levels are based on projection grid; else, stop zoom level is 0, start is the full res level.

Parameters
proj
aoi
zoomLevelsIntitialized by this.
fullResGsdIntitialized by this.

Definition at line 2254 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

Referenced by getZoomLevels().

2255 {
2256  std::string value = m_kwl->findKey( ZOOM_LEVELS_KW );
2257  if ( value.size() )
2258  {
2259  ossimString stringOfPoints(value);
2260  if ( ossim::toSimpleVector(zoomLevels, stringOfPoints) )
2261  {
2262  std::sort( zoomLevels.begin(), zoomLevels.end() );
2263 
2264  // Check for negative and disallow.
2265  if ( zoomLevels[0] < 0 )
2266  {
2267  zoomLevels.clear();
2268 
2269  // Warning message???
2270  }
2271  }
2272  else
2273  {
2274  zoomLevels.clear();
2275  }
2276  }
2277  else
2278  {
2279  zoomLevels.clear();
2280  }
2281 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
bool toSimpleVector(std::vector< T > &result, const ossimString &stringOfPoints)
Definition: ossimCommon.h:537

◆ getZoomLevels() [2/2]

void ossimGpkgWriter::getZoomLevels ( const ossimMapProjection proj,
const ossimIrect aoi,
const ossimDpt sourceGsd,
std::vector< ossim_int32 > &  zoomLevels,
ossimDpt fullResGsd 
) const
private

Computes start and stop level.

If align to grid is on levels are based on projection grid; else, stop zoom level is 0, start is the full res level.

Parameters
proj
aoi
sourceGsdFull res gsd of input.
zoomLevelsIntitialized by this.
fullResGsdIntitialized by this to the highest resolution of zoom levels. This may or may not be the same as the sourceGsd.

Definition at line 2284 of file ossimGpkgWriter.cpp.

References alignToGrid(), getNumberOfZoomLevels(), getProjectionDimensionsInMeters(), getZoomLevels(), ossimDpt::hasNans(), ossimIrect::hasNans(), ossimMapProjection::isGeographic(), m_tileSize, ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

2289 {
2290  if ( proj && (aoi.hasNans() == false) )
2291  {
2292  // Initial assignment of full res gsd. Will change if aligned to grid is on.
2293  fullResGsd = sourceGsd;
2294 
2295  // Check for user specified levels.
2296  getZoomLevels( zoomLevels );
2297 
2298  if ( zoomLevels.size() )
2299  {
2300  if ( alignToGrid() )
2301  {
2302  ossim_int32 zoomLevel = zoomLevels[zoomLevels.size()-1];
2303  if ( proj->isGeographic() )
2304  {
2305  fullResGsd.x = 360.0/(m_tileSize.x*2);
2306  fullResGsd.y = 180.0/m_tileSize.y;
2307  }
2308  else
2309  {
2310  ossimDpt dims;
2311  getProjectionDimensionsInMeters( proj, dims );
2312 
2313  // Gsd that puts Earth in one tile:
2314  fullResGsd.x = dims.x/m_tileSize.x;
2315  fullResGsd.y = dims.y/m_tileSize.y;
2316  }
2317 
2318  if ( zoomLevel )
2319  {
2320  fullResGsd = fullResGsd / ( std::pow( 2.0, zoomLevel ) );
2321  }
2322  }
2323  }
2324  else
2325  {
2326  ossim_int32 levels = getNumberOfZoomLevels( aoi );
2327  if ( levels )
2328  {
2329  if ( alignToGrid() )
2330  {
2331  ossimDpt zoomGsd;
2332 
2333  if ( proj->isGeographic() )
2334  {
2335  zoomGsd.x = 360.0/(m_tileSize.x*2);
2336  zoomGsd.y = 180.0/m_tileSize.y;
2337  }
2338  else
2339  {
2340  ossimDpt dims;
2341  getProjectionDimensionsInMeters( proj, dims );
2342 
2343  // Gsd that puts Earth in one tile:
2344  zoomGsd.x = dims.x/m_tileSize.x;
2345  zoomGsd.y = dims.y/m_tileSize.y;
2346  }
2347 
2348  if ( fullResGsd.hasNans() == false )
2349  {
2350  // If zoom level gsd is below this threshold we stop there.
2351  ossimDpt gsdThreshold = fullResGsd * 1.5;
2352 
2353  // Start full Earth in 2x1 tiles:
2354  ossim_int32 startZoomLevel = 0;
2355  while ( ( zoomGsd.x > gsdThreshold.x ) &&
2356  ( zoomGsd.y > gsdThreshold.y ) )
2357  {
2358  // Go to next level.
2359  zoomGsd = zoomGsd/2.0;
2360  fullResGsd = zoomGsd;
2361  ++startZoomLevel;
2362  }
2363 
2364  ossim_int32 stopZoomLevel = startZoomLevel-(levels-1);
2365 
2366  if ( stopZoomLevel < 0 ) stopZoomLevel = 0;
2367 
2368  for ( ossim_int32 i = stopZoomLevel; i <= startZoomLevel; ++i )
2369  {
2370  zoomLevels.push_back(i);
2371  }
2372  }
2373  }
2374  else // Not grid aligned.
2375  {
2376  //---
2377  // If not grid aligned the full res gsd is the inputs which is
2378  // already set.
2379  //---
2380  for ( ossim_int32 i = 0; i < levels; ++i )
2381  {
2382  zoomLevels.push_back(i);
2383  }
2384  }
2385  }
2386  }
2387  }
2388 
2389  if (traceDebug())
2390  {
2392  << "ossimGpkgWriter::getZoomLevels DEBUG"
2393  << "aoi: " << aoi << "\n"
2394  << "sourceGsd: " << sourceGsd << "\n"
2395  << "\nfullResGsd: " << fullResGsd << "\n"
2396  << "levels: (";
2397  std::vector<ossim_int32>::const_iterator i = zoomLevels.begin();
2398  while ( i != zoomLevels.end() )
2399  {
2401  ++i;
2402  if ( i != zoomLevels.end() )
2403  {
2405  }
2406  else
2407  {
2409  }
2410  }
2411  }
2412 
2413 } // End: ossimGpkgWriter::getZoomLevels( proj, aoi, ... )
double y
Definition: ossimDpt.h:165
virtual bool isGeographic() const
ossim_int32 getNumberOfZoomLevels(const ossimIrect &aoi) const
Zoom levels needed to get AOI down to one tile.
bool hasNans() const
Definition: ossimDpt.h:67
bool alignToGrid() const
void getZoomLevels(std::vector< ossim_int32 > &zoomLevels) const
Gets zoom levels from options keyword list if set.
ossim_int32 y
Definition: ossimIpt.h:142
double x
Definition: ossimDpt.h:164
bool hasNans() const
Definition: ossimIrect.h:337
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32
void getProjectionDimensionsInMeters(const ossimMapProjection *proj, ossimDpt &dims) const
Gets the projection dimensions in meters.

◆ hasImageType()

bool ossimGpkgWriter::hasImageType ( const ossimString imageType) const
virtual

bool hasImageType(const ossimString& imageType) const

Parameters
imageTypestring representing image type.
Returns
true if "imageType" is supported by writer.

Reimplemented from ossimImageFileWriter.

Definition at line 1699 of file ossimGpkgWriter.cpp.

1700 {
1701  if ( (imageType == "ossim_gpkg") || (imageType == "image/gpkg") )
1702  {
1703  return true;
1704  }
1705 
1706  return false;
1707 }

◆ initializeCodec()

void ossimGpkgWriter::initializeCodec ( )
private

Initializes m_fullTileCodec and m_partialTileCodec.

Definition at line 2927 of file ossimGpkgWriter.cpp.

References ossimCodecFactoryRegistry::createCodec(), DEFAULT_JPEG_QUALITY, ossimRefPtr< T >::get(), getCompressionQuality(), getWriterMode(), getWriterModeString(), ossimCodecFactoryRegistry::instance(), m_fullTileCodec, m_fullTileCodecAlpha, m_partialTileCodec, m_partialTileCodecAlpha, OSSIM_GPGK_WRITER_MODE_JPEG, OSSIM_GPGK_WRITER_MODE_MIXED, OSSIM_GPGK_WRITER_MODE_PNG, OSSIM_GPGK_WRITER_MODE_PNGA, ossimPropertyInterface::setProperty(), ossimString::toString(), and ossimRefPtr< T >::valid().

2928 {
2930  if ( mode == OSSIM_GPGK_WRITER_MODE_JPEG )
2931  {
2934  m_fullTileCodecAlpha = false;
2935  m_partialTileCodecAlpha = false;
2936  }
2937  else if(mode == OSSIM_GPGK_WRITER_MODE_PNG)
2938  {
2941  m_fullTileCodecAlpha = false;
2942  m_partialTileCodecAlpha = false;
2943  }
2944  else if( mode == OSSIM_GPGK_WRITER_MODE_PNGA )
2945  {
2948  m_fullTileCodecAlpha = true;
2949  m_partialTileCodecAlpha = true;
2950  }
2951  else if( mode == OSSIM_GPGK_WRITER_MODE_MIXED )
2952  {
2955  m_fullTileCodecAlpha = false;
2956  m_partialTileCodecAlpha = true;
2957  }
2958  else
2959  {
2960  m_fullTileCodec = 0;
2961  m_partialTileCodec = 0;
2962  }
2963 
2965  {
2966  // Note: This will only take for jpeg. Png uses compression_level and need to add.
2967  ossim_uint32 quality = getCompressionQuality();
2968  if ( !quality )
2969  {
2971  }
2972  m_fullTileCodec->setProperty("quality", ossimString::toString(quality));
2974  }
2975  else
2976  {
2977  std::ostringstream errMsg;
2978  errMsg << "ossimGpkgWriter::initializeCodec ERROR:\n"
2979  << "Unsupported writer mode: " << getWriterModeString( mode )
2980  << "\nCheck for ossim png plugin..."
2981  << "\n";
2982  throw ossimException( errMsg.str() );
2983  }
2984 }
static ossimCodecFactoryRegistry * instance()
ossimGpkgWriterMode getWriterMode() const
Gets the writer mode.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
ossimRefPtr< ossimCodecBase > m_partialTileCodec
bool valid() const
Definition: ossimRefPtr.h:75
static ossimString toString(bool aValue)
Numeric to string methods.
std::string getWriterModeString(ossimGpkgWriterMode mode) const
Gets the writer mode as string.
unsigned int ossim_uint32
ossimRefPtr< ossimCodecBase > m_fullTileCodec
Will cache and hold the allocated codecs to use for the encoding.
ossim_uint32 getCompressionQuality() const
Gets the compression quality.
virtual ossimCodecBase * createCodec(const ossimString &type) const
Will loop through all registered factories trying to allocate a codec for the passed in type...
virtual void setProperty(const ossimString &name, const ossimString &value)
bool m_fullTileCodecAlpha
true if codec requires alpha channel.

◆ initializeGpkg()

bool ossimGpkgWriter::initializeGpkg ( )
private

Initializes the output gpkg file.

This method is used for non-connected writing, e.g. openFile(...), writeTile(...)

Assumes new gpkg with no input connection.

Returns
true on success, false on error.

Definition at line 317 of file ossimGpkgWriter.cpp.

318 {
319  static const char MODULE[] = "ossimGpkgWriter::initializeGpkg";
320  if (traceDebug())
321  {
322  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
323  }
324 
325  bool status = false;
326 
327  if ( alignToGrid() ) // Currently only handle align to grid mode.
328  {
329  // Set tile size:
331 
332  // Output projection:
334  if ( proj.valid() )
335  {
336  // Initialize m_projectionBoundingRect.
337  initializeProjectionRect( proj.get() );
338 
340  if ( m_srs_id != -1 )
341  {
342  // Initialize m_sceneBoundingRect:
343  if ( getWmsCutBox( m_sceneBoundingRect ) == false )
344  {
346  }
347 
348  bool needToExpandFlag = true;
349  //---
350  // Set the initial tie point. will make the AOI come out
351  // (0,0) to (n,n). Needed for getExpandedAoi code. Requires
352  // m_sceneBoundingRect or m_projectionBoundingRect(grid aligned).
353  //---
354  setProjectionTie( proj.get() );
355  // Set the clip rect.
356  if ( getClipExtents( m_clipRect, needToExpandFlag ) == false )
357  {
359  }
360 
361  // Get the zoom levels:
362  m_zoomLevels.clear();
363  m_zoomLevelMatrixSizes.clear();
365 
366  ossim_uint32 levels = m_zoomLevels.size();
367 
368  if ( levels )
369  {
370  // Get the gsd for the most expanded out level:
371  ossimDpt largestGsd;
372  getGsd( proj.get(), m_zoomLevels[0], largestGsd );
373 
374  // Get the gsd for the most expanded out level:
375  ossimDpt smallestGsd;
376  getGsd( proj.get(), m_zoomLevels[ levels-1 ], smallestGsd );
377 
378  //---
379  // Set the scale of projection to the largest gsd before
380  // expanding AOI. This will also recenter projection tie
381  // for new gsd.
382  //---
383  applyScaleToProjection( proj.get(), largestGsd );
384 
385  // AOI at zoomed out level:
386  ossimIrect aoi;
387  getAoiFromRect( proj.get(), m_clipRect, aoi );
388 
389  // Expand the AOI to even tile boundary:
390  ossimIrect expandedAoi = aoi;
391  if(needToExpandFlag)
392  {
393  getExpandedAoi( aoi, expandedAoi );
394  }
395 
396  initializeRect( proj.get(), expandedAoi, m_outputRect );
397 
398  if (traceDebug())
399  {
401  << "\n\nfirst level: " << m_zoomLevels[0]
402  << "\nlast level: " << m_zoomLevels[ levels-1 ]
403  << "\nlevel[" << m_zoomLevels[0] << "] gsd: " << largestGsd
404  << "\nlevel[" << m_zoomLevels[levels-1] << "] gsd: " << smallestGsd
405  << "\nexpanded aoi(first zoom level): " << expandedAoi
406  << "\ntile size: " << m_tileSize
407  << "\nscene rect: " << m_sceneBoundingRect
408  << "\nclip rect: " << m_clipRect
409  << "\noutput rect: " << m_outputRect
410  << "\n";
411  }
412 
414  {
416  {
417  ossimDpt gsd;
418  getGsd( proj.get(), gsd );
419 
420  // Write the tile matrix record for each zoom level.
421  std::vector<ossim_int32>::const_iterator zoomLevel = m_zoomLevels.begin();
422  while ( zoomLevel != m_zoomLevels.end() )
423  {
424  // Get the area of interest.
425  ossimIrect aoi;
426  getAoiFromRect( proj.get(), m_outputRect, aoi );
427 
428  // Clipped aoi:
429  ossimIrect clippedAoi;
430  getAoiFromRect( proj.get(), m_clipRect, clippedAoi );
431 
432  // Expanded to tile boundaries:
433  ossimIrect expandedAoi;
434  getExpandedAoi( aoi, expandedAoi );
435 
436  // Get the number of tiles:
437  ossimIpt matrixSize;
438  getMatrixSize( expandedAoi, matrixSize);
439 
440  // Capture for writeTile index check.
441  m_zoomLevelMatrixSizes.push_back( matrixSize );
442 
443  if (traceDebug())
444  {
446  << "\nlevel: " << (*zoomLevel)
447  << "\ngsd: " << gsd
448  << "\naoi: " << aoi
449  << "\nclippedAoi: " << clippedAoi
450  << "\nexpandedAoi: " << expandedAoi
451  << "\nmatrixSize: " << matrixSize
452  << "\n";
453  }
454 
455  if ( writeGpkgTileMatrixTable( m_db, (*zoomLevel), matrixSize, gsd ) )
456  {
457 
458  if ( writeGpkgNsgTileMatrixExtentTable( m_db, (*zoomLevel),
459  expandedAoi, clippedAoi ) )
460  {
461  status = true;
462  }
463  else
464  {
466  << MODULE
467  << " WARNING:\nwriteGpkgNsgTileMatrixExtentTable call failed!"
468  << std::endl;
469  }
470  }
471  else
472  {
474  << MODULE
475  << " WARNING:\nwriteGpkgTileMatrixTable call failed!" << std::endl;
476  }
477 
478  ++zoomLevel;
479 
480  if ( zoomLevel != m_zoomLevels.end() )
481  {
482  gsd = gsd / 2.0;
483 
484  ossimDpt scale( 0.5, 0.5 );
485  proj->applyScale( scale, true );
486  proj->update();
487  }
488 
489  } // Matches: while ( zoomLevel != zoomLevels.end() )
490 
491  } // Matches: if ( writeGpkgTileMatrixSetTable( m_db, m_outputRect ) )
492 
493  } // Matches: if ( writeGpkgContentsTable( m_db, m_outputRect ) )
494  }
495  else
496  {
498  << "Must have at least one zoom level!"
499  << "Set zoom_levels key in option keyword list."
500  << "e.g. \"zoom_levels:()4,5,6,7,8,9,10,11\""
501  << endl;
502  }
503  }
504  }
505  }
506  else if (traceDebug())
507  {
508  ossimNotify(ossimNotifyLevel_WARN) << "Non-grid-aligned mode not supported!\n";
509  }
510 
511  if (traceDebug())
512  {
514  << MODULE << " exit status: " << (status?"true":"false") << std::endl;
515  }
516 
517  return status;
518 }
void getTileSize(ossimIpt &tileSize) const
std::vector< ossim_int32 > m_zoomLevels
Holds zoom level indexes for connectionless write tile.
bool writeGpkgTileMatrixSetTable(sqlite3 *db, const ossimDrect &boundingRect)
bool valid() const
Definition: ossimRefPtr.h:75
ossim_int32 m_srs_id
ossim_int32 writeGpkgSpatialRefSysTable(sqlite3 *db, const ossimMapProjection *proj)
void setProjectionTie(ossimMapProjection *proj) const
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
void getMatrixSize(const ossimIrect &rect, ossimIpt &matrixSize) const
void getAoiFromRect(const ossimMapProjection *proj, const ossimDrect &rect, ossimIrect &aoi)
Get the view coordinates for edge to edge rect.
virtual void applyScale(const ossimDpt &scale, bool recenterTiePoint)
Applies scale to theDeltaLonPerPixel, theDeltaLatPerPixel and theMetersPerPixel data members (eg: the...
ossimDrect m_clipRect
AOI clipped to projection rect.
ossimDrect clipToRect(const ossimDrect &rect) const
Definition: ossimDrect.cpp:769
std::vector< ossimIpt > m_zoomLevelMatrixSizes
Hold zoom level matrix sizes for connectionless write tile.
unsigned int ossim_uint32
void initializeRect(const ossimMapProjection *proj, const ossimIrect &aoi, ossimDrect &rect)
void applyScaleToProjection(ossimMapProjection *proj, const ossimDpt &desiredGsd) const
Get the current gsd from projection.
return status
bool alignToGrid() const
bool writeGpkgTileMatrixTable(sqlite3 *db, ossim_int32 zoom_level, const ossimIpt &matrixSize, const ossimDpt &gsd)
Initialize method.
void getZoomLevels(std::vector< ossim_int32 > &zoomLevels) const
Gets zoom levels from options keyword list if set.
bool writeGpkgContentsTable(sqlite3 *db, const ossimDrect &boundingRect)
ossimDrect m_sceneBoundingRect
Holds the bounding rect of the scene edges either in decimal degrees for geographic projection or Eas...
ossimDrect m_outputRect
Expanded(final) AOI clipped to projection rect.
void initializeProjectionRect(const ossimMapProjection *productProj)
ossimRefPtr< ossimMapProjection > getNewOutputProjection() const
Gets projection from "epsg" code if in options list.
bool writeGpkgNsgTileMatrixExtentTable(sqlite3 *db, ossim_int32 zoom_level, const ossimIrect &expandedAoi, const ossimIrect &clippedAoi)
sqlite3 * m_db
database connection
bool getWmsCutBox(ossimDrect &rect) const
Get rectangle in projected space from key: cut_wms_bbox key:value form: cut_wms_bbox: <minx>...
bool getClipExtents(ossimDrect &rect, bool &alignToGridFlag) const
Get clip rectangle in projected space from key: clip_extents key:value form: clip_extents: <minx>...
ossimDrect m_projectionBoundingRect
Holds the bounding rect of the output projection edges either in decimal degrees for geographic proje...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void getExpandedAoi(const ossimIrect &aoi, ossimIrect &expandedAoi) const
Gets aoi expanded to tile boundaries.

◆ initializeProjectionRect()

void ossimGpkgWriter::initializeProjectionRect ( const ossimMapProjection productProj)
private

Definition at line 2785 of file ossimGpkgWriter.cpp.

References ossimMapProjection::getOrigin(), ossimMapProjection::getPcsCode(), ossimGpt::lat, m_projectionBoundingRect, and OSSIM_RIGHT_HANDED.

2786 {
2787  if ( proj )
2788  {
2789  ossim_uint32 epsgCode = proj->getPcsCode();
2790 
2791  switch( epsgCode )
2792  {
2793  case 4326:
2794  {
2795  if ( proj->getOrigin().lat == 0.0 )
2796  {
2798  ossimDrect( -180.0, 90.0, 180.0, -90.0, OSSIM_RIGHT_HANDED);
2799  }
2800  else
2801  {
2802  std::ostringstream errMsg;
2803  errMsg << "ossimGpkgWriter::initializeProjectionRect ERROR:\n"
2804  << "EPSG 4326 Origin latitude is not at 0.\n";
2805  throw ossimException( errMsg.str() );
2806  }
2807  break;
2808  }
2809  case 3395:
2810  {
2811  //---
2812  // http://spatialreference.org/ref/epsg/3395/
2813  // WGS84 Bounds: -180.0000, -80.0000, 180.0000, 84.0000
2814  // Projected Bounds: -20037508.3428, -15496570.7397, 20037508.3428, 18764656.2314
2815  //---
2817  ossimDrect( -20037508.3428, 18764656.2314,
2818  20037508.3428, -15496570.7397, OSSIM_RIGHT_HANDED );
2819  break;
2820  }
2821  case 3857:
2822  {
2824  ossimDrect( -20037508.342789244, 20037508.342789244,
2825  20037508.342789244, -20037508.342789244, OSSIM_RIGHT_HANDED);
2826  break;
2827  }
2828  default:
2829  {
2830  std::ostringstream errMsg;
2831  errMsg << "ossimGpkgWriter::initializeProjectionRect ERROR:\n"
2832  << "Unhandled espg code: " << epsgCode << "\n";
2833  throw ossimException( errMsg.str() );
2834  }
2835  }
2836  }
2837 
2838  if (traceDebug())
2839  {
2841  << "ossimGpkgWriter::initializeProjectionRect:\n"
2842  << "projection bounding rect: " << m_projectionBoundingRect
2843  << std::endl;
2844  }
2845 
2846 } // End: ossimGpkgWriter::initializeProjectionRect
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
unsigned int ossim_uint32
ossimDrect m_projectionBoundingRect
Holds the bounding rect of the output projection edges either in decimal degrees for geographic proje...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ initializeRect()

void ossimGpkgWriter::initializeRect ( const ossimMapProjection proj,
const ossimIrect aoi,
ossimDrect rect 
)
private

Definition at line 2848 of file ossimGpkgWriter.cpp.

References getGsd(), ossimMapProjection::isGeographic(), ossimGpt::lat, ossimMapProjection::lineSampleToEastingNorthing(), ossimMapProjection::lineSampleToWorld(), ossimGpt::lon, ossimIrect::lr(), ossim::max< ossim_float64 >(), ossim::min< ossim_float64 >(), OSSIM_RIGHT_HANDED, ossimIrect::ul(), ossimDpt::x, and ossimDpt::y.

2851 {
2852  if ( proj )
2853  {
2854  ossimDpt gsd;
2855  getGsd( proj, gsd );
2856  ossimDpt halfGsd = gsd/2.0;
2857 
2858  ossimDpt ulLineSample = aoi.ul();
2859  ossimDpt lrLineSample = aoi.lr();
2860 
2861  if ( proj->isGeographic() )
2862  {
2863  // Convert line, sample to ground points:
2864  ossimGpt ulGpt;
2865  ossimGpt lrGpt;
2866  proj->lineSampleToWorld( ulLineSample, ulGpt );
2867  proj->lineSampleToWorld( lrLineSample, lrGpt );
2868 
2869  ossim_float64 ulx = ossim::max<ossim_float64>( ulGpt.lon - halfGsd.x, -180.0 );
2870  ossim_float64 uly = ossim::min<ossim_float64>( ulGpt.lat + halfGsd.y, 90.0 );
2871  ossim_float64 lrx = ossim::min<ossim_float64>( lrGpt.lon + halfGsd.x, 180.0 );
2872  ossim_float64 lry = ossim::max<ossim_float64>( lrGpt.lat - halfGsd.y, -90.0 );
2873 
2874  rect = ossimDrect( ulx, uly, lrx, lry, OSSIM_RIGHT_HANDED );
2875  }
2876  else
2877  {
2878  ossimDpt ulEastingNorthingPt;
2879  ossimDpt lrEastingNorthingPt;
2881  aoi.ul(), ulEastingNorthingPt );
2883  aoi.lr(), lrEastingNorthingPt );
2884 
2885  // Edge to edge scene bounding rect.
2886  rect = ossimDrect( ulEastingNorthingPt.x - halfGsd.x,
2887  ulEastingNorthingPt.y + halfGsd.y,
2888  lrEastingNorthingPt.x + halfGsd.x,
2889  lrEastingNorthingPt.y - halfGsd.y,
2891  }
2892 
2893  } // Matches: if ( proj.valid() )
2894 
2895  if (traceDebug())
2896  {
2898  << "ossimGpkgWriter::initializeRect:"
2899  << "\naoi: " << aoi
2900  << "\nrect: " << rect
2901  << std::endl;
2902  }
2903 
2904 } // End: ossimGpkgWriter::initializeRect
ossim_float64 max< ossim_float64 >(ossim_float64 a, ossim_float64 b)
Definition: ossimCommon.h:250
double y
Definition: ossimDpt.h:165
virtual bool isGeographic() const
const ossimIpt & ul() const
Definition: ossimIrect.h:274
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
double ossim_float64
virtual ossimGpt lineSampleToWorld(const ossimDpt &projectedPoint) const
ossim_float64 lon
Definition: ossimGpt.h:266
virtual void lineSampleToEastingNorthing(const ossimDpt &liineSample, ossimDpt &eastingNorthing) const
const ossimIpt & lr() const
Definition: ossimIrect.h:276
double x
Definition: ossimDpt.h:164
ossim_float64 lat
Definition: ossimGpt.h:265
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_float64 min< ossim_float64 >(ossim_float64 a, ossim_float64 b)
Definition: ossimCommon.h:223

◆ isOpen()

bool ossimGpkgWriter::isOpen ( ) const
virtual

Implements ossimOutputSource.

Definition at line 171 of file ossimGpkgWriter.cpp.

References m_db.

172 {
173  return (m_db?true:false);
174 }
sqlite3 * m_db
database connection

◆ isValidZoomLevelRowCol()

bool ossimGpkgWriter::isValidZoomLevelRowCol ( ossim_int32  level,
ossim_int32  row,
ossim_int32  col 
) const
private

Checks to see if level, row, column are within range of existing gpkg.

Parameters
levelZero base level.
rowZero based tile row index.
colZero based tile column index.

Definition at line 3074 of file ossimGpkgWriter.cpp.

References m_zoomLevelMatrixSizes, m_zoomLevels, and status.

Referenced by writeTile().

3076 {
3077  bool status = false;
3078 
3079  if ( m_zoomLevels.size() && (m_zoomLevels.size() == m_zoomLevelMatrixSizes.size()) )
3080  {
3081  std::vector<ossim_int32>::const_iterator zIdx = m_zoomLevels.begin();
3082  std::vector<ossimIpt>::const_iterator sIdx = m_zoomLevelMatrixSizes.begin();
3083  while ( zIdx != m_zoomLevels.end() )
3084  {
3085  if ( (*zIdx) == level )
3086  {
3087  if ( ( row < (*sIdx).y ) && ( col < (*sIdx).x ) &&
3088  ( row > -1 ) && ( col > -1 ) )
3089  {
3090  status = true;
3091  break;
3092  }
3093  }
3094  ++zIdx;
3095  ++sIdx;
3096  }
3097  }
3098 
3099  return status;
3100 
3101 } // End: ossimGpkgWriter::isValidZoomLevel( ossim_int32 level ) const
std::vector< ossim_int32 > m_zoomLevels
Holds zoom level indexes for connectionless write tile.
std::vector< ossimIpt > m_zoomLevelMatrixSizes
Hold zoom level matrix sizes for connectionless write tile.
return status

◆ keyIsTrue()

bool ossimGpkgWriter::keyIsTrue ( const std::string &  key) const
private
Returns
true if key is set to true; false, if not.

Definition at line 1960 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::findKey(), m_kwl, and ossimString::toBool().

Referenced by alignToGrid(), and append().

1961 {
1962  bool result = false;
1963  std::string value = m_kwl->findKey( key );
1964  if ( value.size() )
1965  {
1966  result = ossimString(value).toBool();
1967  }
1968  return result;
1969 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
bool toBool() const
String to numeric methods.

◆ loadState()

bool ossimGpkgWriter::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of an object from a keyword list.

Return true if ok or false on error.

Reimplemented from ossimImageFileWriter.

Definition at line 1666 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::extractKeysThatMatch(), ossimRefPtr< T >::get(), ossimImageFileWriter::loadState(), m_kwl, ossimKeywordlist::stripPrefixFromAll(), and ossimRefPtr< T >::valid().

1667 {
1668  if ( m_kwl.valid() )
1669  {
1670  ossimString regularExpression;
1671  if ( prefix )
1672  {
1673  regularExpression = prefix;
1674  }
1675 
1676  regularExpression += "*";
1677  kwl.extractKeysThatMatch( *(m_kwl.get()), regularExpression );
1678 
1679  if ( prefix )
1680  {
1681  regularExpression = prefix;
1682  m_kwl->stripPrefixFromAll( regularExpression );
1683  }
1684  }
1685 
1686  return ossimImageFileWriter::loadState(kwl, prefix);
1687 }
void stripPrefixFromAll(const ossimString &regularExpression)
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
void extractKeysThatMatch(ossimKeywordlist &kwl, const ossimString &regularExpression) const

◆ open()

bool ossimGpkgWriter::open ( )
virtual

Allows a generic interface to open a consumer for writing. If you are a display writer then you would probably show the window or init the device context for writing.

Implements ossimOutputSource.

Definition at line 176 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::addPair(), append(), close(), ossimFilename::exists(), m_kwl, ossimFilename::remove(), ossimString::size(), status, and ossimImageFileWriter::theFilename.

177 {
178  bool status = false;
179 
180  close();
181 
182  if ( theFilename.size() )
183  {
184  int flags = SQLITE_OPEN_READWRITE;
185 
186  if ( theFilename.exists() )
187  {
188  if ( !append() )
189  {
191  flags |= SQLITE_OPEN_CREATE;
192  }
193  }
194  else
195  {
196  flags |= SQLITE_OPEN_CREATE;
197 
198  //---
199  // Set the append flags to false for down stream code since there was
200  // no file to append.
201  //---
202  m_kwl->addPair( ADD_ENTRY_KW, std::string("0"), true );
203  m_kwl->addPair( ADD_LEVELS_KW, std::string("0"), true );
204  }
205 
206  int rc = sqlite3_open_v2( theFilename.c_str(), &m_db, flags, 0 );
207  if ( rc == SQLITE_OK )
208  {
209  status = true;
210 
211  if ( !append() )
212  {
213  //---
214  // Set the application_id:
215  // Requirement 2: Every GeoPackage must contain 0x47503130 ("GP10" in ACII)
216  // in the application id field of the SQLite database header to indicate a
217  // GeoPackage version 1.0 file.
218  //---
219  const ossim_uint32 ID = 0x47503130;
220  std::ostringstream sql;
221  sql << "PRAGMA application_id = " << ID;
222  if ( ossim_sqlite::exec( m_db, sql.str() ) != SQLITE_DONE )
223  {
224  status = false;
225  }
226  }
227  }
228  else
229  {
230  close();
231  }
232  }
233 
234  return status;
235 }
static bool remove(const ossimFilename &pathname)
Removes pathname from filesystem if supported by platform.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
bool append() const
Check if file is to be open new or appended.
int exec(sqlite3 *db, const std::string &sql)
Preforms sqlite3_prepare_v2, sqlite3_step and sqlite3_finalize.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
bool exists() const
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
return status
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
sqlite3 * m_db
database connection
virtual void close()

◆ openFile()

bool ossimGpkgWriter::openFile ( const ossimKeywordlist options)
virtual

Opens file for writing, appending, merging without an input connection.

I.e. opening, then calling writeTile directly.

Option keywords: append: bool false=create_new, true=append_existing epsg: 4326, 3857 filename: output_file.gpkg tile_table_name: default="tiles" writer_mode: mixed(default), jpeg, png, pnga

Parameters
options.Keyword list containing all options.

Implements ossimGpkgWriterInterface.

Definition at line 237 of file ossimGpkgWriter.cpp.

238 {
239  static const char MODULE[] = "ossimGpkgWriter::openFile";
240  if (traceDebug())
241  {
242  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
243  }
244 
245  bool status = false;
246 
247  if ( isOpen() )
248  {
249  close();
250  }
251 
252  // Add the passed in options to the default options.
253  m_kwl->add( 0, options, true );
254 
255  if (traceDebug())
256  {
258  << "\nwriter options/settings:\n"
259  << *(m_kwl.get()) << "\n";
260  }
261 
262  // Get the filename:
263  if ( getFilename( theFilename ) )
264  {
265  // Open it:
266  if ( open() )
267  {
268  if ( m_db )
269  {
270  if ( createTables( m_db ) )
271  {
272  if ( !append() )
273  {
274  // New file:
276  }
277  else // Existing gpkg....
278  {
279  // Get the zoom level info needed for disconnected writeTile checks.
280  std::string tileTableName;
281  getTileTableName( tileTableName );
282 
283  ossimGpkgTileEntry entry;
284  if ( ossim_gpkg::getTileEntry( m_db, tileTableName, entry ) )
285  {
286  entry.getZoomLevels( m_zoomLevels );
288  status = true;
289  }
290  }
291 
292  if ( status )
293  {
294  initializeCodec(); // Throws exception on error.
295 
296  m_writeBlanks = keyIsTrue( INCLUDE_BLANK_TILES_KW );
298  m_batchCount = 0;
299  }
300  }
301  }
302  }
303  }
304 
305  if (traceDebug())
306  {
308  << MODULE << " exit status: " << (status?"true":"false") << std::endl;
309  }
310 
311  // status = true;
312 
313  return status;
314 }
void initializeCodec()
Initializes m_fullTileCodec and m_partialTileCodec.
std::vector< ossim_int32 > m_zoomLevels
Holds zoom level indexes for connectionless write tile.
bool append() const
Check if file is to be open new or appended.
virtual bool isOpen() const
void getZoomLevelMatrixSizes(std::vector< ossimIpt > &zoomLevelMatrixSizes) const
Gets zoom level matrix of all tile matrixes.
bool initializeGpkg()
Initializes the output gpkg file.
bool getTileEntry(sqlite3 *db, const std::string &tileTableName, ossimGpkgTileEntry &entry)
Gets tile entry whos table_name field matches tileTableName.
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossim_uint64 m_batchSize
Number of transactions batched before being executed.
std::vector< ossimIpt > m_zoomLevelMatrixSizes
Hold zoom level matrix sizes for connectionless write tile.
bool m_writeBlanks
Controlled by option key: "include_blank_tiles".
bool createTables(sqlite3 *db)
void getTileTableName(std::string &tileTableName) const
Gets the tile table name.
return status
virtual const ossimFilename & getFilename() const
ossim_uint64 getBatchSize() const
This is the number of transactions batched before being executed.
sqlite3 * m_db
database connection
virtual void close()
void getZoomLevels(std::vector< ossim_int32 > &zoomLevels) const
Gets zoom levels of all tile matrixes.
bool keyIsTrue(const std::string &key) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool open()
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

◆ reInitializeCombiners()

void ossimGpkgWriter::reInitializeCombiners ( )
private

Finds all combiners and calls initialize to reset the bounding box after a view change.

Definition at line 2009 of file ossimGpkgWriter.cpp.

References ossimConnectableObject::accept(), ossimCollectionVisitor::getObjectAs(), ossimCollectionVisitor::getObjects(), ossimImageCombiner::initialize(), ossimImageFileWriter::theInputConnection, ossimRefPtr< T >::valid(), ossimVisitor::VISIT_CHILDREN, and ossimVisitor::VISIT_INPUTS.

Referenced by setView().

2010 {
2011  if ( theInputConnection.valid() )
2012  {
2013  ossimTypeNameVisitor visitor( ossimString("ossimImageCombiner"),
2014  false, // firstofTypeFlag
2017 
2018  theInputConnection->accept( visitor );
2019  if ( visitor.getObjects().size() )
2020  {
2021  for( ossim_uint32 i = 0; i < visitor.getObjects().size(); ++i )
2022  {
2023  ossimImageCombiner* combiner = visitor.getObjectAs<ossimImageCombiner>( i );
2024  if (combiner)
2025  {
2026  combiner->initialize();
2027  }
2028  }
2029  }
2030  }
2031 }
This will be a base for all combiners.
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.

◆ reInitializeCutters()

void ossimGpkgWriter::reInitializeCutters ( const ossimMapProjection proj)
private

Finds all ossimRectangleCutter and calls setRectangle with a nan rect to reset the bounding box after a view change.

Definition at line 2033 of file ossimGpkgWriter.cpp.

References ossimConnectableObject::accept(), getAoiFromRect(), ossimCollectionVisitor::getObjectAs(), ossimCollectionVisitor::getObjects(), m_clipRect, ossimSource::setEnableFlag(), ossimRectangleCutFilter::setRectangle(), ossimImageFileWriter::theInputConnection, ossimRefPtr< T >::valid(), ossimVisitor::VISIT_CHILDREN, and ossimVisitor::VISIT_INPUTS.

Referenced by setView().

2034 {
2035  if ( theInputConnection.valid() && proj )
2036  {
2037  ossimTypeNameVisitor visitor( ossimString("ossimRectangleCutFilter"),
2038  false, // firstofTypeFlag
2041 
2042  theInputConnection->accept( visitor );
2043  if ( visitor.getObjects().size() )
2044  {
2045  ossimIrect rect;
2046  getAoiFromRect( proj, m_clipRect, rect );
2047 
2048  for( ossim_uint32 i = 0; i < visitor.getObjects().size(); ++i )
2049  {
2050  ossimRectangleCutFilter* cutter = visitor.getObjectAs<ossimRectangleCutFilter>( i );
2051  if (cutter)
2052  {
2053  // Set the clip rect of the cutter.
2054  cutter->setRectangle(rect);
2055 
2056  // Enable the getTile...
2057  cutter->setEnableFlag( true );
2058  }
2059  }
2060  }
2061  }
2062 }
void setRectangle(const ossimIrect &rect)
bool valid() const
Definition: ossimRefPtr.h:75
void getAoiFromRect(const ossimMapProjection *proj, const ossimDrect &rect, ossimIrect &aoi)
Get the view coordinates for edge to edge rect.
ossimDrect m_clipRect
AOI clipped to projection rect.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
virtual void setEnableFlag(bool flag)
Definition: ossimSource.cpp:99
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.

◆ requiresEightBit()

bool ossimGpkgWriter::requiresEightBit ( ) const
private

Definition at line 2661 of file ossimGpkgWriter.cpp.

References getWriterMode(), and OSSIM_GPGK_WRITER_MODE_JPEG.

2662 {
2663  bool result = false;
2665  if ( mode == OSSIM_GPGK_WRITER_MODE_JPEG )
2666  {
2667  result = true;
2668  }
2669  return result;
2670 }
ossimGpkgWriterMode getWriterMode() const
Gets the writer mode.

◆ saveState()

bool ossimGpkgWriter::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

saves the state of the object.

Reimplemented from ossimImageFileWriter.

Definition at line 1656 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::add(), ossimRefPtr< T >::get(), m_kwl, ossimImageFileWriter::saveState(), and ossimRefPtr< T >::valid().

1657 {
1658  if ( m_kwl.valid() )
1659  {
1660  // Lazy man save state...
1661  kwl.add( prefix, *(m_kwl.get()), true );
1662  }
1663  return ossimImageFileWriter::saveState(kwl, prefix);
1664 }
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)

◆ setCompressionLevel()

bool ossimGpkgWriter::setCompressionLevel ( const ossimString level)

Set the gpkg compression level from a string.

Parameters
levelShould be one of: z_no_compression z_best_speed z_best_compression z_default_compression
Returns
true on success, false if level is not accepted.

Definition at line 1810 of file ossimGpkgWriter.cpp.

References ossimString::downcase(), and status.

1811 {
1812  bool status = true;
1813 #if 0
1814  ossimString s = level;
1815  s.downcase();
1816 
1817  if(s == "z_no_compression")
1818  {
1819  theCompressionLevel = Z_NO_COMPRESSION;
1820  }
1821  else if(s == "z_best_speed")
1822  {
1823  theCompressionLevel = Z_BEST_SPEED;
1824  }
1825  else if(s == "z_best_compression")
1826  {
1827  theCompressionLevel = Z_BEST_COMPRESSION;
1828  }
1829  else if(s == "z_default_compression")
1830  {
1831  theCompressionLevel = Z_DEFAULT_COMPRESSION;
1832  }
1833  else
1834  {
1835  status = false;
1836  }
1837 
1838  if (traceDebug())
1839  {
1841  << "DEBUG:"
1842  << "\nossimGpkgWriter::setCompressionLevel DEBUG"
1843  << "passed in level: " << level.c_str()
1844  << "writer level: " << getCompressionLevel().c_str()
1845  << std::endl;
1846  }
1847 #endif
1848  return status;
1849 }
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
return status
ossimString getCompressionLevel() const
Get the gpkg compression level as a string.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setCompressionQuality()

void ossimGpkgWriter::setCompressionQuality ( const std::string &  quality)

Definition at line 1768 of file ossimGpkgWriter.cpp.

References ossimKeywordlist::addPair(), ossimKeywordNames::COMPRESSION_QUALITY_KW, and m_kwl.

1769 {
1771  quality );
1772 }
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
static const char * COMPRESSION_QUALITY_KW

◆ setProjectionTie()

void ossimGpkgWriter::setProjectionTie ( ossimMapProjection proj) const
private

Definition at line 2540 of file ossimGpkgWriter.cpp.

References alignToGrid(), getGsd(), ossimMapProjection::isGeographic(), ossimGpt::lat, ossimGpt::lon, m_projectionBoundingRect, m_sceneBoundingRect, ossimMapProjection::setUlTiePoints(), ossimDrect::ul(), ossimDpt::x, and ossimDpt::y.

2541 {
2542  if ( proj )
2543  {
2544  ossimDpt gsd;
2545  getGsd( proj, gsd );
2546  ossimDpt halfGsd = gsd/2.0;
2547 
2548  bool gridAligned = alignToGrid();
2549  bool isGeographic = proj->isGeographic();
2550  if ( isGeographic )
2551  {
2552  ossimGpt tie(0.0, 0.0, 0.0);
2553  if ( gridAligned )
2554  {
2555  tie.lon = m_projectionBoundingRect.ul().x + halfGsd.x;
2556  tie.lat = m_projectionBoundingRect.ul().y - halfGsd.y;
2557  }
2558  else
2559  {
2560  tie.lon = m_sceneBoundingRect.ul().x + halfGsd.x;
2561  tie.lat = m_sceneBoundingRect.ul().y - halfGsd.y;
2562  }
2563  proj->setUlTiePoints(tie);
2564 
2565  if ( traceDebug() )
2566  {
2568  << "ossimGpkgWriter::setProjectionTie DEBUG:\n"
2569  << "tie: " << tie << std::endl;
2570  }
2571  }
2572  else
2573  {
2574  ossimDpt tie( 0.0, 0.0 );
2575  if ( gridAligned )
2576  {
2577  tie.x = m_projectionBoundingRect.ul().x + halfGsd.x;
2578  tie.y = m_projectionBoundingRect.ul().y - halfGsd.y;
2579  }
2580  else
2581  {
2582  tie.x = m_sceneBoundingRect.ul().x + halfGsd.x;
2583  tie.y = m_sceneBoundingRect.ul().y - halfGsd.y;
2584  }
2585 
2586  proj->setUlTiePoints(tie);
2587 
2588  if ( traceDebug() )
2589  {
2591  << "ossimGpkgWriter::setProjectionTie DEBUG:\n"
2592  << "tie: " << tie << std::endl;
2593  }
2594  }
2595  }
2596 
2597 } // End: ossimGpkgWriter::setProjectionTie
const ossimDpt & ul() const
Definition: ossimDrect.h:339
double y
Definition: ossimDpt.h:165
virtual bool isGeographic() const
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
bool alignToGrid() const
ossimDrect m_sceneBoundingRect
Holds the bounding rect of the scene edges either in decimal degrees for geographic projection or Eas...
double x
Definition: ossimDpt.h:164
virtual void setUlTiePoints(const ossimGpt &gpt)
ossimDrect m_projectionBoundingRect
Holds the bounding rect of the output projection edges either in decimal degrees for geographic proje...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setProperty()

void ossimGpkgWriter::setProperty ( ossimRefPtr< ossimProperty property)
virtual

Will set the property whose name matches the argument "property->getName()".

Parameters
propertyObject containing property to set.

Reimplemented from ossimImageFileWriter.

Definition at line 1709 of file ossimGpkgWriter.cpp.

References ossimRefPtr< T >::valid().

1710 {
1711  if ( property.valid() )
1712  {
1713  // See if it's one of our properties:
1714  std::string key = property->getName().string();
1715  if ( ( key == ADD_ALPHA_CHANNEL_KW ) ||
1716  ( key == ADD_ENTRY_KW ) ||
1717  ( key == ADD_LEVELS_KW ) ||
1718  ( key == ALIGN_TO_GRID_KW ) ||
1719  ( key == APPEND_KW ) ||
1720  ( key == BATCH_SIZE_KW ) ||
1721  ( key == COMPRESSION_LEVEL_KW ) ||
1723  ( key == EPSG_KW ) ||
1724  ( key == INCLUDE_BLANK_TILES_KW ) ||
1725  ( key == TILE_SIZE_KW ) ||
1726  ( key == TILE_TABLE_NAME_KW ) ||
1727  ( key == WRITER_MODE_KW ) ||
1728  ( key == ZOOM_LEVELS_KW ) )
1729  {
1730  ossimString value;
1731  property->valueToString(value);
1732  m_kwl->addPair( key, value.string(), true );
1733  }
1734  else
1735  {
1737  }
1738  }
1739 }
bool valid() const
Definition: ossimRefPtr.h:75
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
static const char * COMPRESSION_QUALITY_KW
const std::string & string() const
Definition: ossimString.h:414

◆ setView()

void ossimGpkgWriter::setView ( ossimMapProjection proj)
private

Definition at line 1971 of file ossimGpkgWriter.cpp.

References ossimConnectableObject::accept(), ossimCollectionVisitor::getObjectAs(), ossimCollectionVisitor::getObjects(), ossimImageSourceSequencer::initialize(), reInitializeCombiners(), reInitializeCutters(), ossimViewInterface::setView(), ossimImageFileWriter::theInputConnection, ossimRefPtr< T >::valid(), ossimVisitor::VISIT_CHILDREN, and ossimVisitor::VISIT_INPUTS.

1972 {
1973  if ( theInputConnection.valid() && proj )
1974  {
1975  ossimTypeNameVisitor visitor( ossimString("ossimViewInterface"),
1976  false, // firstofTypeFlag
1979  theInputConnection->accept( visitor );
1980  if ( visitor.getObjects().size() )
1981  {
1982  for( ossim_uint32 i = 0; i < visitor.getObjects().size(); ++i )
1983  {
1984  ossimViewInterface* viewClient = visitor.getObjectAs<ossimViewInterface>( i );
1985  if (viewClient)
1986  {
1987  viewClient->setView( proj );
1988  }
1989  }
1990 
1991  //---
1992  // After a view change the combiners must reset their input rectangles
1993  // for each image.
1994  //---
1996 
1997  //---
1998  // Cutter, if present, must be updated since the view has been
1999  // changed and the cutter's AOI is no longer relative. Note
2000  // the original AOI was already saved for our writer.
2001  //---
2002  reInitializeCutters( proj );
2003 
2005  }
2006  }
2007 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
void reInitializeCutters(const ossimMapProjection *proj)
Finds all ossimRectangleCutter and calls setRectangle with a nan rect to reset the bounding box after...
virtual bool setView(ossimObject *baseObject)=0
void reInitializeCombiners()
Finds all combiners and calls initialize to reset the bounding box after a view change.
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.

◆ writeCodecTile() [1/2]

bool ossimGpkgWriter::writeCodecTile ( ossim_uint8 codecTile,
ossim_int32  codecTileSize,
ossim_int32  zoomLevel,
ossim_int64  row,
ossim_int64  col 
)
virtual

Direct interface to writing a Codec tile to database.

Parameters
codecTileto write.
codecTileSize
zoolLevel
row
col
Note
Can throw ossimException.
Returns
true on success, false on error.

Implements ossimGpkgWriterInterface.

Definition at line 1482 of file ossimGpkgWriter.cpp.

References m_batchCount, m_batchSize, m_db, m_pStmt, and status.

1487 {
1488  bool status = true;
1489 
1490  char* sErrMsg = 0;
1491 
1492  if(m_batchCount == 0)
1493  {
1494  sqlite3_exec(m_db, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
1495  }
1496 
1497  writeCodecTile( m_pStmt, m_db, codecTile, codecTileSize, zoomLevel, row, col);//, quality );
1498  ++m_batchCount;
1499 
1500  if(m_batchCount == m_batchSize)
1501  {
1502  sqlite3_exec(m_db, "END TRANSACTION", NULL, NULL, &sErrMsg);
1503  m_batchCount = 0;
1504  }
1505 
1506  return status;
1507 }
ossim_uint64 m_batchSize
Number of transactions batched before being executed.
sqlite3_stmt * m_pStmt
Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile.
return status
virtual bool writeCodecTile(ossim_uint8 *codecTile, ossim_int32 codecTileSize, ossim_int32 zoomLevel, ossim_int64 row, ossim_int64 col)
Direct interface to writing a Codec tile to database.
sqlite3 * m_db
database connection
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

◆ writeCodecTile() [2/2]

void ossimGpkgWriter::writeCodecTile ( sqlite3_stmt *  pStmt,
sqlite3 *  db,
ossim_uint8 codecTile,
ossim_int32  codecTileSize,
ossim_int32  zoomLevel,
ossim_int64  row,
ossim_int64  col 
)
private

Definition at line 1373 of file ossimGpkgWriter.cpp.

References ossimNotify(), and ossimNotifyLevel_WARN.

1380 {
1381  if ( db && codecTile )
1382  {
1383  // Insert into the database file(gpkg):
1384  int rc = sqlite3_bind_int (pStmt, 1, zoomLevel);
1385  rc |= sqlite3_bind_int (pStmt, 2, col);
1386  rc |= sqlite3_bind_int (pStmt, 3, row);
1387  rc |= sqlite3_bind_blob (pStmt,
1388  4,
1389  (void*)codecTile,
1390  codecTileSize,
1391  SQLITE_TRANSIENT);
1392  if ( rc == SQLITE_OK )
1393  {
1394  rc = sqlite3_step(pStmt);
1395  if ( rc == SQLITE_OK )
1396  {
1398  << "sqlite3_step error: " << sqlite3_errmsg(db) << std::endl;
1399  }
1400 
1401  }
1402  else
1403  {
1405  << "sqlite3_bind_blob error: " << sqlite3_errmsg(db) << std::endl;
1406  }
1407 
1408  sqlite3_clear_bindings(pStmt);
1409  sqlite3_reset(pStmt);
1410 
1411  } // Matches: if ( db && tile.valid() )
1412 }
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ writeEntry()

bool ossimGpkgWriter::writeEntry ( )
private

Writes an entry to gpkg.

This could be either a new file, or a new tile table.

Returns
true on success, false on error.

Definition at line 658 of file ossimGpkgWriter.cpp.

References alignToGrid(), ossimRefPtr< T >::get(), ossimImageWriter::getAreaOfInterest(), ossimImageGeometry::getAsMapProjection(), ossimObject::getClassName(), getGsd(), ossimImageSource::getImageGeometry(), getNewOutputProjection(), ossimIrect::hasNans(), status, ossimImageFileWriter::theInputConnection, and ossimRefPtr< T >::valid().

659 {
660  static const char MODULE[] = "ossimGpkgWriter::writeEntry";
661 
662  bool status = false;
663 
664  // Get the image geometry from the input.
666 
667  // Input projection:
669 
670  // Raw area of interest:
671  ossimIrect sourceAoi = getAreaOfInterest();
672 
673  if ( geom.valid() && sourceProj.valid() && (sourceAoi.hasNans() == false) )
674  {
675  ossimRefPtr<ossimMapProjection> productProjection =
676  getNewOutputProjection( geom.get() );
677 
678  if ( productProjection.valid() )
679  {
680  ossimDpt sourceGsd;
681  getGsd( productProjection.get(), sourceGsd );
682 
683  bool gridAligned = alignToGrid();
684 
685  if ( gridAligned &&
686  ( productProjection->getClassName() == "ossimUtmProjection" ) )
687  {
688  // Turn off grid alignment for utm.
689  if (traceDebug())
690  {
692  << MODULE << " WARNING!"
693  << "\"align_to_grid\" option is invalid a UTM projection and is "
694  << "being disabled..."
695  << std::endl;
696  }
697 
698  m_kwl->addPair( ALIGN_TO_GRID_KW, std::string("0"), true );
699  gridAligned = false;
700  }
701 
702  // Initialize m_sceneBoundingRect:
703  initializeRect( sourceProj.get(), sourceAoi, m_sceneBoundingRect );
704 
705  if ( gridAligned )
706  {
707  // Initialize m_projectionBoundingRect. Only used if grid aligned.
708  initializeProjectionRect( productProjection.get() );
709  }
710 
711  //---
712  // Set the initial tie point. will make the AOI come out
713  // (0,0) to (n,n). Needed for getExpandedAoi code. Requires
714  // m_sceneBoundingRect or m_projectionBoundingRect(grid aligned).
715  //---
716  setProjectionTie( productProjection.get() );
717 
718  if ( gridAligned )
719  {
720  // Set the clip rect.
722  }
723  else
724  {
726  }
727 
728  // Set tile size:
730 
731  // Set the sequence tile size:
733 
734  // Get the first aoi from the clip rect.
735  ossimIrect aoi;
736  getAoiFromRect( productProjection.get(), m_clipRect, aoi );
737 
738  // Get the zoom levels to write:
739  ossimDpt fullResGsd;
740  std::vector<ossim_int32> zoomLevels;
741  getZoomLevels( productProjection.get(),
742  aoi,
743  sourceGsd,
744  zoomLevels,
745  fullResGsd );
746 
747  if ( zoomLevels.size() )
748  {
749  //---
750  // Start zoom level is full res.
751  // Stop zoom level is overview.
752  //---
753 
754  //---
755  // Set the initial full res scale:
756  // Must do this before the below call to
757  // "ossimMapProjection::applyScale"
758  //---
759  bool isGeographic = productProjection->isGeographic();
760  if ( isGeographic )
761  {
762  productProjection->setDecimalDegreesPerPixel( fullResGsd );
763  }
764  else
765  {
766  productProjection->setMetersPerPixel( fullResGsd );
767  }
768 
769  // Recenter tie point after resolution change.
770  setProjectionTie( productProjection.get() );
771 
772  // Stop gsd:
773  ossimDpt stopGsd;
774  getGsd( fullResGsd,
775  zoomLevels[zoomLevels.size()-1],
776  zoomLevels[0],
777  stopGsd );
778 
779  //---
780  // Set the scale of projection to the largest gsd before
781  // expanding AOI. This will also recenter projection tie
782  // for new gsd.
783  //---
784  applyScaleToProjection( productProjection.get(), stopGsd );
785 
786  // propagate to chains.
787  setView( productProjection.get() );
788 
789  // New aoi at zoomed out level:
790  getAoiFromRect( productProjection.get(), m_clipRect, aoi );
791 
792  // Expand the AOI to even tile boundary:
793  ossimIrect expandedAoi;
794  getExpandedAoi( aoi, expandedAoi );
795 
796  initializeRect( productProjection.get(), expandedAoi, m_outputRect );
797 
798  if (traceDebug())
799  {
801  << "source aoi: " << sourceAoi
802  << "\nproduct aoi: " << aoi
803  << "\nexpanded aoi(last zoom level): " << expandedAoi
804  << "\ngsd: " << fullResGsd
805  << "\nstop gsd: " << stopGsd
806  << "\ntile size: " << m_tileSize
807  << "\nscene rect: " << m_sceneBoundingRect
808  << "\nclip rect: " << m_clipRect
809  << "\noutput rect: " << m_outputRect
810  << "\n";
811 
812  if ( gridAligned )
813  {
815  << "\nproj rect: " << m_projectionBoundingRect << "\n";
816  }
817  }
818 
819  m_srs_id = writeGpkgSpatialRefSysTable( m_db, productProjection.get() );
820  if ( m_srs_id != -1 )
821  {
823  {
825  {
826  //---
827  // Note:
828  // Writer starts at "stop" zoom level(low res) and goes
829  // to "start"(high res). I know naming is confusing!
830  //---
832  productProjection.get(),
833  zoomLevels );
834  status = true;
835  }
836  }
837  }
838 
839  } // Matches: if ( zoomLevels.size() )
840 
841  } // Matches: if ( productProjection.valid() )
842 
843  } // Matches: if ( geom.valid() && ... )
844 
845  return status;
846 
847 } // End: ossimGpkgWriter::writeEntry()
void getTileSize(ossimIpt &tileSize) const
bool writeGpkgTileMatrixSetTable(sqlite3 *db, const ossimDrect &boundingRect)
bool valid() const
Definition: ossimRefPtr.h:75
const ossimMapProjection * getAsMapProjection() const
ossim_int32 m_srs_id
ossim_int32 writeGpkgSpatialRefSysTable(sqlite3 *db, const ossimMapProjection *proj)
void setProjectionTie(ossimMapProjection *proj) const
virtual bool isGeographic() const
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
void getAoiFromRect(const ossimMapProjection *proj, const ossimDrect &rect, ossimIrect &aoi)
Get the view coordinates for edge to edge rect.
virtual void setMetersPerPixel(const ossimDpt &gsd)
ossimDrect m_clipRect
AOI clipped to projection rect.
ossimDrect clipToRect(const ossimDrect &rect) const
Definition: ossimDrect.cpp:769
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
void setView(ossimMapProjection *proj)
void initializeRect(const ossimMapProjection *proj, const ossimIrect &aoi, ossimDrect &rect)
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
void applyScaleToProjection(ossimMapProjection *proj, const ossimDpt &desiredGsd) const
Get the current gsd from projection.
return status
bool alignToGrid() const
void getZoomLevels(std::vector< ossim_int32 > &zoomLevels) const
Gets zoom levels from options keyword list if set.
bool writeGpkgContentsTable(sqlite3 *db, const ossimDrect &boundingRect)
ossimDrect m_sceneBoundingRect
Holds the bounding rect of the scene edges either in decimal degrees for geographic projection or Eas...
ossimDrect m_outputRect
Expanded(final) AOI clipped to projection rect.
void initializeProjectionRect(const ossimMapProjection *productProj)
ossimRefPtr< ossimMapProjection > getNewOutputProjection() const
Gets projection from "epsg" code if in options list.
void writeZoomLevels(sqlite3 *db, ossimMapProjection *proj, const std::vector< ossim_int32 > &zoomLevels)
sqlite3 * m_db
database connection
bool hasNans() const
Definition: ossimIrect.h:337
virtual ossimIrect getAreaOfInterest() const
virtual void setTileSize(const ossimIpt &tileSize)
ossimDrect m_projectionBoundingRect
Holds the bounding rect of the output projection edges either in decimal degrees for geographic proje...
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void getExpandedAoi(const ossimIrect &aoi, ossimIrect &expandedAoi) const
Gets aoi expanded to tile boundaries.

◆ writeFile()

bool ossimGpkgWriter::writeFile ( )
privatevirtual

Writes the file to disk or a stream.

Returns
true on success, false on error.

Implements ossimImageFileWriter.

Definition at line 536 of file ossimGpkgWriter.cpp.

537 {
538  static const char MODULE[] = "ossimGpkgWriter::writeFile";
539 
540  if (traceDebug())
541  {
543  << MODULE << " entered..."
544  << "\nwriter options/settings:\n"
545  << *(m_kwl.get()) << "\n";
546  }
547 
548  bool status = false;
549 
551  m_batchCount = 0;
552 
553  try // Exceptions can be thrown...
554  {
556  {
557  //---
558  // To hold the original input to the image source sequencer. Only used
559  // if we mess with the input chain, e.g. add a scalar remapper.
560  //---
561  ossimRefPtr<ossimConnectableObject> originalSequencerInput = 0;
562 
563  //---
564  // Set up input connection for eight bit if needed.
565  // Some writers, e.g. jpeg are only 8 bit.
566  //---
568  requiresEightBit() )
569  {
570  originalSequencerInput = theInputConnection->getInput(0);
571 
573 
574  // Connect scalar remapper to sequencer input.
576 
577  // Connect sequencer to the scalar remapper.
580  }
581 
582  // Note only the master process used for writing...
584  {
585  if (!isOpen())
586  {
587  open();
588  }
589 
590  if ( m_db )
591  {
592  status = createTables( m_db );
593  }
594 
595  if ( status )
596  {
597  if ( keyIsTrue( ADD_LEVELS_KW ) )
598  {
599  status = addLevels();
600  }
601  else
602  {
603  status = writeEntry();
604  }
605  }
606 
607  close();
608  }
609  else // Matches: if( theInputConnection->isMaster() )
610  {
611  // Slave process only used to get tiles from the input.
613  }
614 
615  // Reset the connection if needed.
616  if( originalSequencerInput.valid() )
617  {
618  theInputConnection->connectMyInputTo(0, originalSequencerInput.get());
619  originalSequencerInput = 0;
620  }
621 
622  } // Matches: if ( theInputConnection.isValid() ... )
623  }
624  catch ( const ossimException& e )
625  {
627  << MODULE << " Caught exception!\n"
628  << e.what()
629  << std::endl;
630  status = false;
631  }
632  catch ( const RBD_COMMON::BaseException& me ) // Matrix exeption...
633  {
635  << MODULE << " Caught Matrix exception!\n"
636  << me.what()
637  << std::endl;
638  status = false;
639  }
640  catch ( ... )
641  {
643  << MODULE << " Caught unknown exception!\n"
644  << std::endl;
645  status = false;
646  }
647 
648  if (traceDebug())
649  {
651  << MODULE << " exit status: " << (status?"true":"false") << std::endl;
652  }
653 
654  return status;
655 
656 } // End: ossimGpkgWriter::writeFile
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool isOpen() const
bool requiresEightBit() const
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossim_uint64 m_batchSize
Number of transactions batched before being executed.
virtual const char * what() const
Returns the error message.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
bool createTables(sqlite3 *db)
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
return status
ossim_uint64 getBatchSize() const
This is the number of transactions batched before being executed.
virtual ossimErrorCode getErrorStatus() const
bool writeEntry()
Writes an entry to gpkg.
sqlite3 * m_db
database connection
virtual void close()
8 bit unsigned integer
bool keyIsTrue(const std::string &key) const
bool addLevels()
Adds levels to an existing an gpkg.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool open()
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

◆ writeGpkgContentsTable()

bool ossimGpkgWriter::writeGpkgContentsTable ( sqlite3 *  db,
const ossimDrect boundingRect 
)
private

Definition at line 1579 of file ossimGpkgWriter.cpp.

References ossimGpkgContentsRecord::init(), ossimGpkgContentsRecord::insert(), ossimDrect::lr(), m_srs_id, m_tileTableName, status, ossimDrect::ul(), ossimDpt::x, and ossimDpt::y.

1580 {
1581  bool status = false;
1582  if ( db )
1583  {
1584  ossimGpkgContentsRecord record;
1585  ossimDpt minPt( rect.ul().x, rect.lr().y);
1586  ossimDpt maxPt( rect.lr().x, rect.ul().y);
1587 
1588  if ( record.init( m_tileTableName, m_srs_id, minPt, maxPt ) )
1589  {
1590  status = record.insert( db );
1591  }
1592  }
1593  return status;
1594 }
bool insert(sqlite3 *db)
Inserst this record into gpkg_spatial_ref_sys table.
ossim_int32 m_srs_id
virtual bool init(sqlite3_stmt *pStmt)
Initialize from database.
std::string m_tileTableName
return status

◆ writeGpkgNsgTileMatrixExtentTable()

bool ossimGpkgWriter::writeGpkgNsgTileMatrixExtentTable ( sqlite3 *  db,
ossim_int32  zoom_level,
const ossimIrect expandedAoi,
const ossimIrect clippedAoi 
)
private

Definition at line 1632 of file ossimGpkgWriter.cpp.

References ossimIrect::lr(), m_clipRect, m_tileTableName, status, ossimIrect::ul(), ossimIpt::x, and ossimIpt::y.

1636 {
1637  bool status = false;
1638  if ( db )
1639  {
1640  // Compute the image rect:
1641  ossimIrect imageRect( clippedAoi.ul().x - expandedAoi.ul().x,
1642  clippedAoi.ul().y - expandedAoi.ul().y,
1643  clippedAoi.lr().x - expandedAoi.ul().x,
1644  clippedAoi.lr().y - expandedAoi.ul().y );
1645 
1647  if ( record.init( m_tileTableName, zoom_level, imageRect, m_clipRect ) )
1648  {
1649  status = record.insert( db );
1650  }
1651  }
1652  return status;
1653 
1654 } // ossimGpkgWriter::writeGpkgNsgTileMatrixExtentTable( ... )
const ossimIpt & ul() const
Definition: ossimIrect.h:274
ossimDrect m_clipRect
AOI clipped to projection rect.
std::string m_tileTableName
const ossimIpt & lr() const
Definition: ossimIrect.h:276
return status
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141

◆ writeGpkgSpatialRefSysTable()

ossim_int32 ossimGpkgWriter::writeGpkgSpatialRefSysTable ( sqlite3 *  db,
const ossimMapProjection proj 
)
private
Returns
the "srs_id" number pointing to the gpkg_spatial_ref_sys record for our projection.

Definition at line 1544 of file ossimGpkgWriter.cpp.

References ossimGpkgSpatialRefSysRecord::ERROR, ossimGpkgSpatialRefSysRecord::init(), ossimGpkgSpatialRefSysRecord::insert(), ossimGpkgSpatialRefSysRecord::m_srs_id, ossimGpkgSpatialRefSysRecord::OK, ossimGpkgSpatialRefSysRecord::OK_EXISTS, ossimNotify(), and ossimNotifyLevel_WARN.

1546 {
1547  //---
1548  // NOTE: the "srs_id" is NOT synonomous with the m_organization_coordsys_id, e.g
1549  // 4326. We need this so that other records can tie themselves to the correct
1550  // gpkg_spatial_ref_sys record.
1551  //---
1552  ossim_int32 srs_id = -1;
1553  if ( db && proj )
1554  {
1556  ossimGpkgSpatialRefSysRecord::InitCode returnCode = record.init( db, proj );
1557  if ( returnCode == ossimGpkgSpatialRefSysRecord::OK )
1558  {
1559  if ( record.insert( db ) )
1560  {
1561  srs_id = record.m_srs_id;
1562  }
1563  }
1564  else if ( returnCode == ossimGpkgSpatialRefSysRecord::OK_EXISTS )
1565  {
1566  // Record exists in database already(epsg:4326):
1567  srs_id = record.m_srs_id;
1568  }
1569  else if ( returnCode == ossimGpkgSpatialRefSysRecord::ERROR )
1570  {
1572  << "ossimGpkgWriter::writeGpkgSpatialRefSysTable ERROR initialized record!\n";
1573  }
1574  }
1575  return srs_id;
1576 
1577 } // End: ossimGpkgWriter::writeGpkgSpatialRefSysTable
bool insert(sqlite3 *db)
Inserst this record into gpkg_contents table.
virtual bool init(sqlite3_stmt *pStmt)
Initialize from database.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ writeGpkgTileMatrixSetTable()

bool ossimGpkgWriter::writeGpkgTileMatrixSetTable ( sqlite3 *  db,
const ossimDrect boundingRect 
)
private

Definition at line 1596 of file ossimGpkgWriter.cpp.

References ossimGpkgTileMatrixSetRecord::init(), ossimGpkgTileMatrixSetRecord::insert(), ossimDrect::lr(), m_srs_id, m_tileTableName, status, ossimDrect::ul(), ossimDpt::x, and ossimDpt::y.

1597 {
1598  bool status = false;
1599  if ( db )
1600  {
1602  ossimDpt minPt( rect.ul().x, rect.lr().y);
1603  ossimDpt maxPt( rect.lr().x, rect.ul().y);
1604 
1605  if ( record.init( m_tileTableName, m_srs_id, minPt, maxPt ) )
1606  {
1607  status = record.insert( db );
1608  }
1609  }
1610  return status;
1611 
1612 } // End: ossimGpkgWriter::writeGpkgTileMatrixSetTable
ossim_int32 m_srs_id
std::string m_tileTableName
return status
bool insert(sqlite3 *db)
Inserst this record into gpkg_spatial_ref_sys table.
virtual bool init(sqlite3_stmt *pStmt)
Initialize from database.

◆ writeGpkgTileMatrixTable()

bool ossimGpkgWriter::writeGpkgTileMatrixTable ( sqlite3 *  db,
ossim_int32  zoom_level,
const ossimIpt matrixSize,
const ossimDpt gsd 
)
private

Initialize method.

Parameters
db
zoom_level.Zero being whole Earth...
matrixSizeSize of tile matrix, i.e. number of horizontal vertical tiles.
gsdSize of one pixel either in meters or lat lon.
Returns
true on success, false on error.

Definition at line 1614 of file ossimGpkgWriter.cpp.

References ossimGpkgTileMatrixRecord::init(), ossimGpkgTileMatrixRecord::insert(), m_tileSize, m_tileTableName, and status.

1618 {
1619  bool status = false;
1620  if ( db )
1621  {
1623  if ( record.init( m_tileTableName, zoom_level, matrixSize, m_tileSize, gsd ) )
1624  {
1625  status = record.insert( db );
1626  }
1627  }
1628  return status;
1629 
1630 } // End: ossimGpkgWriter::writeGpkgTileMatrixTable
bool insert(sqlite3 *db)
Inserst this record into gpkg_spatial_ref_sys table.
virtual bool init(sqlite3_stmt *pStmt)
Initialize from database.
std::string m_tileTableName
return status

◆ writeTile() [1/2]

bool ossimGpkgWriter::writeTile ( ossimRefPtr< ossimImageData > &  tile,
ossim_int32  zoomLevel,
ossim_int64  row,
ossim_int64  col 
)
virtual

Direct interface to writing a tile to database.

Parameters
tileto write.
zoolLevel
row
col
Note
Can throw ossimException.
Returns
true on success, false on error.

Implements ossimGpkgWriterInterface.

Definition at line 1439 of file ossimGpkgWriter.cpp.

References ossimDataObject::getDataObjectStatus(), isValidZoomLevelRowCol(), m_batchCount, m_batchSize, m_db, m_pStmt, m_writeBlanks, OSSIM_EMPTY, OSSIM_NULL, status, and ossimRefPtr< T >::valid().

1443 {
1444  bool status = false;
1445 
1446  if ( tile.valid() )
1447  {
1448  // Check for valid zoom level:
1449  if ( isValidZoomLevelRowCol( zoomLevel, row, col ) )
1450  {
1451 
1452  // Only write tiles that have data in them:
1453  if (tile->getDataObjectStatus() != OSSIM_NULL )
1454  {
1455  if( (tile->getDataObjectStatus() != OSSIM_EMPTY) || m_writeBlanks )
1456  {
1457  char* sErrMsg = 0;
1458 
1459  if(m_batchCount == 0)
1460  {
1461  sqlite3_exec(m_db, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
1462  }
1463 
1464  writeTile( m_pStmt, m_db, tile, zoomLevel, row, col);//, quality );
1465  ++m_batchCount;
1466 
1467  if(m_batchCount == m_batchSize)
1468  {
1469  sqlite3_exec(m_db, "END TRANSACTION", NULL, NULL, &sErrMsg);
1470  m_batchCount = 0;
1471  }
1472  }
1473  }
1474 
1475  status = true;
1476  }
1477  }
1478 
1479  return status;
1480 }
virtual bool writeTile(ossimRefPtr< ossimImageData > &tile, ossim_int32 zoomLevel, ossim_int64 row, ossim_int64 col)
Direct interface to writing a tile to database.
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimDataObjectStatus getDataObjectStatus() const
bool isValidZoomLevelRowCol(ossim_int32 level, ossim_int32 row, ossim_int32 col) const
Checks to see if level, row, column are within range of existing gpkg.
ossim_uint64 m_batchSize
Number of transactions batched before being executed.
bool m_writeBlanks
Controlled by option key: "include_blank_tiles".
sqlite3_stmt * m_pStmt
Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile.
return status
sqlite3 * m_db
database connection
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

◆ writeTile() [2/2]

void ossimGpkgWriter::writeTile ( sqlite3_stmt *  pStmt,
sqlite3 *  db,
ossimRefPtr< ossimImageData > &  tile,
ossim_int32  zoomLevel,
ossim_int64  row,
ossim_int64  col 
)
private

Definition at line 1304 of file ossimGpkgWriter.cpp.

References ossimImageData::computeAlphaChannel(), ossimCodecBase::encode(), ossimDataObject::getDataObjectStatus(), getWriterMode(), m_fullTileCodec, m_fullTileCodecAlpha, m_partialTileCodec, m_partialTileCodecAlpha, OSSIM_FULL, OSSIM_GPGK_WRITER_MODE_JPEG, OSSIM_GPGK_WRITER_MODE_MIXED, ossimNotify(), ossimNotifyLevel_WARN, and ossimRefPtr< T >::valid().

1310 {
1311  if ( db && tile.valid() )
1312  {
1313  std::vector<ossim_uint8> codecTile; // To hold the jpeg encoded tile.
1314  bool encodeStatus;
1315  std::string ext;
1316  int mode = getWriterMode();
1317 
1318  if ( tile->getDataObjectStatus() == OSSIM_FULL )
1319  {
1320  if ( m_fullTileCodecAlpha )
1321  {
1322  tile->computeAlphaChannel();
1323  }
1324  encodeStatus = m_fullTileCodec->encode(tile, codecTile);
1325  if((mode == OSSIM_GPGK_WRITER_MODE_JPEG)||(mode == OSSIM_GPGK_WRITER_MODE_MIXED)) ext = ".jpg";
1326  else ext = ".png";
1327  }
1328  else
1329  {
1331  {
1332  tile->computeAlphaChannel();
1333  }
1334  encodeStatus = m_partialTileCodec->encode(tile, codecTile);
1335  if(mode == OSSIM_GPGK_WRITER_MODE_JPEG) ext = ".jpg";
1336  else ext = ".png";
1337  }
1338 
1339  if ( encodeStatus )
1340  {
1341  // Insert into the database file(gpkg):
1342  int rc = sqlite3_bind_int (pStmt, 1, zoomLevel);
1343  rc |= sqlite3_bind_int (pStmt, 2, col);
1344  rc |= sqlite3_bind_int (pStmt, 3, row);
1345  rc |= sqlite3_bind_blob (pStmt,
1346  4,
1347  (void*)&codecTile.front(),
1348  codecTile.size(),
1349  SQLITE_TRANSIENT);
1350  if ( rc == SQLITE_OK )
1351  {
1352  rc = sqlite3_step(pStmt);
1353  if ( rc == SQLITE_OK )
1354  {
1356  << "sqlite3_step error: " << sqlite3_errmsg(db) << std::endl;
1357  }
1358 
1359  }
1360  else
1361  {
1363  << "sqlite3_bind_blob error: " << sqlite3_errmsg(db) << std::endl;
1364  }
1365 
1366  sqlite3_clear_bindings(pStmt);
1367  sqlite3_reset(pStmt);
1368  }
1369 
1370  } // Matches: if ( db && tile.valid() )
1371 }
ossimGpkgWriterMode getWriterMode() const
Gets the writer mode.
virtual void computeAlphaChannel()
Computes the alpha channel.
ossimRefPtr< ossimCodecBase > m_partialTileCodec
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual bool encode(const ossimRefPtr< ossimImageData > &in, std::vector< ossim_uint8 > &out) const =0
Encode method.
ossimRefPtr< ossimCodecBase > m_fullTileCodec
Will cache and hold the allocated codecs to use for the encoding.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool m_fullTileCodecAlpha
true if codec requires alpha channel.

◆ writeTiles()

void ossimGpkgWriter::writeTiles ( sqlite3 *  db,
const ossimIrect aoi,
ossim_int32  zoomLevel,
const ossim_float64 totalTiles,
ossim_float64 tilesWritten 
)
private

Definition at line 1195 of file ossimGpkgWriter.cpp.

References ossimImageSourceSequencer::getNumberOfTilesHorizontal(), ossimImageSourceSequencer::getNumberOfTilesVertical(), m_tileTableName, ossimImageSourceSequencer::setAreaOfInterest(), ossimImageSourceSequencer::setToStartOfSequence(), and ossimImageFileWriter::theInputConnection.

1200 {
1201  if ( db )
1202  {
1203  // Initialize the sequencer:
1206 
1209 
1210  char * sErrMsg = 0;
1211  sqlite3_stmt* pStmt = 0; // The current SQL statement
1212  std::ostringstream sql;
1213  sql << "INSERT INTO " << m_tileTableName << "( zoom_level, tile_column, tile_row, tile_data ) VALUES ( "
1214  << "?, " // 1: zoom level
1215  << "?, " // 2: col
1216  << "?, " // 3: row
1217  << "?" // 4: blob
1218  << " )";
1219 
1220  if (traceDebug())
1221  {
1223  << "sql:\n" << sql.str() << "\n";
1224  }
1225 
1226  int rc = sqlite3_prepare_v2(db, // Database handle
1227  sql.str().c_str(), // SQL statement, UTF-8 encoded
1228  -1, // Maximum length of zSql in bytes.
1229  &pStmt, // OUT: Statement handle
1230  NULL);
1231 
1232  bool writeBlanks = keyIsTrue( INCLUDE_BLANK_TILES_KW );
1233 
1234  if(rc == SQLITE_OK)
1235  {
1236  for ( ossim_int64 row = 0; row < ROWS; ++row )
1237  {
1238  for ( ossim_int64 col = 0; col < COLS; ++col )
1239  {
1240  // Grab the tile.
1242  if ( tile.valid() )
1243  {
1244  // Only write tiles that have data in them:
1245  if (tile->getDataObjectStatus() != OSSIM_NULL )
1246  {
1247  if( (tile->getDataObjectStatus() != OSSIM_EMPTY) || writeBlanks )
1248  {
1249  if(m_batchCount == 0)
1250  {
1251  sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, &sErrMsg);
1252  }
1253 
1254  writeTile( pStmt, db, tile, zoomLevel, row, col);//, quality );
1255  ++m_batchCount;
1256 
1257  if(m_batchCount == m_batchSize)
1258  {
1259  sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &sErrMsg);
1260  m_batchCount = 0;
1261  }
1262  }
1263  }
1264  }
1265  else
1266  {
1267  std::ostringstream errMsg;
1268  errMsg << "ossimGpkgWriter::writeTiles ERROR: "
1269  << "Sequencer returned null tile pointer for ("
1270  << col << ", " << row << ")";
1271 
1272  throw ossimException( errMsg.str() );
1273  }
1274 
1275  // Always increment the tiles written thing.
1276  ++tilesWritten;
1277 
1278  if ( needsAborting() ) break;
1279 
1280  } // End: col loop
1281 
1282  setPercentComplete( (tilesWritten / totalTiles) * 100.0 );
1283 
1284  if ( needsAborting() )
1285  {
1286  setPercentComplete( 100 );
1287  break;
1288  }
1289 
1290  } // End: row loop
1291 
1292  sqlite3_finalize(pStmt);
1293  }
1294  else
1295  {
1297  << "sqlite3_prepare_v2 error: " << sqlite3_errmsg(db) << std::endl;
1298  }
1299 
1300  } // if ( db )
1301 
1302 } // End: ossimGpkgWriter::writeTiles( ... )
virtual bool writeTile(ossimRefPtr< ossimImageData > &tile, ossim_int32 zoomLevel, ossim_int64 row, ossim_int64 col)
Direct interface to writing a tile to database.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual void setAreaOfInterest(const ossimIrect &areaOfInterest)
ossim_uint64 m_batchSize
Number of transactions batched before being executed.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
std::string m_tileTableName
ossim_int64 getNumberOfTilesHorizontal() const
long long ossim_int64
virtual void setPercentComplete(double percentComplete)
bool keyIsTrue(const std::string &key) const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int64 getNumberOfTilesVertical() const
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

◆ writeZoomLevels()

void ossimGpkgWriter::writeZoomLevels ( sqlite3 *  db,
ossimMapProjection proj,
const std::vector< ossim_int32 > &  zoomLevels 
)
private

Definition at line 1048 of file ossimGpkgWriter.cpp.

1054 {
1055  static const char MODULE[] = "ossimGpkgWriter::writeZoomLevels";
1056  if (traceDebug())
1057  {
1058  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered..." << std::endl;
1059  }
1060 
1061  if ( db && proj )
1062  {
1063  initializeCodec(); // Throws exception on error.
1064 
1065  ossimDpt gsd;
1066  getGsd( proj, gsd );
1067 
1068  // To communicate the percent complete.
1069  ossim_float64 tilesWritten = 0.0;
1070  ossim_float64 totalTiles = 0.0;
1071 
1072  std::vector<ossim_int32>::const_iterator zoomLevel = zoomLevels.begin();
1073  while ( zoomLevel != zoomLevels.end() )
1074  {
1075  // Get the area of interest.
1076  ossimIrect aoi;
1077  getAoiFromRect( proj, m_outputRect, aoi );
1078 
1079  // Clipped aoi:
1080  ossimIrect clippedAoi;
1081  getAoiFromRect( proj, m_clipRect, clippedAoi );
1082 
1083  // Expanded to tile boundaries:
1084  ossimIrect expandedAoi;
1085  getExpandedAoi( aoi, expandedAoi );
1086 
1087  // Get the number of tiles:
1088  ossimIpt matrixSize;
1089  getMatrixSize( expandedAoi, matrixSize);
1090 
1091  if ( totalTiles < 1 )
1092  {
1093  //---
1094  // First time through, compute total tiles for percent complete output.
1095  // This will be inaccurate if user skips zoom levels for some reason.
1096  //
1097  // NOTE: Numbers get very large, i.e. billions of tiles.
1098  // Was busting the int 32 boundary multiplying
1099  // (matrixSize.x * matrixSize.y).
1100  //---
1101  ossim_float64 x = matrixSize.x;
1102  ossim_float64 y = matrixSize.y;
1103  totalTiles = x * y;
1104 
1105  ossim_int32 levels = zoomLevels.size();
1106  if ( levels > 1 )
1107  {
1108  // Tile count doubles in each direction with each additional level.
1109  ossim_int32 z = 1;
1110  do
1111  {
1112  x = x * 2.0;
1113  y = y * 2.0;
1114  totalTiles += (x * y);
1115  ++z;
1116  } while ( z < levels );
1117  }
1118 
1119  if (traceDebug())
1120  {
1122  << "total tiles: " << totalTiles << "\n";
1123  }
1124  }
1125  if (traceDebug())
1126  {
1128  << "ossimGpkgWriter::writeZoomLevels DEBUG:"
1129  << "\nlevel: " << (*zoomLevel)
1130  << "\ngsd: " << gsd
1131  << "\naoi: " << aoi
1132  << "\nclippedAoi: " << clippedAoi
1133  << "\nexpandedAoi: " << expandedAoi
1134  << "\nmatrixSize: " << matrixSize
1135  << "\n";
1136  }
1137 
1138  if ( writeGpkgTileMatrixTable( db, (*zoomLevel), matrixSize, gsd ) )
1139  {
1140 
1141  if ( writeGpkgNsgTileMatrixExtentTable( db, (*zoomLevel),
1142  expandedAoi, clippedAoi ) )
1143  {
1144  writeTiles( db, expandedAoi, (*zoomLevel), totalTiles, tilesWritten );
1145  // writeZoomLevel( db, expandedAoi, (*zoomLevel), totalTiles, tilesWritten );
1146  }
1147  else
1148  {
1150  << MODULE
1151  << " WARNING:\nwriteGpkgNsgTileMatrixExtentTable call failed!" << std::endl;
1152  }
1153  }
1154  else
1155  {
1157  << MODULE
1158  << " WARNING:\nwriteGpkgTileMatrixTable call failed!" << std::endl;
1159  }
1160 
1161  if ( needsAborting() ) break;
1162 
1163  ++zoomLevel;
1164 
1165  if ( zoomLevel != zoomLevels.end() )
1166  {
1167  gsd = gsd / 2.0;
1168 
1169  ossimDpt scale( 0.5, 0.5 );
1170  proj->applyScale( scale, true );
1171  proj->update();
1172 
1173  // Propagate projection to chains and update aoi's of cutters.
1174  setView( proj );
1175  }
1176 
1177  } // Matches: while ( zoomLevel != zoomLevels.end() )
1178 
1179  } // Matches: if ( db && proj )
1180 
1182  {
1183  char * sErrMsg = 0;
1184  sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &sErrMsg);
1185  }
1186 
1187  if (traceDebug())
1188  {
1190  << MODULE << " exited...\n";
1191  }
1192 
1193 } // ossimGpkgWriter::writeZoomLevels( ... )
ossim_uint32 x
void initializeCodec()
Initializes m_fullTileCodec and m_partialTileCodec.
ossim_uint32 y
void getGsd(const ossimDpt &fullResGsd, ossim_int32 fullResZoomLevel, ossim_int32 currentZoomLevel, ossimDpt &gsd)
void getMatrixSize(const ossimIrect &rect, ossimIpt &matrixSize) const
void getAoiFromRect(const ossimMapProjection *proj, const ossimDrect &rect, ossimIrect &aoi)
Get the view coordinates for edge to edge rect.
virtual void applyScale(const ossimDpt &scale, bool recenterTiePoint)
Applies scale to theDeltaLonPerPixel, theDeltaLatPerPixel and theMetersPerPixel data members (eg: the...
ossimDrect m_clipRect
AOI clipped to projection rect.
double ossim_float64
void writeTiles(sqlite3 *db, const ossimIrect &aoi, ossim_int32 zoomLevel, const ossim_float64 &totalTiles, ossim_float64 &tilesWritten)
ossim_uint64 m_batchSize
Number of transactions batched before being executed.
void setView(ossimMapProjection *proj)
bool writeGpkgTileMatrixTable(sqlite3 *db, ossim_int32 zoom_level, const ossimIpt &matrixSize, const ossimDpt &gsd)
Initialize method.
ossim_int32 y
Definition: ossimIpt.h:142
ossimDrect m_outputRect
Expanded(final) AOI clipped to projection rect.
bool writeGpkgNsgTileMatrixExtentTable(sqlite3 *db, ossim_int32 zoom_level, const ossimIrect &expandedAoi, const ossimIrect &clippedAoi)
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void getExpandedAoi(const ossimIrect &aoi, ossimIrect &expandedAoi) const
Gets aoi expanded to tile boundaries.
int ossim_int32
ossim_uint64 m_batchCount
Working variable for holding the current batch count.

Member Data Documentation

◆ m_batchCount

ossim_uint64 ossimGpkgWriter::m_batchCount
private

Working variable for holding the current batch count.

Definition at line 647 of file ossimGpkgWriter.h.

Referenced by close(), finalizeTileProcessing(), writeCodecTile(), and writeTile().

◆ m_batchSize

ossim_uint64 ossimGpkgWriter::m_batchSize
private

Number of transactions batched before being executed.

Definition at line 650 of file ossimGpkgWriter.h.

Referenced by writeCodecTile(), and writeTile().

◆ m_clipRect

ossimDrect ossimGpkgWriter::m_clipRect
private

AOI clipped to projection rect.

This is "edge to edge" bounds.

Definition at line 667 of file ossimGpkgWriter.h.

Referenced by reInitializeCutters(), and writeGpkgNsgTileMatrixExtentTable().

◆ m_db

sqlite3* ossimGpkgWriter::m_db
private

database connection

Definition at line 644 of file ossimGpkgWriter.h.

Referenced by addLevels(), close(), finalizeTileProcessing(), isOpen(), writeCodecTile(), and writeTile().

◆ m_fullTileCodec

ossimRefPtr<ossimCodecBase> ossimGpkgWriter::m_fullTileCodec
private

Will cache and hold the allocated codecs to use for the encoding.

There is a full and partial as in mixed mode you could use jpeg for full tiles and png with alpha for partial (edge) tiles.

Definition at line 689 of file ossimGpkgWriter.h.

Referenced by close(), initializeCodec(), and writeTile().

◆ m_fullTileCodecAlpha

bool ossimGpkgWriter::m_fullTileCodecAlpha
private

true if codec requires alpha channel.

Definition at line 693 of file ossimGpkgWriter.h.

Referenced by initializeCodec(), and writeTile().

◆ m_kwl

ossimRefPtr<ossimKeywordlist> ossimGpkgWriter::m_kwl
private

◆ m_outputRect

ossimDrect ossimGpkgWriter::m_outputRect
private

Expanded(final) AOI clipped to projection rect.

This is "edge to edge" bounds.

Definition at line 673 of file ossimGpkgWriter.h.

◆ m_partialTileCodec

ossimRefPtr<ossimCodecBase> ossimGpkgWriter::m_partialTileCodec
private

Definition at line 690 of file ossimGpkgWriter.h.

Referenced by close(), initializeCodec(), and writeTile().

◆ m_partialTileCodecAlpha

bool ossimGpkgWriter::m_partialTileCodecAlpha
private

Definition at line 694 of file ossimGpkgWriter.h.

Referenced by initializeCodec(), and writeTile().

◆ m_projectionBoundingRect

ossimDrect ossimGpkgWriter::m_projectionBoundingRect
private

Holds the bounding rect of the output projection edges either in decimal degrees for geographic projection or Easting/Northings(meters) for map projection.

This is "edge to edge" bounds.

Definition at line 657 of file ossimGpkgWriter.h.

Referenced by initializeProjectionRect(), and setProjectionTie().

◆ m_pStmt

sqlite3_stmt* ossimGpkgWriter::m_pStmt
private

Holds Statement handle from sqlite3_prepare_v2(...) for connectionless write tile.

Definition at line 706 of file ossimGpkgWriter.h.

Referenced by close(), finalizeTileProcessing(), writeCodecTile(), and writeTile().

◆ m_sceneBoundingRect

ossimDrect ossimGpkgWriter::m_sceneBoundingRect
private

Holds the bounding rect of the scene edges either in decimal degrees for geographic projection or Easting/Northings(meters) for map projection.

or Easting/Northings(meters). This is "edge to edge" bounds.

Definition at line 664 of file ossimGpkgWriter.h.

Referenced by setProjectionTie().

◆ m_srs_id

ossim_int32 ossimGpkgWriter::m_srs_id
private

Definition at line 679 of file ossimGpkgWriter.h.

Referenced by writeGpkgContentsTable(), and writeGpkgTileMatrixSetTable().

◆ m_tileSize

ossimIpt ossimGpkgWriter::m_tileSize
private

◆ m_tileTableName

std::string ossimGpkgWriter::m_tileTableName
private

◆ m_writeBlanks

bool ossimGpkgWriter::m_writeBlanks
private

Controlled by option key: "include_blank_tiles".

Definition at line 709 of file ossimGpkgWriter.h.

Referenced by writeTile().

◆ m_zoomLevelMatrixSizes

std::vector<ossimIpt> ossimGpkgWriter::m_zoomLevelMatrixSizes
private

Hold zoom level matrix sizes for connectionless write tile.

Definition at line 700 of file ossimGpkgWriter.h.

Referenced by isValidZoomLevelRowCol().

◆ m_zoomLevels

std::vector<ossim_int32> ossimGpkgWriter::m_zoomLevels
private

Holds zoom level indexes for connectionless write tile.

Definition at line 697 of file ossimGpkgWriter.h.

Referenced by isValidZoomLevelRowCol().


The documentation for this class was generated from the following files: