Skip to main content
added 41 characters in body
Source Link
MickyT
  • 12.2k
  • 2
  • 26
  • 48

SQL (POSTGIS), 286 269 261 240 226 218218 216

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

SELECT SUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM (SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))i)a WHERE(ST_XMax(d)-ST_XMin(d))^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

Edit Found a couple more.

SQL (POSTGIS), 286 269 261 240 226 218

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

SELECT SUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM (SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))i)a WHERE(ST_XMax(d)-ST_XMin(d))^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

SQL (POSTGIS), 286 269 261 240 226 218 216

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

SELECT SUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM(SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))i)a WHERE(ST_XMax(d)-ST_XMin(d))^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

Edit Found a couple more.

added 2 characters in body
Source Link
MickyT
  • 12.2k
  • 2
  • 26
  • 48

SQL (POSTGIS), 286 269 261 240 226226 218

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

WITHSELECT ISUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom ASd FROM (SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))SELECT SUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM i)a WHERE(ST_XMax(d)-ST_XMin(d))^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

SQL (POSTGIS), 286 269 261 240 226

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

WITH I AS(SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))SELECT SUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM i)a WHERE(ST_XMax(d)-ST_XMin(d))^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

SQL (POSTGIS), 286 269 261 240 226 218

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

SELECT SUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM (SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))i)a WHERE(ST_XMax(d)-ST_XMin(d))^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

changed the square test/filter and summed(1) rather the count(*)
Source Link
MickyT
  • 12.2k
  • 2
  • 26
  • 48

SQL (POSTGIS), 286 269 261 240240 226

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

WITH I AS(SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))SELECT COUNTSUM(*1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM i)a WHERE ST_Area(d)=(ST_XMax(d)-ST_XMin(d))^2AND^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

SQL (POSTGIS), 286 269 261 240

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

WITH I AS(SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))SELECT COUNT(*)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM i)a WHERE ST_Area(d)=(ST_XMax(d)-ST_XMin(d))^2AND(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area against each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

SQL (POSTGIS), 286 269 261 240 226

This is a query for the PostGIS extension to PostgreSQL. I haven't counted the input values in the total.

WITH I AS(SELECT ST_Union(ST_Boundary(ST_MakeEnvelope(a,b,c,d)))g FROM(VALUES
-- Coordinate input
(2, 1, 3, 11)
,(1, 10, 5, 19)
,(6, 10, 11, 3)
,(8, 8, 15, 15)
,(13, 13, 9, 5)
,(15, 1, 19, 7)
,(17, 19, 19, 17)
)i(a,b,c,d))SELECT SUM(1)FROM(SELECT(ST_Dump(ST_Polygonize(g))).geom d FROM i)a WHERE(ST_XMax(d)-ST_XMin(d))^2+(ST_YMax(d)-ST_YMin(d))^2=ST_Area(d)*2

Explanation

The query builds geometries for each coordinate pair. Unions the exterior rings to properly node the lines. Turns the results into polygons and tests the width against height and the area doubled against the sum of each side squared.

It will run as a standalone query on any PostgreSQL database with the PostGIS Extension.

Changed things around a bit and managed to trim a few characters
Source Link
MickyT
  • 12.2k
  • 2
  • 26
  • 48
Loading
added 13 characters in body
Source Link
MickyT
  • 12.2k
  • 2
  • 26
  • 48
Loading
deleted 4 characters in body
Source Link
MickyT
  • 12.2k
  • 2
  • 26
  • 48
Loading
Source Link
MickyT
  • 12.2k
  • 2
  • 26
  • 48
Loading