The solution is as follows: (the original data is abstract, as I understand it is a table of free-rotating equal polygons in the form of squares: see Figure 1)
1) In QGIS, run the Vector tool - "Geometry processing" - "Extract nodes"
Result table exper_pol_to_poi see figure 2;
2) In the pgAdmin, create a table for lines with the LineString type, for example:
CREATE TABLE exper_linestrings
(
gid serial NOT NULL,
name text,
my_linestrings geometry (LineString),
CONSTRAINT exper_linestrings_pkey PRIMARY KEY (gid)
)
WITH (
OIDS = FALSE
);
ALTER TABLE exper_linestrings
OWNER TO postgres;
And from your points create and insert in table 2 adjacent lines
INSERT INTO exper_linestrings (gid, my_linestrings)
VALUES (1,
ST_GeomFromText ('LineString (
55.2351515108097 35.6899496191,
54.2351516092924 37.4220004525878) ', 4326))
;
INSERT INTO exper_linestrings (gid, my_linestrings)
VALUES (2,
ST_GeomFromText ('LineString (
56.9672023710924 36.6899494742072,
55.2351515108097 35.6899496191
) ', 4326))
;
Result 2 lines forming a right angle, see figure 3;
4) Knowing the size of your polygon as a square, you need to create 3 parallel lines relative to your 2 source lines using this SQL code for my data, specify it for your example:
create table my_linestrings_exper as
SELECT ST_OffsetCurve (my_linestrings, 0.667) geom FROM exper_linestrings
UNION ALL
SELECT ST_OffsetCurve (my_linestrings, 1.334) my_linestrings FROM exper_linestrings
UNION ALL
SELECT ST_OffsetCurve (my_linestrings, 2.0) my_linestrings FROM exper_linestrings
UNION ALL
SELECT my_linestrings FROM exper_linestrings;
The result is the my_linestrings_exper table, see figure 4;
5) Then you need to get internal points of intersection of 4 internal lines as an option, run the SQL:
create table my_exper_poi as SELECT
a.my_linestrings as a,
b.my_linestrings as b,
st_intersection (a.my_linestrings, b.my_linestrings)
FROM my_linestrings_exper as a, my_linestrings_exper as b
WHERE
st_crosses (a.my_linestrings, b.my_linestrings);
Result table my_exper_poi, see figure 5
6) In QGIS, run the Vector tool - "Geometry processing" - "Extract nodes" into the my_linestrings_exper table, as a result the result of the exper_pol_to_poi_all table and merge all the points obtained in the general table, see figure 6;
7) On your exper_pol_to_poi_all table, run the Delaunay Triangulation tool and get the following table, for example: exper_pol_triangl, see figure 7?
8) In QGIS in the "Pencil" editing mode, in the exper_pol_triangl table, select the triangles that fall into the area of interest, use the "Vector" tool - "Geoprocessing" - "Merge by feature" (check "only selected objects" "Classification" - by all indications) result exper_pol_triangl 1 see figure 8-9;
9) Perform this operation 8 more times and combine 9 small squares in the source polygon, for example, SQL:
create table datageo_exper_pol
as
SELECT id, geom
FROM
exper_pol_triangl 1
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 2
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 3
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 4
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 5
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 6
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 7
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 8
exper_pol_triangl all
SELECT id, geom
FROM
exper_pol_triangl 9;
We are looking at the result,
here are your polygons with 9 squares, and they behave very well see figure 10,