Skip to content

Commit

Permalink
COS43 DIGITANIE
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrzeczkowicz committed Oct 27, 2024
1 parent d210c17 commit 7f89ea5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 25 deletions.
14 changes: 7 additions & 7 deletions bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ std::set<pathLink> link_paths(const Surface_mesh &mesh, const std::vector<std::l

std::set<pathLink> result;

for (int selected_label: {3, 8, 9}) {
for (int selected_label: {LABEL_WATER, LABEL_RAIL, LABEL_ROAD}) {
// List path with selected label
std::list<int> same_label_paths;
for (std::size_t i = 0; i < paths.size(); i++) {
Expand Down Expand Up @@ -605,7 +605,7 @@ class SurfaceCost : public ceres::SizedCostFunction<1, 1, 1, 1> {
local_cost = abs(z[0] - ((double) point_bottom.z())) * normal_angle_coef[location_bottom.first];
if (grad != nullptr) *grad = (z[0] > point_bottom.z()) ? 1 : -1;
if (l != 0 && l != label) {
if ((l != 8 && l != 9) || (label != 8 && label != 9)) {
if ((l != LABEL_RAIL && l != LABEL_ROAD) || (label != LABEL_RAIL && label != LABEL_ROAD)) {
local_cost += cost * normal_angle_coef[location_bottom.first];
}
}
Expand All @@ -621,7 +621,7 @@ class SurfaceCost : public ceres::SizedCostFunction<1, 1, 1, 1> {
local_cost = abs(z[0] - ((double) point_bottom.z())) * normal_angle_coef[location_bottom.first];
if (grad != nullptr) *grad = (z[0] > point_bottom.z()) ? 1 : -1;
if (l != 0 && l != label) {
if ((l != 8 && l != 9) || (label != 8 && label != 9)) {
if ((l != LABEL_RAIL && l != LABEL_ROAD) || (label != LABEL_RAIL && label != LABEL_ROAD)) {
local_cost += cost * normal_angle_coef[location_bottom.first];
}
}
Expand All @@ -639,7 +639,7 @@ class SurfaceCost : public ceres::SizedCostFunction<1, 1, 1, 1> {
local_cost = (((double) point_top.z()) - z[0]) * normal_angle_coef[location_top.first];
if (grad != nullptr) *grad = -1;
if (l != 0 && l != label) {
if ((l != 8 && l != 9) || (label != 8 && label != 9)) {
if ((l != LABEL_RAIL && l != LABEL_ROAD) || (label != LABEL_RAIL && label != LABEL_ROAD)) {
local_cost += cost * normal_angle_coef[location_top.first];
}
}
Expand Down Expand Up @@ -1096,7 +1096,7 @@ pathBridge bridge (pathLink link, const Surface_mesh &mesh, const AABB_tree &tre
auto point_bottom = PMP::construct_point(location_bottom, mesh);
point_cost = abs(bridge.z_segment[i] - point_bottom.z()) * normal_angle_coef[location_bottom.first];
if (l != 0 && l != bridge.label) {
if ((l != 8 && l != 9) || (bridge.label != 8 && bridge.label != 9)) {
if ((l != LABEL_RAIL && l != LABEL_ROAD) || (bridge.label != LABEL_RAIL && bridge.label != LABEL_ROAD)) {
point_cost += theta * normal_angle_coef[location_bottom.first];
} else {
bridge_crossing.insert(location_bottom.first);
Expand All @@ -1113,7 +1113,7 @@ pathBridge bridge (pathLink link, const Surface_mesh &mesh, const AABB_tree &tre
auto point_bottom = PMP::construct_point(location_bottom, mesh);
point_cost = abs(bridge.z_segment[i] - point_bottom.z()) * normal_angle_coef[location_bottom.first];
if (l != 0 && l != bridge.label) {
if ((l != 8 && l != 9) || (bridge.label != 8 && bridge.label != 9)) {
if ((l != LABEL_RAIL && l != LABEL_ROAD) || (bridge.label != LABEL_RAIL && bridge.label != LABEL_ROAD)) {
point_cost += theta * normal_angle_coef[location_bottom.first];
} else {
bridge_crossing.insert(location_bottom.first);
Expand All @@ -1131,7 +1131,7 @@ pathBridge bridge (pathLink link, const Surface_mesh &mesh, const AABB_tree &tre
auto l = label[location_top.first];
point_cost = abs(bridge.z_segment[i] - ((double) point_top.z())) * normal_angle_coef[location_top.first];
if (l != 0 && l != bridge.label) {
if ((l != 8 && l != 9) || (bridge.label != 8 && bridge.label != 9)) {
if ((l != LABEL_RAIL && l != LABEL_ROAD) || (bridge.label != LABEL_RAIL && bridge.label != LABEL_ROAD)) {
point_cost += theta * normal_angle_coef[location_top.first];
} else {
bridge_crossing.insert(location_top.first);
Expand Down
66 changes: 51 additions & 15 deletions label.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string>
#include <array>

//Digitanie COS11 labels
//Digitanie COS43 labels

struct Label {
unsigned char value;
Expand All @@ -15,22 +15,58 @@ struct Label {
Label(unsigned char value, std::string label, unsigned char red, unsigned char green, unsigned char blue): value(value), label(label), red(red), green(green), blue(blue) {}
};

static std::array<Label, 13> LABELS {
static std::array<Label, 45> LABELS {
Label(0, "other", 255, 255, 255),
Label(1, "bare ground", 100, 50, 0),
Label(2, "low vegetation", 0, 250, 50),
Label(3, "water", 0, 50, 250),
Label(4, "building", 250, 50, 50),
Label(5, "high vegetation", 0, 100, 50),
Label(6, "parking", 200, 200, 200),
Label(7, "pedestrian", 200, 150, 50),
Label(8, "road", 100, 100, 100),
Label(9, "railways", 200, 100, 200),
Label(10, "swimming pool", 50, 150, 250),
Label(11, "rail crossing", 250, 150, 0),
Label(12, "unknown", 250, 250, 150)
Label(1, "construction_site", 140, 90, 100),
Label(2, "bare_ground", 71, 58, 17),
Label(3, "bare_parking", 160, 130, 105),
Label(4, "bare_road", 160, 119, 34),
Label(5, "bare_pedestrian", 230, 167, 31),
Label(6, "sand", 234, 220, 90),
Label(7, "snow", 240, 239, 220),
Label(8, "field", 235, 255, 6),
Label(9, "sport_vegetation", 190, 215, 165),
Label(10, "grassland", 140, 240, 118),
Label(11, "aquaculture", 11, 222, 189),
Label(12, "hedge", 119, 211, 0),
Label(13, "shrub", 113, 184, 48),
Label(14, "vegetation", 0, 210, 50),
Label(15, "arboriculture", 120, 155, 100),
Label(16, "tree", 0, 120, 15),
Label(17, "spiney", 30, 143, 100),
Label(18, "forest", 0, 70, 0),
Label(19, "winter_high_vegetation", 90, 180, 170),
Label(20, "ice", 59, 173, 240),
Label(21, "river", 30, 145, 246),
Label(22, "pond", 0, 75, 190),
Label(23, "sea", 0, 55, 105),
Label(24, "swimmingpool", 100, 130, 255),
Label(25, "bridge", 160, 160, 246),
Label(26, "boat", 130, 41, 244),
Label(27, "railways", 75, 20, 132),
Label(28, "road", 141, 91, 210),
Label(29, "private_road", 205, 140, 242),
Label(30, "central_reservation", 163, 127, 180),
Label(31, "parking", 170, 60, 160),
Label(32, "pedestrian", 190, 38, 194),
Label(33, "yard", 255, 175, 200),
Label(34, "sport", 255, 115, 180),
Label(35, "cemetery", 125, 15, 70),
Label(36, "impervious", 219, 20, 123),
Label(37, "terrace", 200, 20, 79),
Label(38, "container", 255, 65, 75),
Label(39, "storage_tank", 195, 85, 0),
Label(40, "greenhouse", 255, 150, 85),
Label(41, "building", 240, 0, 0),
Label(42, "high_building", 127, 1, 0),
Label(43, "pipeline", 35, 85, 85),
Label(44, "unknown", 250, 250, 150)
};

const unsigned char LABEL_OTHER = 12;
const unsigned char LABEL_OTHER = 44;

const unsigned char LABEL_RAIL = 27;
const unsigned char LABEL_WATER = 21;
const unsigned char LABEL_ROAD = 28;

#endif /* !LABEL_H_ */
2 changes: 1 addition & 1 deletion path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ std::map<int, CGAL::Polygon_with_holes_2<Exact_predicates_kernel>> compute_path_
if (filtered_sm.number_of_faces() > 0) {

int lab = label[*(CGAL::faces(filtered_sm).first)];
if (lab == 3 || lab == 8 || lab == 9) {
if (lab == LABEL_WATER || lab == LABEL_RAIL || lab == LABEL_ROAD) {

Arrangement_2 arr;
std::map<Arrangement_2::Vertex_handle, Surface_mesh::vertex_index> point_map;
Expand Down
4 changes: 2 additions & 2 deletions raster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void Raster::fill_holes() {
std::list<std::pair<float,std::list<std::pair<int,int>>>> holes;
for (int L = 1; L < ySize - 1; L++) {
for (int P = 1; P < xSize -1; P++) {
if ((land_cover[L][P] >= 1 && land_cover[L][P] <= 3) || land_cover[L][P] >= 6) {
if (land_cover[L][P] == LABEL_RAIL || land_cover[L][P] == LABEL_ROAD || land_cover[L][P] == LABEL_WATER) {
if ((dsm[L][P] <= dsm[L+1][P]) && (dsm[L][P] <= dsm[L-1][P]) && (dsm[L][P] <= dsm[L][P+1]) && (dsm[L][P] <= dsm[L][P-1])) {
holes.push_back(std::pair<float,std::list<std::pair<int,int>>>(dsm[L][P], {std::pair<int,int>(P,L)}));
}
Expand Down Expand Up @@ -192,7 +192,7 @@ void Raster::fill_holes() {
std::list<std::pair<float,std::list<std::pair<int,int>>>> holes;
for (int L = 1; L < ySize - 1; L++) {
for (int P = 1; P < xSize -1; P++) {
if ((land_cover[L][P] >= 1 && land_cover[L][P] <= 3) || land_cover[L][P] >= 6) {
if (land_cover[L][P] == LABEL_RAIL || land_cover[L][P] == LABEL_ROAD || land_cover[L][P] == LABEL_WATER) {
if ((dsm[L][P] >= dsm[L+1][P]) && (dsm[L][P] >= dsm[L-1][P]) && (dsm[L][P] >= dsm[L][P+1]) && (dsm[L][P] >= dsm[L][P-1])) {
holes.push_back(std::pair<float,std::list<std::pair<int,int>>>(dsm[L][P], {std::pair<int,int>(P,L)}));
}
Expand Down

0 comments on commit 7f89ea5

Please sign in to comment.