| 1 | package org.openstreetmap.josm.plugins.conflation;
|
|---|
| 2 |
|
|---|
| 3 | import com.vividsolutions.jump.feature.AbstractBasicFeature;
|
|---|
| 4 | import com.vividsolutions.jump.feature.AttributeType;
|
|---|
| 5 | import com.vividsolutions.jump.feature.BasicFeature;
|
|---|
| 6 | import com.vividsolutions.jump.feature.FeatureSchema;
|
|---|
| 7 | import java.util.Map;
|
|---|
| 8 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | public class OsmFeature extends AbstractBasicFeature {
|
|---|
| 12 | private Object[] attributes;
|
|---|
| 13 |
|
|---|
| 14 | public OsmFeature(OsmPrimitive prim) {
|
|---|
| 15 | super(new FeatureSchema());
|
|---|
| 16 | Map<String, String> keys = prim.getKeys();
|
|---|
| 17 | attributes = new Object[keys.size() + 1];
|
|---|
| 18 | getSchema().addAttribute("GEOMETRY", AttributeType.GEOMETRY);
|
|---|
| 19 | for (String key : keys.keySet()) {
|
|---|
| 20 | getSchema().addAttribute(key, AttributeType.STRING);
|
|---|
| 21 | setAttribute(key, keys.get(key));
|
|---|
| 22 | }
|
|---|
| 23 | JTSConversion conversion = new JTSConversion();
|
|---|
| 24 | setGeometry(conversion.convert(prim));
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | @Override
|
|---|
| 28 | public void setAttributes(Object[] attributes) {
|
|---|
| 29 | this.attributes = attributes;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | @Override
|
|---|
| 33 | public void setAttribute(int attributeIndex, Object newAttribute) {
|
|---|
| 34 | attributes[attributeIndex] = newAttribute;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | @Override
|
|---|
| 38 | public Object getAttribute(int i) {
|
|---|
| 39 | return attributes[i];
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | @Override
|
|---|
| 43 | public Object[] getAttributes() {
|
|---|
| 44 | return attributes;
|
|---|
| 45 | }
|
|---|
| 46 | }
|
|---|