Method, device and equipment for converting postgis geometry data and storage medium
By obtaining the PostGIS geometry type and forcibly converting it to a derived geometry, parsing the parameters and writing them into an intermediate geometry, and then using mapping relationships to convert it to an Oracle geometry, the complexity of PostGIS geometric data conversion is solved, and the conversion efficiency is improved.
Patent Information
- Application Number
- CN202311763849.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-12-19
AI Technical Summary
The process of converting existing PostGIS geometric data to Oracle geometric data is complex, difficult to operate, and inefficient.
By obtaining the geometry type of the PostGIS geometry, forcibly converting it to a derived geometry, parsing the parameters of the derived geometry and writing them into an intermediate geometry, and using the mapping relationship between the intermediate geometry and the Oracle geometry, converting it into an Oracle geometry.
It simplifies the conversion process from PostGIS geometric data to Oracle geometric data and improves conversion efficiency.
Smart Images

Figure CN117668087B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of geometric data processing technology, and in particular to a method, apparatus, device, and storage medium for converting PostGIS geometric data. Background Technology
[0002] In scenarios involving data migration from a PostGIS spatial database to an Oracle spatial database, or in scenarios where an Oracle spatial database uses geometric data from a PostGIS spatial database, it is often necessary to first convert the PostGIS geometric data in the PostGIS spatial database into Oracle geometric data that is compatible with Oracle spatial database reading and writing.
[0003] Currently, the main method for converting PostGIS geometric data to Oracle geometric data is to directly write the parameters parsed from the geometric structure storing PostGIS geometric data into the geometric structure storing Oracle geometric data, based on the mapping relationship between the elements of the geometric structure storing PostGIS geometric data and the geometric structure storing Oracle geometric data.
[0004] This direct conversion method requires determining each parameter sequentially from the geometric structure storing the PostGIS geometric data when data conversion is involved, and writing conversion statements based on the mapping relationship between the PostGIS and Oracle geometric data on that parameter. However, geometric data comes in various types, and the parameters representing the storage method of geometric data in the geometric structure are different for each type. When dealing with a large amount of data conversion, writing conversion statements for each parameter of each geometric data undoubtedly makes the geometric data conversion process very complex, difficult to operate, and inefficient. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and storage medium for converting PostGIS geometric data, in order to solve the problems of complex, difficult-to-operate, and inefficient conversion processes for converting PostGIS geometric data to Oracle geometric data; and to simplify the complexity of the conversion process from PostGIS geometric data to Oracle geometric data and improve conversion efficiency.
[0006] According to one aspect of the present invention, a method for converting PostGIS geometric data is provided, comprising:
[0007] Obtain the PostGIS geometry and the geometry type of the PostGIS geometry; the PostGIS geometry is geometric data represented by the first geometric structure corresponding to the PostGIS spatial database;
[0008] The PostGIS geometry is forcibly converted into a derived geometry based on the geometry type; the derived geometry is a geometric structure derived from the first geometric structure based on the geometry type.
[0009] The derived geometry is parsed to obtain geometry parameters, and the geometry parameters are written into an intermediate geometry; there is a mapping relationship between the structure elements of the intermediate geometry and the second geometric structure corresponding to the Oracle spatial database.
[0010] The intermediate geometry is converted into an Oracle geometry according to the mapping relationship; the Oracle geometry is geometric data represented by the second geometric structure.
[0011] According to another aspect of the present invention, a PostGIS geometric data conversion apparatus is provided, comprising:
[0012] The data acquisition module is used to acquire PostGIS geometry and the geometry type of the PostGIS geometry; the PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database;
[0013] A forced conversion module is used to forcibly convert the PostGIS geometry into a derived geometry according to the geometry type; the derived geometry is a geometric structure derived from the first geometric structure according to the geometry type.
[0014] The parsing and writing module is used to parse the derived geometry to obtain geometry parameters and write the geometry parameters into an intermediate geometry; there is a mapping relationship between the structure elements of the intermediate geometry and the second geometric structure corresponding to the Oracle spatial database.
[0015] The data conversion module is used to convert the intermediate geometry into an Oracle geometry according to the mapping relationship; the Oracle geometry is geometric data represented by the second geometric structure.
[0016] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0017] At least one processor; and
[0018] A memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to perform the PostGIS geometric data conversion method according to any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the PostGIS geometric data conversion method according to any embodiment of the present invention.
[0021] The technical solution of this invention involves obtaining a PostGIS geometry and its geometry type. The PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database. Based on the geometry type, the PostGIS geometry is forcibly converted into a derived geometry. The derived geometry is a geometric structure derived from the first geometric structure based on its geometry type. The derived geometry is parsed to obtain geometry parameters, which are then written into an intermediate geometry. A mapping relationship exists between the structure elements of the intermediate geometry and a second geometric structure corresponding to the Oracle spatial database. Based on this mapping relationship, the intermediate geometry is converted into an Oracle geometry. The Oracle geometry is geometric data represented by the second geometric structure. By defining an intermediate geometry and using it to convert PostGIS geometry to Oracle geometry, the problem of complex, difficult-to-operate, and inefficient conversion processes for converting PostGIS geometric data to Oracle geometric data is solved. This achieves the technical effect of simplifying the complexity of the conversion process and improving conversion efficiency.
[0022] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a flowchart of a PostGIS geometric data conversion method provided in Embodiment 1 of the present invention;
[0025] Figure 2 This is a flowchart of a method for converting point-type PostGIS geometric data according to Embodiment 2 of the present invention;
[0026] Figure 3 This is a flowchart of a method for converting line-type PostGIS geometric data according to Embodiment 3 of the present invention;
[0027] Figure 4 This is a flowchart of a method for converting surface-type PostGIS geometric data according to Embodiment 4 of the present invention;
[0028] Figure 5 This is a flowchart of a method for converting PostGIS geometric data of a polyhedral surface type according to Embodiment 4 of the present invention;
[0029] Figure 6 This is a schematic diagram of the structure of a PostGIS geometric data conversion device provided in Embodiment 3 of the present invention;
[0030] Figure 7 This is a schematic diagram of the structure of an electronic device that implements the PostGIS geometric data conversion method according to an embodiment of the present invention. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] Example 1
[0034] Figure 1 This is a flowchart of a PostGIS geometric data conversion method provided in Embodiment 1 of the present invention. This embodiment is applicable to converting PostGIS geometric data into Oracle geometric data. The method can be executed by a PostGIS geometric data conversion device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0035] S110. Obtain the PostGIS geometry and its geometry type; the PostGIS geometry is geometric data represented by the first geometric structure corresponding to the PostGIS spatial database.
[0036] In this context, PostGIS geometric data refers to geometric data represented by the first geometric structure corresponding to the PostGIS spatial database. PostGIS geometric data can be two-dimensional, three-dimensional, or four-dimensional data.
[0037] PostGIS is an open-source spatial database, an extension of the open-source object-relational database system PostgreSQL. It adds the ability to store and manage spatial data, providing spatial information services such as spatial data types, spatial indexes, spatial operation functions, and spatial operators. Generally, the first geometric structure corresponding to the PostGIS spatial database is the lwgeom structure. A structure (struct) refers to a collection of data consisting of a series of data of the same or different types.
[0038] The first geometric structure is the structure used in the PostGIS spatial database to store geometric data. It defines how geometric data is stored in the PostGIS spatial database. Generally, the PostGIS spatial database uses the Gserialized structure to store geometric data.
[0039] In this embodiment, PostGIS geometry can be obtained by directly acquiring PostGIS geometry represented by a structure from the PostGIS spatial database, i.e., geometric data represented by a first geometric structure; or by accessing the PostGIS spatial database to obtain binary (Well-Known Binary, WKB) geometric data and converting the binary geometric data into PostGIS geometry. The geometry type of a PostGIS geometry can be determined based on parameters of the geometry type variables contained within the PostGIS geometry. The geometry types of PostGIS geometry include: points, lines, polygons, and polyhedral surfaces.
[0040] In one optional embodiment, obtaining the PostGIS geometry and its geometry type includes: accessing a PostGIS spatial database to obtain binary geometric data; converting the binary geometric data into a Gserialized geometric structure using a geometry constructor function of the PostGIS spatial database; converting the Gserialized geometric structure into a PostGIS geometry represented by a first geometric structure using a geometry conversion function of the PostGIS spatial database; the first geometric structure being an lwgeom structure; and determining the geometry type corresponding to the PostGIS geometry based on the geometry type variable of the first geometric structure.
[0041] In this embodiment, the PostGIS spatial database is accessed to obtain WKB geometric data. Using PostGIS's geometry constructor, such as the ST_GEOMFROMWKB function, the WKB geometric data is converted into geometric data represented by a Gserialized geometric structure. Then, using geometry conversion functions in the PostGIS open-source code, such as the lwgeom_from_gserialized function, the data is converted into an lwgeom structure. The lwgeom structure is parsed, and the geometry type parameter corresponding to the geometry type variable 'type' within the lwgeom structure is obtained as the geometry type of the PostGIS geometry.
[0042] S120. Force PostGIS geometry to be converted into derived geometry according to geometry type; derived geometry is a geometric structure derived from the first geometric structure according to geometry type.
[0043] Among them, the derived geometry is a geometric structure derived from the first geometric structure according to the geometry type. The first geometric structure is the lwgeom structure, and the derived structure is a geometric structure derived from the lwgeom structure according to the geometry type.
[0044] Optionally, PostGIS geometry types include: point, line, polygon, and polyhedral surface. Point types include single-point and multi-point (mpoint); line types include single-line and multi-line (mline); polygon types include single-poly and multi-poly (mpoly); and polyhedral surface types include single-polyhedral surface (psurface) and multi-polyhedral surface (msurface). Specifically, a multi-point geometry is composed of multiple single points; a multi-line geometry is composed of multiple single lines; a multi-polyhedral geometry is composed of multiple single faces; a single-polyhedral surface geometry is composed of a single polyhedral surface; and a multi-polyhedral surface geometry is composed of multiple polyhedral surfaces.
[0045] Therefore, the geometric structures derived from the lwgeom structure according to the geometric type include: the derived point structure corresponding to the point type (represented as lwpoint structure), the derived line structure corresponding to the line type (represented as lwline structure), the derived surface structure corresponding to the surface type (represented as lwpoly structure), and the derived polyhedral surface structure corresponding to the polyhedral surface type (represented as lwsurface structure).
[0046] In this embodiment, the PostGIS geometry represented by the lwgeom structure is converted into a derived geometry by means of forced conversion.
[0047] In one optional embodiment, if the geometry type is a point type, the PostGIS geometry is forcibly converted to a derived point geometry; if the geometry type is a line type, the PostGIS geometry is forcibly converted to a derived line geometry; if the geometry type is a polygon type, the PostGIS geometry is forcibly converted to a derived polygon geometry; and if the geometry type is a polyhedral surface type, the PostGIS geometry is forcibly converted to a derived polyhedral surface geometry.
[0048] In this embodiment, when the geometry type is a point type, the PostGIS geometry represented by the lwgeom structure is forcibly converted into a derived point geometry represented by the lwpoint structure; when the geometry type is a line type, the PostGIS geometry represented by the lwgeom structure is forcibly converted into a derived line geometry represented by the lwline structure; when the geometry type is a surface type, the PostGIS geometry represented by the lwgeom structure is forcibly converted into a derived surface geometry represented by the lwpoly structure; and when the geometry type is a polyhedral surface type, the PostGIS geometry represented by the lwgeom structure is forcibly converted into a derived polyhedral surface geometry represented by the lwsurface structure.
[0049] S130. Parse the derived geometry to obtain the geometry parameters; and write the geometry parameters into the intermediate geometry; there is a mapping relationship between the structure elements of the intermediate geometry and the second geometry structure corresponding to the Oracle spatial database.
[0050] Intermediate geometry is a structure defined for data conversion between derived geometries corresponding to PostGIS geometries and Oracle geometries, such as the `geo_struct_t` structure. Secondary geometry structure is the structure used in Oracle spatial databases to store geometric data. The secondary geometry structure defines how Oracle spatial databases store geometric data. Generally, Oracle spatial databases use the `SDO_GEOMETRY` structure to store geometric data.
[0051] There is a mapping relationship between the structure elements of the intermediate geometry and the structure elements of the corresponding second geometric structure in the Oracle spatial database. Geometric parameters are parameters defined by the intermediate geometry regarding geometric attributes.
[0052] In this embodiment, the derived geometry defines the geometric parameters contained in the first structure under the corresponding geometry type. Therefore, the geometric parameters can be obtained by parsing the structure variables contained in the derived geometry. The derived geometry is a structure derived from the lwgeom structure based on the geometry type, and the geometric parameters may differ for different geometry types. For each type of geometry, the geometric parameters include: geometry dimension dim, geometry type parameter type, geometry coordinate system parameter srid, and geometry coordinates. The geometric parameters contained in the derived surface structure also include: geometry ring parameter nrings; the parameters contained in the derived polyhedral surface structure also include: geometry ring parameter nrings and geometry composite parameter geoms.
[0053] In an optional embodiment, the structure elements of the intermediate geometry include: intermediate geometry variables and parameter types corresponding to each intermediate geometry variable; the intermediate geometry variables include: geometry dimension variable dim, geometry type variable geotype, geometry coordinate system variable srid, first geometry coordinate variable p, second geometry coordinate variable ord, and second geometry coordinate interpretation variable ele; the first geometry coordinate variable is used to store the coordinates of a single-point type geometry; the second geometry coordinate variable is used to store the coordinates of other geometry types besides the single-point type; the second geometry coordinate interpretation variable is used to explain the parameters of the second geometry coordinate variable;
[0054] Wherein, the parameter type corresponding to the first geometric coordinate variable is represented by a single-point data storage geometric structure; the parameter type corresponding to the second geometric coordinate variable and the second geometric coordinate interpretation variable is represented by a floating-point data storage geometric structure; the single-point data storage geometric structure is used to define the storage method of single-point coordinates; the floating-point data storage geometric structure is used to define the storage method of floating-point data.
[0055] In an optional embodiment, the intermediate geometry includes intermediate geometry variables including: geometry dimension variable geodim, geometry type variable geoType, geometry coordinate system variable geosrid, first geometry coordinate variable geop, second geometry coordinate variable geoodrd, and second geometry coordinate interpretation variable geoele.
[0056] `geoType` is used to define the type of intermediate geometry. The first geometry coordinate variable `p` stores the coordinates of a single point. The second geometry coordinate variable `geoord` stores the coordinates of other geometries besides the single-point type. The second geometry coordinate interpretation variable `geoele` represents the information of the elements contained in the geometry, such as a cube containing multiple face elements. Elements can also contain their own child elements. The information of an element is an array with three numbers. For example, (1,1003,1,4,2003,1) contains two elements: the first element is (1,1003,1), and the second element is (4,2003,1). The meaning of each array is as follows: the first number represents the starting offset of the element in `geoord`. For example, if `geoord` is (5,4,2,12,8,15,3,7), the starting offset of the element is 5, and (8,15) is the first point of the element. If the elements are connected, the offset of the last point of the element is the starting offset of the next element. For example, (8,15) is the end point of the element and also the starting point of the next element. The second number represents the element's type, with a maximum of four digits. If the element is a composite type, it is followed by its child elements. The third number specifies how the element should be interpreted. For composite elements, it indicates the number of child elements. For single elements, it is used to further interpret the element type; for example, (1,1003,3) represents a rectangle, and (1,1003,4) represents a circle.
[0057] In one optional embodiment, the parameter type corresponding to the first geometric coordinate variable is represented by a single-point data storage structure; the parameter type corresponding to the second geometric coordinate variable and the second geometric coordinate interpretation variable is represented by a floating-point data storage structure; the single-point data storage structure is used to define the storage method of single-point coordinates; the floating-point data storage structure is used to define the storage method of floating-point data.
[0058] In this embodiment, the parameter type corresponding to the first geometric coordinate variable p is represented by the single-point data storage structure point_t; the single-point data storage structure point_t is used to define the storage method of single-point coordinates. The parameter type corresponding to the second geometric coordinate variable ord and the second geometric coordinate interpretation variable is represented by the floating-point data storage structure arr_t; the floating-point data storage structure arr_t is used to define the storage method of floating-point data.
[0059] In one specific embodiment, the intermediate geometry is defined as follows:
[0060]
[0061] The definition of a three-dimensional single-point data storage geometry is as follows:
[0062]
[0063] The definition of the floating-point data storage geometry structure is as follows:
[0064]
[0065] S140. Convert the intermediate geometry into an Oracle geometry according to the mapping relationship; the Oracle geometry is geometric data represented by a second geometric structure.
[0066] In this context, Oracle geometry refers to geometric data represented using a second geometry structure. Generally, the second geometry structure corresponding to an Oracle spatial database is the SDO_GEOMETRY structure.
[0067] In this embodiment, after determining the intermediate geometry, the structure variables of the intermediate geometry are mapped to the geometry variables of the Oracle geometry according to the mapping relationship between the structure elements of the intermediate geometry and the structure elements of the corresponding second geometry structure in the Oracle spatial database, thereby realizing the conversion of PostGIS geometry into Oracle geometry through the intermediate geometry.
[0068] The technical solution of this invention involves obtaining a PostGIS geometry and its geometry type. The PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database. Based on the geometry type, the PostGIS geometry is forcibly converted into a derived geometry. The derived geometry is a geometric structure derived from the first geometric structure based on its geometry type. The derived geometry is parsed to obtain geometry parameters, which are then written into an intermediate geometry. A mapping relationship exists between the structure elements of the intermediate geometry and a second geometric structure corresponding to the Oracle spatial database. Based on this mapping relationship, the intermediate geometry is converted into an Oracle geometry. The Oracle geometry is geometric data represented by the second geometric structure. By defining an intermediate geometry and using it to convert PostGIS geometry into Oracle geometry, the complexity of the conversion process from PostGIS geometric data to Oracle geometric data is simplified, and the conversion efficiency is improved.
[0069] Example 2
[0070] Figure 2 This is a flowchart of a method for converting point-type PostGIS geometric data according to Embodiment 2 of the present invention. This embodiment further defines the conversion process of point-type PostGIS geometric data in the above embodiments. Figure 2 As shown, the method includes:
[0071] S210. Obtain the PostGIS geometry and its geometry type; the PostGIS geometry is geometric data represented by the first geometric structure corresponding to the PostGIS spatial database; the geometry type is a point type; the point type includes: single point type and multi-point type.
[0072] S220. Force PostGIS geometry to be converted into a derived point structure based on point type; the derived point structure is a geometric structure derived from the first geometric structure based on the point type.
[0073] In this embodiment, when the geometry type is point type, the PostGIS geometry is forcibly converted into a derived point geometry lwpoint.
[0074] S230. For the derived point structure, parse the derived point structure to obtain the geometric parameters, and write the geometric parameters into the intermediate geometry. The geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, and geometric coordinate parameter.
[0075] Specifically, when the geometry type parameter is a single-point type, the geometry coordinate parameter includes the geometry coordinates; when the geometry type parameter is a multi-point type, the geometry coordinate parameter includes the geometry coordinates and the number of geometry coordinates; the number of geometry coordinates is equal to the product of the geometry dimension and the number of points.
[0076] For example, the `lwpoint->POINT` parameter of the derived point structure is parsed to obtain the geometry dimension `dim`, the geometry type parameter `type` (e.g., `type=1` for single-point type, `type=5` for multi-point type), and the geometry coordinate system parameter `srid`. For single-point type, `memcpy` copies `POINT->serialized_pointlist` data into a pre-created `double point_val[n]` array of length `n`. Each `sizeof(double)` represents the coordinate value of the point data to be converted in each dimension (e.g., x, y, z), resulting in the number of geometry coordinates `dim`. For multi-point type, multi-points are stored as multiple single points in PostGIS. Therefore, by iterating through each single point in the multi-point array, the geometry coordinates of the multi-point array and the number of geometry coordinates `npoints*dim` can be obtained.
[0077] S240. When the geometry type is a single point type, assign the geometry dimension parameter to the geometry dimension variable of the intermediate geometry, assign the single point type to the geometry type variable of the intermediate geometry, assign the geometry coordinate system parameter to the geometry coordinate system variable of the intermediate geometry, assign the geometry coordinates to the first geometry coordinate variable of the intermediate geometry, and set the second geometry coordinate variable to null.
[0078] In this embodiment, the intermediate geometry variables include: geometry dimension variable geodim, geometry type variable geotype, geometry coordinate system variable geosrid, first geometry coordinate variable geop, second geometry coordinate variable geoodrd, and second geometry coordinate interpretation variable geoele.
[0079] Specifically, for single-point type geometries, the first geometry coordinate variable `geoord` stores the geometry coordinates. The second geometry coordinate variable `geoord` and the second geometry coordinate interpretation variable `geoele` are not needed and can be set to null values, such as NULL. A single-point type intermediate geometry can be represented as:
[0080] geo_struct_t
[0081] {
[0082] geodim = dim;
[0083] geotype = type;
[0084] geosrid=srid
[0085] px=point_val[0], py=point_val[1], pz=point_val[2];
[0086] ele->arr_num = 0;
[0087] ele->arr_element = NULL;
[0088] ord->arr_num = 0;
[0089] ord->arr_element = NULL;
[0090] }
[0091] S250. When the geometry type is multi-point, assign the geometry dimension to the geometry dimension variable of the intermediate geometry, assign the geometry type parameter to the geometry type variable of the intermediate geometry, assign the geometry coordinate system parameter to the geometry coordinate system variable of the intermediate geometry, set the first geometry coordinate variable to null, assign the geometry coordinates in the geometry coordinate parameter to the second geometry coordinate variable of the intermediate geometry, and update the second geometry coordinate interpretation variable according to the geometry type parameter and the geometry coordinate parameter.
[0092] Specifically, for multi-point geometry, a second geometry coordinate variable `geop` is used to store the geometry coordinates; a second geometry coordinate interpretation variable `geoele` is used to interpret and explain the second geometry coordinate variable `geop`. The first geometry coordinate variable `geop` does not need to be used and can be set to any value such as NAN.
[0093] Multi-point intermediate geometry can be represented as:
[0094] geo_struct_t
[0095] {
[0096] geodim = dim;
[0097] geotype = type;
[0098] geosrid=srid
[0099] geop = NAN;
[0100] ele->arr_num = dim;
[0101] ele->arr_element[0]=1; ele->arr_element[1]=1; ele->arr_element[2]=npoints;
[0102] ord->arr_num = npoints*dim;
[0103] ord->arr_element; / / Geometric coordinates
[0104] }
[0105] The second geometric coordinate variable includes: the number of geometric coordinates `arr_num` and the geometric coordinates `arr_element`. The number of geometric coordinates `arr_num` = the number of points `npoints` * the geometric dimension `geodim`. The geometric coordinates `arr_element` are obtained by iterating through the data of individual points.
[0106] S260. Convert the intermediate geometry into an Oracle geometry according to the mapping relationship; the Oracle geometry is geometric data represented by a second geometric structure.
[0107] The technical solution of this invention involves obtaining a PostGIS geometry and its geometry type. The PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database. The geometry type is a point type, including single-point and multi-point types. Based on the point type, the PostGIS geometry is forcibly converted into a derived point structure. The derived point structure is a geometric structure derived from the first geometric structure based on the point type. For the derived point structure, geometry parameters are parsed to obtain geometry parameters, which are then written into an intermediate geometry. The geometry parameters include geometry dimensions, geometry type parameters, geometry coordinate system parameters, and geometry coordinate parameters. When the geometry type is a single-point type, the geometry dimension parameter is assigned to the geometry dimension variable of the intermediate geometry, and the single-point type parameter is assigned to the intermediate geometry. The intermediate geometry's geometry type variable is defined, and its coordinate system parameters are assigned to the intermediate geometry's coordinate system variable. The geometry coordinates are assigned to the first geometry coordinate variable of the intermediate geometry, and the second geometry coordinate variable is set to null. When the geometry type is multi-point, the geometry dimensions are assigned to the intermediate geometry's dimension variable, the geometry type parameters are assigned to the intermediate geometry's geometry type variable, the geometry coordinate system parameters are assigned to the intermediate geometry's coordinate system variable, the first geometry coordinate variable is set to null, and the geometry coordinates from the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry. The second geometry coordinate interpretation variable is then updated based on the geometry type and coordinate parameters. Finally, the intermediate geometry is converted to an Oracle geometry based on a mapping relationship. The Oracle geometry is geometric data represented using the second geometric structure. By defining an intermediate geometry and calling it, the conversion of point-type PostGIS geometry to Oracle geometry simplifies the complexity of the conversion process and improves conversion efficiency.
[0108] Example 3
[0109] Figure 3 This is a flowchart of a method for converting line-type PostGIS geometric data according to Embodiment 3 of the present invention. This embodiment further defines the conversion process of line-type PostGIS geometric data in the above embodiments. Figure 3 As shown, the method includes:
[0110] S310. Obtain the PostGIS geometry and its geometry type; the PostGIS geometry is geometric data represented by the first geometric structure corresponding to the PostGIS spatial database; the geometry type is a line type; the line type includes: single-line type and multi-line type.
[0111] S320. Force PostGIS geometry to be converted into a derived line structure according to the geometry type; the derived line structure is a geometric structure derived from the first geometric structure according to the line type.
[0112] In this embodiment, when the geometry type is line type, the PostGIS geometry is forcibly converted into a derived line geometry lwline.
[0113] S330. For a derived line structure, parse the derived line structure to obtain the geometric parameters, and write the geometric parameters into the intermediate geometry. The geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, and geometric coordinate parameter.
[0114] Specifically, when the geometry type parameter is a single-line type, the geometry coordinate parameter includes the geometry coordinates; when the geometry type parameter is a multi-line type, the geometry coordinate parameter includes the geometry coordinates and the number of geometry coordinates; the number of geometry coordinates is equal to the product of the geometry dimension and the number of lines.
[0115] Specifically, the `lwline>POINTS` parameter of the derived point structure is parsed to obtain the geometry dimension `dim`, the geometry type parameter `type` (e.g., `type=2` for single-line type, `type=6` for multi-line type), and the geometry coordinate system parameter `srid`. For single-line type, `memcpy` copies `POINTS->serialized_pointlist` data of length 3 * `POINTS->npoints` `sizeof(double)` to the prepared data storage structure, thus obtaining all the coordinate data of the corresponding line, and the number of geometry coordinates is the geometry dimension `dim`. For multi-line type, the parsing function of the single-line type is called, traversing all lines, and the number of geometry coordinates is equal to the product of the geometry dimension `dim` and the number of lines `ngeoms`.
[0116] S340. When the geometry type is line type, assign the geometry dimension to the geometry dimension variable of the intermediate geometry, assign the geometry type parameter to the geometry type variable of the intermediate geometry, assign the geometry coordinate system parameter to the geometry coordinate system variable of the intermediate geometry, set the first geometry coordinate variable to any value, assign the geometry coordinates in the geometry coordinate parameter to the second geometry coordinate variable of the intermediate geometry; update the second geometry coordinate interpretation variable according to the geometry type parameter and the geometry ring parameter.
[0117] Specifically, for multi-line geometry, the second geometry coordinate variable `geoord` stores the geometry coordinates; the second geometry coordinate interpretation variable `geoele` interprets and explains the second geometry coordinate variable `geop`. The first geometry coordinate variable `geop` does not need to be used and can be set to any value such as `NAN`.
[0118] Specifically, a single-line type intermediate geometry can be represented as:
[0119] geo_struct_t
[0120] {
[0121] geodim = dim;
[0122] geotype = type;
[0123] geosrid=srid
[0124] geop = NAN;
[0125] ele->arr_num = dim;
[0126] ele->arr_element={1,2,1};
[0127] ord->arr_num = dim * npoints;
[0128] ord->arr_element; / / Geometric coordinates
[0129] }
[0130] The intermediate geometry of a multi-line type can be represented as:
[0131] geo_struct_t
[0132] {
[0133] geodim = dim;
[0134] geotype = type;
[0135] geosrid=srid
[0136] geop = NAN;
[0137] ele->arr_num = dim * ngeoms; / / ngeoms is the number of lines
[0138] ele->arr_element[i]; / / When i%3 = 0, assign the value as the number of coordinates already written plus 1; when i%3 = 1, assign the value as 2; when i%3 = 2, assign the value as 1;
[0139] ord->arr_num; / / arr_num equals the sum of the number of all written coordinates, dynamically changing until all traversals are completed;
[0140] ord->arr_element; / / Geometric coordinates
[0141] }
[0142] S350. Convert the intermediate geometry into an Oracle geometry based on the mapping relationship; the Oracle geometry is geometric data represented by a second geometric structure.
[0143] The technical solution of this invention involves obtaining a PostGIS geometry and its geometry type. The PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database. The geometry type is a line type, including single-line and multi-line types. The PostGIS geometry is forcibly converted into a derived line structure based on its geometry type. The derived line structure is a geometric structure derived from the first geometric structure based on its line type. When the geometry type is a line type, the geometry dimension is assigned to the geometry dimension variable of the intermediate geometry, the geometry type parameter is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to an arbitrary value, and the geometry coordinates in the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry. The second geometry coordinate interpretation variable is updated based on the geometry type parameter and the geometry coordinate parameter. Finally, the intermediate geometry is converted into an Oracle geometry based on a mapping relationship. The Oracle geometry is geometric data represented by the second geometric structure. By defining intermediate geometry and calling intermediate geometry to convert line-type PostGIS geometry into Oracle geometry, the complexity of the conversion process from line-type PostGIS geometry data to Oracle geometry data is simplified, and the conversion efficiency is improved.
[0144] Example 4
[0145] Figure 4 This is a flowchart of a method for converting PostGIS geometric data of a polyhedral surface type according to Embodiment 4 of the present invention. This embodiment further defines the conversion process of PostGIS geometric data of the surface type in the above embodiments. Figure 4 As shown, the method includes:
[0146] S410. Obtain the PostGIS geometry and its geometry type; the PostGIS geometry is geometric data represented by the first geometric structure corresponding to the PostGIS spatial database; the geometry type is a face type; face types include: single-face type and multi-face type.
[0147] S420. Force PostGIS geometry to be converted into a derived surface structure according to the geometry type; the derived surface structure is a geometric structure derived from the first geometric structure according to the surface type.
[0148] In this embodiment, when the geometry type is a surface type, the PostGIS geometry is forcibly converted into a derived surface structure lwpoly.
[0149] S430. For derived surface structures, parse the derived surface structures to obtain geometric parameters, and write the geometric parameters into the intermediate geometry. The geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, geometric coordinate parameter, and geometric ring parameter.
[0150] The geometric coordinate parameters include: geometric coordinates and the number of geometric coordinates.
[0151] Specifically, the `rings` parameter in the derived face structure `lwpoly` is parsed to obtain the geometry dimension `dim`, the geometry type parameter `type` (e.g., `geotype=3` indicates a single-face type, `type=7` indicates a multi-face type), and the geometry coordinate system parameter `srid`. The value of `lwpoly->nrings` is parsed to obtain the geometry ring parameter `nrings`. The `rings` parameter is iterated based on the value of `lwpoly->nrings`. Assuming the execution is performed for the i-th time, `dim*(rings[i]->npoints)` represents the number of data points corresponding to this ring. This number of data points multiplied by `sizeof(double)` is copied to a storage structure. When `i` changes, the size of this storage structure is reallocated, and data is added thereafter to obtain the geometry coordinate parameters. For multi-face types, the parsing function for single-face types is called to iterate through all faces.
[0152] S440. When the geometry type is a face type, assign the geometry dimension to the geometry dimension variable of the intermediate geometry, assign the point type to the geometry type variable of the intermediate geometry, assign the geometry coordinate system to the geometry coordinate system variable of the intermediate geometry, set the first geometry coordinate variable to an arbitrary value, assign the geometry coordinates in the geometry coordinate parameters to the second geometry coordinate variable of the intermediate geometry, and update the second geometry coordinate interpretation variable according to the geometry type parameter and the geometry ring parameter.
[0153] Specifically, for multi-faceted geometries, the second geometry coordinate variable `geoord` stores the geometry coordinates; the second geometry coordinate interpretation variable `geoele` interprets and explains the second geometry coordinate variable `geop`. The first geometry coordinate variable `geop` does not need to be used and can be set to any value such as `NAN`.
[0154] Specifically, a single-sided intermediate geometry can be represented as:
[0155] geo_struct_t
[0156] {
[0157] geodim = dim;
[0158] geotype = type;
[0159] geosrid=srid
[0160] geop = NAN;
[0161] ele->arr_num = dim * nrings;
[0162] ele->arr_element; / / The first group of arr_element is assigned the value {1,1003,1}. The first number of each subsequent group is the number of data points before the first data point of this ring plus 1. The second data point is 2003, and the third data point is 1.
[0163] ord->arr_num; / / arr_num is 3*(the sum of rings[i]->npoints);
[0164] ord->arr_element; / / Geometric coordinates
[0165] }
[0166] A multifaceted intermediate geometry can be represented as:
[0167] geo_struct_t
[0168] {
[0169] geodim = dim;
[0170] geotype = type;
[0171] geosrid=srid
[0172] geop = NAN;
[0173] ele->arr_num = dim * nrings;
[0174] ele->arr_element[i]; / / When i%3=0, arr_element is assigned the number of coordinates already written plus 1; the remaining corresponding data are the results obtained by calling the parsing function of the single-sided type;
[0175] ord->arr_num; / / This equals the sum of the number of all written coordinates, dynamically changing until all coordinates have been traversed;
[0176] ord->arr_element; / / Geometric coordinates;
[0177] }
[0178] S450. Convert the intermediate geometry into an Oracle geometry based on the mapping relationship; the Oracle geometry is geometric data represented by a second geometric structure.
[0179] The technical solution of this invention involves obtaining a PostGIS geometry and its geometry type. The PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database. The geometry type is a face type, including single-face and multi-face types. The PostGIS geometry is forcibly converted into a derived face structure based on its geometry type. The derived face structure is a geometric structure derived from the first geometric structure based on its face type. For the derived face structure, geometry parameters are obtained by parsing the derived face structure and writing these parameters into an intermediate geometry. The geometry parameters include geometry dimensions, geometry type parameters, and geometry... The system defines coordinate system parameters, geometry coordinate parameters, and geometry ring parameters. When the geometry type is a polygon, the geometry dimension is assigned to the geometry dimension variable of the intermediate geometry, the point type is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to an arbitrary value, and the geometry coordinates from the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry. The second geometry coordinate interpretation variable is then updated based on the geometry type and geometry ring parameters. Finally, the intermediate geometry is converted to an Oracle geometry based on a mapping relationship. An Oracle geometry is geometric data represented using a second geometric structure. By defining an intermediate geometry and calling it, the conversion of polygon-type PostGIS geometry to Oracle geometry simplifies the complexity of the conversion process and improves conversion efficiency.
[0180] Example 5
[0181] Figure 5 This is a flowchart of a method for converting PostGIS geometric data of a polyhedral surface type according to Embodiment 5 of the present invention. This embodiment further defines the conversion process of PostGIS geometric data of the polyhedral surface type described in the above embodiments. Figure 5 As shown, the method includes:
[0182] S510. Obtain the PostGIS geometry and its geometry type; the PostGIS geometry is geometric data represented by the first geometric structure corresponding to the PostGIS spatial database; the geometry type is a polyhedral surface type; the polyhedral surface type includes: single polyhedral surface type and multiple polyhedral surface type.
[0183] S520. Force PostGIS geometry to be converted into a derived polyhedral surface structure according to the geometry type; the derived polyhedral surface structure is a geometric structure derived from the first geometric structure according to the polyhedral surface type.
[0184] In this embodiment, when the geometry type is a polyhedral surface type, the PostGIS geometry is forcibly converted into a derived polyhedral surface structure lwsurface.
[0185] S530. For the derived polyhedral surface structure, analyze the derived polyhedral surface structure to obtain the geometric parameters, and write the geometric parameters into the intermediate geometry. The geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, geometric coordinate parameter, geometric ring parameter, and geometric composite parameter.
[0186] The geometric coordinate parameters include: geometric coordinates and the number of geometric coordinates.
[0187] Specifically, the `geoms` parameter in the derived polyhedral surface structure `lwsurface` is parsed to obtain the geometric dimension `dim`, the geometric type parameter `type` (e.g., `geotype=4` indicates a single polyhedral surface type, `type=8` indicates a multi-polyhedral surface type), and the geometric coordinate system parameter `srid`. The value of `lwpsurface->ngeoms` is used to obtain the geometric composite parameter `geoms` and the geometric ring parameter `rings`. The `geoms` parameter is iterated based on the value of `lwpsurface->ngeoms`. Assuming the i-th execution, `3*geoms->rings[i]->npoints` represents the number of data points corresponding to this ring. This number of points multiplied by `sizeof(double)` is copied to a storage structure. When `i` changes, the size of this storage structure is `realloc`, and data is added thereafter to obtain the geometric coordinate parameters. For polyhedral types, the parsing function for a single polyhedral surface type is called to iterate through all polyhedral surfaces.
[0188] S540. When the geometry type is a polyhedral surface type, assign the geometry dimension to the geometry variable of the intermediate geometry, assign the point type to the geometry type variable of the intermediate geometry, assign the geometry coordinate system parameter to the geometry coordinate system variable of the intermediate geometry, set the first geometry coordinate variable to the default value, assign the geometry coordinate in the geometry coordinate parameter to the second geometry coordinate variable of the intermediate geometry; and update the second geometry coordinate interpretation variable according to the geometry type, geometry ring parameter, and geometry composite parameter.
[0189] For polyhedral surfaces, the second geometric coordinate variable `geoord` stores the geometric coordinates; the second geometric coordinate interpretation variable `geoele` explains the second geometric coordinate variable `geop`. The first geometric coordinate variable `geop` is not needed and can be set to any value, such as `NAN`.
[0190] Specifically, an intermediate geometry of a single polyhedral surface type can be represented as:
[0191] geo_struct_t
[0192] {
[0193] geodim = dim;
[0194] geotype = type;
[0195] geosrid=srid
[0196] geop = NAN;
[0197] ele->arr_num; / / arr_num is 3*(the sum of geoms->rings[i]->npoints plus 1);
[0198] ele->arr_element; / / Assign the first group to {1,1006,ngeoms}, and the first number of each group after that is the number of data before the first data of this geoms plus 1 (ele->arr_element[3]=1), the second data is 1003, the third data is 1, assuming there is a cycle, the algorithm of the first data of the cycle of each geoms remains unchanged, the second data is 2003, and the third data is 1;
[0199] ord->arr_num / / arr_num is the sum of 3*(geoms->rings[i]->npoints);
[0200] ord->arr_element; / / Geometric coordinates
[0201] }
[0202] The intermediate geometry of a polyhedral surface type can be represented as:
[0203] geo_struct_t
[0204] {
[0205] geodim = dim;
[0206] geotype = type;
[0207] geosrid=srid
[0208] geop = NAN;
[0209] ele->arr_num; / / arr_num is the sum of the coordinates of all polyhedron surfaces;
[0210] ele->arr_element[i]; / / When i%3=0, the value is the number of coordinates that have been written at this time plus 1, that is, the sum of all the coordinates that have been written plus 1 (assuming 6 coordinates have been written, the value is 7); the rest of the corresponding data are the results obtained by calling the single-sided function;
[0211] ord->arr_num; / / This equals the sum of all the coordinates that have been written, and changes dynamically until all coordinates have been traversed;
[0212] ord->arr_element; / / Geometric coordinates;
[0213] }
[0214] S550. Convert the intermediate geometry into an Oracle geometry based on the mapping relationship; the Oracle geometry is geometric data represented by a second geometric structure.
[0215] The technical solution of this invention involves obtaining a PostGIS geometry and its geometry type. The PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database. The geometry type is a polyhedral surface type, including single polyhedral surface types and multiple polyhedral surface types. The PostGIS geometry is forcibly converted into a derived polyhedral surface structure based on its geometry type. The derived polyhedral surface structure is a geometric structure derived from the first geometric structure based on its polyhedral surface type. For the derived polyhedral surface structure, its geometry parameters are parsed and written into an intermediate geometry. The geometry parameters include geometric dimensions, geometric... The system defines several parameters for an intermediate geometry, including volume type parameters, geometric coordinate system parameters, geometric coordinate parameters, geometric ring parameters, and geometric composite parameters. When the geometry type is a polyhedral surface, the geometric dimensions are assigned to the intermediate geometry's geometric variable, the point type is assigned to the intermediate geometry's geometric type variable, the geometric coordinate system parameters are assigned to the intermediate geometry's geometric coordinate system variable, the first geometric coordinate variable is set to its default value, and the geometric coordinates from the geometric coordinate parameters are assigned to the intermediate geometry's second geometric coordinate variable. The second geometric coordinate interpretation variable is then updated based on the geometry type, geometric ring parameters, and geometric composite parameters. Finally, the intermediate geometry is converted to an Oracle geometry based on a mapping relationship. The Oracle geometry is geometric data represented using the second geometric structure. By defining an intermediate geometry and calling it, the conversion of a polyhedral surface type PostGIS geometry to an Oracle geometry simplifies the process and improves efficiency.
[0216] Example 6
[0217] Figure 6 This is a schematic diagram of the structure of a PostGIS geometric data conversion device provided in Embodiment 3 of the present invention.
[0218] like Figure 6 As shown, the device includes:
[0219] The data acquisition module 610 is used to acquire PostGIS geometry and the geometry type of the PostGIS geometry; the PostGIS geometry is geometric data represented by a first geometric structure corresponding to the PostGIS spatial database;
[0220] The forced conversion module 620 is used to forcibly convert the PostGIS geometry into a derived geometry according to the geometry type; the derived geometry is a geometric structure derived from the first geometric structure according to the geometry type.
[0221] The parsing and writing module 630 is used to parse the derived geometry to obtain geometry parameters and write the geometry parameters into an intermediate geometry; there is a mapping relationship between the structure elements of the intermediate geometry and the second geometric structure corresponding to the Oracle spatial database.
[0222] The data conversion module 640 is used to convert the intermediate geometry into an Oracle geometry according to the mapping relationship; the Oracle geometry is geometric data represented by the second geometric structure.
[0223] Optionally, the data acquisition module 610 is specifically used for:
[0224] Access the PostGIS spatial database to obtain binary geometric data;
[0225] The binary geometric data is converted into a Gserialized geometric structure using the geometry constructor function of the PostGIS spatial database.
[0226] The Gserialized geometric structure is converted into a PostGIS geometric structure represented by a first geometric structure using the geometry conversion function of the PostGIS spatial database; the first geometric structure is the lwgeom structure.
[0227] The geometry type corresponding to the PostGIS geometry is determined based on the geometry type variable of the first geometric structure.
[0228] Optionally, the geometry types of the PostGIS geometry include: point type, line type, polygon type, and polyhedral surface type; the point type includes: single-point type and multi-point type; the line type includes: single-line type and multi-line type; the polygon type includes: single-face type and multi-face type; the polyhedral surface type includes: single polyhedral surface type and multi-polyhedral surface type.
[0229] The derived geometry includes: a derived point structure corresponding to the point type, a derived line structure corresponding to the line type, a derived surface structure corresponding to the surface type, and a derived polyhedral surface structure corresponding to the polyhedral surface type.
[0230] Optional, the forced conversion module 620 is specifically used for:
[0231] If the geometry type is a point type, the PostGIS geometry will be forcibly converted into a derived point geometry;
[0232] If the geometry type is a line type, the PostGIS geometry will be forcibly converted into a derived line geometry;
[0233] If the geometry type is a face type, the PostGIS geometry will be forcibly converted into a derived face geometry;
[0234] If the geometry type is a polyhedral surface type, the PostGIS geometry will be forcibly converted into a derived polyhedral surface geometry.
[0235] Optionally, the structure elements of the intermediate geometry include: intermediate geometry variables and parameter types corresponding to each intermediate geometry variable;
[0236] The intermediate geometric variables include: geometric dimension variables, geometric type variables, geometric coordinate system variables, first geometric coordinate variables, second geometric coordinate variables, and second geometric coordinate interpretation variables. The first geometric coordinate variable stores the coordinates of a single-point type geometric object. The second geometric coordinate variable stores the coordinates of other geometric objects besides the single-point type. The second geometric coordinate interpretation variable explains the parameters of the second geometric coordinate variable. The parameter type corresponding to the first geometric coordinate variable is represented by a single-point data storage structure. The parameter types corresponding to the second geometric coordinate variable and the second geometric coordinate interpretation variable are represented by a floating-point data storage structure. The single-point data storage structure defines the storage method for single-point coordinates. The floating-point data storage structure defines the storage method for floating-point data.
[0237] Optionally, the derived geometry includes: derived point structure, derived line structure, derived surface structure, and derived polyhedral surface structure;
[0238] For the derived point structure and the derived line structure, the geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, and geometric coordinate parameter;
[0239] For the derived line structure, the geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, and geometric coordinate parameter;
[0240] For derived surface structures, the geometric parameters include: geometric dimensions, geometric type parameters, geometric coordinate system parameters, geometric coordinate parameters, and geometric ring parameters;
[0241] For the derived polyhedral structure, the geometric parameters include: geometric dimensions, geometric type parameters, geometric coordinate system parameters, geometric coordinate parameters, geometric ring parameters, and geometric composite parameters.
[0242] Optional, the parsing and writing module 630 is specifically used for:
[0243] When the geometry type is a single point type, the geometry dimension parameter is assigned to the geometry dimension variable of the intermediate geometry, the single point type is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the geometry coordinates are assigned to the first geometry coordinate variable of the intermediate geometry, and the second geometry coordinate variable is set to a null value.
[0244] When the geometry type is a multi-point type or a line type, the geometry dimension is assigned to the geometry dimension variable of the intermediate geometry, the geometry type parameter is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to an arbitrary value, and the geometry coordinates in the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry; and the second geometry coordinate interpretation variable is updated according to the geometry type parameter and the geometry coordinate parameters.
[0245] When the geometry type is a face type, the geometry dimension is assigned to the geometry dimension variable of the intermediate geometry, the point type is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to an arbitrary value, and the geometry coordinates in the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry; and the second geometry coordinate interpretation variable is updated according to the geometry type parameter and the geometry ring parameter.
[0246] When the geometry type is a polyhedral surface type, the geometry dimension is assigned to the geometry variable of the intermediate geometry, the point type is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to the default value, and the geometry coordinates in the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry; and the second geometry coordinate interpretation variable is updated according to the geometry type, the geometry ring parameter, and the geometry composite parameter.
[0247] The PostGIS geometric data conversion device provided in this embodiment of the invention can execute the PostGIS geometric data conversion method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0248] Example 7
[0249] Figure 7 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0250] like Figure 7 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0251] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0252] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as PostGIS geometric data transformation methods.
[0253] In some embodiments, the PostGIS geometric data conversion method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the PostGIS geometric data conversion method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the PostGIS geometric data conversion method by any other suitable means (e.g., by means of firmware).
[0254] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0255] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0256] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0257] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0258] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0259] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0260] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0261] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for converting PostGIS geometry data, characterized in that, The method comprises the following steps: acquiring a PostGIS geometry and a geometry type of the PostGIS geometry; the PostGIS geometry is geometry data represented by a first geometry structure corresponding to a PostGIS spatial database; the PostGIS geometry is forcibly converted into a derived geometry according to the geometry type; the derived geometry is a geometry structure derived from the first geometry structure according to the geometry type; the derived geometry is parsed to obtain geometry parameters, and the geometry parameters are written into an intermediate geometry; the intermediate geometry and a second geometry structure corresponding to an Oracle spatial database have a mapping relationship between structure elements; the intermediate geometry is converted into an Oracle geometry according to the mapping relationship; the Oracle geometry is geometry data represented by the second geometry structure; wherein, the structure elements of the intermediate geometry comprise intermediate geometry variables and parameter types corresponding to each intermediate geometry variable; the intermediate geometry variables comprise a geometry dimension variable, a geometry type variable, a geometry coordinate system variable, a first geometry coordinate variable, a second geometry coordinate variable and a second geometry coordinate interpretation variable; the first geometry coordinate variable is used for storing the coordinates of a single-point-type geometry; the second geometry coordinate variable is used for storing the coordinates of other geometries except the single-point-type geometry; and the second geometry coordinate interpretation variable is used for explaining the parameters of the second geometry coordinate variable.
2. The method of claim 1, wherein, The method comprises the following steps: acquiring a PostGIS geometry and a geometry type of the PostGIS geometry, comprising: accessing a PostGIS spatial database to obtain binary geometry data; the binary geometry data is converted into a Gserialized geometry structure through a geometry constructor of the PostGIS spatial database; the Gserialized geometry structure is converted into a PostGIS geometry represented by a first geometry structure through a geometry conversion function of the PostGIS spatial database; the first geometry structure is an lwgeom structure; 3. The method of claim 1, wherein, the geometry type corresponding to the PostGIS geometry is determined according to a geometry type variable of the first geometry structure. The geometry type of the PostGIS geometry comprises a point type, a line type, a surface type and a polyhedral surface type; the point type comprises a single-point-type and a multi-point-type; the line type comprises a single-line-type and a multi-line-type; the surface type comprises a single-surface-type and a multi-surface-type; and the polyhedral surface type comprises a single polyhedral surface type and a multi-polyhedral surface type; 4. The method of claim 3, wherein, the derived geometry comprises a derived point structure corresponding to the point type, a derived line structure corresponding to the line type, a derived surface structure corresponding to the surface type and a derived polyhedral surface structure corresponding to the polyhedral surface type. the PostGIS geometry is forcibly converted into a derived geometry according to the geometry type, comprising: If the geometry type is a point type, the PostGIS geometry will be forcibly converted into a derived point geometry; If the geometry type is a line type, the PostGIS geometry will be forcibly converted into a derived line geometry; If the geometry type is a face type, the PostGIS geometry will be forcibly converted into a derived face geometry; If the geometry type is a polyhedral surface type, the PostGIS geometry will be forcibly converted into a derived polyhedral surface geometry.
5. The method of claim 1, wherein, The parameter type corresponding to the first geometric coordinate variable is represented by a single-point data storage structure; the parameter type corresponding to the second geometric coordinate variable and the second geometric coordinate interpretation variable is represented by a floating-point data storage structure; the single-point data storage structure is used to define the storage method of single-point coordinates; the floating-point data storage structure is used to define the storage method of floating-point data.
6. The method of claim 5, wherein, The derived geometry includes: derived point structures, derived line structures, derived surface structures, and derived polyhedral surface structures; For the derived point structure and the derived line structure, the geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, and geometric coordinate parameter; For the derived line structure, the geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, and geometric coordinate parameter; For derived surface structures, the geometric parameters include: geometric dimensions, geometric type parameters, geometric coordinate system parameters, geometric coordinate parameters, and geometric ring parameters; For the derived polyhedral surface structure, the geometric parameters include: geometric dimension, geometric type parameter, geometric coordinate system parameter, geometric coordinate parameter, geometric ring parameter, and geometric composite parameter.
7. The method of claim 6, wherein, Writing the geometry parameters into the intermediate geometry includes: When the geometry type is a single point type, the geometry dimension is assigned to the geometry dimension variable of the intermediate geometry, the single point type is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the geometry coordinate parameter is assigned to the first geometry coordinate variable of the intermediate geometry, and the second geometry coordinate variable is set to a null value. When the geometry type is a multi-point type or a line type, the geometry dimension is assigned to the geometry dimension variable of the intermediate geometry, the geometry type parameter is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to an arbitrary value, and the geometry coordinates in the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry; and the second geometry coordinate interpretation variable is updated according to the geometry type parameter and the geometry coordinate parameters. When the geometry type is a face type, the geometry dimension is assigned to the geometry dimension variable of the intermediate geometry, the geometry type parameter is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to an arbitrary value, and the geometry coordinates in the geometry coordinate parameter are assigned to the second geometry coordinate variable of the intermediate geometry; and the second geometry coordinate interpretation variable is updated according to the geometry type parameter and the geometry ring parameter. When the geometry type is a polyhedral surface type, the geometry dimension is assigned to the geometry variable of the intermediate geometry, the geometry type parameter is assigned to the geometry type variable of the intermediate geometry, the geometry coordinate system parameter is assigned to the geometry coordinate system variable of the intermediate geometry, the first geometry coordinate variable is set to the default value, and the geometry coordinates in the geometry coordinate parameters are assigned to the second geometry coordinate variable of the intermediate geometry; and the second geometry coordinate interpretation variable is updated according to the geometry type parameter, the geometry ring parameter, and the geometry composite parameter.
8. A device for converting PostGIS geometry data, characterized by, include: The data acquisition module is used to acquire PostGIS geometry and the geometry type of the PostGIS geometry; The PostGIS geometry is geometric data represented by the first geometric structure corresponding to the PostGIS spatial database; A forced conversion module is used to forcibly convert the PostGIS geometry into a derived geometry according to the geometry type; the derived geometry is a geometric structure derived from the first geometric structure according to the geometry type. The parsing and writing module is used to parse the derived geometry to obtain geometry parameters and write the geometry parameters into an intermediate geometry; there is a mapping relationship between the structure elements of the intermediate geometry and the second geometric structure corresponding to the Oracle spatial database. The data conversion module is used to convert the intermediate geometry into an Oracle geometry according to the mapping relationship; The Oracle geometry is geometric data represented using the second geometric structure; The intermediate geometry's structural elements include: intermediate geometry variables and parameter types corresponding to each intermediate geometry variable; the intermediate geometry variables include: geometry dimension variables, geometry type variables, geometry coordinate system variables, first geometry coordinate variables, second geometry coordinate variables, and second geometry coordinate interpretation variables; the first geometry coordinate variables are used to store the coordinates of single-point type geometry; the second geometry coordinate variables are used to store the coordinates of other geometry types besides the single-point type; the second geometry coordinate interpretation variables are used to explain the parameters of the second geometry coordinate variables.
9. An electronic device, comprising: The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the PostGIS geometric data conversion method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the PostGIS geometric data conversion method according to any one of claims 1-7.
Citation Information
Patent Citations
Geometric feature description data file generation method and geometric feature format conversion method
CN115100357A