Skip to content

Commit

Permalink
Merge pull request #49 from Digitelektro/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
Digitelektro authored Nov 3, 2022
2 parents 3c33000 + c905a4d commit 4813ced
Show file tree
Hide file tree
Showing 18 changed files with 1,041 additions and 242 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Thumbs.db
/.qmake.cache
/.qmake.stash
Build/
build/

# qtcreator generated files
*.pro.user*
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ ExternalProject_Add(libcorrect
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)

find_package(OpenCV REQUIRED PATHS "D:/Programozas/opencv/own_build/install/")
find_package(OpenCV)

link_directories(
${CMAKE_BINARY_DIR}/sgp4-build/libsgp4
${CMAKE_BINARY_DIR}/libcorrect-build/lib
)

add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-D_USE_MATH_DEFINES -D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING)

add_executable(meteordemod
main.cpp
Expand Down Expand Up @@ -124,12 +124,14 @@ if(WIN32)
${OpenCV_LIBS}
sgp4.lib
correct.lib
stdc++fs
)
else()
target_link_libraries(meteordemod
${OpenCV_LIBS}
sgp4.a
correct.a
stdc++fs
)
endif()

Expand All @@ -148,8 +150,8 @@ if(UNIX AND NOT APPLE)
if (DEBIAN_FOUND)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "1")
SET(CPACK_PACKAGE_VERSION_MINOR "4")
SET(CPACK_PACKAGE_VERSION_PATCH "4")
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
72 changes: 28 additions & 44 deletions GIS/shaperenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ GIS::ShapeRenderer::ShapeRenderer(const std::string shapeFile, const cv::Scalar
, mAltitude(altitude)
, mThicknes(5)
, mPointRadius(10)
, mFontScale(2)
, mFontHeight(40)
, mFontLineWidth(2)
{

}
Expand All @@ -25,7 +26,7 @@ void GIS::ShapeRenderer::setTextFieldName(const std::string &name)
mTextFieldName = name;
}

void GIS::ShapeRenderer::drawShapeMercator(cv::Mat &src, float xStart, float yStart)
void GIS::ShapeRenderer::drawShapeMercator(cv::Mat &src, float xStart, float yStart, float scale)
{
if(!load()) {
return;
Expand All @@ -43,7 +44,7 @@ void GIS::ShapeRenderer::drawShapeMercator(cv::Mat &src, float xStart, float ySt
for(polyLineIterator->begin(); *polyLineIterator != polyLineIterator->end(); ++(*polyLineIterator)) {
//std::cout << polyLineIterator->point.x << " " << polyLineIterator->point.y << std::endl;

PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToMercatorProjection(polyLineIterator->point.y, polyLineIterator->point.x, mEarthRadius + mAltitude);
PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToMercatorProjection<float>({polyLineIterator->point.y, polyLineIterator->point.x, 0}, mEarthRadius + mAltitude, scale);

coordinate.x += -xStart;
coordinate.y += -yStart;
Expand All @@ -65,7 +66,7 @@ void GIS::ShapeRenderer::drawShapeMercator(cv::Mat &src, float xStart, float ySt
for(recordIterator->begin(); *recordIterator != recordIterator->end(); ++(*recordIterator)) {
ShapeReader::Point point(*recordIterator);

PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToMercatorProjection(point.y, point.x, mEarthRadius + mAltitude);
PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToMercatorProjection<float>({point.y, point.x, 0}, mEarthRadius + mAltitude, scale);
coordinate.x += -xStart;
coordinate.y += -yStart;

Expand All @@ -83,7 +84,7 @@ void GIS::ShapeRenderer::drawShapeMercator(cv::Mat &src, float xStart, float ySt
ShapeReader::Point point(*recordIterator);
std::vector<std::string> fieldValues = dbFilereader.getFieldValues(i);

PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToMercatorProjection(point.y, point.x, mEarthRadius + mAltitude);
PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToMercatorProjection<float>({point.y, point.x, 0}, mEarthRadius + mAltitude, scale);
coordinate.x += -xStart;
coordinate.y += -yStart;

Expand Down Expand Up @@ -113,18 +114,19 @@ void GIS::ShapeRenderer::drawShapeMercator(cv::Mat &src, float xStart, float ySt
}

if(drawName) {
double fontScale = cv::getFontScaleFromHeight(cv::FONT_ITALIC, mFontHeight, mFontLineWidth);
int baseLine;
cv::Size size = cv::getTextSize(fieldValues[namePos], cv::FONT_ITALIC, mFontScale, mThicknes, &baseLine);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, mFontScale, cv::Scalar(0,0,0), mThicknes+1, cv::LINE_AA);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, mFontScale, mColor, mThicknes, cv::LINE_AA);
cv::Size size = cv::getTextSize(fieldValues[namePos], cv::FONT_ITALIC, fontScale, mFontLineWidth, &baseLine);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, fontScale, cv::Scalar(0,0,0), mFontLineWidth+1, cv::LINE_AA);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, fontScale, mColor, mFontLineWidth, cv::LINE_AA);
}
}
}
}
}
}

void GIS::ShapeRenderer::drawShapeEquidistant(cv::Mat &src, float xStart, float yStart, float centerLatitude, float centerLongitude)
void GIS::ShapeRenderer::drawShapeEquidistant(cv::Mat &src, float xStart, float yStart, float centerLatitude, float centerLongitude, float scale)
{
if(!load()) {
return;
Expand All @@ -142,7 +144,7 @@ void GIS::ShapeRenderer::drawShapeEquidistant(cv::Mat &src, float xStart, float
for(polyLineIterator->begin(); *polyLineIterator != polyLineIterator->end(); ++(*polyLineIterator)) {
//std::cout << polyLineIterator->point.x << " " << polyLineIterator->point.y << std::endl;

PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToAzimuthalEquidistantProjection(polyLineIterator->point.y, polyLineIterator->point.x, centerLatitude, centerLongitude, mEarthRadius + mAltitude);
PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToAzimuthalEquidistantProjection<float>({polyLineIterator->point.y, polyLineIterator->point.x, 0}, {centerLatitude, centerLongitude, 0}, mEarthRadius + mAltitude, scale);

coordinate.x += -xStart;
coordinate.y += -yStart;
Expand All @@ -166,7 +168,7 @@ void GIS::ShapeRenderer::drawShapeEquidistant(cv::Mat &src, float xStart, float
for(recordIterator->begin(); *recordIterator != recordIterator->end(); ++(*recordIterator)) {
ShapeReader::Point point(*recordIterator);

PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToAzimuthalEquidistantProjection(point.y, point.x, centerLatitude, centerLongitude, mEarthRadius + mAltitude);
PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToAzimuthalEquidistantProjection<float>({point.y, point.x, 0}, {centerLatitude, centerLongitude, 0}, mEarthRadius + mAltitude, scale);
coordinate.x += -xStart;
coordinate.y += -yStart;

Expand All @@ -188,7 +190,7 @@ void GIS::ShapeRenderer::drawShapeEquidistant(cv::Mat &src, float xStart, float
ShapeReader::Point point(*recordIterator);
std::vector<std::string> fieldValues = dbFilereader.getFieldValues(i);

PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToAzimuthalEquidistantProjection(point.y, point.x, centerLatitude, centerLongitude, mEarthRadius + mAltitude);
PixelGeolocationCalculator::CartesianCoordinateF coordinate = PixelGeolocationCalculator::coordinateToAzimuthalEquidistantProjection<float>({point.y, point.x, 0}, {centerLatitude, centerLongitude, 0}, mEarthRadius + mAltitude, scale);
coordinate.x += -xStart;
coordinate.y += -yStart;

Expand Down Expand Up @@ -222,10 +224,11 @@ void GIS::ShapeRenderer::drawShapeEquidistant(cv::Mat &src, float xStart, float
}

if(drawName) {
double fontScale = cv::getFontScaleFromHeight(cv::FONT_ITALIC, mFontHeight, mFontLineWidth);
int baseLine;
cv::Size size = cv::getTextSize(fieldValues[namePos], cv::FONT_ITALIC, mFontScale, mThicknes, &baseLine);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, mFontScale, cv::Scalar(0,0,0), mThicknes+1, cv::LINE_AA);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, mFontScale, mColor, mThicknes, cv::LINE_AA);
cv::Size size = cv::getTextSize(fieldValues[namePos], cv::FONT_ITALIC, fontScale, mFontLineWidth, &baseLine);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, fontScale, cv::Scalar(0,0,0), mFontLineWidth+1, cv::LINE_AA);
cv::putText(src, fieldValues[namePos], cv::Point2d(coordinate.x - (size.width/2), coordinate.y - size.height + baseLine), cv::FONT_ITALIC, fontScale, mColor, mFontLineWidth, cv::LINE_AA);
}
}
}
Expand All @@ -235,36 +238,17 @@ void GIS::ShapeRenderer::drawShapeEquidistant(cv::Mat &src, float xStart, float

bool GIS::ShapeRenderer::equidistantCheck(float latitude, float longitude, float centerLatitude, float centerLongitude)
{
bool longResult = true;
bool latResult = true;

int minLongitude = static_cast<int>(centerLongitude - 90);
int maxLongitude = static_cast<int>(centerLongitude + 90);
int minLatitude = static_cast<int>(centerLatitude - 45);
int maxLatitude = static_cast<int>(centerLatitude + 45);

//Normalize
minLongitude = ((minLongitude + 540) % 360 - 180);
maxLongitude = ((maxLongitude + 540) % 360 - 180);
minLatitude = ((minLatitude + 270) % 180 - 90);
maxLatitude = ((maxLatitude + 270) % 180 - 90);

if(maxLatitude < minLatitude)
{
latResult = latitude > minLatitude || latitude < maxLatitude;
}
else
{
latResult = latitude > minLatitude && latitude < maxLatitude;
}
if(maxLongitude < minLongitude)
{
longResult = longitude < minLongitude || longitude < maxLongitude;
}
else
//Degree To radian
latitude = M_PI * latitude / 180.0f;
longitude = M_PI * longitude / 180.0f;
centerLatitude= M_PI * centerLatitude / 180.0f;
centerLongitude= M_PI * centerLongitude / 180.0f;

float deltaSigma = std::sin(centerLatitude) * std::sin(latitude) + std::cos(latitude) * std::cos(longitude - centerLongitude);
if (deltaSigma < 0.0)
{
longResult = longitude > minLongitude && longitude < maxLongitude;
return false;
}

return longResult && latResult;
return true;
}
14 changes: 9 additions & 5 deletions GIS/shaperenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class ShapeRenderer : public ShapeReader
void addNumericFilter(const std::string name, int value);
void setTextFieldName(const std::string &name);

void drawShapeMercator(cv::Mat &src, float xStart, float yStart);
void drawShapeEquidistant(cv::Mat &src, float xStart, float yStart, float centerLatitude, float centerLongitude);
void drawShapeMercator(cv::Mat &src, float xStart, float yStart, float scale);
void drawShapeEquidistant(cv::Mat &src, float xStart, float yStart, float centerLatitude, float centerLongitude, float scale);

public: //setters
void setThickness(int thickness) {
Expand All @@ -30,8 +30,11 @@ class ShapeRenderer : public ShapeReader
void setPointRadius(int radius) {
mPointRadius = radius;
}
void setFontScale(int scale) {
mFontScale = scale;
void setFontHeight(int height) {
mFontHeight = height;
}
void setFontLineWidth(int width) {
mFontLineWidth = width;
}

private:
Expand All @@ -45,7 +48,8 @@ class ShapeRenderer : public ShapeReader
std::string mTextFieldName;
int mThicknes;
int mPointRadius;
int mFontScale;
int mFontHeight;
int mFontLineWidth;
};

} //namespace GIS
Expand Down
3 changes: 3 additions & 0 deletions MeteorDemod.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ CONFIG -= app_bundle
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS LIQUID_BUILD_CPLUSPLUS
DEFINES +=_USE_MATH_DEFINES
DEFINES += _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING

QMAKE_LFLAGS += -lstdc++fs

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
Expand Down
24 changes: 18 additions & 6 deletions common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,18 @@ void Settings::parseIni(const std::string &path)
ini::extract(mIniParser.sections["Program"]["RollM2"], mM2Roll, -2.9f);
ini::extract(mIniParser.sections["Program"]["PitchM2"], mM2Pitch, 0.3f);
ini::extract(mIniParser.sections["Program"]["YawM2"], mM2Yaw, 0.0f);
ini::extract(mIniParser.sections["Program"]["TimeOffsetM2"], mTimeOffsetM2Sec, 0);
ini::extract(mIniParser.sections["Program"]["NightPassTreshold"], mNightPassTreshold, 10.0f);
ini::extract(mIniParser.sections["Program"]["ProjectionScale"], mProjectionScale, 0.75f);
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"]["GenerateComposite125"], mGenerateComposite125, true);
ini::extract(mIniParser.sections["Program"]["GenerateComposite221"], mGenerateComposite221, 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);

ini::extract(mIniParser.sections["Demodulator"]["CostasBandwidth"], mCostasBw, 50);
ini::extract(mIniParser.sections["Demodulator"]["RRCFilterOrder"], mRRCFilterOrder, 64);
Expand All @@ -71,7 +82,8 @@ void Settings::parseIni(const std::string &path)

ini::extract(mIniParser.sections["Watermark"]["Place"], mWaterMarkPlace);
ini::extract(mIniParser.sections["Watermark"]["Color"], mWaterMarkColor, HTMLColor(0xAD880C));
ini::extract(mIniParser.sections["Watermark"]["Size"], mWaterMarkSize, 5);
ini::extract(mIniParser.sections["Watermark"]["Size"], mWaterMarkSize, 80);
ini::extract(mIniParser.sections["Watermark"]["Width"], mWaterMarkLineWidth, 3);
ini::extract(mIniParser.sections["Watermark"]["Text"], mWaterMarkText);

ini::extract(mIniParser.sections["ReceiverLocation"]["Draw"], mDrawreceiver, false);
Expand All @@ -84,20 +96,20 @@ void Settings::parseIni(const std::string &path)

ini::extract(mIniParser.sections["ShapeFileGraticules"]["FileName"], mShapeGraticulesFile);
ini::extract(mIniParser.sections["ShapeFileGraticules"]["Color"], mShapeGraticulesColor, HTMLColor(0xC8C8C8));
ini::extract(mIniParser.sections["ShapeFileGraticules"]["Thickness"], mShapeGraticulesThickness, 5);
ini::extract(mIniParser.sections["ShapeFileGraticules"]["Thickness"], mShapeGraticulesThickness, 1);

ini::extract(mIniParser.sections["ShapeFileCoastLines"]["FileName"], mShapeCoastLinesFile);
ini::extract(mIniParser.sections["ShapeFileCoastLines"]["Color"], mShapeCoastLinesColor, HTMLColor(0x808000));
ini::extract(mIniParser.sections["ShapeFileCoastLines"]["Thickness"], mShapeCoastLinesThickness, 5);
ini::extract(mIniParser.sections["ShapeFileCoastLines"]["Thickness"], mShapeCoastLinesThickness, 2);

ini::extract(mIniParser.sections["ShapeFileBoundaryLines"]["FileName"], mShapeBoundaryLinesFile);
ini::extract(mIniParser.sections["ShapeFileBoundaryLines"]["Color"], mShapeBoundaryLinesColor, HTMLColor(0xC8C8C8));
ini::extract(mIniParser.sections["ShapeFileBoundaryLines"]["Thickness"], mShapeBoundaryLinesThickness, 5);
ini::extract(mIniParser.sections["ShapeFileBoundaryLines"]["Thickness"], mShapeBoundaryLinesThickness, 2);

ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["FileName"], mShapePopulatedPlacesFile);
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["Color"], mShapePopulatedPlacesColor, HTMLColor(0x5A42F5));
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["Thickness"], mShapePopulatedPlacesThickness, 5);
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["FontScale"], mShapePopulatedPlacesFontScale, 2);
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["Width"], mShapePopulatedPlacesFontWidth, 2);
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["Size"], mShapePopulatedPlacesFontSize, 40);
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["PointRadius"], mShapePopulatedPlacesPointradius, 10);
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["FilterColumnName"], mShapePopulatedPlacesFilterColumnName, std::string("ADM0CAP"));
ini::extract(mIniParser.sections["ShapeFilePopulatedPlaces"]["NumericFilter"], mShapePopulatedPlacesNumbericFilter, 1);
Expand Down
Loading

0 comments on commit 4813ced

Please sign in to comment.