CAD-based rendering method, apparatus and device, medium

CN123013216APending Publication Date: 2026-10-30SICHUAN QICHENG YUNZHI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611463240.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-20
Publication Date
2026-10-30

AI Technical Summary

Benefits of technology

[0017]本发明与现有技术相比,通过获取待转换文件,在待转换文件为第一CAD文件的情况下,利用预设的双引擎融合机制解析第一CAD文件,获得目标解析文件,然后基于目标解析文件将第一CAD文件转换为第一GeoJSON文件,再对第一GeoJSON文件进行渲染。这样,相较于现有技术中对CAD文件进行可视化渲染时,通过单一的解析引擎对CAD文件进行数据提取,基于提取出的数据进行转换和渲染,本方案采用双引擎融合机制解析所述第一CAD文件,使得解析出的目标解析文件能够兼顾不同引擎的优缺点,数据完整性和准确率更高,进而使得后续的转换和渲染可视化的效果更高,提高了CAD文件数据转换和可视化的效果。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123013216A_ABST
    Figure CN123013216A_ABST
Patent Text Reader

Abstract

The application is applied to the technical field of data conversion and visualization, and discloses a rendering method, device and equipment based on CAD, and a medium. The method comprises the following steps: obtaining a to-be-converted file; in the case that the to-be-converted file is a first CAD file, a preset double-engine fusion mechanism is used to analyze the first CAD file, and a target analysis file is obtained; the first CAD file is converted into a first GeoJSON file based on the target analysis file; and the first GeoJSON file is rendered. Thus, compared with the prior art of extracting data from a CAD file by using a single analysis engine and converting and rendering based on the extracted data, the present application uses a double-engine fusion mechanism to analyze the first CAD file, so that the target analysis file obtained by analysis can take into account the advantages and disadvantages of different engines, the data integrity and accuracy are higher, and the subsequent conversion and rendering visualization effect is higher, thereby improving the CAD file data conversion and visualization effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data conversion and visualization technology, specifically to a CAD-based rendering method, apparatus, device, and medium. Background Technology

[0002] Computer-aided design (CAD) files are the core vector data carriers in fields such as engineering surveying, architectural planning, municipal design, and land spatial planning. They are characterized by high precision, rich features, and clear layer hierarchy. To achieve web-based visualization, intelligent rendering, and large-model-assisted drafting of CAD engineering data, the industry generally needs to convert CAD files with closed formats and poor compatibility into the standardized GeoJSON (Geographic JavaScript Object Notation) file format, which can be recognized by front-end map engines and large models. There is also a need for bidirectional data conversion and rendering, where GeoJSON files are used to generate CAD files in reverse.

[0003] In existing technologies, CAD files need to be converted to GeoJSON files for visualization rendering. However, traditional CAD file conversion typically uses a single parsing engine to extract data from the CAD file, and then performs conversion and rendering based on the extracted data. However, a single engine has its advantages and disadvantages; different engines have different focuses in parsing, and users can only choose one for parsing and conversion, unable to handle both simultaneously. Furthermore, a single engine is prone to problems such as missing or incorrect feature parsing, distorted feature statistics, and incomplete layer data, resulting in low data integrity and accuracy. This fails to provide a reliable data foundation for subsequent format conversion and accurate rendering, thus affecting the data conversion and visualization effects.

[0004] Therefore, in order to overcome the above-mentioned technical problems, the present invention provides a CAD-based rendering method, apparatus, device, and medium. Summary of the Invention

[0005] The technical problem this invention aims to solve is how to improve the conversion and visualization effects of CAD file data. The objective is to provide a CAD-based rendering method, apparatus, device, and medium to enhance the conversion and visualization effects of CAD file data. This is achieved through a single parsing...

[0006] This invention is achieved through the following technical solution:

[0007] In a first aspect, a CAD-based rendering method is provided, the method comprising: acquiring a file to be converted; if the file to be converted is a first CAD file, parsing the first CAD file using a preset dual-engine fusion mechanism to obtain a target parsing file; converting the first CAD file into a first GeoJSON file based on the target parsing file; and rendering the first GeoJSON file.

[0008] In some embodiments, the step of parsing the first CAD file using a preset dual-engine fusion mechanism to obtain a target parsed file includes: parsing the first CAD file to be converted layer by layer using a first parsing engine and a second parsing engine respectively to obtain first parsing data and second parsing data corresponding to each layer; obtaining the number of first features corresponding to each layer based on the first parsing data corresponding to each layer; obtaining the number of second features corresponding to each layer based on the second parsing data corresponding to each layer; for each layer, determining the target parsing data based on the number of first features and the number of second features respectively in the first parsing data and the second parsing data; and aggregating the target parsing data corresponding to all layers to obtain the target parsed file.

[0009] In some embodiments, converting the first CAD file into a first GeoJSON file based on the target parsing file includes: obtaining a first CAD entity from the target parsing file; mapping the first CAD entity to a GeoJSON geometric object; and obtaining the first GeoJSON file based on the GeoJSON geometric object.

[0010] In some embodiments, mapping the first CAD entity to a GeoJSON geometric object includes: if the first CAD entity is an arc entity, obtaining the arc geometric parameters of the arc entity; obtaining the number of segments corresponding to the arc entity based on the geometric parameters and a preset chord height deviation; performing equidistant sampling on the arc entity based on the number of segments to obtain a number of sampling points; and connecting each of the sampling points sequentially using polyline segments to map the arc entity to a polyline segment geometric object.

[0011] In some embodiments, obtaining the first GeoJSON file based on the GeoJSON geometric object includes: obtaining the entity coordinates corresponding to each first CAD entity; determining the entity coordinates corresponding to each first CAD entity as the initial coordinates of the GeoJSON geometric object it maps to; traversing all GeoJSON geometric objects; using a preset conversion function to convert the initial coordinates of the traversed GeoJSON geometric objects to obtain the GeoJSON entity coordinates corresponding to the traversed GeoJSON geometric objects; and merging the GeoJSON geometric objects and the GeoJSON entity coordinates to obtain the first GeoJSON file.

[0012] In some embodiments, rendering the first GeoJSON file includes: compressing the first GeoJSON file and obtaining the compressed size; determining a rendering strategy based on the compressed size; and rendering the first GeoJSON file based on the rendering strategy.

[0013] In some embodiments, after obtaining the file to be converted, the method further includes: if the file to be converted is a second GeoJSON file, obtaining layer attribute data corresponding to each element in the second GeoJSON file; determining the layer where each element is located based on the layer attribute data; mapping each element by layer to obtain the second CAD entity corresponding to each layer; and generating a second CAD file based on the second CAD entity corresponding to each layer.

[0014] Secondly, a CAD-based rendering device, the device comprising: a file acquisition module configured to acquire a file to be converted; a parsing module configured to, when the file to be converted is a first CAD file, parse the first CAD file using a preset dual-engine fusion mechanism to obtain a target parsed file; a first conversion module configured to convert the first CAD file into a first GeoJSON file based on the target parsed file; and a rendering module configured to render the first GeoJSON file.

[0015] Thirdly, an electronic device includes a processor and a memory storing program instructions, the processor being configured to execute the aforementioned CAD-based rendering method when the program instructions are executed.

[0016] Fourthly, a storage medium storing program instructions, characterized in that the program instructions, when running, execute the aforementioned CAD-based rendering method.

[0017] Compared with existing technologies, this invention obtains a file to be converted. In the case of a first CAD file, it uses a pre-defined dual-engine fusion mechanism to parse the first CAD file, obtaining a target parsed file. Then, based on the target parsed file, the first CAD file is converted into a first GeoJSON file, which is then rendered. This approach, compared to existing technologies that extract data from CAD files using a single parsing engine and then perform conversion and rendering based on the extracted data, utilizes a dual-engine fusion mechanism to parse the first CAD file. This allows the parsed target parsed file to take into account the advantages and disadvantages of different engines, resulting in higher data integrity and accuracy. Consequently, the subsequent conversion, rendering, and visualization effects are improved, enhancing the overall quality of CAD file data conversion and visualization. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:

[0019] Figure 1 This is a flowchart illustrating a CAD-based rendering method provided in an embodiment of this disclosure;

[0020] Figure 2 This is a schematic diagram of an application web interface provided in an embodiment of this disclosure;

[0021] Figure 3 This is a schematic diagram of a CAD-based rendering device provided in an embodiment of this disclosure;

[0022] Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.

[0024] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0025] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0026] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0027] In this application, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0028] Please see Figure 1 , Figure 1 This is a schematic flowchart illustrating a CAD-based rendering method according to an exemplary embodiment of this application. The method includes:

[0029] Step S101: Obtain the file to be converted.

[0030] Step S102: If the file to be converted is a first CAD file, the first CAD file is parsed using a preset dual-engine fusion mechanism to obtain the target parsed file.

[0031] Step S103: Convert the first CAD file into a first GeoJSON file based on the target parsing file.

[0032] Step S104: Render the first GeoJSON file.

[0033] In this embodiment, by acquiring the file to be converted, and in the case of a first CAD file, a preset dual-engine fusion mechanism is used to parse the first CAD file to obtain a target parsed file. Then, based on the target parsed file, the first CAD file is converted into a first GeoJSON file, and then the first GeoJSON file is rendered. Compared to existing technologies that use a single parsing engine to extract data from CAD files and then convert and render based on the extracted data, this solution uses a dual-engine fusion mechanism to parse the first CAD file. This allows the parsed target parsed file to take into account the advantages and disadvantages of different engines, resulting in higher data integrity and accuracy. Consequently, the subsequent conversion, rendering, and visualization effects are improved, enhancing the overall effectiveness of CAD file data conversion and visualization.

[0034] It should be noted that the first CAD file can be a drawing format (DWG, Drawing) file or a drawing exchange format (DXF, Drawing Exchange Format) file.

[0035] Furthermore, before using the preset dual-engine fusion mechanism to parse the first CAD file and obtain the target parsed file, the process also includes: if the file to be converted is a DWG format file, calling the preset conversion component to convert the DWG format file into a DXF format file.

[0036] It should be noted that the default conversion component is ODA File Converter, which is a component that losslessly converts DWG format files to DXF format files.

[0037] Furthermore, the first CAD file is parsed using a pre-defined dual-engine fusion mechanism to obtain the target parsed file. This includes: parsing the first CAD file to be converted layer by layer using the first parsing engine and the second parsing engine respectively, to obtain the first parsing data and the second parsing data corresponding to each layer; obtaining the number of first features corresponding to each layer based on the first parsing data corresponding to each layer; obtaining the number of second features corresponding to each layer based on the second parsing data corresponding to each layer; for each layer, determining the target parsing data based on the number of first features and the number of second features respectively in the first parsing data and the second parsing data; and aggregating the target parsing data corresponding to all layers to obtain the target parsing file.

[0038] In this way, the first and second parsing engines are used to parse the first CAD file to be converted layer by layer, obtaining the first and second parsing data corresponding to each layer. This does not rely on a single engine, avoiding the single-point failure of a single engine that directly leads to the overall parsing failure. The system no longer completely depends on the compatibility of a single parsing engine, and the overall parsing robustness is significantly improved. Then, for each layer, the target parsing data is determined from the first and second parsing data respectively, based on the number of first elements obtained from the first parsing data and the number of second elements obtained from the second parsing data. The target parsing data corresponding to all layers are collected to obtain the target parsing file. The number of elements in the layer dimension is used as a quantitative screening index. There is no need for manual intervention to compare graphics or complex primitive geometric comparison algorithms. The number of elements output by the two sets of parsing outputs under the same layer is directly compared to determine the target parsing data for that layer. This makes the target parsing data integrate the parsing results of the two engines, resulting in higher data integrity and accuracy.

[0039] It should be noted that the primary parsing engine is the ezdxf library. This is an open-source Python library that can be used to extract detailed structural information from CAD files, such as layers, linetypes, block definitions, and attributes.

[0040] The second parsing engine is either GDAL (Geospatial Data Abstraction Library) or the fiona library.

[0041] The GDAL library is an open-source geospatial data processing library. The fiona library is a Python library built upon the GDAL library.

[0042] It should be noted that the first parsed data is the parsed data obtained by the first parsing engine after parsing the first CAD file to be converted. The first parsed data includes the feature data of the first features obtained by the first parsing engine. The number of first features corresponding to each layer is the number of first features corresponding to each layer in the first parsed data.

[0043] The second parsed data is obtained by parsing the first CAD file to be converted using the second parsing engine. The second parsed data includes the feature data of the second features obtained by the second parsing engine. The number of second features corresponding to each layer is the number of second features corresponding to each layer in the second parsed data.

[0044] Furthermore, for each layer, target parsing data is determined from the first parsing data and the second parsing data based on the number of first elements and the number of second elements, respectively. This includes: for each layer, if the number of first elements corresponding to the layer is greater than or equal to the number of second elements corresponding to the layer, the first parsing data corresponding to the layer is determined as the target parsing data; if the number of first elements corresponding to the layer is less than the number of second elements corresponding to the layer, the second parsing data corresponding to the layer is determined as the target parsing data.

[0045] In this way, since ezdxf excels at block reference expansion and composite entity decomposition, while GDAL / fiona has native support for special entities such as labels (DIMENSION), the number of features indirectly reflects which engine has a more complete parsing of the layer. The parsing data corresponding to that engine is determined as the target parsing data, so that the target parsing file obtained later can more completely and accurately reflect the data in the first CAD file.

[0046] Furthermore, the first CAD file is converted into a first GeoJSON file based on the target parsing file, including: obtaining the first CAD entity in the target parsing file; mapping the first CAD entity to a GeoJSON geometric object; and obtaining the first GeoJSON file based on the GeoJSON geometric object.

[0047] In this way, by obtaining the first CAD entity from the target parsing file, mapping the first CAD entity to a GeoJSON geometric object, and then obtaining the first GeoJSON file based on the GeoJSON geometric object, the accurate conversion between CAD entities and GeoJSON geometric objects is achieved.

[0048] It should be noted that a first CAD entity can be a single feature or a combination of multiple features.

[0049] The first CAD entity can be a LINE entity, which is a straight line entity. It can be mapped to a geometric object of type LineString.

[0050] The first CAD entity can be a CIRCLE entity, which is a circular entity. It can be mapped to a Point geometry object. This Point geometry object represents the center of the CIRCLE entity. It should be noted that this Point geometry object also has a corresponding radius parameter, which is the radius of the CIRCLE entity.

[0051] The first CAD entity can be a HATCH entity, which is a face-filled entity. It can be mapped to a Polygon (face) geometry object. A Polygon is used to represent a closed face. A Polygon is composed of polyline segments and does not support arcs; all arcs must be pre-discreteed into polylines.

[0052] The first CAD entity can be an arc-shaped entity.

[0053] It should be noted that GeoJSON geometry objects also have corresponding attribute parameters, which include one or more of the following: the layer in which the GeoJSON geometry object is located, its color, geometry type, and the entity type corresponding to the GeoJSON geometry object.

[0054] The layers and colors remain unchanged during the conversion.

[0055] Furthermore, mapping the first CAD entity to a GeoJSON geometric object includes: if the first CAD entity is an arc entity, obtaining the arc geometric parameters of the arc entity; obtaining the number of segments corresponding to the arc entity based on the geometric parameters and a preset chord height deviation; performing equidistant sampling on the arc entity based on the number of segments to obtain several sampling points; and connecting each sampling point sequentially using polyline segments to map the arc entity to a polyline segment geometric object. In this way, by using a preset chord height deviation as a constraint, determining the number of segments based on the geometric parameters of the arc entity, then performing equidistant sampling on the arc entity based on the number of segments to obtain several sampling points, and then connecting each sampling point sequentially using polyline segments to map the arc entity to a polyline segment geometric object, the standardized conversion of the arc entity through discrete sampling polyline fitting is achieved.

[0056] It should be noted that the curved body is a circular arc.

[0057] The arc geometry parameter of an arc entity is the radius of the arc entity.

[0058] In some embodiments, if the arc entity itself has its own stored radius, it can be obtained directly. Otherwise, the central angle, the starting coordinates, and the ending coordinates of the arc entity can be obtained first; then calculations can be performed. Obtain the convexity value of the arc entity; where, This refers to the convexity value. The central angle is used; the straight-line distance between the starting and ending coordinates is calculated to obtain the chord length of the arc entity; by calculation... , to obtain the radius of the arc entity; where, The radius is ; Let be the chord length.

[0059] It should be noted that, When the value is 0, it indicates that the distance between the starting and ending points is a line segment. If If it is not 0, it indicates that the area between the start and end points is an arc, which is an arc entity.

[0060] Furthermore, the number of segments corresponding to the arc entity is obtained based on geometric parameters and a preset chord height deviation, including: by calculating... , thus obtaining the number of segments. Among them, The number of segments; This represents the chord height deviation.

[0061] It should be noted that the chord height deviation is used to constrain the maximum vertical distance from the midpoint of the polyline segment to the original curve when approximating a curve with a polyline.

[0062] It should be noted that by sampling the arc entity at equal intervals based on the number of segments, a number of sampling points are obtained, meaning that each sampling point divides the arc entity into n equal segments. The number of segments is set. This allows for automatic densification of large arcs and automatic sparsening of small arcs during segmentation, ensuring consistent approximation accuracy for curves of different sizes. This reduces the problems of data redundancy in small curves and insufficient accuracy in large curves caused by a fixed number of segments.

[0063] It should be noted that the sampling points are connected sequentially using line segments, that is, adjacent sampling points are connected.

[0064] After connection, the arc entity is transformed into multiple connected polyline segments, which are used to approximate the arc, thus achieving the discretization of the arc.

[0065] Optionally, obtaining the first GeoJSON file based on the GeoJSON geometry object includes: directly generating the first GeoJSON file based on the GeoJSON geometry object.

[0066] Optionally, obtaining the first GeoJSON file based on GeoJSON geometric objects includes: obtaining the entity coordinates corresponding to each first CAD entity; determining the initial coordinates of the GeoJSON geometric objects mapped to each first CAD entity; traversing all GeoJSON geometric objects; transforming the initial coordinates of the traversed GeoJSON geometric objects using a preset transformation function to obtain the GeoJSON entity coordinates corresponding to the traversed GeoJSON geometric objects; and merging the GeoJSON geometric objects and GeoJSON entity coordinates to obtain the first GeoJSON file.

[0067] This process involves obtaining the entity coordinates corresponding to each first CAD entity and using them as the initial coordinates for the mapped GeoJSON geometric objects. It then iterates through all GeoJSON geometric objects, transforming the initial coordinates using a preset transformation function to obtain the GeoJSON entity coordinates. Finally, the GeoJSON geometric objects and their coordinates are merged to obtain the first GeoJSON file. This achieves unified coordinate transformation of GeoJSON geometric objects, enabling batch conversion from the CAD local drawing coordinate system to the GIS target coordinate system. It reduces the problem of geolocation failure caused by directly outputting the original CAD coordinates and improves the applicability of file conversion.

[0068] The initial coordinates of the traversed GeoJSON geometric objects are transformed using a preset transformation function to obtain the GeoJSON entity coordinates corresponding to the traversed GeoJSON geometric objects.

[0069] It should be noted that the default conversion function is the Transformer.from_crs() function from the pyproj library.

[0070] In some embodiments, calling `Transformer.from_crs(source_crs,"EPSG:4326",always_xy=True)` can transform the initial coordinates of the traversed GeoJSON geometric objects to obtain the GeoJSON entity coordinates corresponding to the traversed GeoJSON geometric objects. Here, `source_crs` represents the initial coordinate system, i.e., the coordinate system in which the initial coordinates are located, for example: Gauss-Kruger projection coordinate system EPSG:4526; "EPSG:4326" is the target coordinate system, which is the coordinate system of the GeoJSON entity coordinates, representing the WGS84 geographic coordinate system; `always_xy=True` forces the input and output to follow the order of (x, y) or (longitude, latitude), avoiding coordinate misalignment caused by differences in axis order between different coordinate systems.

[0071] In some embodiments, when the initial coordinate system is the Gauss-Kruger projection coordinate system, the Transformer.from_crs() function can automatically perform the inverse projection solution, restore the projected coordinates to CGCS2000 geodetic latitude and longitude through the transverse Mercator inverse transformation, and then perform the datum transformation to convert the CGCS2000 geodetic latitude and longitude to WGS84 latitude and longitude, thus realizing the coordinate system conversion without the need for manual calculation of formulas.

[0072] It should be noted that merging GeoJSON geometric objects and GeoJSON entity coordinates to obtain the first GeoJSON file involves assembling the GeoJSON geometric object with its corresponding GeoJSON entity coordinates to obtain GeoJSON features. These GeoJSON features are then merged to obtain a feature array. This feature array is then written to a GeoJSON file, resulting in the first GeoJSON file.

[0073] It should be noted that the feature array is called FeatureCollection, which is an array container for features; it is a collection of features.

[0074] Furthermore, the first GeoJSON file is rendered, including: compressing the first GeoJSON file and obtaining the compressed size; determining a rendering strategy based on the compressed size; and rendering the first GeoJSON file based on the rendering strategy.

[0075] By using the compressed file size as a criterion to determine the rendering strategy, and then rendering the first GeoJSON file based on the rendering strategy, the rendering strategy can be adaptively determined according to the size of the first GeoJSON file, thus improving the rendering effect.

[0076] Furthermore, the first GeoJSON file is compressed, and the compressed volume is obtained, including: performing coordinate normalization and geometric object simplification on the first GeoJSON file; obtaining the volume of the processed first GeoJSON file; and determining this volume as the compressed volume.

[0077] Furthermore, the rendering strategy is determined based on the compressed volume, including: when the compressed volume is less than 20KB, the preset small volume strategy is confirmed as the rendering strategy; when the compressed volume is greater than or equal to 20KB and less than 100KB, the preset medium volume strategy is confirmed as the rendering strategy; when the compressed volume is greater than or equal to 100KB and less than 500KB, the preset large volume strategy is confirmed as the rendering strategy; and when the compressed volume is greater than or equal to 500KB, the preset ultra-large volume strategy is confirmed as the rendering strategy.

[0078] It should be noted that the small volume strategy is as follows: serialize the feature array in the processed first GeoJSON file; generate prompt words based on the serialized feature array, so as to generate SVG (Scalable Vector Graphics) based on the prompt words using the preset LLM (Large Language Model).

[0079] The volumetric strategy is as follows: The processed first GeoJSON file is simplified to obtain a simplified GeoJSON file. Specifically, for Polygon geometric objects, only the outer ring is retained; when the number of coordinates corresponding to any geometric object exceeds 50 points, uniform downsampling is performed on that geometric object; preset non-critical attribute fields are deleted. The feature array in the simplified GeoJSON file is serialized; a prompt word is generated based on the serialized feature array to facilitate the generation of SVG graphics using a preset LLM model based on the prompt word.

[0080] The large-volume strategy is as follows: The processed first GeoJSON file is split into multiple sub-blocks no larger than 50KB, based on layers. The feature arrays in each sub-block are serialized; based on the serialized feature arrays, prompt words are generated. In rounds, multiple SVG sub-graphics are generated using a preset LLM model based on the prompt words corresponding to each sub-block. The generated SVG sub-graphics are merged to obtain the complete SVG graphic.

[0081] The strategy for handling large file sizes is as follows: The processed first GeoJSON file is split into multiple sub-blocks, each no larger than 50KB, based on layers. The feature arrays within each sub-block are serialized. Based on the serialized feature arrays, prompts are generated. Each layer is considered a round, and multiple SVG sub-graphics are generated using a preset LLM model based on the prompts corresponding to each sub-block in each round. The generated SVG sub-graphics are then merged to obtain the complete SVG graphic.

[0082] It should be noted that the prompts are generated according to a template. Specifically, the template includes: the role of the LLM model, which can be a geographic data visualization expert, a task objective for generating SVG graphics, input data (i.e., the serialized feature array), rendering strategy, and coordinate range description.

[0083] It's important to note that the coordinate range specified refers to the entire coordinate range of the first GeoJSON file. This tells the model the latitude and longitude boundaries of the entire image, ensuring that the pixel mapping rules of each batch of generated SVG graphics are completely consistent, preventing misalignment of the merged graphics.

[0084] Furthermore, after obtaining the file to be converted, the process also includes: if the file to be converted is a second GeoJSON file, obtaining the layer attribute data corresponding to each feature in the second GeoJSON file; determining the layer where each feature is located based on the layer attribute data; mapping each feature to each layer to obtain the second CAD entity corresponding to each layer; and generating a second CAD file based on the second CAD entity corresponding to each layer.

[0085] In this way, after obtaining the file to be converted, if the file is a second GeoJSON file, the layer attribute data corresponding to each feature in the second GeoJSON file is obtained. Based on the layer attribute data, the layer in which each feature is located is determined. Each feature is mapped layer by layer to obtain the corresponding second CAD entity. Then, a second CAD file is generated based on the second CAD entities corresponding to each layer. This method can restore the layer organization structure using the layer attributes carried by GeoJSON features, avoiding the output of all features mixed into a single layer. The generated second CAD file retains the layer division, performs feature mapping on a layer-by-layer basis, and the processing of each layer is independent. This realizes the reverse generation of GeoJSON vector data into CAD files. Combined with the aforementioned CAD to GeoJSON forward conversion link, it realizes the bidirectional conversion capability between CAD and GeoJSON.

[0086] It should be noted that layer attribute data refers to the properties.layer attribute values ​​of features, which have a one-to-one mapping relationship with DXF layers. That is, features with the same properties.layer attribute value are on the same layer, and features with different properties.layer attribute values ​​are on different layers.

[0087] If a feature does not have layer attribute data, the default layer will be used to determine the layer in which the feature is located.

[0088] It should be noted that in the second GeoJSON file, one feature corresponds to one geometry object.

[0089] It should be noted that during mapping, if the geometric object corresponding to the mapped feature is a Point geometric object, and the entity_type in the properties of that Point geometric object is TEXT / MTEXT and contains text content, then the second CAD entity mapped to it will be a TEXT entity. This TEXT entity can reproduce the text content.

[0090] If the geometric object corresponding to the mapped element is a Point geometric object, and the entity_type in the properties corresponding to the Point geometric object is not TEXT / MTEXT, then the second CAD entity mapped to it is a POINT entity.

[0091] If the geometric object corresponding to the mapped element is a LineString geometric object, then the second CAD entity it maps to is an LWPOLYLINE entity, which is an open polyline.

[0092] If the geometric object corresponding to the mapped element is a Polygon geometric object, then the second CAD entity mapped to it is a set of closed LWPOLYLINE entities, which are lightweight polylines.

[0093] If the geometric object corresponding to the mapped element is a MultiPolygon geometric object, then the second CAD entity mapped to it is a set of closed LWPOLYLINE entities.

[0094] It should be noted that generating the second CAD file based on the second CAD entities corresponding to each layer includes: traversing each second CAD entity; in the initial CAD file, if the layer containing the traversed second CAD entity has already been created, the second CAD entity is directly written to that layer. If the layer containing the traversed second CAD entity has not been created, the layer is created in the initial CAD file, and the second CAD entity is written to that layer; after the traversal is complete, the initial CAD file containing all the second CAD entities is determined as the second CAD file.

[0095] It should be noted that the second CAD file can also include coordinate data corresponding to the second CAD entity. Specifically, coordinate transformation can also be performed by calling the Transformer.from_crs() function. This will not be elaborated further here.

[0096] It should be noted that, when the file to be converted is a second GeoJSON file, the second GeoJSON file can also be identified as the first GeoJSON file, and then the subsequent rendering steps of the first GeoJSON file can be performed, thus achieving adaptive rendering of the second GeoJSON file.

[0097] In some embodiments, this solution can provide a web interface through the Flask framework to receive user-uploaded files to be converted, execute the methods described above, display layer statistics and conversion results, and allow users to download GeoJSON, export DXF / DWG, or generate SVG.

[0098] For details, please refer to Figure 2 . Figure 2 This is a schematic diagram of the web interface used in this solution.

[0099] like Figure 2 As shown, the web interface includes a file upload area, a source coordinate system input box, a function selection configuration item, an advanced options collapsible bar, and a "Select file and start conversion" button.

[0100] The file upload area is marked with a dashed box. You can upload files to be converted by dragging and dropping, or you can click the "Click to Select" button to select the files to be converted in a pop-up window.

[0101] The source coordinate system input box can be used to fill in the code of the initial coordinate system, for example: EPSG:4526; if left blank, the coordinate system transformation will not be performed, and the original coordinates of the drawing will be retained.

[0102] The feature selection options include the expand block reference option and the split file by diagram option.

[0103] The "Expand Block Reference" option is checked by default, which automatically disassembles the internal block references of the drawing and fully reads all layers and elements of the drawing.

[0104] The option to split files by drawing is optional. When enabled, multiple layout drawings within a drawing will be split into independent CAD files.

[0105] The Advanced Options collapsible bar can be expanded to show more underlying parameters for drawing conversion, such as drawing precision, font compatibility, and version compatibility.

[0106] Once the above settings are complete, you can click the "Select File and Start Conversion" button to perform the above method for file conversion and / or rendering.

[0107] This solution can achieve the following effects:

[0108] 1. Due to the adoption of a dual-engine parallel parsing and intelligent merging mechanism, the problem of difficulty in balancing accuracy and compatibility with a single parser is solved. It can automatically take the optimal result of each parser for each layer, which greatly improves the success rate and geometric fidelity of CAD file parsing.

[0109] 2. A complete reverse mapping rule for GeoJSON to CAD entities was established, and automatic layering by layer attribute was supported, achieving high-fidelity data backflow. This allows engineering drawings converted from GeoJSON to be directly edited in the CAD environment, breaking the bottleneck of unidirectional data flow from GIS to CAD.

[0110] 3. It realizes the inverse conversion between the engineering coordinate system and WGS84 latitude and longitude, ensuring the strict consistency of coordinates of geographic data after traveling back and forth between the CAD system and the GIS system, and meeting the high requirements of engineering design for absolute coordinate accuracy.

[0111] 4. An adaptive rendering strategy based on data volume tiers was implemented. Leveraging the powerful code generation capabilities of the LLM model, compared to traditional methods based on preset style libraries, this solution can dynamically balance rendering effects and performance according to data volume, and generate SVG maps with creative and aesthetic effects that far exceed template limitations in small data volume scenarios.

[0112] 5. The system employs an LLM generation and post-processing verification degradation mechanism, making it robust and capable of automatically recovering from LLM generation failures or abnormal results, ensuring that the final output is a valid graphic.

[0113] Combination Figure 3 As shown, this embodiment of the present disclosure provides a CAD-based rendering device 300, which includes: a file acquisition module 301, a parsing module 302, a first conversion module 303, and a rendering module 304.

[0114] The file acquisition module 301 is configured to acquire the file to be converted.

[0115] The parsing module 302 is configured to parse the first CAD file using a preset dual-engine fusion mechanism to obtain the target parsing file when the file to be converted is the first CAD file.

[0116] The first conversion module 303 is configured to convert the first CAD file into a first GeoJSON file based on the target parsing file.

[0117] Rendering module 304, configured to render the first GeoJSON file.

[0118] The CAD-based rendering apparatus provided in this embodiment acquires a file to be converted. If the file is a first CAD file, a preset dual-engine fusion mechanism is used to parse the first CAD file to obtain a target parsed file. Then, based on the target parsed file, the first CAD file is converted into a first GeoJSON file, which is then rendered. Compared to existing technologies that use a single parsing engine to extract data from CAD files and perform conversion and rendering based on the extracted data, this solution uses a dual-engine fusion mechanism to parse the first CAD file. This allows the parsed target parsed file to take into account the advantages and disadvantages of different engines, resulting in higher data integrity and accuracy. Consequently, the subsequent conversion, rendering, and visualization effects are improved, enhancing the overall effectiveness of CAD file data conversion and visualization.

[0119] Furthermore, the parsing module is configured to parse the first CAD file using a preset dual-engine fusion mechanism to obtain the target parsing file in the following manner: The first parsing engine and the second parsing engine are used to parse the first CAD file to be converted layer by layer to obtain the first parsing data and the second parsing data corresponding to each layer; the number of first features corresponding to each layer is obtained based on the first parsing data; the number of second features corresponding to each layer is obtained based on the second parsing data; for each layer, the target parsing data is determined from the first parsing data and the second parsing data respectively based on the number of first features and the number of second features; and the target parsing data corresponding to all layers are aggregated to obtain the target parsing file.

[0120] Furthermore, the first conversion module is configured to convert the first CAD file into a first GeoJSON file based on the target parsing file in the following manner: obtaining the first CAD entity in the target parsing file; mapping the first CAD entity to a GeoJSON geometric object; and obtaining the first GeoJSON file based on the GeoJSON geometric object.

[0121] Furthermore, the first conversion module is configured to map the first CAD entity to a GeoJSON geometric object in the following manner: when the first CAD entity is an arc entity, obtain the arc geometric parameters of the arc entity; obtain the number of segments corresponding to the arc entity based on the geometric parameters and the preset chord height deviation; perform equidistant sampling on the arc entity based on the number of segments to obtain several sampling points; and connect each sampling point sequentially using polyline segments to map the arc entity to a polyline segment geometric object.

[0122] Furthermore, the first conversion module is configured to obtain the first GeoJSON file based on the GeoJSON geometric object in the following manner: obtain the entity coordinates corresponding to each first CAD entity; determine the initial coordinates of the GeoJSON geometric object mapped to each first CAD entity; traverse all GeoJSON geometric objects; use a preset conversion function to convert the initial coordinates of the traversed GeoJSON geometric objects to obtain the GeoJSON entity coordinates corresponding to the traversed GeoJSON geometric objects; merge the GeoJSON geometric objects and the GeoJSON entity coordinates to obtain the first GeoJSON file.

[0123] Furthermore, the rendering module is configured to render the first GeoJSON file in the following manner: compressing the first GeoJSON file and obtaining the compressed size; determining a rendering strategy based on the compressed size; and rendering the first GeoJSON file based on the rendering strategy.

[0124] Furthermore, the CAD-based rendering device also includes a second conversion module. The second conversion module is configured to, after acquiring the file to be converted (if the file is a second GeoJSON file), obtain the layer attribute data corresponding to each feature within the second GeoJSON file; determine the layer where each feature is located based on the layer attribute data; map each feature layer by layer to obtain the second CAD entity corresponding to each layer; and generate a second CAD file based on the second CAD entities corresponding to each layer.

[0125] Combination Figure 4 As shown, this embodiment of the present disclosure provides an electronic device 400, including a processor 401 and a memory 402. Optionally, the device may further include a communication interface 403 and a bus 404. The processor 401, communication interface 403, and memory 402 can communicate with each other via the bus 404. The communication interface 403 can be used for information transmission. The processor 401 can call logical instructions in the memory 402 to execute the above-mentioned... Figure 1 The rendering method shown is based on CAD.

[0126] Furthermore, the logical instructions in the aforementioned memory 402 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.

[0127] The memory 402, as a storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in this embodiment. The processor 401 executes functional applications and data processing by running the program instructions / modules stored in the memory 402, thus achieving the above-described functionality. Figure 1 The rendering method shown is based on CAD.

[0128] The memory 402 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 402 may include high-speed random access memory and may also include non-volatile memory.

[0129] This disclosure provides a storage medium storing computer-executable instructions configured to execute the CAD-based rendering method described above.

[0130] The aforementioned storage media can be either transient computer-readable storage media or non-transitory computer-readable storage media. Non-transitory storage media include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, and can also be transient storage media.

[0131] The foregoing description and accompanying drawings fully illustrate embodiments of this disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, procedural, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the order of operation may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. Moreover, the terminology used in this application is for describing embodiments only and is not intended to limit the claims. As used in the description of embodiments and claims, the singular forms “a,” “an,” and “the” are intended to equally include the plural forms unless the context clearly indicates otherwise. Similarly, the term “and / or” as used in this application means including one or more of the associated listed items and all possible combinations thereof. Additionally, when used in this application, the term "comprise" and its variations "comprises" and / or "comprising" refer to the presence of stated features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof. Without further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, or apparatus that includes said element. In this document, each embodiment may focus on the differences from other embodiments, and similar or identical parts between embodiments can be referred to mutually. For methods, products, etc., disclosed in the embodiments, if they correspond to the method section disclosed in the embodiments, the relevant parts can be referred to the description of the method section.

[0132] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this disclosure. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0133] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different blocks may also occur in a different order than those disclosed in the description; sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

Claims

1. A CAD-based rendering method, characterized in that, include: Get the file to be converted; When the file to be converted is a first CAD file, the first CAD file is parsed using a preset dual-engine fusion mechanism to obtain the target parsed file; Based on the target parsing file, the first CAD file is converted into a first GeoJSON file; Render the first GeoJSON file.

2. The method according to claim 1, characterized in that, The step of parsing the first CAD file using a preset dual-engine fusion mechanism to obtain the target parsed file includes: The first and second parsing engines are used to parse the first CAD file to be converted by layer to obtain the first and second parsing data corresponding to each layer. The number of first features corresponding to each layer is obtained based on the first parsed data of each layer; the number of second features corresponding to each layer is obtained based on the second parsed data of each layer. For each layer, the target parsing data is determined from the first parsing data and the second parsing data based on the number of the first feature and the number of the second feature, respectively. Collect the target parsing data corresponding to all layers to obtain the target parsing file.

3. The method according to claim 1, characterized in that, The step of converting the first CAD file into a first GeoJSON file based on the target parsing file includes: Obtain the first CAD entity from the target parsing file; Map the first CAD entity to a GeoJSON geometry object; The first GeoJSON file is obtained based on the GeoJSON geometry object.

4. The method according to claim 3, characterized in that, The process of mapping the first CAD entity to a GeoJSON geometric object includes: When the first CAD entity is an arc entity, obtain the arc geometry parameters of the arc entity; The number of segments corresponding to the arc entity is obtained based on the geometric parameters and the preset chord height deviation; Based on the number of segments, the arc entity is sampled at equal intervals to obtain a number of sampling points; By sequentially connecting the sampling points using polyline segments, the arc entity is mapped to a polyline segment geometric object.

5. The method according to claim 3, characterized in that, The step of obtaining the first GeoJSON file based on the GeoJSON geometry object includes: Obtain the entity coordinates corresponding to each first CAD entity; The coordinates of each first CAD entity are determined as the initial coordinates of the GeoJSON geometric object it is mapped to; Iterate through all GeoJSON geometry objects; The initial coordinates of the traversed GeoJSON geometric objects are transformed using a preset transformation function to obtain the GeoJSON entity coordinates corresponding to the traversed GeoJSON geometric objects. Merge the GeoJSON geometry object and the GeoJSON entity coordinates to obtain the first GeoJSON file.

6. The method according to claim 1, characterized in that, The rendering of the first GeoJSON file includes: Compress the first GeoJSON file and obtain the compressed size; The rendering strategy is determined based on the compressed volume. The first GeoJSON file is rendered based on the rendering strategy.

7. The method according to any one of claims 1 to 6, characterized in that, After obtaining the file to be converted, the process also includes: If the file to be converted is a second GeoJSON file, obtain the layer attribute data corresponding to each feature from the second GeoJSON file; The layer in which each element is located is determined based on the layer attribute data. By mapping each element to a separate layer, the second CAD entity corresponding to each layer can be obtained. A second CAD file is generated based on the second CAD entities corresponding to each layer.

8. A CAD-based rendering device, characterized in that, include: The file acquisition module is configured to acquire files to be converted. The parsing module is configured to, when the file to be converted is a first CAD file, use a preset dual-engine fusion mechanism to parse the first CAD file to obtain the target parsed file; The first conversion module is configured to convert the first CAD file into a first GeoJSON file based on the target parsing file; The rendering module is configured to render the first GeoJSON file.

9. An electronic device comprising a processor and a memory storing program instructions, characterized in that, The processor is configured to execute the CAD-based rendering method as described in any one of claims 1 to 7 when running the program instructions.

10. A storage medium storing program instructions, characterized in that, When the program instructions are executed, they perform the CAD-based rendering method as described in any one of claims 1 to 7.