Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix selecting complex polygons/ #225

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d98ac91
add test and fix for complex polygons
pierot Jun 13, 2018
4a4702a
no formatting
pierot Jun 14, 2018
1597d71
merge
pierot Sep 25, 2018
d5b5f8c
Merge branch 'xerions-master'
pierot Sep 25, 2018
c8a4ec9
fix travis, based on https://github.com/xerions/mariaex/pull/236/comm…
pierot Oct 2, 2018
8441a6e
fix test by skipping geometry tests when nu geometry support
pierot Oct 2, 2018
140837c
Merge remote-tracking branch 'upstream/master'
pierot Jan 28, 2019
f6faec3
add multipolygon
jeroenbourgois Sep 13, 2019
6969129
bump
jeroenbourgois Sep 13, 2019
6a81027
tweak
jeroenbourgois Sep 13, 2019
c98d932
another fix attempts
jeroenbourgois Sep 14, 2019
b5b5833
test
jeroenbourgois Sep 17, 2019
e982539
fix
jeroenbourgois Sep 17, 2019
d7bebc9
fix
jeroenbourgois Sep 19, 2019
ec1a857
merge
jeroenbourgois Sep 19, 2019
98ab01d
fix
jeroenbourgois Sep 19, 2019
8c63fcd
test
jeroenbourgois Sep 19, 2019
e5028f7
yaf
jeroenbourgois Sep 19, 2019
6dd9429
logging
jeroenbourgois Sep 19, 2019
5556368
another test
jeroenbourgois Sep 19, 2019
dca804f
another test
jeroenbourgois Sep 19, 2019
a34be28
fix
jeroenbourgois Sep 19, 2019
e1916d1
tmp multipolygon fix
jeroenbourgois Oct 4, 2019
76e3458
fix
jeroenbourgois Oct 4, 2019
46a1088
debug data
jeroenbourgois Oct 4, 2019
4afa78a
mp1
jeroenbourgois Oct 4, 2019
703ba7e
fix
jeroenbourgois Oct 4, 2019
c7a48e6
yat
jeroenbourgois Oct 7, 2019
e652110
fix acc reduce
jeroenbourgois Oct 7, 2019
9d219a6
proress
jeroenbourgois Oct 7, 2019
e58a59d
more
jeroenbourgois Oct 7, 2019
8e8f32a
trying
jeroenbourgois Oct 7, 2019
9fec1c1
fix: FIX
jeroenbourgois Nov 5, 2019
fdd8fad
fix: order matters
jeroenbourgois Nov 5, 2019
811cc18
fix
jeroenbourgois Nov 5, 2019
fa42c77
chore: cleanup
jeroenbourgois Nov 5, 2019
07aa4e5
error
jeroenbourgois Nov 5, 2019
0d4cb27
try bump
jeroenbourgois Nov 5, 2019
f438518
more error output
jeroenbourgois Nov 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/mariaex/row_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ defmodule Mariaex.RowParser do
defp decode_geometry(<<_len::8-little, srid::32-little, 1::8-little, 3::32-little, num_rings::32-little, rest::bits >>, fields, null_bitfield, acc, datetime, json_library) do
decode_rings(rest, num_rings, {srid, fields, null_bitfield, acc}, datetime, json_library)
end
defp decode_geometry(<<_len::8-little, _var_a::8-little, _var_b::8-little, srid::32-little, 1::8-little, 3::32-little, num_rings::32-little, rest::bits>>, fields, null_bitfield, acc, datetime, json_library) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the _var_a and _var_b values? Are we able to match on these more?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to match and maybe do something useful with it, but I have no clue what they are or what they contain. If someone can shed some light on this, I would be happy to adapt the code.

decode_rings(rest, num_rings, {srid, fields, null_bitfield, acc}, datetime, json_library)
end

### GEOMETRY HELPERS

Expand Down Expand Up @@ -496,4 +499,4 @@ defmodule Mariaex.RowParser do
json = json_library.decode!(string)
decode_text_part(rest, fields, [json | acc], datetime, json_library)
end
end
end
30 changes: 16 additions & 14 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
%{"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], [], "hexpm"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"coverex": {:hex, :coverex, "1.4.10", "f6b68f95b3d51d04571a09dd2071c980e8398a38cf663db22b903ecad1083d51", [:mix], [{:httpoison, "~> 0.9", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"db_connection": {:hex, :db_connection, "1.1.0", "b2b88db6d7d12f99997b584d09fad98e560b817a20dab6a526830e339f54cdb3", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
"decimal": {:hex, :decimal, "1.1.0", "3333732f17a90ff3057d7ab8c65f0930ca2d67e15cca812a91ead5633ed472fe", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.0.3", "89bdbaf2aca8bbb5c97d8b3b55c5dd0cff517ecc78d417e87f1d0982e514557b", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.6.3", "d489d7ca2d4323e307bedc4bfe684323a7bf773ecfd77938f3ee8074e488e140", [:mix, :rebar3], [{:certifi, "0.7.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "1.2.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "0.10.0", "4727b3a5e57e9a4ff168a3c2883e20f1208103a41bccc4754f15a9366f49b676", [:mix], [{:hackney, "~> 1.6.3", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], [], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
"poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}}
%{
"certifi": {:hex, :certifi, "0.7.0", "861a57f3808f7eb0c2d1802afeaae0fa5de813b0df0979153cbafcd853ababaf", [:rebar3], []},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []},
"coverex": {:hex, :coverex, "1.4.10", "f6b68f95b3d51d04571a09dd2071c980e8398a38cf663db22b903ecad1083d51", [:mix], [{:httpoison, "~> 0.9", [hex: :httpoison, optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}]},
"db_connection": {:hex, :db_connection, "1.1.0", "b2b88db6d7d12f99997b584d09fad98e560b817a20dab6a526830e339f54cdb3", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]},
"decimal": {:hex, :decimal, "1.1.0", "3333732f17a90ff3057d7ab8c65f0930ca2d67e15cca812a91ead5633ed472fe", [:mix], []},
"earmark": {:hex, :earmark, "1.0.3", "89bdbaf2aca8bbb5c97d8b3b55c5dd0cff517ecc78d417e87f1d0982e514557b", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
"hackney": {:hex, :hackney, "1.6.3", "d489d7ca2d4323e307bedc4bfe684323a7bf773ecfd77938f3ee8074e488e140", [:mix, :rebar3], [{:certifi, "0.7.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
"httpoison": {:hex, :httpoison, "0.10.0", "4727b3a5e57e9a4ff168a3c2883e20f1208103a41bccc4754f15a9366f49b676", [:mix], [{:hackney, "~> 1.6.3", [hex: :hackney, optional: false]}]},
"idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], []},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
"poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
}
57 changes: 57 additions & 0 deletions test/geometry_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,61 @@ defmodule GeometryTest do
]
]
end

@tag :geometry_a
test "inserts large polygon", context do
table = "geometry_test_insert_large_polygon"
:ok = query("CREATE TABLE #{table} (id serial, polygon geometry)", [])

polygon = %Mariaex.Geometry.Polygon{
coordinates: [
[
{4.375889897346497, 51.20387196361823},
{4.381211400032043, 51.19935444755919},
{4.393399357795715, 51.19709552339094},
{4.399235844612122, 51.19515921451808},
{4.40902054309845, 51.19257734276737},
{4.416401982307434, 51.19182426958834},
{4.426015019416809, 51.19300766477249},
{4.434083104133606, 51.19903175088785},
{4.438546299934387, 51.20494749738101},
{4.445756077766418, 51.21312073325066},
{4.449189305305481, 51.21849707104884},
{4.449532628059387, 51.22226013396642},
{4.44197952747345, 51.22763540452407},
{4.430821537971497, 51.2349447650688},
{4.424641728401184, 51.23698687887106},
{4.421551823616028, 51.2403185541701},
{4.410393834114075, 51.24128576954669},
{4.40352737903595, 51.24171563651943},
{4.397862553596497, 51.23924384656603},
{4.399750828742981, 51.23311753378148},
{4.398205876350403, 51.2251628580361},
{4.375889897346497, 51.20387196361823}
]
],
srid: 0
}

:ok = query(~s{INSERT INTO #{table} (id, polygon) VALUES (?, ?)}, [1, polygon])

assert query("SELECT polygon from #{table} WHERE id = ?", [1]) == [[polygon]]

polygon = %Mariaex.Geometry.Polygon{
coordinates: [
[
{4.375889897346497, 51.20387196361823},
{4.381211400032043, 51.19935444755919},
{4.399750828742981, 51.23311753378148},
{4.398205876350403, 51.2251628580361},
{4.375889897346497, 51.20387196361823}
]
],
srid: 0
}

:ok = query(~s{INSERT INTO #{table} (id, polygon) VALUES (?, ?)}, [2, polygon])

assert query("SELECT polygon from #{table} WHERE id = ?", [2]) == [[polygon]]
end
end