Skip to content

Commit

Permalink
Handle NULL projections in the stepper
Browse files Browse the repository at this point in the history
  • Loading branch information
niess committed Oct 26, 2018
1 parent e40c264 commit ae89620
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/turtle/stepper.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ static enum turtle_return compute_geomap(struct turtle_stepper * stepper,
struct turtle_map * map = layer->a.map;
const struct turtle_projection * projection =
turtle_map_projection(map);
return turtle_projection_project(projection, geographic[0],
geographic[1], geographic + 3, geographic + 4);
if (projection != NULL) {
return turtle_projection_project(projection, geographic[0],
geographic[1], geographic + 3, geographic + 4);
} else {
geographic[3] = geographic[1];
geographic[4] = geographic[0];
return TURTLE_RETURN_SUCCESS;
}
}

static enum turtle_return get_geographic(struct turtle_stepper * stepper,
Expand Down Expand Up @@ -231,9 +237,14 @@ static void stepper_elevation_map(struct turtle_stepper * stepper,
{
const struct turtle_projection * projection =
turtle_map_projection(layer->a.map);
double x, y;
turtle_projection_project(projection, latitude, longitude, &x, &y);
turtle_map_elevation(layer->a.map, x, y, ground_elevation, inside);
if (projection != NULL) {
double x, y;
turtle_projection_project(projection, latitude, longitude, &x, &y);
turtle_map_elevation(layer->a.map, x, y, ground_elevation, inside);
} else {
turtle_map_elevation(layer->a.map, longitude, latitude,
ground_elevation, inside);
}
}

static void stepper_elevation_flat(struct turtle_stepper * stepper,
Expand Down

0 comments on commit ae89620

Please sign in to comment.