Skip to content

Commit

Permalink
AddSegregated, fixes #527
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoniecz committed Jul 23, 2018
1 parent 5d54acb commit 23e7ffb
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public class OsmTaggings
"ground","earth","dirt","grass","sand","mud","ice","salt","snow","woodchips"
};

public static final String[] ANYTHING_PAVED = {
"paved", "asphalt", "cobblestone", "cobblestone:flattened", "sett",
"concrete", "concrete:lanes", "concrete:plates", "paving_stones",
"metal", "wood", "unhewn_cobblestone"
};

public static final String[] ALL_ROADS = {
"motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link",
"secondary", "secondary_link", "tertiary", "tertiary_link",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import de.westnordost.streetcomplete.quests.religion.AddReligionToWaysideShrine;
import de.westnordost.streetcomplete.quests.localized_name.data.PutRoadNameSuggestionsHandler;
import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao;
import de.westnordost.streetcomplete.quests.segregated.AddCyclewaySegregation;
import de.westnordost.streetcomplete.quests.surface.AddPathSurface;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingBusStop;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingCrosswalk;
Expand Down Expand Up @@ -123,6 +124,7 @@ public class QuestModule
new AddWheelChairAccessToilets(o),
new AddReligionToWaysideShrine(o),
new AddBikeParkingType(o),
new AddCyclewaySegregation(o),
new MarkCompletedBuildingConstruction(o),

// ↓ 8. defined in the wiki, but not really used by anyone yet. Just collected for
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package de.westnordost.streetcomplete.quests.segregated;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.data.meta.OsmTaggings;
import de.westnordost.streetcomplete.data.osm.SimpleOverpassQuestType;
import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder;
import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao;
import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment;

public class AddCyclewaySegregation extends SimpleOverpassQuestType {

@Inject
public AddCyclewaySegregation(OverpassMapDataDao overpassServer) {
super(overpassServer);
}

@Override
protected String getTagFilters() {
return
"ways with " +
"(" +
"(highway = path and bicycle = designated and foot = designated)" +
" or (highway = footway and bicycle = designated)" +
" or (highway = cycleway and foot = designated)" +
")" +
" and surface ~" + TextUtils.join("|", OsmTaggings.ANYTHING_PAVED) +
" and !segregated";
}

@Override
public AbstractQuestAnswerFragment createForm() {
return new AddCyclewaySegregationForm();
}

@Override
public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) {
List<String> values = answer.getStringArrayList(AddCyclewaySegregationForm.OSM_VALUES);
if (values != null && values.size() == 1) {
changes.add("segregated", values.get(0));
}
}

@Override
public String getCommitMessage() {
return "Add segregated status for combined footway with cycleway";
}

@Override
public int getIcon() {
return R.drawable.ic_quest_path_segregation;
}

@Override
public int getTitle(@NonNull Map<String, String> tags) {
return R.string.quest_segregated_title;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.westnordost.streetcomplete.quests.segregated;

import de.westnordost.streetcomplete.R;
import de.westnordost.streetcomplete.quests.ImageListQuestAnswerFragment;
import de.westnordost.streetcomplete.view.Item;

public class AddCyclewaySegregationForm extends ImageListQuestAnswerFragment {
@Override
protected Item[] getItems() {
return new Item[]{
new Item("yes", R.drawable.ic_path_segregated, R.string.quest_segregated_separated),
new Item("no", R.drawable.ic_path_segregated_no, R.string.quest_segregated_mixed),
};
}

@Override protected int getItemsPerRow() { return 2; }
}
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,7 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards

<string name="notification_channel_download">"Download"</string>
<string name="quest_playground_access_title">Is this playground publicly accessible?</string>

<string name="quest_segregated_title">How are the footway and cycleway laid out here?</string>
<string name="quest_segregated_separated">Segregated from one another</string>
<string name="quest_segregated_mixed">Cyclists and pedestrians share same space</string>
</resources>

0 comments on commit 23e7ffb

Please sign in to comment.