Method for quickly building three-dimensional model of storage yard based on latitude and longitude coordinates
Through the method based on latitude and longitude coordinates, the Gaode Map and ThreeJs library quickly construct a three-dimensional yard model, which solves the problem of time-consuming and labor-intensive and lacks geographical accuracy of traditional modeling methods, and achieves efficient and accurate yard modeling.
Patent Information
- Application Number
- CN202411680196.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional three-dimensional yard modeling methods are time-consuming and labor-intensive, difficult to update in time, and lack geographical accuracy, which cannot meet the needs of modern logistics industry for efficient management and navigation.
Using a method based on latitude and longitude coordinates, the yard geographical coordinates are obtained through Gaode maps, and the latitude and longitude data are converted into three-dimensional spatial coordinates using trigonometric functions. The threeJs library is used to quickly build a yard three-dimensional model.
It realizes the rapid and efficient construction of a three-dimensional yard model, which significantly improves modeling efficiency and geographical accuracy, can meet the needs of rapid iteration of the yard, and saves manpower and time costs.
Smart Images

Figure CN119600218A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of three-dimensional modeling of large storage yards, and in particular to a method for quickly building a three-dimensional model of a storage yard based on ThreeJs and longitude and latitude coordinates. Background Art
[0002] With the development of modern logistics industry, yard management has played an increasingly important role in warehousing and logistics management. Yards are mainly used to store goods, containers and other items, and the effectiveness of their management directly affects the efficiency and cost control of logistics. The general yard management method mainly relies on manual records and two-dimensional plane drawings to divide the container area and carry out the operation of picking up and dropping boxes. It is not only inefficient, but also prone to data errors and information lags. On this basis, three-dimensional yards came into being.
[0003] In the traditional 3D modeling process, modelers need to obtain the specific size and layout of the yard through on-site measurement, and then divide the container areas based on this. Then, they use drones to collect point cloud data, and then combine professional 3D modeling software (such as AutoCAD, 3dsMax, etc.) or other client drag-and-drop systems to perform manual modeling. This method has the following significant disadvantages:
[0004] Time-consuming and labor-intensive: The manual measurement and modeling process is complex and time-consuming, requires specialized equipment and skills, and the measurement results may vary between different people.
[0005] Difficulty in updating data: The layout of the yard changes frequently, and traditional modeling methods make it difficult to update the 3D model in a timely manner, resulting in inaccurate data, which in turn affects decision-making.
[0006] Lack of geographic accuracy: The three-dimensional model of the yard created by manual dragging on the client is difficult to meet the needs of precise management and navigation, and often a new system needs to be developed to meet the navigation needs within the yard.
[0007] Therefore, a low-cost technical solution for quickly building a three-dimensional model of a storage yard while meeting the requirements of accurate geographic data and timely updating of the three-dimensional model is urgently needed. Summary of the invention
[0008] In view of the above technical problems in the related art, the present invention provides a method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates, which can solve the above problems.
[0009] To achieve the above technical objectives, the technical solution of the present invention is implemented as follows:
[0010] The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates includes the following steps:
[0011] S1. Obtain the longitude and latitude geographic coordinates of the storage yard based on Amap.
[0012] S2. converting the obtained longitude and latitude data into spatial coordinate data suitable for three-dimensional modeling through trigonometric functions;
[0013] S3. After obtaining the three-dimensional coordinates, initialize ThreeJs;
[0014] S4. Modeling the ground surface of the storage yard;
[0015] S5, modeling the box area;
[0016] S6. Perform model optimization.
[0017] Furthermore, in step S1, the vector map drawing capability of Amap is used to locate the map to the storage yard that needs to be modeled, and the editing mode is turned on. The geographic boundary data of the storage yard is obtained by directly marking points on the map interface, and points are marked inside the storage yard to obtain the distribution data of each container area inside.
[0018] Furthermore, the location and size of the boxes are determined by setting the number of containers to be stacked in horizontal and vertical rows in each box area.
[0019] Furthermore, in step S2, the obtained longitude and latitude lng and lat are mapped to the angles θ and φ of spherical coordinates with a radius of r, and the spatial coordinates x = r*sin(θ)*cos(φ), y = r*cos(θ), z = r*sin(θ)*sin(φ) are obtained through trigonometric function transformation, where θ = (90°-lat)×(π / 180°), φ = (180°+lng)×(π / 180°).
[0020] Furthermore, the coordinate function is converted into JavaScript code and encapsulated into a general method for calling.
[0021] Furthermore, the initialization of ThreeJs in step S3 includes the following steps:
[0022] S3.1. Create a ThreeJs renderer object, including setting the size and background color of the renderer;
[0023] S3.2. Create a ThreeJs scene object and add all 3D objects, light sources, and cameras to the scene;
[0024] S3.3, set the camera position and viewing angle to ensure that the entire yard model can be clearly viewed;
[0025] S3.4. Add light sources, including ambient light, parallel light, or point light, to enhance the visual effect of the 3D model.
[0026] Furthermore, in step S4, the yard ground modeling is performed based on the spatial coordinate data converted in step S2, using the PlaneGeometry class of ThreeJs to create the ground geometry, adjusting the size and position of the yard ground model according to the actual size, and adding the yard ground model to the ThreeJs engine.
[0027] Furthermore, the box area modeling in step S5 is based on the box area space coordinate data converted in step S2, using the BoxGeometry class to create the box area geometry, and adding the box area model to the ThreeJs engine.
[0028] Furthermore, the model optimization in step S6 includes: adding materials and textures to the yard ground model and the container area model, adding user interaction functions and animation effects, and optimizing the rendering of the model.
[0029] The beneficial effects of the present invention are as follows: the present invention obtains the longitude and latitude coordinates of the storage yard and its internal container area directly from the Amap, and generates the three-dimensional spatial coordinates and container area distribution data of the storage yard through specific function conversion, thereby efficiently constructing a three-dimensional model of the storage yard without the need for on-site measured data. The modeling efficiency and geographic accuracy can be significantly improved, and the demand for rapid iteration of the storage yard can be met, saving manpower and time costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0031] The present invention is further described in detail below with reference to the accompanying drawings.
[0032] Figure 1 It is a flowchart of the steps of the method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates described in an embodiment of the present application;
[0033] Figure 2 It is a flowchart of the steps of obtaining a three-dimensional coordinate map through Amap as described in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the present invention.
[0035] like Figure 1 As shown, the method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates disclosed in the present invention includes the following steps:
[0036] Step 1: Get the longitude and latitude coordinates of the storage yard based on Amap. Specifically, use the vector graphics drawing capability of Amap to locate the storage yard to be modeled and start the editing mode. Figure 2 As shown, the geographic boundary data of the yard is obtained by directly marking points on the map interface, and the distribution data of each container area inside the yard is obtained by marking points. The position and size of the containers are determined by setting the number of containers stacked horizontally and vertically in each container area. Through this step, the longitude and latitude coordinate arrays of the yard boundary and each internal container area can be obtained respectively.
[0037] Step 2: The acquired longitude and latitude coordinate data needs to be converted into three-dimensional coordinate data in space before it can be used. Using trigonometric calculations, through the correspondence between longitude and latitude and the angle when the sphere is created, the spherical coordinate system uses radius r, polar angle (also called zenith angle, θ) and azimuth (φ) to represent the position of a point, while the Cartesian coordinate system uses x, y, z to represent the position of this point. There is the following relationship between the spherical coordinate system and the Cartesian coordinate system:
[0038] x = rsin(θ)cos(φ);
[0039] y = rcos(θ);
[0040] z = rsin(θ)sin(φ);
[0041] Where r is the distance from the origin to the target point, equivalent to the radius. θ is the angle downward from the positive z-axis, similar to the angle of latitude, often called the "zenith angle" or polar angle. φ is the horizontal angle, similar to the angle of longitude, usually measured from the x-axis.
[0042] Given the longitude and latitude (lng and lat), it is necessary to map them to the angles θ and φ of the spherical coordinates, where the latitude lat corresponds to the polar angle θ of the spherical coordinates, the latitude range is from +90° to -90° (from the North Pole to the South Pole), and the corresponding spherical angle range is from 0 to π (from the positive z-axis to the negative z-axis), then the angle corresponding to θ is expressed as: 90°-lat, in order to facilitate the calculation of trigonometric functions, the corresponding angle is converted into radians and expressed as: (90°-lat)×(π / 180°); where the longitude lng corresponds to the azimuth φ of the spherical coordinates, the longitude range is from -180° to 180°, and the corresponding spherical angle range is from 0 to 2π, then the angle corresponding to φ is expressed as: 180°+lng, in order to facilitate the calculation of trigonometric functions, the corresponding angle is converted into radians and expressed as: (180°+lng)×(π / 180°).
[0043] With the angles θ and φ, we can use the conversion formula from spherical coordinates to Cartesian coordinates to calculate the three-dimensional coordinates:
[0044] x coordinate: x=r*sin(θ)*cos(φ);
[0045] This formula represents the horizontal coordinate of the projection of a point on the xy plane, which combines the polar angle θ and the azimuth angle φ.
[0046] y coordinate: y = r * cos (θ);
[0047] This formula represents the projection of a point on the z-axis. Since θ is related to the angle of the z-axis, y is only related to θ.
[0048] z coordinate: z = r*sin(θ)*sin(φ);
[0049] This formula represents the projection of a point onto the xz plane. It combines the polar angle θ and the azimuth angle φ.
[0050] The trigonometric functions derived above are used to convert the longitude and latitude data into spatial coordinate data suitable for three-dimensional modeling. The corresponding three-dimensional coordinates are calculated through the correspondence between the longitude and latitude and the angle when the sphere is created. The function is converted into JS code and encapsulated into a general method for calling.
[0051] According to the above formula, the following JS conversion function can be obtained:
[0052]
[0053] Among them, lng and lat represent the longitude and latitude in geographic coordinates respectively, and radius is the radius of the sphere, which represents the distance from the center of the sphere to the surface point. In three-dimensional rendering, this radius is usually used to scale the sphere. If applied to the earth model, radius can represent the scaling radius of the earth. phi represents the azimuth corresponding to the longitude, theta represents the polar angle corresponding to the latitude, lglt2xyz is the method name exposed by the function, and (x, y, z) is the three-dimensional coordinate.
[0054] Furthermore, the lglt2xyz method is called cyclically through the forEach method of the array to convert the longitude and latitude data of the yard boundary and the container area into an array of three-dimensional space coordinates. The calling method is as follows:
[0055]
[0056]
[0057] Among them, coordinates is a set of geographic coordinate data obtained from Amap. Each point contains longitude (lng) and latitude (lat). Radius is the radius of the earth. ForEach is an array loop method in JavaScript. (x, y, z) is the three-dimensional space coordinate calculated by the function.
[0058] Step 3. After obtaining the three-dimensional coordinates, initialize ThreeJs, which mainly includes the following steps: create a ThreeJs renderer object, including setting the size and background color of the renderer; create a ThreeJs scene object, and add all 3D objects, light sources, and cameras to the scene; set the camera position and viewing angle to ensure that the entire yard model can be clearly viewed; add light sources, including ambient light, parallel light, or point light sources, to enhance the visual effect of the three-dimensional model.
[0059] Specifically: initialize a scene configuration object through the THREE.Scene() class method; then simulate a visual angle through the THREE.PerspectiveCamera() camera creation method; call the .position() method in the visual angle to adjust the visual position and fix it in an orientation so that you can better observe the scene; update the camera's aspect ratio to the aspect ratio of the wandering window, and calculate the ratio window.innerWidth / window.innerHeight through the window method to ensure the correct display ratio; call updateProjectionMatrix() to update the camera's projection matrix to apply the updated aspect ratio; call the scene.add() method to add the camera to the scene so that you can see the view it captures when selecting the software.
[0060] Furthermore, call the THREE.AxesHelper instance to create a three-dimensional coordinate axis of a specified size as an auxiliary coordinate axis; add the auxiliary coordinate axis to the scene so that its effect can be seen during rendering; call the scene.add() method to add the created coordinate axis object to the scene.
[0061] When adding a directional light source, call the DirectionalLight method, set the color to white (0xffffff) and the intensity to 1; add the ambient light source to the scene to provide a soft global lighting effect; call the scene.add() method to add the created light source object to the scene.
[0062] Step 4: Model the yard ground. According to the spatial coordinate data converted in step 2, use the PlaneGeometry class of ThreeJs to create the ground geometry. Adjust the size and position of the yard ground model according to the actual size, and add the yard ground model to the ThreeJs engine.
[0063] Specifically: call the geometry PlaneGeometry instance method to create a ground in the scene; use light gray (0xcccccc) to create a MeshBasicMaterial instance of a basic material; combine the geometry and material to create a mesh Mesh instance, thus generating a ground with the specified color and plane shape; rotate the ground along the X-axis by -Math.PI / 2 (ie -90 degrees) so that its plane is parallel to the ground, that is, the horizontal position at y=0; add the ground object to the scene so that the ground effect can be seen during rendering; call the scene.add() method to add the created ground object to the scene.
[0064] Step 5: Model the container area. According to the container area spatial coordinate data converted in step 2, use the BoxGeometry class to create the geometry of the container area, and add the container area model to the ThreeJs engine. The position and size of the boxes are determined by setting the number of containers stacked horizontally and vertically in each container area.
[0065] The box area modeling includes creating the box area location and creating the container body. The creation of the box area location includes: converting the box area coordinate point obtained by clicking on the Gaode map through trigonometric functions, and looping to call the BufferGeometry instance according to the converted coordinate data to create the box area location through the instance; calling THREE.LineDashedMaterial() to create a dotted line material, specifying the color to be white (0xffffff), setting the dotted line mode, dashSize (dash line length) to 3, and gapSize (interval length) to 4; calling the computedLineDistances() method to calculate the distance of the dotted line segment, so as to correctly display the dotted line effect to represent each individual box area; calling the scene.add() method to add the created box area object to the scene. Creating a container body includes: setting the horizontal and vertical number of containers in the box area, as well as the layer height through each box area in the previous step; looping through the number of boxes to call the THREE.BoxGeometry() method to create the box geometry in the box area; calling the THREE.TextureLoader() method to set the material of the box; calling THREE.Mesh() to add the material and box to the mesh; calling the scene.add() method to add the created box object to the scene.
[0066] Step 6: Optimize the model, specifically: add appropriate materials and textures to the yard ground model and the container area model to enhance the realism and visual effects of the three-dimensional scene, choose to add appropriate materials, such as: MeshBasicMaterial or MeshPhongMaterial in ThreeJs, and load the added texture image through TextureLoader in ThreeJs; add basic user interaction functions and necessary animation effects to facilitate users to freely view and operate the three-dimensional model and perform business operations in the container area; use the OrbitControls class to implement perspective scaling, rotation, and translation, so that users can view the yard model from different angles; the rendering loop of ThreeJs continuously refreshes the scene, and improves rendering performance through algorithms and techniques, for example, reducing the number of polygons, using instanced rendering, etc., to ensure smoothness on ordinary browsers.
[0067] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates, characterized in that: The following steps are involved: S1. Obtain the longitude and latitude geographic coordinates of the storage yard based on Amap. S2. converting the obtained longitude and latitude data into spatial coordinate data suitable for three-dimensional modeling through trigonometric functions; S3. After obtaining the three-dimensional coordinates, initialize ThreeJs; S4. Modeling the ground surface of the storage yard; S5, modeling the box area; S6. Perform model optimization.
2. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 1, characterized in that: In step S1, the vector map drawing capability of Amap is used to locate the map to the yard to be modeled, and the editing mode is turned on. The geographic boundary data of the yard is obtained by directly marking points on the map interface, and points are marked inside the yard to obtain the distribution data of each container area inside.
3. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 2, characterized in that: The location and size of the boxes are determined by setting the number of containers to be stacked in horizontal and vertical rows in each box area.
4. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 1, characterized in that: In step S2, the obtained longitude and latitude lng and lat are mapped to the angles θ and φ of spherical coordinates with a radius of r, and the spatial coordinates x = r*sin(θ)*cos(φ), y = r*cos(θ), z = r*sin(θ)*sin(φ) are obtained through trigonometric function transformation, where θ = (90°-lat)×(π / 180°), φ = (180°+lng)×(π / 180°).
5. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 4, characterized in that: Convert the coordinate function into JavaScript code and encapsulate it into a general method for calling.
6. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 1, characterized in that: The initialization of ThreeJs in step S3 includes the following steps: S3.
1. Create a ThreeJs renderer object, including setting the size and background color of the renderer; S3.
2. Create a ThreeJs scene object and add all 3D objects, light sources, and cameras to the scene; S3.3, set the camera position and viewing angle to ensure that the entire yard model can be clearly viewed; S3.
4. Add light sources, including ambient light, parallel light, or point light, to enhance the visual effect of the 3D model.
7. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 1, characterized in that: The yard ground modeling in step S4 is based on the spatial coordinate data converted in step S2, using the PlaneGeometry class of ThreeJs to create the ground geometry, adjusting the size and position of the yard ground model according to the actual size, and adding the yard ground model to the ThreeJs engine.
8. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 3, characterized in that: The box area modeling in step S5 is based on the box area space coordinate data converted in step S2, using the BoxGeometry class to create the box area geometry, and adding the box area model to the ThreeJs engine.
9. The method for quickly building a three-dimensional model of a storage yard based on longitude and latitude coordinates according to claim 1, characterized in that: The model optimization in step S6 includes: adding materials and textures to the yard ground model and the container area model, adding user interaction functions and animation effects, and optimizing the rendering of the model.
Citation Information
Patent Citations
A small map-based sectioning or isolating method and device
CN109902387A
3D annotation editing method and system based on mapbox-gl
CN116912361A
Pipe network data three-dimensional visualization processing method
CN117456143A
Geographic information labeling method and device for panoramic view, equipment and storage medium
CN118897870A