internal virtual bool FixRingOrientation_() { bool bFound = false; if (m_fixSelfTangency) { bFound = FixRingSelfTangency_(); } if (m_shape.GetPathCount(m_geometry) == 1) { int path = m_shape.GetFirstPath(m_geometry); double area = m_shape.GetRingArea(path); m_shape.SetExterior(path, true); if (area < 0) { int first = m_shape.GetFirstVertex(path); m_shape.ReverseRingInternal_(first); m_shape.SetLastVertex_(path, m_shape.GetPrevVertex(first)); // fix // last // after // the // reverse return(true); } return(false); } m_path_orientation_index = m_shape.CreatePathUserIndex(); // used to // store // discovered // orientation // (3 - // extrior, // 2 - // interior) m_path_parentage_index = m_shape.CreatePathUserIndex(); // used to // resolve OGC // order for (int path_1 = m_shape.GetFirstPath(m_geometry); path_1 != -1; path_1 = m_shape.GetNextPath(path_1)) { m_shape.SetPathUserIndex(path_1, m_path_orientation_index, 0); m_shape.SetPathUserIndex(path_1, m_path_parentage_index, -1); } com.epl.geometry.AttributeStreamOfInt32 bunch = new com.epl.geometry.AttributeStreamOfInt32(0); m_y_scanline = com.epl.geometry.NumberUtils.TheNaN; com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D(); m_unknown_ring_orientation_count = m_shape.GetPathCount(m_geometry); m_node_1_user_index = m_shape.CreateUserIndex(); m_node_2_user_index = m_shape.CreateUserIndex(); for (int ivertex = m_sorted_vertices.GetFirst(m_sorted_vertices.GetFirstList()); ivertex != -1; ivertex = m_sorted_vertices.GetNext(ivertex)) { int vertex = m_sorted_vertices.GetData(ivertex); m_shape.GetXY(vertex, pt); if (pt.y != m_y_scanline && bunch.Size() != 0) { bFound |= ProcessBunchForRingOrientationTest_(bunch); m_sweep_comparator.Reset(); bunch.Clear(false); } bunch.Add(vertex); // all vertices that have same y are added to the // bunch m_y_scanline = pt.y; if (m_unknown_ring_orientation_count == 0) { break; } } if (m_unknown_ring_orientation_count > 0) { bFound |= ProcessBunchForRingOrientationTest_(bunch); bunch.Clear(false); } m_shape.RemoveUserIndex(m_node_1_user_index); m_shape.RemoveUserIndex(m_node_2_user_index); // dbg_verify_ring_orientation_();//debug for (int path_2 = m_shape.GetFirstPath(m_geometry); path_2 != -1;) { if (m_shape.GetPathUserIndex(path_2, m_path_orientation_index) == 3) { // exterior m_shape.SetExterior(path_2, true); int afterPath = path_2; for (int nextHole = m_shape.GetPathUserIndex(path_2, m_path_parentage_index); nextHole != -1;) { int p = m_shape.GetPathUserIndex(nextHole, m_path_parentage_index); m_shape.MovePath(m_geometry, m_shape.GetNextPath(afterPath), nextHole); afterPath = nextHole; nextHole = p; } path_2 = m_shape.GetNextPath(afterPath); } else { m_shape.SetExterior(path_2, false); path_2 = m_shape.GetNextPath(path_2); } } m_shape.RemovePathUserIndex(m_path_orientation_index); m_shape.RemovePathUserIndex(m_path_parentage_index); return(bFound); }