Ignore:
Timestamp:
2011-08-16T23:55:53+02:00 (13 years ago)
Author:
sbrunner
Message:

allow inner of other multipolygone, remove area=yes, fix undo, use build-comom.xml

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  
        11build
         2bin
  • applications/editors/josm/plugins/multipoly-convert/.classpath

    r20416 r26544  
    33        <classpathentry kind="src" path="src"/>
    44        <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"/>
    65        <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"/>
    77        <classpathentry kind="output" path="bin"/>
    88</classpath>
  • applications/editors/josm/plugins/multipoly-convert/build.xml

    r26174 r26544  
    3030<project name="multipoly-convert" default="dist" basedir=".">
    3131    <!-- 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})"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <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
    6838    <target name="dist" depends="compile,revision">
     39        <echo message="creating ${ant.project.name}.jar ... "/>
    6940        <copy todir="${plugin.build.dir}/images">
    7041            <fileset dir="images"/>
     
    7344            <fileset dir="data"/>
    7445        </copy>
     46        <copy todir="${plugin.build.dir}">
     47            <fileset dir=".">
     48                <include name="README"/>
     49                <include name="LICENSE"/>
     50            </fileset>
     51        </copy>
    7552        <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
    7653            <manifest>
    7754                <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/multipoly_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"/>
    8158                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    8259                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    83                 <attribute name="Plugin-Link" value="http://www.stephane-brunner.ch/mediawiki/index.php/Plugins"/>
    8460                <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&amp;format=raw" /-->
    8661            </manifest>
    8762        </jar>
    8863    </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 the
    110         ** 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 plugin
    127         -->
    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 plugin
    139         -->
    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.jar
    156         -->
    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>
    19864</project>
  • applications/editors/josm/plugins/multipoly-convert/src/converttomultipoly/MultipolyAction.java

    r23189 r26544  
    99import java.util.Collection;
    1010import java.util.HashSet;
    11 import java.util.Iterator;
    1211import java.util.LinkedList;
    1312
     
    1716import org.openstreetmap.josm.actions.JosmAction;
    1817import org.openstreetmap.josm.command.AddCommand;
     18import org.openstreetmap.josm.command.ChangePropertyCommand;
    1919import org.openstreetmap.josm.command.Command;
    2020import org.openstreetmap.josm.command.SequenceCommand;
     
    6060            for (RelationMember rm : r.getMembers()) {
    6161                OsmPrimitive m = rm.getMember();
    62                 if (m instanceof Way) {
     62                if (m instanceof Way && rm.getRole().compareTo("inner") != 0) {
    6363                    relationsInMulti.add(m);
    6464                }
     
    6868        // List of selected ways
    6969        ArrayList<Way> selectedWays = new ArrayList<Way>();
    70 
    7170
    7271        // For every selected way
     
    9594        // Add ways to it
    9695        for (int i = 0; i < selectedWays.size(); i++) {
    97                 Way way = selectedWays.get(i);
     96            Way way = selectedWays.get(i);
    9897
    99                 // Create new relation
    100                     Relation rel = new Relation();
    101                     rel.put("type", "multipolygon");
     98            // Create new relation
     99            Relation rel = new Relation();
     100            rel.put("type", "multipolygon");
    102101
    103102            RelationMember rm = new RelationMember("outer", way);
    104103            rel.addMember(rm);
    105104
    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")) {
    108107                    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                }
    113112            }
    114                     // Add relation
    115                     cmds.add(new AddCommand(rel));
     113            // Add relation
     114            cmds.add(new AddCommand(rel));
    116115        }
    117116        // Commit
     
    132131    /** Enable this action only if something is selected */
    133132    @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);
    137157    }
    138158}
  • applications/editors/josm/plugins/multipoly-convert/src/converttomultipoly/MultipolyPlugin.java

    r23189 r26544  
    1717    protected String name;
    1818
    19 //        public MultipolyPlugin(PluginInformation info) {
    2019        public MultipolyPlugin(PluginInformation info) {
    2120        super(info);
Note: See TracChangeset for help on using the changeset viewer.