Skip to content

Commit

Permalink
Tests for dbscan algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 16, 2018
1 parent d4d9186 commit e46b00d
Show file tree
Hide file tree
Showing 9 changed files with 544 additions and 0 deletions.
84 changes: 84 additions & 0 deletions python/plugins/processing/tests/testdata/expected/dbscan_5_2.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ dbscan_5_2.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-0.426063829787234</gml:X><gml:Y>-2.61063829787234</gml:Y></gml:coord>
<gml:coord><gml:X>9.09095744680851</gml:X><gml:Y>4.22553191489362</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.426063829787234,2.19255319148936</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.45053191489362,1.96914893617021</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.40585106382979,0.807446808510639</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.199468085106383,-0.443617021276596</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.63989361702128,0.315957446808511</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.28776595744681,-0.823404255319149</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>1</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.04734042553191,0.070212765957447</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.7">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>6.90159574468085,0.40531914893617</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>9.09095744680851,-2.61063829787234</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>6</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_5_2>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_5_2 fid="points_wighted.9">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.04734042553191,4.22553191489362</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>8</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_5_2>
</gml:featureMember>
</ogr:FeatureCollection>
37 changes: 37 additions & 0 deletions python/plugins/processing/tests/testdata/expected/dbscan_5_2.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="dbscan_5_2" type="ogr:dbscan_5_2_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="dbscan_5_2_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLUSTER_ID" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ dbscan_multiple_clusters.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-0.426063829787234</gml:X><gml:Y>-2.61063829787234</gml:Y></gml:coord>
<gml:coord><gml:X>9.09095744680851</gml:X><gml:Y>4.22553191489362</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.426063829787234,2.19255319148936</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.45053191489362,1.96914893617021</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.40585106382979,0.807446808510639</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.199468085106383,-0.443617021276596</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.63989361702128,0.315957446808511</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.28776595744681,-0.823404255319149</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>1</ogr:id>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.04734042553191,0.070212765957447</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.7">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>6.90159574468085,0.40531914893617</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>9.09095744680851,-2.61063829787234</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>6</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_multiple_clusters fid="points_wighted.9">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.04734042553191,4.22553191489362</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>8</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_multiple_clusters>
</gml:featureMember>
</ogr:FeatureCollection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="dbscan_multiple_clusters" type="ogr:dbscan_multiple_clusters_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="dbscan_multiple_clusters_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLUSTER_ID" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ dbscan_no_clusters.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-0.426063829787234</gml:X><gml:Y>-2.61063829787234</gml:Y></gml:coord>
<gml:coord><gml:X>9.09095744680851</gml:X><gml:Y>4.22553191489362</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.426063829787234,2.19255319148936</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.45053191489362,1.96914893617021</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.40585106382979,0.807446808510639</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.199468085106383,-0.443617021276596</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.63989361702128,0.315957446808511</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.28776595744681,-0.823404255319149</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>1</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.04734042553191,0.070212765957447</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.7">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>6.90159574468085,0.40531914893617</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>9.09095744680851,-2.61063829787234</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>6</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
<gml:featureMember>
<ogr:dbscan_no_clusters fid="points_wighted.9">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.04734042553191,4.22553191489362</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>8</ogr:id>
<ogr:CLUSTER_ID xsi:nil="true"/>
</ogr:dbscan_no_clusters>
</gml:featureMember>
</ogr:FeatureCollection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="dbscan_no_clusters" type="ogr:dbscan_no_clusters_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="dbscan_no_clusters_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLUSTER_ID" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Loading

0 comments on commit e46b00d

Please sign in to comment.