Skip to content

Commit

Permalink
updated Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
sathwikreddy56 committed Oct 23, 2024
1 parent c987b60 commit f569bf6
Show file tree
Hide file tree
Showing 2 changed files with 331 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,36 @@ SHELL [ "/usr/bin/bash", "-c" ]
ENV DEBIAN_FRONTEND noninteractive
ENV WM_PROJECT_INST_DIR /opt
RUN dpkg-reconfigure debconf --frontend=noninteractive && \
apt-get update && \
apt-get upgrade -y && \
apt-get update && \
apt-get install -y wget gnupg2 cmake git apt-transport-https ca-certificates \
software-properties-common sudo build-essential \
pkg-config g++ libboost-program-options-dev \
libboost-date-time-dev libboost-test-dev && \
libboost-date-time-dev libboost-test-dev python3-pip && \
cd /opt/src && \
DEBIAN_FRONTEND=noninteractive ./windninja/scripts/build_deps_ubuntu_2004.sh && \
rm -rf /var/lib/apt/lists

RUN cd /opt/src/windninja && \
mkdir build && \
mkdir /data && \
cd /opt/src/windninja/build && \
cmake -D SUPRESS_WARNINGS=ON -DNINJAFOAM=ON .. && \
cmake -D SUPRESS_WARNINGS=ON -DNINJAFOAM=ON -DBUILD_FETCH_DEM=ON .. && \
make -j4 && \
make install && \
ldconfig && \
cd /opt/src/windninja && \
/usr/bin/bash -c scripts/build_libs.sh

RUN mkdir -p $FOAM_RUN/../applications && \
cp -r /opt/src/windninja/src/ninjafoam/* $FOAM_RUN/../applications && \
cd $FOAM_RUN/../applications/8 && \
mkdir /openfoam && \
cp -r /opt/openfoam8/* /openfoam/ &&\
. /opt/openfoam8/etc/bashrc && \
wmake libso && \
cd utility/applyInit && \
wmake

CMD /usr/bin/bash -c /usr/local/bin/WindNinja
VOLUME /data
WORKDIR /data
WORKDIR /data
316 changes: 316 additions & 0 deletions autotest/test_cop30.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
/******************************************************************************
*
* $Id$
*
* Project: WindNinja
* Purpose:
* Author: sathwik reddy chandiri <lmnn3@mst.edu>
*
******************************************************************************
*
* THIS SOFTWARE WAS DEVELOPED AT THE ROCKY MOUNTAIN RESEARCH STATION (RMRS)
* MISSOULA FIRE SCIENCES LABORATORY BY EMPLOYEES OF THE FEDERAL GOVERNMENT
* IN THE COURSE OF THEIR OFFICIAL DUTIES. PURSUANT TO TITLE 17 SECTION 105
* OF THE UNITED STATES CODE, THIS SOFTWARE IS NOT SUBJECT TO COPYRIGHT
* PROTECTION AND IS IN THE PUBLIC DOMAIN. RMRS MISSOULA FIRE SCIENCES
* LABORATORY ASSUMES NO RESPONSIBILITY WHATSOEVER FOR ITS USE BY OTHER
* PARTIES, AND MAKES NO GUARANTEES, EXPRESSED OR IMPLIED, ABOUT ITS QUALITY,
* RELIABILITY, OR ANY OTHER CHARACTERISTIC.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/

/*
** FIXME!!!
** This test won't compile on windows msvc due to NOMINMAX (maybe?), disable
*/
#ifndef WIN32
#include <boost/test/unit_test.hpp>

#include <string>

#include "fetch_factory.h"
#include "ninja.h"

#include "cpl_conv.h"

#include "gdal_priv.h"

/******************************************************************************
* "COP30" TEST FIXTURE
******************************************************************************/
struct COP30TestData
{
COP30TestData()
{
GDALAllRegister();
OGRRegisterAll();
fetch = NULL;
poDS = NULL;
pszFilename =
CPLFormFilename( NULL, CPLGenerateTempFilename( "COP30_TEST" ), ".tif" );
RASTER_X_SIZE = 738;
RASTER_Y_SIZE = 919;
}
~COP30TestData()
{
/* COP30Fetch may leave a file */
if( CPLCheckForFile( (char*) pszFilename.c_str(), NULL ) )
{
VSIUnlink( pszFilename.c_str() );
}
if( NULL != fetch )
{
delete fetch;
}
if( NULL != poDS )
{
GDALClose( (GDALDatasetH) poDS );
}
}
double adfBbox[4];
double adfGeoTransform[6];

SurfaceFetch *fetch;
GDALDataset *poDS;

std::string pszFilename;
int RASTER_X_SIZE;
int RASTER_Y_SIZE;
};

/******************************************************************************
* "COP30" BOOST TEST SUITE
*******************************************************************************
* Tests:
* COP30/us_box
* COP30/world_point
* COP30/world_box
* COP30/gdal
******************************************************************************/

BOOST_FIXTURE_TEST_SUITE( COP30, COP30TestData )

/**
* Test bounding box region fetching functionality on US map.
*/
BOOST_AUTO_TEST_CASE( us_box )
{

/*Initialize bounding box around Mackay, Idaho*/
adfBbox[0] = 44.0249023401036;
adfBbox[1] = -113.463446144564;
adfBbox[2] = 43.7832152227745;
adfBbox[3] = -113.749693430469;

fetch = FetchFactory::GetSurfaceFetch(FetchFactory::COP30);
BOOST_REQUIRE_MESSAGE( NULL != fetch, "GetSurfaceFetch returned NULL" );

int rc = fetch->FetchBoundingBox(adfBbox, 30.0, pszFilename.c_str(), NULL);

BOOST_REQUIRE( rc >= 0 );

poDS = (GDALDataset*) GDALOpen( pszFilename.c_str(), GA_Update );

BOOST_REQUIRE_MESSAGE( NULL != poDS, "GDALOpen returned NULL" );

if(rc > 0)
{
GDALFillBandNoData( poDS, 1, 100 );
}

BOOST_REQUIRE_MESSAGE( !GDALHasNoData( poDS, 1 ), "poDS contains no data after GDALOpen" );


poDS->GetGeoTransform(adfGeoTransform);

BOOST_CHECK( CPLIsEqual( 279635.0, (int)(adfGeoTransform[0] + 0.5) ) );
BOOST_CHECK( CPLIsEqual( 30.0, adfGeoTransform[1] ) );
BOOST_CHECK( CPLIsEqual( 0.0, adfGeoTransform[2] ) );
BOOST_CHECK( CPLIsEqual( 4878315.0, (int)(adfGeoTransform[3] + 0.5) ) );
BOOST_CHECK( CPLIsEqual( 0.0, adfGeoTransform[4]) );
BOOST_CHECK( CPLIsEqual( -30.0, adfGeoTransform[5]) );


int nXSize, nYSize;
nXSize = poDS->GetRasterXSize();
nYSize = poDS->GetRasterYSize();

BOOST_CHECK_EQUAL( RASTER_X_SIZE, nXSize );
BOOST_CHECK_EQUAL( RASTER_Y_SIZE, nYSize );

/*If test makes it here, fetch and poDS are not NULL and should be free'd
for next test. */
delete fetch;
GDALClose( (GDALDatasetH) poDS );
fetch = NULL;
poDS = NULL;
}

/**
* Test fetch point coordinate on world map.
*/
BOOST_AUTO_TEST_CASE( world_point )
{
double adfCenter[2];
double adfBuffer[2];

/*Initialize point around Mt. Everest*/
adfCenter[0] = 86.923596;
adfCenter[1] = 27.985818;
adfBuffer[0] = 20.0;
adfBuffer[1] = 20.0;

SurfaceFetch *fetch =
FetchFactory::GetSurfaceFetch( FetchFactory::COP30 );

BOOST_REQUIRE_MESSAGE( NULL != fetch, "GetSurfaceFetch returned NULL" );

int rc = fetch->FetchPoint( adfCenter, adfBuffer, lengthUnits::kilometers,
90.0, pszFilename.c_str(), NULL );
BOOST_REQUIRE( rc >= 0 );

poDS = (GDALDataset*) GDALOpen( pszFilename.c_str(), GA_Update );

BOOST_REQUIRE_MESSAGE( NULL != poDS, "GDALOpen returned NULL" );

if(rc > 0)
{
GDALFillBandNoData( poDS, 1, 100 );
}

BOOST_REQUIRE_MESSAGE( !GDALHasNoData( poDS, 1 ), "poDS contains no data after GDALOpen" );


int nXSize, nYSize;
nXSize = poDS->GetRasterXSize();
nYSize = poDS->GetRasterYSize();

BOOST_CHECK( nXSize >= 1 );
BOOST_CHECK( nYSize >= 1 );
/*If test makes it here, fetch and poDS are not NULL and should be free'd
for next test. */
delete fetch;
GDALClose( (GDALDatasetH) poDS );
fetch = NULL;
poDS = NULL;
}

/*TODO: THIS FAILS, HAVE TO FIX DATELINE STUFF */
/**
* Test bounding box on world map.
*/
/*
BOOST_AUTO_TEST_CASE( world_box )
{
return -1;
GDALAllRegister();
double adfBbox[4];
const char* pszFilename = "out.tif";
double adfGeoTransform[6];
// dateline
adfBbox[0] = 44.0249023401036;
adfBbox[1] = 179.999;
adfBbox[2] = 43.7832152227745;
adfBbox[3] = 180.001;
SurfaceFetch *fetch =
FetchFactory::GetSurfaceFetch(FetchFactory::WORLD_COP30);
int rc = fetch->FetchBoundingBox(adfBbox, 30.0, pszFilename.c_str(), NULL);
delete fetch;
if(rc < 0)
return rc;
GDALDataset* poDS;
poDS = (GDALDataset*)GDALOpen(pszFilename.c_str(), GA_Update);
if(poDS != NULL)
return -1;
if(rc > 0)
{
GDALFillBandNoData(poDS, 1, 100);
}
if(GDALHasNoData(poDS, 1))
{
GDALClose((GDALDatasetH)poDS);
return 1;
}
poDS->GetGeoTransform(adfGeoTransform);
int nXSize, nYSize;
nXSize = poDS->GetRasterXSize();
nYSize = poDS->GetRasterYSize();
GDALClose((GDALDatasetH)poDS);
VSIUnlink(pszFilename);
}
*/

BOOST_AUTO_TEST_CASE( gdal )
{
/* mackay */
adfBbox[0] = 44.0249023401036;
adfBbox[1] = -113.463446144564;
adfBbox[2] = 43.7832152227745;
adfBbox[3] = -113.749693430469;

CPLString osPath = FindDataPath( "mackay.tif" );

fetch = FetchFactory::GetSurfaceFetch(FetchFactory::CUSTOM_GDAL, osPath.c_str() );

int rc = fetch->FetchBoundingBox(adfBbox, 30.0, pszFilename.c_str(), NULL);
BOOST_REQUIRE( rc >= 0 );

poDS = (GDALDataset*)GDALOpen(pszFilename.c_str(), GA_Update);
BOOST_REQUIRE_MESSAGE( NULL != poDS, "GDALOpen returned NULL" );

if(rc > 0)
{
GDALFillBandNoData(poDS, 1, 100);
}
BOOST_REQUIRE_MESSAGE( !GDALHasNoData( poDS, 1 ), "poDS contains no data after GDALOpen" );

poDS->GetGeoTransform(adfGeoTransform);

BOOST_CHECK( CPLIsEqual( 279635.0, (int)(adfGeoTransform[0] + 0.5) ) );
BOOST_CHECK( CPLIsEqual( 30.0, adfGeoTransform[1] ) );
BOOST_CHECK( CPLIsEqual( 0.0, adfGeoTransform[2] ) );
BOOST_CHECK( CPLIsEqual( 4878315.0, (int)(adfGeoTransform[3] + 0.5) ) );
BOOST_CHECK( CPLIsEqual( 0.0, adfGeoTransform[4]) );
BOOST_CHECK( CPLIsEqual( -30.0, adfGeoTransform[5]) );

int nXSize, nYSize;
nXSize = poDS->GetRasterXSize();
nYSize = poDS->GetRasterYSize();

BOOST_CHECK( RASTER_X_SIZE >= 1 );
BOOST_CHECK( RASTER_Y_SIZE >= 1 );

VSIUnlink(pszFilename.c_str());

/*If test makes it here, fetch and poDS are not NULL and should be free'd
for next test. */
delete fetch;
GDALClose( (GDALDatasetH) poDS );
fetch = NULL;
poDS = NULL;
}

BOOST_AUTO_TEST_SUITE_END()
/******************************************************************************
* END "COP30" BOOST TEST SUITE
*****************************************************************************/

#endif /* WIN32 */

0 comments on commit f569bf6

Please sign in to comment.