Changeset 34005 in osm for applications/editors/josm/plugins/indoorhelper/src/model
- Timestamp:
- 2018-01-13T18:19:22+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/indoorhelper/src/model
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/indoorhelper/src/model/IndoorHelperModel.java
r33997 r34005 46 46 * @author rebsc 47 47 */ 48 public class IndoorHelperModel{ 48 public class IndoorHelperModel { 49 49 50 50 private TagCatalog tags; … … 74 74 * directly to the relation otherwise add it to nodes and/or ways. 75 75 * 76 * @author rebsc 76 77 * @param object the object which defines the tag-set you want to add 77 78 * @param userTags the tags which are given by the user input 78 * @author rebsc 79 */ 80 public void addTagsToOSM(IndoorObject object, List<Tag> userTags) { 79 */ 80 public void addTagsToOSM(IndoorObject object, List<Tag> userTags) { 81 81 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { 82 82 83 83 DataSet ds = Main.main.getEditDataSet(); 84 84 List<Tag> tags = this.getObjectTags(object); 85 85 Collection<Relation> relations = ds.getRelations(); … … 92 92 93 93 // Put value on {@link relationToAdd} if selected object is a relation. 94 relationToAdd = getRelationFromDataSet(ds,relations); 95 96 if(relationToAdd != null) { 97 98 99 100 101 } else{102 103 104 105 94 relationToAdd = getRelationFromDataSet(ds, relations); 95 96 if (relationToAdd != null) { 97 //Add tags to relation 98 for (Tag t : tags) { 99 Main.main.undoRedo.add(new ChangePropertyCommand(relationToAdd, t.getKey(), t.getValue())); 100 } 101 } else { 102 //Add tags to ways or nodes 103 for (Tag t : tags) { 104 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 105 } 106 106 } 107 107 //If the selected dataset is empty 108 108 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 109 109 110 110 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 111 111 } 112 112 } … … 117 117 * @param object the object which defines the tag-set you want to add 118 118 */ 119 119 public void addTagsToOSM(IndoorObject object) { 120 120 121 121 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { … … 138 138 * Method which adds a list of tag-sets to the currently selected OSM data. Tags directly to ways and/or nodes. 139 139 * 140 * @author rebsc 140 141 * @param userTags the tags which are given by the user input 141 * @author rebsc 142 */ 143 public void addTagsToOSM(List<Tag> userTags) { 142 */ 143 public void addTagsToOSM(List<Tag> userTags) { 144 144 145 145 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty()) { … … 149 149 Main.main.undoRedo.add(new ChangePropertyCommand(Main.main.getInProgressSelection(), t.getKey(), t.getValue())); 150 150 } 151 } 152 else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 151 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 153 152 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 154 153 } … … 158 157 * Method which adds the relation to OSM data. Also adds the selected tag-set to relation object. 159 158 * 159 * @author rebsc 160 160 * @param String the Multipolygon Role as String 161 * @author rebsc 162 */ 163 public void addRelation(String role){ 164 Relation newRelation = new Relation(); 165 RelationMember newMember; 166 DataSet ds = Main.main.getEditDataSet(); 161 */ 162 public void addRelation(String role) { 163 Relation newRelation = new Relation(); 164 RelationMember newMember; 165 DataSet ds = Main.main.getEditDataSet(); 167 166 168 167 // Create new relation and add a new member with specific role 169 if(!MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) {170 168 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 169 for (OsmPrimitive osm : ds.getSelected()) { 171 170 newMember = new RelationMember(role == null ? "" : role, osm); 172 171 newRelation.addMember(newMember); 173 172 } 174 175 173 } 174 // Add relation to OSM data 176 175 MainApplication.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation)); 177 176 } … … 180 179 * Method which edits the selected object to the currently selected OSM data (relations). 181 180 * 181 * @author rebsc 182 182 * @param role The Multipolygon Role as String 183 * @param relation 184 * @author rebsc 185 */ 186 public void editRelation(String role, Collection<OsmPrimitive> innerRelation){ 187 188 RelationMember newMember; 189 DataSet ds = Main.main.getEditDataSet(); 190 Collection<Relation> relations = ds.getRelations(); 191 Relation relation = getRelationFromDataSet(ds,relations); 183 */ 184 public void editRelation(String role, Collection<OsmPrimitive> innerRelation) { 185 186 RelationMember newMember; 187 DataSet ds = Main.main.getEditDataSet(); 188 Collection<Relation> relations = ds.getRelations(); 189 Relation relation = getRelationFromDataSet(ds, relations); 192 190 193 191 if (!MainApplication.getLayerManager().getEditDataSet().selectionEmpty() && !Main.main.getInProgressSelection().isEmpty() && 194 195 196 192 !innerRelation.isEmpty() && getRole(ds, relations).equals("outer")) { 193 194 //Add new relation member to selected relation 197 195 for (OsmPrimitive osm : innerRelation) { 198 196 newMember = new RelationMember(role == null ? "" : role, osm); … … 201 199 202 200 //Check if dataset is not empty or if {@link innerRelation} has no value 203 }else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty() || innerRelation.isEmpty()) { 201 } else if (MainApplication.getLayerManager().getEditDataSet().selectionEmpty() || innerRelation.isEmpty()) { 204 202 JOptionPane.showMessageDialog(null, tr("No data selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 205 203 206 204 //If selected object is not a relation member or not a relation member with role "outer" 207 } else if(!getRole(ds,relations).equals("outer")) {208 tr("No relation or no relation member with role \"outer\" selected."), tr("Error"), JOptionPane.ERROR_MESSAGE);209 }210 211 } 212 213 /** 205 } else if (!getRole(ds, relations).equals("outer")) { 206 JOptionPane.showMessageDialog(null, 207 tr("No relation or no relation member with role \"outer\" selected."), tr("Error"), JOptionPane.ERROR_MESSAGE); 208 } 209 } 210 211 /** 214 212 * Returns the current ranking of the preset counter, which includes the 4 most used items. 215 213 * … … 220 218 } 221 219 222 223 224 /*************************************************225 * HELPER METHODS226 *227 */228 229 220 /** 230 221 * Function which returns the the relation (if any) of the currently selected object. 231 222 * If not returns null. 223 * @author rebsc 232 224 * @param ds actual working dataset 233 225 * @param relations collection of relations in the dataset 234 226 * @return relation of currently selected dataset 235 * @author rebsc236 227 */ 237 228 private Relation getRelationFromDataSet(DataSet ds, Collection<Relation> relations) { 238 for(Relation r: relations) {239 for(RelationMember rm: r.getMembers()) {240 for(OsmPrimitive osm: ds.getSelected()) {241 if(rm.refersTo(osm)) {242 243 244 245 246 247 229 for (Relation r: relations) { 230 for (RelationMember rm: r.getMembers()) { 231 for (OsmPrimitive osm: ds.getSelected()) { 232 if (rm.refersTo(osm)) { 233 return r; 234 } 235 } 236 } 237 } 238 return null; 248 239 } 249 240 … … 251 242 * Function which returns the relation role (if any) of the currently selected object. 252 243 * If object is not a relation returns empty string. 244 * @author rebsc 253 245 * @param ds active dataset 254 246 * @param relations collection of relations in the dataset 255 247 * @return role of currently selected relation member if any 256 * @author rebsc257 248 */ 258 249 private String getRole(DataSet ds, Collection<Relation> relations) { 259 250 260 if(isRelationMember(ds,relations)) {261 for(Relation r: relations) {262 for(RelationMember rm: r.getMembers()) {263 for(OsmPrimitive osm: ds.getSelected()) {264 if(rm.refersTo(osm)) {265 266 267 268 269 270 271 251 if (isRelationMember(ds, relations)) { 252 for (Relation r: relations) { 253 for (RelationMember rm: r.getMembers()) { 254 for (OsmPrimitive osm: ds.getSelected()) { 255 if (rm.refersTo(osm)) { 256 return rm.getRole(); 257 } 258 } 259 } 260 } 261 } 262 return ""; 272 263 } 273 264 274 265 /** 275 266 * Function which returns true if the currently selected object is a relation 267 * @author rebsc 276 268 * @param ds active dataset 277 269 * @return true if selected object is a relation 278 * @author rebsc279 270 */ 280 271 private boolean isRelationMember(DataSet ds, Collection<Relation> relations) { 281 for(Relation r: relations) { 282 for(RelationMember rm: r.getMembers()) { 283 for(OsmPrimitive osm: ds.getSelected()) { 284 if(rm.refersTo(osm)) { 285 return true; 286 } 287 } 288 } 289 } 290 return false; 291 } 292 293 294 /** 295 * 296 * 297 * 298 * 299 * 300 * 301 * 302 * 303 * 304 */ 272 for (Relation r: relations) { 273 for (RelationMember rm: r.getMembers()) { 274 for (OsmPrimitive osm: ds.getSelected()) { 275 if (rm.refersTo(osm)) { 276 return true; 277 } 278 } 279 } 280 } 281 return false; 282 } 305 283 } -
applications/editors/josm/plugins/indoorhelper/src/model/PresetCounter.java
r33997 r34005 137 137 return 0; 138 138 } 139 140 139 } 141 142 143 144 /**145 *146 *147 *148 *149 *150 *151 *152 *153 *154 */155 140 } -
applications/editors/josm/plugins/indoorhelper/src/model/TagCatalog.java
r33997 r34005 19 19 20 20 package model; 21 22 /**23 * Class to provide the indoor tagging catalog.24 *25 * @author egru26 * @author rebsc27 *28 */29 import static org.openstreetmap.josm.tools.I18n.tr;30 21 31 22 import java.util.ArrayList; … … 53 44 case DOOR_PRIVATE: 54 45 tagList.add(new Tag("door", "yes")); 55 tagList.add(new Tag 46 tagList.add(new Tag("access", "private")); 56 47 return tagList; 57 48 case DOOR_PUBLIC: 58 49 tagList.add(new Tag("door", "yes")); 59 tagList.add(new Tag 50 tagList.add(new Tag("access", "public")); 60 51 return tagList; 61 52 case ELEVATOR: … … 69 60 return tagList; 70 61 case ACCESS_PRIVATE: 71 72 62 tagList.add(new Tag("access", "private")); 63 return tagList; 73 64 case ACCESS_PUBLIC: 74 75 65 tagList.add(new Tag("access", "public")); 66 return tagList; 76 67 case TOILET_FEMALE: 77 68 tagList.add(new Tag("indoor", "room")); … … 95 86 return tagList; 96 87 case CORRIDOR: 97 98 88 tagList.add(new Tag("indoor", "corridor")); 89 return tagList; 99 90 case BENCH: 100 101 91 tagList.add(new Tag("amenity", "bench")); 92 return tagList; 102 93 case ZONE: 103 104 94 tagList.add(new Tag("area", "zone")); 95 return tagList; 105 96 case NONE: 106 97 return tagList; 107 98 default: 108 99 tagList = null; … … 116 107 * @author egru 117 108 * @author rebsc 118 *119 109 */ 120 110 public enum IndoorObject { 121 111 CONCRETE_WALL, GLASS_WALL, ROOM, TOILET_MALE, TOILET_FEMALE, ELEVATOR, DOOR_PRIVATE, DOOR_PUBLIC, ENTRANCE, 122 ENTRANCE_EXIT_ONLY,ACCESS_PRIVATE,ACCESS_PUBLIC, STEPS,CORRIDOR,BENCH,ZONE,NONE;112 ENTRANCE_EXIT_ONLY, ACCESS_PRIVATE, ACCESS_PUBLIC, STEPS, CORRIDOR, BENCH, ZONE, NONE; 123 113 } 124 125 126 /**127 *128 *129 *130 *131 *132 *133 *134 *135 *136 */137 114 }
Note:
See TracChangeset
for help on using the changeset viewer.