Skip to content

Commit

Permalink
Removed repeated points so that the line string validated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Serrano committed Aug 22, 2018
1 parent 3b2ee4d commit 57fe7e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion geomodelr/cpp/faults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ map<wstring, vector<line>> find_faults_multiple_planes_intersection(const map<ws
map<wstring, vector<line>> faults_intersection;
double start_x = 0.0;
for (size_t k=0; k<planes_cpp.size(); k++){
find_faults_plane_intersection(faults_cpp,planes_cpp[k],faults_intersection, k, start_x);
find_faults_plane_intersection(faults_cpp, planes_cpp[k], faults_intersection, k, start_x);
}

return faults_intersection;
Expand Down
12 changes: 11 additions & 1 deletion geomodelr/cpp/section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "section.hpp"
#include <cmath>
#include <iostream>

Section::~Section()
{
Expand Down Expand Up @@ -151,10 +152,19 @@ SectionPython::SectionPython(const wstring& name, double cut,

pylist pypt = pylist(points[lines[i][j]]);
point2 aux = point2(python::extract<double>(pypt[0]), python::extract<double>(pypt[1]));
if ( lin.size() ) {
if ( geometry::distance(lin.back(), aux) < boost_tol ) {
continue;
}
}
lin.push_back(aux);
}

if ( not geometry::is_valid(lin) or not geometry::is_simple(lin) ) {
if ( geomodelr_verbose ) {
wstring name = python::extract<wstring>( lnames[i] );
std::wcerr << L"ignoring line " << name << L" is valid: "
<< geometry::is_valid(lin) << L" is simple "<< geometry::is_simple(lin) << L"\n" ;
}
continue; // This should guarantee that the line has at least 2 points.
}

Expand Down
2 changes: 1 addition & 1 deletion geomodelr/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__( self, geolojson, delete=True, params={'faults': 'basic'} ):
# Add units to model before deleting geojson.
units = self.geojson['properties']['units'].keys()
self.units = units

print "all faults", self.faults.keys()
# Save space.
if delete:
del self.geojson
Expand Down
6 changes: 3 additions & 3 deletions geomodelr/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,14 +1173,14 @@ def test_anchored_lines( self ):
["s2", 2, points_2, pols_2, units, faults_2, fname, [[0, False], [0, True]]]], { "F1": "FAULT" }, {})
model.make_matches()
self.assertEqual(len(model.not_extended_faults["F1"]), 36)
self.assertEqual(len(model.faults["F1"]), 48)
self.assertEqual(len(model.faults["F1"]), 42)

model = cpp.Model([-1,-1,-1,4,4,4],[-1,-1,-1,4,4,4],[0, 0], [1, 0], [], {}, [["s1", 1, points_1, pols_1, units, faults_1, fname, [[0, False], [0, True]]],
["s2", 2, points_2, pols_2, units, faults_2, fname, []]], { "F1": "FAULT" }, {})
model.make_matches()

self.assertEqual(len(model.not_extended_faults["F1"]), 35)
self.assertEqual(len(model.faults["F1"]), 42)
self.assertEqual(len(model.not_extended_faults["F1"]), 36)
self.assertEqual(len(model.faults["F1"]), 39)

model = cpp.Model([-1,-1,-1,4,4,4],[-1,-1,-1,4,4,4],[0, 0], [1, 0], [], {}, [["s1", 1, points_1, pols_1, units, faults_1, fname, []], ["s2", 2, points_2, pols_2, units, faults_2, fname, []]], { "F1": "FAULT" }, {})
model.make_matches()
Expand Down

0 comments on commit 57fe7e0

Please sign in to comment.