If the article is an original article, please indicate the source of the original article when reprinting.
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/131805718
Domestic Kylin system related development
Previous: " Kylin System Development Notes (11): Use gdb to locate crash exceptions on the domestic Kylin system, advanced location code lines and special test demo" Next
: Stay tuned...
foreword
The global Beidou positioning terminal development is done on the Kylin system. The Beidou GPS sends the geodetic coordinates, and the application needs the latitude and longitude coordinates, so it needs to be converted. You can use a formula to convert, but a project involving Shanhe Smart uses WG.
related blog
" Kylin System Development Notes (12): Compile the GDAL library on the domestic Kylin system, build a basic development environment and a basic demo" "Qt +
GDAL Development Notes (1): Compile the GDAL library on the windows system mingw32, build a development environment and foundation Demo》
Introduction to Geodetic Coordinates
overview
Geodetic coordinates are the coordinates of the reference ellipsoid in geodetic surveying. The position of the ground point P is expressed by the longitude L of the earth, the latitude B of the earth and the height H of the earth.
principle
When the point is on the reference ellipsoid, it is only represented by geodetic longitude and geodetic latitude. The geodetic longitude is the angle between the geodetic plane passing through the point and the origin geodetic plane (the meridian plane passing through the Greenwich Observatory). It is stipulated that counting from the starting meridian plane, the east longitude from 0° to 180° is called east longitude; the west longitude from 0° to 180° is called west longitude. Geodetic latitude is the angle between the normal line passing through the point and the equatorial plane. It is stipulated that starting from the equatorial plane, the north latitude from 0° to 90° from the equatorial plane is called north latitude; the south latitude from 0° to 90° is called south latitude. The geodetic height is the distance from the ground point along the normal to the reference ellipsoid.
Beijing 54 coordinate system: BJZ54
The Beijing 54 coordinate system (BJZ54) means that the Beijing 54 coordinate system is the ginseng geodetic coordinate system. A point on the earth can be located by longitude L54, latitude M54 and geodetic height H54. It is based on the Krasovsky ellipsoid. The resulting coordinate system after the local adjustment.
- Semi-major axis a = 6378245m
- Semi-minor axis b = 6356863.0188m
- First eccentricity squared e2 = 0.006693421622
- Flatness α =1/298.3
World Geodetic Coordinate System: WGS-84
The WGS-84 coordinate system is the world geodetic coordinate system, its coordinate origin is at the center of the earth, and the WGS-84 ellipsoid (1984 world geodetic coordinate system) is adopted.
The WGS-84 coordinate system is a geodetic coordinate system developed and determined by the US Department of Defense, and it is a protocol earth coordinate system.
The definition of the WGS-84 coordinate system is: the origin is the center of mass of the earth, and the Z-axis of the space rectangular coordinate system points to the direction of the earth pole (CTP) defined by BIH (1984.0), which is the origin of the international agreement CIO, which is jointly recommended by IAU and IUGG. The X-axis points to the intersection of the zero-degree meridian defined by the BIH and the CTP equator, and the Y-axis and Z-axis form a right-handed coordinate system.
The WGS-84 ellipsoid adopts the measurement constants recommended by the 17th Congress of the International Union of Geodesy and Geophysics, and uses two commonly used basic geometric parameters:
- Semi-major axis a = 6378137m
- Semi-minor axis b = 6356752.3142m
- First eccentricity squared e2 = 0.00669437999013
- Flatness α= 1/298.257223563
National Geodetic Coordinate System: CGCS2000
The 2000 National Geodetic Coordinate System is the latest national geodetic coordinate system in my country. The English name is China Geodetic Coordinate System 2000, and the English abbreviation is CGCS2000.
The origin of the 2000 national geodetic coordinate system is the center of mass of the entire earth including the ocean and atmosphere; the Z-axis of the 2000 national geodetic coordinate system points from the origin to the direction of the earth reference pole of epoch 2000.0, and the direction of this epoch is given by the International Time Bureau The fixed epoch is the initial orientation calculation of 1984.0, and the time evolution of the orientation ensures that there will be no residual global rotation relative to the crust. Axis and X axis form a right-handed orthogonal coordinate system. Use the scale in the sense of general relativity.
- Semi-major axis a = 6378137m
- Semi-minor axis b = 6356752.314m
- First eccentricity squared e2 = 0.00669438002290
- Flatness α = 1/298.257222101
GDAL library
overview
GDAL (Geospatial Data Abstraction Library) is an open source raster spatial data conversion library under the X/MIT license agreement. It utilizes an abstract data model to express the various supported file formats. It also has a collection of command-line tools for data transformation and manipulation. OGR is a fork of the GDAL project that provides support for vector data. There are many well-known GIS products that use the GDAL/OGR library, including ESRI's ARCGIS 9.3, Google Earth and the cross-platform GRASS GIS system. Using the GDAL/OGR library, the Linux-based geospatial data management system can provide support for vector and raster file data.
Features
- GDAL provides support for a variety of raster data, including Arc/Info ASCII Grid (asc), GeoTiff (tiff), Erdas Imagine Images (img), ASCII DEM (dem) and other formats.
- GDAL uses an abstract data model (abstract data model) to parse the data formats it supports. The abstract data model includes datasets, coordinate systems, affine geographic coordinate transformation (Affine Geo Transform), and geodetic control points (GCPs). Metadata, Raster Band, Color Table, Subdatasets Domain, Image_Structure Domain, XML Domains.
- GDALMajorObject class: an object with metadata.
- GDALDdataset class: usually a collection of associated raster bands extracted from a raster file and the metadata of these bands;
- GDALDdataset is also responsible for the georeferencing transform and coordinate system definition of all raster bands.
- GDALDriver class: file format driver class, GDAL will create an entity of this class for each supported file format to manage the file format.
- GDALDriverManager class: file format driver management class, used to manage the GDALDriver class.
OGR Architecture
- Geometry class: Geometry (including OGRGeometry and other classes) encapsulates the vector data model of OpenGIS, and provides some geometric operations, mutual conversion between WKB (Well Knows Binary) and WKT (Well Known Text) formats, and spatial reference system ( projection).
- Spatial Reference class: OGRSpatialReference encapsulates the definition of projection and datum.
- Feature class: OGRFeature encapsulates the definition of a complete feature, and a complete feature includes a geometry and a series of attributes of the geometry.
- Feature Definition class: OGRFeatureDefn encapsulates feature attributes, type, name and its default spatial reference system. An OGRFeatureDefn object usually corresponds to a layer.
- Layer class: OGRLayer is an abstract base class that represents a layer of features in the data source class OGRDataSource.
- Data Source class: OGRDataSource is an abstract base class representing a file or a database containing OGRLayer objects.
- Drivers class: OGRSFDriver corresponds to each supported vector file format. Class OGRSFDriver is registered and managed by class OGRSFDriverRegistrar.
download link
Home: https://gdal.org/download.html
select version 3.2.1
compile GDAL
Step 1: Download and decompress
cd ~/work/src/
tar xvf gdal-3.2.1.tar.gz
Step 2: Configure configure
cd gdal-3.2.1
./configure
Error "configure: error: PROJ 6 symbols not found", need to compile PROJ6:
Please refer to the following chapter "Compile PROJ6". After the compilation is complete, go back here to continue the configuration:
cd gdal-3.2.1
./configure
Configure via:
Proj6 is also yes.
Step 3: Compile make
make -j4
Start compiling:
This gdal library compiles, it takes some time.
After the compilation is complete, continue to make without j to ensure that the compilation is passed correctly.
Step 4: Install make install
Requires administrator privileges to install
sudo make install
Step 5: New construction introduces the foundation
The previous installations are all installed to the system path, so the library of the system path is first introduced here.
There will be an error here:
It requires sudo ldconfig, re-introduce the library into the system, compile and run again as follows:
The version is successfully printed out. Because it is linux, there are some dependent libraries. This v1.0.0 version depends on the system include and lib (PS: the library will be sealed into the module again later, but not this time).
Compile PROJ6
Step 1: Download and decompress
Download address: https://proj.org
Select version 6.2.0
to download and copy to the virtual machine:
cd ~/workl/src
tar xfv proj-6.2.0.tar.gz
Step 2: Configure configure
cd proj-6.2.0/
./configure
The configuration was successful:
Step 3: Compile make
make -j4
Start compiling:
After the compilation is complete, continue to make without j to ensure that the compilation is passed correctly.
Step 4: Install make install
To use administrator privileges, otherwise the installation will fail and the system directory cannot be created:
sudo make install
Test, you can rely on it without ldconfig, so far the proj6 library has been compiled.
DemoModular
Demo source code
GDALManager.at
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += \
$$PWD/GDALManager.h
SOURCES += \
$$PWD/GDALManager.cpp
win32 {
}else {
DEFINES += LINUX
# GDAL系统安装的默认路径位/usr/local
# 系统库,头文件路径和库文件默认已包含
LIBS += -lgdal
}
win32 {
}else {
DEFINES += LINUX
# PROJ系统安装的默认路径位/usr/local
# 系统库,头文件路径和库文件默认已包含
LIBS += -lproj
}
GDALManager.h
#ifndef GDALMANAGER_H
#define GDALMANAGER_H
#include <QObject>
class GDALManager : public QObject
{
Q_OBJECT
public:
explicit GDALManager(QObject *parent = 0);
signals:
public:
static void testEnv(); // v1.0.0 测试环境
private:
};
#endif // GDALMANAGER_H
GDALManager.cpp
#include "GDALManager.h"
#include "gdal.h"
#include <QDebug>
#include <QDateTime>
//#define LOG qDebug()<<__FILE__<<__LINE__
//#define LOG qDebug()<<__FILE__<<__LINE__<<__FUNCTION__
//#define LOG qDebug()<<__FILE__<<__LINE__<<QThread()::currentThread()
//#define LOG qDebug()<<__FILE__<<__LINE__<<QDateTime::currentDateTime().toString("yyyy-MM-dd")
#define LOG qDebug()<<__FILE__<<__LINE__<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss:zzz")
GDALManager::GDALManager(QObject *parent)
: QObject(parent)
{
// 注册所有驱动
GDALAllRegister();
}
void GDALManager::testEnv()
{
QString version = QString(GDALVersionInfo("RELEASE_NAME"));
LOG << version;
}
Demo project template v1.0.0
Previous: " Kylin System Development Notes (11): Use gdb to locate crash exceptions on the domestic Kylin system, advanced location code lines and special test demo" Next
: Stay tuned...
If the article is an original article, please indicate the source of the original article when reprinting.
The blog address of this article: https://hpzwl.blog.csdn.net/article/details/131805718