Skip to content

Commit

Permalink
Merge pull request #104 from Digitelektro/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
Digitelektro authored Apr 7, 2024
2 parents bf991c9 + b3680f2 commit d1425ea
Show file tree
Hide file tree
Showing 48 changed files with 2,857 additions and 903 deletions.
63 changes: 34 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ cmake_minimum_required(VERSION 3.5)

include(ExternalProject)

project(Meteordemod LANGUAGES CXX)
project(meteordemod
VERSION 2.6.5
LANGUAGES CXX
)

configure_file(cmake/version.h.in version.h)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVERSION_BUILD=${VERSION_BUILD_NUMBER}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_BUILD=${VERSION_BUILD_NUMBER}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -13,6 +21,10 @@ if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()


if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.2")
Expand Down Expand Up @@ -40,6 +52,7 @@ ExternalProject_Add(libcorrect
)

find_package(OpenCV)
find_package(OpenCL)

link_directories(
${CMAKE_BINARY_DIR}/sgp4-build/libsgp4
Expand All @@ -50,48 +63,33 @@ add_definitions(-D_USE_MATH_DEFINES -D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATI

add_executable(meteordemod
main.cpp
imageproc/spreadimage.cpp
imageproc/spreadimage.h
imageproc/threatimage.cpp
imageproc/threatimage.h
decoder/bitio.cpp
decoder/bitio.h
imageproc/projectimage.cpp
imageproc/blendimages.cpp
imageproc/tps.cpp
decoder/correlation.cpp
decoder/correlation.h
decoder/meteorimage.cpp
decoder/meteorimage.h
decoder/packetparser.cpp
decoder/packetparser.h
decoder/reedsolomon.cpp
decoder/reedsolomon.h
decoder/viterbi.cpp
decoder/viterbi.h
decoder/deinterleaver.cpp
decoder/meteordecoder.cpp
decoder/meteordecoder.h
decoder/protocol/ccsds.cpp
decoder/protocol/vcdu.cpp
decoder/protocol/lrpt/decoder.cpp
decoder/protocol/lrpt/msumr/segment.cpp
decoder/protocol/lrpt/msumr/bitio.cpp
decoder/protocol/lrpt/msumr/image.cpp
common/settings.cpp
common/settings.h
common/version.h
tools/matrix.cpp
tools/matrix.h
tools/tlereader.cpp
tools/tlereader.h
tools/vector.cpp
tools/vector.h
tools/pixelgeolocationcalculator.cpp
tools/pixelgeolocationcalculator.h
tools/databuffer.cpp
tools/databuffer.h
tools/iniparser.cpp
tools/iniparser.h
tools/threadpool.cpp
tools/threadpool.h
tools/opencl.cpp
GIS/shapereader.cpp
GIS/shapereader.h
GIS/shaperenderer.cpp
GIS/shaperenderer.h
GIS/dbfilereader.cpp
GIS/dbfilereader.h
DSP/meteordemodulator.cpp
DSP/agc.cpp
DSP/pll.cpp
Expand All @@ -118,9 +116,19 @@ include_directories(
${CMAKE_SOURCE_DIR}/external/libcorrect/include
)

target_include_directories(meteordemod PUBLIC
"${PROJECT_BINARY_DIR}"
)

add_dependencies(meteordemod sgp4)
add_dependencies(meteordemod libcorrect)

if(OpenCL_FOUND)
target_compile_definitions(meteordemod PUBLIC OPENCL_FOUND=1)
include_directories(${OpenCL_INCLUDE_DIRS})
target_link_libraries(meteordemod ${OpenCL_LIBRARIES})
endif()

if(WIN32)
target_link_libraries(meteordemod
${OpenCV_LIBS}
Expand Down Expand Up @@ -150,9 +158,6 @@ if(UNIX AND NOT APPLE)
find_file (DEBIAN_FOUND debian_version debconf.conf PATHS /etc)
if (DEBIAN_FOUND)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "5")
SET(CPACK_PACKAGE_VERSION_PATCH "5")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Digitelektro")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/Digitelektro/MeteorDemod")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Russian Meteor M2 weather satellite data decoder")
Expand Down
18 changes: 18 additions & 0 deletions GIS/shapereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <iostream>
#include <iterator>
#include <limits>
#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -170,6 +171,10 @@ class ShapeReader {
pointBuffer.valueAtIndex(index, y, LittleEndian);
}

bool operator==(const Point& rhs) {
return (std::abs(x - rhs.x) <= std::numeric_limits<double>::epsilon()) && (std::abs(y - rhs.y) <= std::numeric_limits<double>::epsilon());
}

double x;
double y;
};
Expand Down Expand Up @@ -235,6 +240,19 @@ class ShapeReader {
return *this;
}
}
PolyLineIterator operator++(int) {
auto temp = *this;
if(mNumberOfPoint < mPolyLineHeader.numberOfpoints) {
DataBuffer pointBuffer(16);
mInputStream.read(reinterpret_cast<char*>(pointBuffer.buffer()), pointBuffer.size());
point = Point(pointBuffer);
mNumberOfPoint++;
} else {
mNumberOfPoint = 0;
point = Point();
}
return temp;
}

PolyLineIterator begin() {
int filePosition = mRecordPosition + 12; // Recordpos + Recordheader
Expand Down
41 changes: 41 additions & 0 deletions GIS/shaperenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ void GIS::ShapeRenderer::drawShape(const cv::Mat& src, Transform_t transform) {
for(polyLineIterator->begin(); *polyLineIterator != polyLineIterator->end(); ++(*polyLineIterator)) {
if(transform(polyLineIterator->point.y, polyLineIterator->point.x)) {
polyLines.push_back(cv::Point2d(polyLineIterator->point.y, polyLineIterator->point.x));
} else {
if(polyLines.size() > 1) {
cv::polylines(src, polyLines, false, mColor, mThicknes);
polyLines.clear();
}
}
}

Expand All @@ -45,6 +50,42 @@ void GIS::ShapeRenderer::drawShape(const cv::Mat& src, Transform_t transform) {
}
}
}
} else if(getShapeType() == ShapeReader::ShapeType::stPolygon) {
auto recordIterator = getRecordIterator();

if(recordIterator) {
for(recordIterator->begin(); *recordIterator != recordIterator->end(); ++(*recordIterator)) {
auto polyLineIterator = getPolyLineIterator(*recordIterator);

if(polyLineIterator) {
bool isFirst = true;
ShapeReader::Point first;
std::vector<cv::Point> polyLines;
for(polyLineIterator->begin(); *polyLineIterator != polyLineIterator->end(); ++(*polyLineIterator)) {
if(!isFirst && (first == polyLineIterator->point)) {
if(polyLines.size() > 1) {
cv::polylines(src, polyLines, false, mColor, mThicknes);
}
isFirst = true;
polyLines.clear();
continue;
}
if(isFirst) {
first = polyLineIterator->point;
isFirst = false;
}
if(transform(polyLineIterator->point.y, polyLineIterator->point.x)) {
polyLines.push_back(cv::Point2d(polyLineIterator->point.y, polyLineIterator->point.x));
} else {
if(polyLines.size() > 1) {
cv::polylines(src, polyLines, false, mColor, mThicknes);
polyLines.clear();
}
}
}
}
}
}
} else if(getShapeType() == ShapeReader::ShapeType::stPoint) {
auto recordIterator = getRecordIterator();

Expand Down
3 changes: 3 additions & 0 deletions cmake/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define VERSION_MAJOR @meteordemod_VERSION_MAJOR@
#define VERSION_MINOR @meteordemod_VERSION_MINOR@
#define VERSION_FIX @meteordemod_VERSION_PATCH@
3 changes: 2 additions & 1 deletion common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ void Settings::parseIni(const std::string& path) {
ini::extract(mIniParser.sections["Program"]["CompositeProjectionScale"], mCompositeProjectionScale, 0.75f);
ini::extract(mIniParser.sections["Program"]["CompositeAzimuthalEquidistantProjection"], mCompositeEquadistantProjection, true);
ini::extract(mIniParser.sections["Program"]["CompositeMercatorProjection"], mCompositeMercatorProjection, false);
ini::extract(mIniParser.sections["Program"]["GenerateComposite123"], mGenerateComposite123, true);
ini::extract(mIniParser.sections["Program"]["GenerateComposite321"], mGenerateComposite321, true);
ini::extract(mIniParser.sections["Program"]["GenerateComposite125"], mGenerateComposite125, true);
ini::extract(mIniParser.sections["Program"]["GenerateComposite221"], mGenerateComposite221, true);
ini::extract(mIniParser.sections["Program"]["GenerateComposite224"], mGenerateComposite224, true);
ini::extract(mIniParser.sections["Program"]["GenerateComposite68"], mGenerateComposite68, true);
ini::extract(mIniParser.sections["Program"]["GenerateCompositeThermal"], mGenerateCompositeThermal, true);
ini::extract(mIniParser.sections["Program"]["GenerateComposite68Rain"], mGenerateComposite68Rain, true);
Expand Down
57 changes: 25 additions & 32 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ class Settings {
uint8_t B;
};

struct ProjectionSetting {
std::string satelliteNameInTLE;
float scanAngle;
float yaw;
float pitch;
float roll;
float timeOffsetMs;
};

friend std::istream& operator>>(std::istream& is, HTMLColor& color) {
std::string rgb;
is >> rgb;
Expand Down Expand Up @@ -105,35 +114,15 @@ class Settings {
return mJpegQuality;
}

std::string getSatNameInTLE() {
std::string name;
ini::extract(mIniParser.sections[getSateliteName()]["SatNameInTLE"], name);
return name;
}
float getScanAngle() {
float angle;
ini::extract(mIniParser.sections[getSateliteName()]["ScanAngle"], angle, 110.8f);
return angle;
}
float getRoll() {
float roll;
ini::extract(mIniParser.sections[getSateliteName()]["Roll"], roll, 0.0f);
return roll;
}
float getPitch() {
float pitch;
ini::extract(mIniParser.sections[getSateliteName()]["Pitch"], pitch, 0.0f);
return pitch;
}
float getYaw() {
float yaw;
ini::extract(mIniParser.sections[getSateliteName()]["Yaw"], yaw, 0.0f);
return yaw;
}
int getTimeOffsetSec() {
int timeOffset;
ini::extract(mIniParser.sections["Program"]["TimeOffset"], timeOffset, 0);
return timeOffset;
ProjectionSetting getProjectionSetting(const std::string& satellite) {
ProjectionSetting result;
ini::extract(mIniParser.sections[satellite]["SatNameInTLE"], result.satelliteNameInTLE);
ini::extract(mIniParser.sections[satellite]["ScanAngle"], result.scanAngle, 110.8f);
ini::extract(mIniParser.sections[satellite]["Roll"], result.roll, 0.0f);
ini::extract(mIniParser.sections[satellite]["Pitch"], result.pitch, 0.0f);
ini::extract(mIniParser.sections[satellite]["Yaw"], result.yaw, 0.0f);
ini::extract(mIniParser.sections[satellite]["TimeOffset"], result.timeOffsetMs, 0.0f);
return result;
}

bool equadistantProjection() const {
Expand Down Expand Up @@ -164,15 +153,18 @@ class Settings {
bool compositeMercatorProjection() const {
return mCompositeMercatorProjection;
}
bool generateComposite123() const {
return mGenerateComposite123;
bool generateComposite321() const {
return mGenerateComposite321;
}
bool generateComposite125() const {
return mGenerateComposite125;
}
bool generateComposite221() const {
return mGenerateComposite221;
}
bool generateComposite224() const {
return mGenerateComposite224;
}
bool generateComposite68() const {
return mGenerateComposite68;
}
Expand Down Expand Up @@ -310,9 +302,10 @@ class Settings {

bool mCompositeEquadistantProjection;
bool mCompositeMercatorProjection;
bool mGenerateComposite123;
bool mGenerateComposite321;
bool mGenerateComposite125;
bool mGenerateComposite221;
bool mGenerateComposite224;
bool mGenerateComposite68;
bool mGenerateCompositeThermal;
bool mGenerateComposite68Rain;
Expand Down
8 changes: 0 additions & 8 deletions common/version.h

This file was deleted.

22 changes: 0 additions & 22 deletions decoder/bitio.h

This file was deleted.

Loading

0 comments on commit d1425ea

Please sign in to comment.