How PHP calculates the area of irregular figures through coordinates

now there is a need to calculate the area of the graph through coordinates. Now we know the longitude and latitude coordinates of each point of the graph, using Baidu coordinates. How to calculate the area?

Php
Mar.29,2021

what did you do when you were at school? you have to decompose it into rectangles and triangles according to the coordinates, and then calculate the area and then add it up. This is a problem that pupils can do. Do you want to use calculus for something that doesn't even have a curve?

by the way, Baidu map can already calculate the coverage area, so you don't need to calculate it yourself at all. Even if your calculation is not correct, the units have to be converted according to the scale

.

https://blog.csdn.net/chengua.
look at this


regardless of the intrinsic algorithm, try postgis . It is an enhanced plug-in for PostgreSQL, which can easily store data in specific coordinate categories and query the results of geographic elements such as area and distance. The disadvantage is to communicate with the database once.

if you consider implementing it directly in the source language (such as php), consider first understanding a formula called Shoelace . This calculates convex polygons based on coordinate discretization. There will be a problem if the selected polygon is not convex.

considering other algorithms, there are many ways to calculate the area, which can be iteratively divided into small triangles through vector calculation, or approximately instead of calculation. The latter is to use a unit square to simulate the irregular polygons you require, in which the uncovered ones are replaced by half a unit square to get an approximate image composed of many unit squares. Then use the number of unit squares * unit area.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7b48d3-162e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7b48d3-162e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?