Changeset 26544 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-08-16T23:55:53+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/multipoly-convert
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/multipoly-convert
- Property svn:ignore
-
old new 1 1 build 2 bin
-
- Property svn:ignore
-
applications/editors/josm/plugins/multipoly-convert/.classpath
r20416 r26544 3 3 <classpathentry kind="src" path="src"/> 4 4 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-openjdk"/> 5 <classpathentry combineaccessrules="false" kind="src" path="/josm"/>6 5 <classpathentry kind="lib" path="/usr/share/josm/josm.jar" sourcepath="/home2/brunner/workspace/josm-0.0.svn3094/src"/> 6 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 7 7 <classpathentry kind="output" path="bin"/> 8 8 </classpath> -
applications/editors/josm/plugins/multipoly-convert/build.xml
r26174 r26544 30 30 <project name="multipoly-convert" default="dist" basedir="."> 31 31 <!-- enter the SVN commit message --> 32 <property name="commit.message" value=" Changed the constructor signature of the plugin main class"/>32 <property name="commit.message" value="preset maintenance (${ant.project.name})"/> 33 33 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 34 34 <property name="plugin.main.version" value="3835"/> 35 <!-- compilation properties --> 36 <property name="josm.build.dir" value="../../core"/> 37 <property name="josm.home.dir" value="${user.home}/.josm"/> 38 <property name="josm" location="../../core/dist/josm-custom.jar"/> 39 <property name="plugin.build.dir" value="build"/> 40 <property name="plugin.dist.dir" value="../../dist"/> 41 <property name="plugin.name" value="${ant.project.name}"/> 42 <property name="plugin.jar" value="${plugin.dist.dir}/${plugin.name}.jar"/> 43 <!-- There's no josm.jar in the svn, so point "josm" to a local copy of your JOSM binary --> 44 <property name="josm" location="../../core/dist/josm-custom.jar"/> 45 <property name="ant.build.javac.target" value="1.5"/> 46 <target name="init"> 47 <mkdir dir="${plugin.build.dir}"> 48 </mkdir> 49 <mkdir dir="${plugin.dist.dir}"> 50 </mkdir> 51 </target> 52 <target name="compile" depends="init"> 53 <echo message="creating ${plugin.jar}"/> 54 <javac srcdir="src" target="1.5" classpath="${josm}" destdir="build" debug="true"> 55 <include name="**/*.java"/> 56 </javac> 57 </target> 58 <target name="revision"> 59 <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false"> 60 <env key="LANG" value="C"/> 61 <arg value="info"/> 62 <arg value="--xml"/> 63 <arg value="."/> 64 </exec> 65 <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/> 66 <delete file="REVISION"/> 67 </target> 35 36 <import file="../build-common.xml"/> 37 68 38 <target name="dist" depends="compile,revision"> 39 <echo message="creating ${ant.project.name}.jar ... "/> 69 40 <copy todir="${plugin.build.dir}/images"> 70 41 <fileset dir="images"/> … … 73 44 <fileset dir="data"/> 74 45 </copy> 46 <copy todir="${plugin.build.dir}"> 47 <fileset dir="."> 48 <include name="README"/> 49 <include name="LICENSE"/> 50 </fileset> 51 </copy> 75 52 <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}"> 76 53 <manifest> 77 54 <attribute name="Author" value="Stéphane Brunner"/> 78 <attribute name="Plugin-Class" value=" converttomultipoly.MultipolyPlugin"/>79 <attribute name="Plugin-Description" value=" Simply convert an area to a multipolygon."/>80 <attribute name="Plugin-Icon" value="images/m ultipoly_convert.png"/>55 <attribute name="Plugin-Class" value="mergeoverlap.MergeOverlapPlugin"/> 56 <attribute name="Plugin-Description" value="Merge overlapping part of ways."/> 57 <attribute name="Plugin-Icon" value="images/merge_overlap.png"/> 81 58 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> 82 59 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/> 83 <attribute name="Plugin-Link" value="http://www.stephane-brunner.ch/mediawiki/index.php/Plugins"/>84 60 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/> 85 <!--attribute name="2830_Plugin-Url" value="20583;http://trac.openstreetmap.org/browser/applications/editors/josm/dist/multipoly-convert.jar?rev=20584&format=raw" /-->86 61 </manifest> 87 62 </jar> 88 63 </target> 89 <target name="clean">90 <delete dir="${plugin.build.dir}"/>91 <delete file="${plugin.jar}"/>92 </target>93 <target name="clean_install">94 <delete file="${plugins}/multipoly-convert.jar"/>95 </target>96 <target name="install" depends="dist">97 <property environment="env"/>98 <condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins">99 <and>100 <os family="windows"/>101 </and>102 </condition>103 <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>104 </target>105 <!--106 ************************** Publishing the plugin ***********************************107 -->108 <!--109 ** extracts the JOSM release for the JOSM version in ../core and saves it in the110 ** property ${coreversion.info.entry.revision}111 **112 -->113 <target name="core-info">114 <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false">115 <env key="LANG" value="C"/>116 <arg value="info"/>117 <arg value="--xml"/>118 <arg value="../../core"/>119 </exec>120 <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/>121 <echo>Building against core revision ${coreversion.info.entry.revision}.</echo>122 <echo>Plugin-Mainversion is set to ${plugin.main.version}.</echo>123 <delete file="core.info.xml"/>124 </target>125 <!--126 ** commits the source tree for this plugin127 -->128 <target name="commit-current">129 <echo>Commiting the plugin source with message '${commit.message}' ...</echo>130 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">131 <env key="LANG" value="C"/>132 <arg value="commit"/>133 <arg value="-m '${commit.message}'"/>134 <arg value="."/>135 </exec>136 </target>137 <!--138 ** updates (svn up) the source tree for this plugin139 -->140 <target name="update-current">141 <echo>Updating plugin source ...</echo>142 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">143 <env key="LANG" value="C"/>144 <arg value="up"/>145 <arg value="."/>146 </exec>147 <echo>Updating ${plugin.jar} ...</echo>148 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">149 <env key="LANG" value="C"/>150 <arg value="up"/>151 <arg value="../dist/${plugin.jar}"/>152 </exec>153 </target>154 <!--155 ** commits the plugin.jar156 -->157 <target name="commit-dist">158 <echo>159 ***** Properties of published ${plugin.jar} *****160 Commit message : '${commit.message}'161 Plugin-Mainversion: ${plugin.main.version}162 JOSM build version: ${coreversion.info.entry.revision}163 Plugin-Version : ${version.entry.commit.revision}164 ***** / Properties of published ${plugin.jar} *****165 166 Now commiting ${plugin.jar} ...167 </echo>168 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false">169 <env key="LANG" value="C"/>170 <arg value="-m '${commit.message}'"/>171 <arg value="commit"/>172 <arg value="${plugin.jar}"/>173 </exec>174 </target>175 <!-- ** make sure svn is present as a command line tool ** -->176 <target name="ensure-svn-present">177 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false" failonerror="false" resultproperty="svn.exit.code">178 <env key="LANG" value="C"/>179 <arg value="--version"/>180 </exec>181 <fail message="Fatal: command 'svn --version' failed. Please make sure svn is installed on your system.">182 <!-- return code not set at all? Most likely svn isn't installed -->183 <condition>184 <not>185 <isset property="svn.exit.code"/>186 </not>187 </condition>188 </fail>189 <fail message="Fatal: command 'svn --version' failed. Please make sure a working copy of svn is installed on your system.">190 <!-- error code from SVN? Most likely svn is not what we are looking on this system -->191 <condition>192 <isfailure code="${svn.exit.code}"/>193 </condition>194 </fail>195 </target>196 <target name="publish" depends="ensure-svn-present,core-info,commit-current,update-current,clean,dist,commit-dist">197 </target>198 64 </project> -
applications/editors/josm/plugins/multipoly-convert/src/converttomultipoly/MultipolyAction.java
r23189 r26544 9 9 import java.util.Collection; 10 10 import java.util.HashSet; 11 import java.util.Iterator;12 11 import java.util.LinkedList; 13 12 … … 17 16 import org.openstreetmap.josm.actions.JosmAction; 18 17 import org.openstreetmap.josm.command.AddCommand; 18 import org.openstreetmap.josm.command.ChangePropertyCommand; 19 19 import org.openstreetmap.josm.command.Command; 20 20 import org.openstreetmap.josm.command.SequenceCommand; … … 60 60 for (RelationMember rm : r.getMembers()) { 61 61 OsmPrimitive m = rm.getMember(); 62 if (m instanceof Way ) {62 if (m instanceof Way && rm.getRole().compareTo("inner") != 0) { 63 63 relationsInMulti.add(m); 64 64 } … … 68 68 // List of selected ways 69 69 ArrayList<Way> selectedWays = new ArrayList<Way>(); 70 71 70 72 71 // For every selected way … … 95 94 // Add ways to it 96 95 for (int i = 0; i < selectedWays.size(); i++) { 97 96 Way way = selectedWays.get(i); 98 97 99 100 101 98 // Create new relation 99 Relation rel = new Relation(); 100 rel.put("type", "multipolygon"); 102 101 103 102 RelationMember rm = new RelationMember("outer", way); 104 103 rel.addMember(rm); 105 104 106 for ( Iterator<String> keyi = way.getKeys().keySet().iterator() ; keyi.hasNext() ;) {107 String key = keyi.next();105 for (String key : way.getKeys().keySet()) { 106 if (!key.equals("area") || !way.get(key).equals("yes")) { 108 107 rel.put(key, way.get(key)); 109 System.out.println(key);110 if (key.compareTo("source") != 0) {111 way.remove(key);112 108 } 109 if (!key.equals("source")) { 110 cmds.add(new ChangePropertyCommand(way, key, null)); 111 } 113 112 } 114 115 113 // Add relation 114 cmds.add(new AddCommand(rel)); 116 115 } 117 116 // Commit … … 132 131 /** Enable this action only if something is selected */ 133 132 @Override 134 protected void updateEnabledState( 135 Collection<? extends OsmPrimitive> selection) { 136 setEnabled(selection != null && !selection.isEmpty()); 133 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 134 if (selection == null) { 135 setEnabled(false); 136 return; 137 } 138 for (OsmPrimitive primitive: selection) { 139 if (!(primitive instanceof Way)) { 140 setEnabled(false); 141 return; 142 } 143 if (!((Way)primitive).isClosed()) { 144 setEnabled(false); 145 return; 146 } 147 for (Relation r: OsmPrimitive.getFilteredList(primitive.getReferrers(), Relation.class)) { 148 for (RelationMember rm: r.getMembers()) { 149 if (rm.getMember() == primitive && !"inner".equals(rm.getRole())) { 150 setEnabled(false); 151 return; 152 } 153 } 154 } 155 } 156 setEnabled(selection.size() >= 1); 137 157 } 138 158 } -
applications/editors/josm/plugins/multipoly-convert/src/converttomultipoly/MultipolyPlugin.java
r23189 r26544 17 17 protected String name; 18 18 19 // public MultipolyPlugin(PluginInformation info) {20 19 public MultipolyPlugin(PluginInformation info) { 21 20 super(info);
Note:
See TracChangeset
for help on using the changeset viewer.