Skip to content

Commit

Permalink
ask about detailing surface=paved/unpaved
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoniecz committed Jun 14, 2017
1 parent 22599d3 commit 7f8f07e
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import de.westnordost.streetcomplete.quests.bike_parking_cover.AddBikeParkingCover;
import de.westnordost.streetcomplete.quests.building_levels.AddBuildingLevels;
import de.westnordost.streetcomplete.quests.bus_stop_shelter.AddBusStopShelter;
import de.westnordost.streetcomplete.quests.road_surface.DetailPavedRoadSurface;
import de.westnordost.streetcomplete.quests.road_surface.DetailUnpavedRoadSurface;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingBusStop;
import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingCrosswalk;
import de.westnordost.streetcomplete.quests.toilets_fee.AddToiletsFee;
Expand All @@ -35,6 +37,8 @@ public class QuestModule
new AddRoofShape(o),
// new AddPlaceName(), doesn't make sense as long as the app cannot tell the generic name of elements
new AddRoadSurface(o),
new DetailPavedRoadSurface(o),
new DetailUnpavedRoadSurface(o),
new AddBusStopShelter(o),
new AddToiletsFee(o),
new AddHousenumber(o),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,38 @@
import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao;
import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment;

public class AddRoadSurface extends SimpleOverpassQuestType
{
// well, all roads have surfaces, what I mean is that not all ways with highway key are
// "something with a surface"
private static final String[] ROADS_WITH_SURFACES = {
// "trunk","trunk_link","motorway","motorway_link", // too much, motorways are almost by definition asphalt (or concrete)
"primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link",
"unclassified", "residential", "bicycle_road", "living_street", "pedestrian",
"track", "road",
/*"service", */ // this is too much, and the information value is very low
};

@Inject public AddRoadSurface(OverpassMapDataDao overpassServer)
{
public class AddRoadSurface extends SimpleOverpassQuestType {
@Inject
public AddRoadSurface(OverpassMapDataDao overpassServer) {
super(overpassServer);
}

@Override
protected String getTagFilters()
{
return " ways with ( highway ~ " + TextUtils.join("|",ROADS_WITH_SURFACES) + " and" +
" !surface)";
protected String getTagFilters() {
return " ways with ( highway ~ " + TextUtils.join("|", RoadSurfaceConfig.ROADS_WITH_SURFACES) + " and" +
" !surface)";
}

@Override
public int importance()
{
public int importance() {
return QuestImportance.MAJOR;
}

public AbstractQuestAnswerFragment createForm()
{
public AbstractQuestAnswerFragment createForm() {
return new AddRoadSurfaceForm();
}

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) {
changes.add("surface", answer.getString(AddRoadSurfaceForm.SURFACE));
}

@Override public String getCommitMessage()
{
@Override
public String getCommitMessage() {
return "Add road surfaces";
}

@Override public String getIconName() { return "street_surface"; }
@Override
public String getIconName() {
return "street_surface";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,86 +12,29 @@
import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment;
import de.westnordost.streetcomplete.view.GroupedImageSelectAdapter;

public class AddRoadSurfaceForm extends AbstractQuestFormAnswerFragment
{
public static final String SURFACE = "surface";

private final Surface[] SURFACES = new Surface[] {
new Surface("paved", R.drawable.panorama_surface_paved, R.string.quest_surface_value_paved, new Surface[]{
new Surface("asphalt", R.drawable.surface_asphalt, R.string.quest_surface_value_asphalt),
new Surface("concrete", R.drawable.surface_concrete, R.string.quest_surface_value_concrete),
new Surface("sett", R.drawable.surface_sett, R.string.quest_surface_value_sett),
new Surface("paving_stones", R.drawable.surface_paving_stones, R.string.quest_surface_value_paving_stones),
new Surface("cobblestone", R.drawable.surface_cobblestone, R.string.quest_surface_value_cobblestone),
new Surface("wood", R.drawable.surface_wood, R.string.quest_surface_value_wood),
}),
new Surface("unpaved", R.drawable.panorama_surface_unpaved, R.string.quest_surface_value_unpaved, new Surface[]{
new Surface("compacted", R.drawable.surface_compacted, R.string.quest_surface_value_compacted),
new Surface("gravel", R.drawable.surface_gravel, R.string.quest_surface_value_gravel),
new Surface("fine_gravel", R.drawable.surface_fine_gravel, R.string.quest_surface_value_fine_gravel),
new Surface("pebblestone", R.drawable.surface_pebblestone, R.string.quest_surface_value_pebblestone),
new Surface("grass_paver", R.drawable.surface_grass_paver, R.string.quest_surface_value_grass_paver),
}),
new Surface("ground", R.drawable.panorama_surface_ground, R.string.quest_surface_value_ground, new Surface[]{
new Surface("dirt", R.drawable.surface_dirt, R.string.quest_surface_value_dirt),
new Surface("grass", R.drawable.surface_grass, R.string.quest_surface_value_grass),
new Surface("sand", R.drawable.surface_sand, R.string.quest_surface_value_sand),
}),
};

private GroupedImageSelectAdapter imageSelector;

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = super.onCreateView(inflater, container, savedInstanceState);

setTitle(R.string.quest_streetSurface_title);

View contentView = setContentView(R.layout.quest_street_surface);

RecyclerView surfaceSelect = (RecyclerView) contentView.findViewById(R.id.surfaceSelect);
imageSelector = new GroupedImageSelectAdapter(Arrays.<GroupedImageSelectAdapter.Item>asList(SURFACES));
surfaceSelect.setAdapter(imageSelector);
surfaceSelect.setNestedScrollingEnabled(false);

return view;
}

@Override protected void onClickOk()
{
Bundle answer = new Bundle();
if(getSelectedSurface() != null)
{
answer.putString(SURFACE, getSelectedSurface().value);
}
applyFormAnswer(answer);
}

@Override public boolean hasChanges()
{
return getSelectedSurface() != null;
}

private Surface getSelectedSurface()
{
return (Surface) imageSelector.getSelectedItem();
}

private static class Surface extends GroupedImageSelectAdapter.Item
{
public final String value;

public Surface(String value, int drawableId, int titleId)
{
super(drawableId, titleId);
this.value = value;
}

public Surface(String value, int drawableId, int titleId, GroupedImageSelectAdapter.Item[] items)
{
super(drawableId, titleId, items);
this.value = value;
}
public class AddRoadSurfaceForm extends RoadSurfaceForm {
RoadSurfaceForm.Surface[] GetSurfaceMenuStructure() {
return new RoadSurfaceForm.Surface[]{
new RoadSurfaceForm.Surface("paved", R.drawable.panorama_surface_paved, R.string.quest_surface_value_paved, new RoadSurfaceForm.Surface[]{
new RoadSurfaceForm.Surface("asphalt", R.drawable.surface_asphalt, R.string.quest_surface_value_asphalt),
new RoadSurfaceForm.Surface("concrete", R.drawable.surface_concrete, R.string.quest_surface_value_concrete),
new RoadSurfaceForm.Surface("sett", R.drawable.surface_sett, R.string.quest_surface_value_sett),
new RoadSurfaceForm.Surface("paving_stones", R.drawable.surface_paving_stones, R.string.quest_surface_value_paving_stones),
new RoadSurfaceForm.Surface("cobblestone", R.drawable.surface_cobblestone, R.string.quest_surface_value_cobblestone),
new RoadSurfaceForm.Surface("wood", R.drawable.surface_wood, R.string.quest_surface_value_wood),
}),
new RoadSurfaceForm.Surface("unpaved", R.drawable.panorama_surface_unpaved, R.string.quest_surface_value_unpaved, new RoadSurfaceForm.Surface[]{
new RoadSurfaceForm.Surface("compacted", R.drawable.surface_compacted, R.string.quest_surface_value_compacted),
new RoadSurfaceForm.Surface("gravel", R.drawable.surface_gravel, R.string.quest_surface_value_gravel),
new RoadSurfaceForm.Surface("fine_gravel", R.drawable.surface_fine_gravel, R.string.quest_surface_value_fine_gravel),
new RoadSurfaceForm.Surface("pebblestone", R.drawable.surface_pebblestone, R.string.quest_surface_value_pebblestone),
new RoadSurfaceForm.Surface("grass_paver", R.drawable.surface_grass_paver, R.string.quest_surface_value_grass_paver),
}),
new RoadSurfaceForm.Surface("ground", R.drawable.panorama_surface_ground, R.string.quest_surface_value_ground, new RoadSurfaceForm.Surface[]{
new RoadSurfaceForm.Surface("dirt", R.drawable.surface_dirt, R.string.quest_surface_value_dirt),
new RoadSurfaceForm.Surface("grass", R.drawable.surface_grass, R.string.quest_surface_value_grass),
new RoadSurfaceForm.Surface("sand", R.drawable.surface_sand, R.string.quest_surface_value_sand),
}),
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.westnordost.streetcomplete.quests.road_surface;

import android.os.Bundle;
import android.text.TextUtils;

import javax.inject.Inject;

import de.westnordost.streetcomplete.data.QuestImportance;
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 DetailPavedRoadSurface extends SimpleOverpassQuestType {
@Inject
public DetailPavedRoadSurface(OverpassMapDataDao overpassServer) {
super(overpassServer);
}

@Override
protected String getTagFilters() {
return " ways with ( highway ~ " + TextUtils.join("|", RoadSurfaceConfig.ROADS_WITH_SURFACES) + " and" +
" surface=paved)";
}

@Override
public int importance() {
return QuestImportance.MINOR;
}

public AbstractQuestAnswerFragment createForm() {
return new DetailPavedRoadSurfaceForm();
}

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) {
changes.modify("surface", answer.getString(DetailPavedRoadSurfaceForm.SURFACE));
}

@Override
public String getCommitMessage() {
return "Detail road surfaces";
}

@Override
public String getIconName() {
return "street_surface";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.westnordost.streetcomplete.quests.road_surface;

import de.westnordost.streetcomplete.R;

public class DetailPavedRoadSurfaceForm extends RoadSurfaceForm {
RoadSurfaceForm.Surface[] GetSurfaceMenuStructure() {
return new RoadSurfaceForm.Surface[]{
new RoadSurfaceForm.Surface("asphalt", R.drawable.surface_asphalt, R.string.quest_surface_value_asphalt),
new RoadSurfaceForm.Surface("concrete", R.drawable.surface_concrete, R.string.quest_surface_value_concrete),
new RoadSurfaceForm.Surface("sett", R.drawable.surface_sett, R.string.quest_surface_value_sett),
new RoadSurfaceForm.Surface("paving_stones", R.drawable.surface_paving_stones, R.string.quest_surface_value_paving_stones),
new RoadSurfaceForm.Surface("cobblestone", R.drawable.surface_cobblestone, R.string.quest_surface_value_cobblestone),
new RoadSurfaceForm.Surface("wood", R.drawable.surface_wood, R.string.quest_surface_value_wood),
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package de.westnordost.streetcomplete.quests.road_surface;

import android.os.Bundle;
import android.text.TextUtils;

import javax.inject.Inject;

import de.westnordost.streetcomplete.data.QuestImportance;
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 DetailUnpavedRoadSurface extends SimpleOverpassQuestType {
@Inject
public DetailUnpavedRoadSurface(OverpassMapDataDao overpassServer) {
super(overpassServer);
}

@Override
protected String getTagFilters() {
return " ways with ( highway ~ " + TextUtils.join("|", RoadSurfaceConfig.ROADS_WITH_SURFACES) + " and" +
" surface=unpaved)";
}

@Override
public int importance() {
return QuestImportance.MINOR;
}

public AbstractQuestAnswerFragment createForm() {
return new DetailUnpavedRoadSurfaceForm();
}

public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) {
changes.modify("surface", answer.getString(DetailUnpavedRoadSurfaceForm.SURFACE));
}

@Override
public String getCommitMessage() {
return "Detail road surfaces";
}

@Override
public String getIconName() {
return "street_surface";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package de.westnordost.streetcomplete.quests.road_surface;

import de.westnordost.streetcomplete.R;

public class DetailUnpavedRoadSurfaceForm extends RoadSurfaceForm {
Surface[] GetSurfaceMenuStructure() {
return new Surface[]{
new RoadSurfaceForm.Surface("compacted", R.drawable.surface_compacted, R.string.quest_surface_value_compacted),
new RoadSurfaceForm.Surface("gravel", R.drawable.surface_gravel, R.string.quest_surface_value_gravel),
new RoadSurfaceForm.Surface("fine_gravel", R.drawable.surface_fine_gravel, R.string.quest_surface_value_fine_gravel),
new RoadSurfaceForm.Surface("pebblestone", R.drawable.surface_pebblestone, R.string.quest_surface_value_pebblestone),
new RoadSurfaceForm.Surface("grass_paver", R.drawable.surface_grass_paver, R.string.quest_surface_value_grass_paver),
new RoadSurfaceForm.Surface("dirt", R.drawable.surface_dirt, R.string.quest_surface_value_dirt),
new RoadSurfaceForm.Surface("grass", R.drawable.surface_grass, R.string.quest_surface_value_grass),
new RoadSurfaceForm.Surface("sand", R.drawable.surface_sand, R.string.quest_surface_value_sand),
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.westnordost.streetcomplete.quests.road_surface;

public class RoadSurfaceConfig {
// well, all roads have surfaces, what I mean is that not all ways with highway key are
// "something with a surface"
static final String[] ROADS_WITH_SURFACES = {
// "trunk","trunk_link","motorway","motorway_link", // too much, motorways are almost by definition asphalt (or concrete)
"primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link",
"unclassified", "residential", "bicycle_road", "living_street", "pedestrian",
"track", "road",
/*"service", */ // this is too much, and the information value is very low
};
}
Loading

0 comments on commit 7f8f07e

Please sign in to comment.