Index: /applications/editors/josm/plugins/public_transport/.checkstyle
===================================================================
--- /applications/editors/josm/plugins/public_transport/.checkstyle	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/.checkstyle	(revision 34718)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+  <local-check-config name="JOSM" location="/JOSM/tools/checkstyle/josm_checks.xml" type="project" description="">
+    <additional-data name="protect-config-file" value="false"/>
+  </local-check-config>
+  <fileset name="all" enabled="true" check-config-name="JOSM" local="true">
+    <file-match-pattern match-pattern="." include-pattern="true"/>
+  </fileset>
+  <filter name="DerivedFiles" enabled="true"/>
+  <filter name="FilesFromPackage" enabled="true">
+    <filter-data value=".svn"/>
+    <filter-data value="data"/>
+    <filter-data value="images"/>
+    <filter-data value="resources"/>
+    <filter-data value="styles"/>
+    <filter-data value="scripts"/>
+  </filter>
+</fileset-config>
Index: /applications/editors/josm/plugins/public_transport/.classpath
===================================================================
--- /applications/editors/josm/plugins/public_transport/.classpath	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/.classpath	(revision 34718)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
+	<classpathentry kind="output" path="build"/>
+</classpath>
Index: /applications/editors/josm/plugins/public_transport/.project
===================================================================
--- /applications/editors/josm/plugins/public_transport/.project	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/.project	(revision 34718)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JOSM-public_transport</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.sonarlint.eclipse.core.sonarlintBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.sonarlint.eclipse.core.sonarlintNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+	</natures>
+</projectDescription>
Index: /applications/editors/josm/plugins/public_transport/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- /applications/editors/josm/plugins/public_transport/.settings/org.eclipse.jdt.core.prefs	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/.settings/org.eclipse.jdt.core.prefs	(revision 34718)
@@ -0,0 +1,115 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.8
Index: /applications/editors/josm/plugins/public_transport/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- /applications/editors/josm/plugins/public_transport/.settings/org.eclipse.jdt.ui.prefs	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/.settings/org.eclipse.jdt.ui.prefs	(revision 34718)
@@ -0,0 +1,60 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_type_arguments=false
Index: /applications/editors/josm/plugins/public_transport/LICENSE
===================================================================
--- /applications/editors/josm/plugins/public_transport/LICENSE	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/LICENSE	(revision 34718)
@@ -0,0 +1,345 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+	51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Index: /applications/editors/josm/plugins/public_transport/README
===================================================================
--- /applications/editors/josm/plugins/public_transport/README	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/README	(revision 34718)
@@ -0,0 +1,123 @@
+
+The JOSM Plugin "Public Transport" is designed to simplify the mapping and editing of public transport routes according to the Oxmoa scheme (see USED NOTIONS). In the first section, we will describe how to create a line from scratch. If there exists already one or more lines running partly or completely parallel, you can take advantage of this (see third section). Also, you can easily convert lines from older mapping formats to the Oxmoa scheme (see fourth section). The last section contains a reference of all items in the plugin.
+
+This manual refers to the prototype version of 2010-01-30. This is not even a beta version, so DON'T FORGET TO SAVE YOUR WORK BEFORE you use this plugin. Later versions may simplify the steps explained below. Feel free to make suggestions for simplications or extra functionality or report bugs to me (mailto:roland.olbricht(at)gmx.de). From the first mature version on, the plugin source code should appear in the OSM SVN and thus the plugin won't any more require any special installation procedures.
+
+
+HOW TO INSTALL
+
+In JOSM: Bearbeiten > Einstellungen, dort Plugins (Stecker) -> Liste laden
+cp public_transport.jar ~/.josm/plugins/
+In JOSM: Bearbeiten > Einstellungen, dort Plugins (Stecker): Public Transport aus der Liste wählen
+JOSM neustarten, Aktualisierung überspringen
+
+
+MAP A BUS LINE FROM SCRATCH
+
+The Oxmoa schema consists of a relation per direction (details see USED NOTIONS) and contains the itinerary (the way a bus actually takes from its starting stop to its terminus) and the stops served by the bus. You need to specify one half of the itinerary, the stops and the back direction can mostly be derived by the software.
+
+Download the area where your bus route takes place. Create a new relation with the standard relation editor and set the tags "type=route", "route=bus" and "ref" set to the line number. Then choose the menue item "Public Transport > Route patterns". Now you can find your route in the list of the main window. Select it and change to the tab "Itinerary". Now select on the map the first way that belongs to your line and press "Add". Mark the second item and press "Add" again. You can select several ways at once and press "Add". If your ways are added in the wrong order or with wrong roles, mark them (click the first entry in the window, then shift-click the last entry in the window) and press "Sort". If there appear one or more lines "[gap]", then your ways don't fit together. If sorting won't solve that, there are gaps in your itinerary and you need to add the missing links or split ways (mark the way, the node where to split at and then use menu "Tools > Split Way") if your bus service only partly uses them. You can delete one or more items from the list by marking them and clicking on "Delete". You can also move one or more items by marking them, clicking on "Mark" (this copies them to the clipboard, like the middle mouse button on X servers), then "Delete", then mark the first item before which you want to insert the items and click "Add".
+
+Now you can add the bus stops in a convienient way: change to the tab "Meta" and press "Suggest Stops". This will compile a list of stops that are near the itinerary. You can choose up to which distance from the itinerary stops should be considered and whether stops only the right hand side, only on the left hand side or on both sides are possible. Now change to the tab "Stops". You can identify stops by marking them and then click "Mark" and/or "Show". Delete spurious stops by marking them and pressing "Delete". Add missing stops by marking them on the map, marking the entry before which you want to insert the stop (unmark all entries if you want to append stops to the end), then press "Add".
+
+
+REUSE A PARTLY PARALLEL LINE
+
+The plugin has an internal clipboard to simplify copying parts of the itinerary or the stops from one bus route to another. Data is put into the clipboard in the X server paradigm. Mark one or more entry from the itinerary list or stops list and click the respective button "Copy". The objects themselves are kept by they state being marked on the map. The plugin additionally saves their order and role. You can paste data from clipboard by using the respective button "Add".
+
+To do this, first choose the source relation at the tab "Overview" and change to the tab "Itinerary". Mark there the entries you want to copy and click "Mark". Then choose at the tab "Overview" your destination relation and mark at the tab "Itinerary" the entry before which you want to paste the entries or unmark all entries if you want to append the data from clipboard.
+
+Stops can be copied in the same way: first choose the source relation at the tab "Overview" and change to the tab "Stops". Mark there the entries you want to copy and click "Mark". Then choose at the tab "Overview" your destination relation and mark at the tab "Stops" the entry before which you want to paste the entries or unmark all entries if you want to append the data from clipboard.
+
+
+REUSE AN OLD RELATION
+
+If you have a bus route in an old format, you can with the help of the plugin spread it into separate relations for both (or more) directions. First, use the standard relation editor of JOSM to duplicate the relation: click on the most lower but one icon on the left toolbar. this opens the relation window on the right. Choose there the relation to duplicate. Click then there on the third button to duplicate the relation, then change "to" and "from" in the opening dialog.
+
+Now open "Public transport > Route patterns ..." and select there the new relation. Change to the tab "Itinerary" and click "Reflect" to reflect the itinerary. If this does not work properly, first click "Sort" to sort the itinerary, then if necessary again "Reflect" to bring them in their proper order.
+
+To edit the bus stops, use one of the functions described above: "Suggest Stops" to have a clean restart from scratch. Or use the buttons in the tab "Stops".
+
+
+USED NOTIONS
+
+Note: I'm not a native English speaker. So if you have suggestions for better wording, please send them to me (mailto:roland.olbricht(at)gmx.de).
+
+...
+https://wiki.openstreetmap.org/wiki/User:Oxomoa/Public_transport_schema#Network_information_.28lines_and_routes.29
+
+
+REFERENCE MANUAL
+
+* Tab "Overview"
+
+- List "Existing route patterns"
+The large list in the center contains all relations that are recognised as bus routes. They are listed with the value of their tag "ref" and the ID of their relation. A relation is considered as bus service if it has the tags "type=route" and "route=bus".
+
+- Button "Refresh"
+This button refreshes the list "Existing route patterns".
+
+
+* Tab "Tags"
+
+The content of this tag is not yet implemented.
+
+
+* Tab "Itinerary"
+
+- List of member ways
+This list contains all the current members of the relation you are editing that are ways. The intended format of a route relation (see Oxmoa scheme at USED NOTIONS above) expects a continuos list of ways that represents the itinerary the bus takes in reality. Whenever two ways don't fit head on tail, a marker "[gap]" is put between them in an extra line to make breaks clearly visible. This is not a member of the relation but just a marker. You can change the role of a way in the right column. To achieve maximum backward compability, you should choose "forward" or "backward". To properly display relations that don't follow the Oxmoa scheme, all other roles including the empty are also displayed and you can choose despite "forward" and "backward" also an empty role.
+
+- Button "Show"
+Ths button changes the view on the map such that all marked entries are visible.
+
+- Button "Mark"
+Ths button marks all entries that are marked in the list as objects on the map and unmarks all other ways. It also copies a list of the marked entries to the plugin's internal clipboard, such that roles and the order can be reconstructed.
+
+- Button "Add"
+This button adds all ways that are currently marked on the map as entries in the list. The entries are added in arbitrary order before the first marked entry. You can order the just added elements by marking them and clicking "Sort".
+
+- Button "Delete"
+This button deletes all currently marked entries.
+
+- Button "Sort"
+If one or more entries are marked, all marked entries are sorted. I.e. their order and role is changed such that they form a continuous itinerary. If this is not possible, the plugin tries to construct long series of continuous sections. If no entries are marked, the entire list are sorted.
+
+- Button "Reflect"
+If one or more entries are marked, their order is reflected and their roles get flipped. I.e. every entry it put after its successor and its role is changed from "backward" to "forward", from "forward" to "backward" or left unchanged if it is empty.
+
+
+* Tab "Stops"
+
+- List of member nodes
+This list contains all the current members of the relation you are editing that are nodes. The intended format of a route relation (see Oxmoa scheme at USED NOTIONS above) expects a list of nodes that represents the stops in the order the bus takes them in reality. The roles can be changed to "forward" or "backward" but due to Oxmoa scheme, they should remain empty.
+
+- Button "Show"
+Ths button changes the view on the map such that all marked entries are visible.
+
+- Button "Mark"
+Ths button marks all entries that are marked in the list as objects on the map and unmarks all other nodes. It also copies a list of the marked entries to the plugin's internal clipboard, such that roles and the order can be reconstructed.
+
+- Button "Add"
+This button adds all ways that are currently marked on the map as entries in the list. The entries are added in arbitrary order before the first marked entry. You can order the just added elements by marking them and clicking "Sort".
+
+- Button "Delete"
+This button deletes all currently marked entries.
+
+- Button "Sort"
+If one or more entries are marked, all marked entries are sorted. The sorting order depends on the itinerary and the settings for the distance limit, the right hand side and the left hand side in the meta "tab": the sorting algorithm attaches each stop to the nearest segment of the itinerary and then orders them in the order they are passed on the itinerary. Then all stops that can't be attached are added to the end of the list.
+
+- Button "Reflect"
+If one or more entries are marked, their order is reflected. I.e. every entry it put after its successor.
+
+
+* Tab "Meta"
+
+- Checkbox "Stops are possible"
+This checkbox controls the behaviour of the button "Suggest stops" and the button "Sort" in the tab "Stops". If you mark only one of the boxes "Right hand side" or "Left hand side", only stops on the respective side are taken into account. If you mark both boxes, stops on both sides are taken into account.
+
+- Text field "Maximum distance from route"
+This textfield also controls the behaviour of the button "Suggest stops" and the button "Sort" in the tab "Stops". Only stops that have a distance less or equal the limit set here are taken into account.
+
+- Button "Suggest stops"
+This button replaces the current list of stops by a list of all stops that are on the itinerary with regard to the setting of the checkboxes and the text field described above.
Index: /applications/editors/josm/plugins/public_transport/build.xml
===================================================================
--- /applications/editors/josm/plugins/public_transport/build.xml	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/build.xml	(revision 34718)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project name="public_transport" default="dist" basedir=".">
+
+    <!-- enter the SVN commit message -->
+    <property name="commit.message" value="Commit message"/>
+    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
+    <property name="plugin.main.version" value="14153"/>
+
+    <property name="plugin.author" value="Roland M. Olbricht"/>
+    <property name="plugin.class" value="org.openstreetmap.josm.plugins.public_transport.PublicTransportPlugin"/>
+    <property name="plugin.description" value="This plugin simplifies the mapping and editing of public transport routes."/>
+    <!-- <property name="plugin.icon" value=""/> -->
+    <property name="plugin.link" value="https://wiki.openstreetmap.org/wiki/JOSM/Plugins/public_transport"/>
+
+    <!-- ** include targets that all plugins have in common ** -->
+    <import file="../build-common.xml"/>
+</project>
Index: /applications/editors/josm/plugins/public_transport/resources/html2wiki.awk
===================================================================
--- /applications/editors/josm/plugins/public_transport/resources/html2wiki.awk	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/resources/html2wiki.awk	(revision 34718)
@@ -0,0 +1,30 @@
+{
+  buf = $0;
+  result = "";
+  match_idx = match(buf, "\<a id=\"[^\"]*\"\/\>");
+  while (match_idx > 0)
+  {
+    result = result substr(buf, 0, match_idx);
+    result = result "<span id=\"" substr(buf, match_idx+7, RLENGTH-10) "\"></span>";
+    buf = substr(buf, match_idx+RLENGTH);
+    match_idx = match(buf, "\<a id=\"[^\"]*\"\/\>");
+  };
+  result = result buf
+
+  buf = result;
+  result = "";
+  match_idx = match(buf, "\<a href=\"[^\"]*\"\>");
+  while (match_idx > 0)
+  {
+    result = result substr(buf, 0, match_idx);
+    result = result "[[" substr(buf, match_idx+9, RLENGTH-11) "|";
+    buf = substr(buf, match_idx+RLENGTH);
+    match_idx = match(buf, "\<\/a\>");
+    result = result substr(buf, 0, match_idx);
+    result = result "]]";
+    buf = substr(buf, match_idx+RLENGTH);
+    match_idx = match(buf, "\<a href=\"[^\"]*\"\>");
+  };
+  result = result buf
+  print result;
+}
Index: /applications/editors/josm/plugins/public_transport/resources/public_transport.html
===================================================================
--- /applications/editors/josm/plugins/public_transport/resources/public_transport.html	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/resources/public_transport.html	(revision 34718)
@@ -0,0 +1,633 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8" lang="en"></meta>
+  <title>Public Transport Plugin for JOSM</title>
+</head>
+<body>
+
+<h1>Public Transport Plugin for JOSM</h1>
+
+<p>
+<a href="#chapter.introduction">Introduction</a> -
+<a href="#chapter.tutorial">Examples how to Use</a> -
+<a href="#chapter.notions">Used Notions</a> -
+<a href="#chapter.items">Reference Manual</a>
+</p>
+
+<div>
+<h2>Table of Contents</h2>
+</div>
+
+<p>
+<a href="#chapter.introduction">Introduction</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.installation">How to Install</a><br/>
+<a href="#chapter.tutorial">Examples how to Use</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.map_waypoints">Map Stops from Waypoints</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.map_stopwatch">Map Stops with a Tracklog and a Stopwatch</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.map_tracklog">Map Stops with a Tracklog only</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.scratch">Map a Bus Line from Scratch</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.parallel">Reuse a partly parallel line</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.legacy">Reuse an Old Relation</a><br/>
+<a href="#chapter.notions">Used Notions</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.clipboard">clipboard</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.entry">entry</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.gpx_file">GPX file</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.itinerary">itinerary</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.line">line</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.mark">mark</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.network">network</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.node">node</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.oxmoa">Oxmoa scheme</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.bus_route">public transport route</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.relation">relation</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.route_type">route type</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.select">select</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.stop">stop</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.track">track</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#notion.way">way</a><br/>
+<a href="#chapter.stops_from_gpx">Create Stops from GPX</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.tracks">Tab <em>Tracks</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.tracks.list">List <em>Tracks in this GPX file</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.settings">Tab <em>Settings</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.settings.type">Combo box <em>Type of stops to add</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.settings.gps">Text field <em>Time on your GPS device</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.settings.stopwatch">Text field <em>Time on your stopwatch</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.settings.time_window">Text field <em>Time window</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.settings.threshold">Text field <em>Move Threshold</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.settings.suggest_stops">Button <em>Suggest Stops</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.trackstops">Tab <em>Stops</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.list">List of created stops</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.find">Button <em>Find</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.show">Button <em>Show</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.mark">Button <em>Mark</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.detach">Button <em>Detach</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.add">Button <em>Add</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.delete">Button <em>Delete</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.trackstops.sort">Button <em>Sort</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.waypoints">Tab <em>Waypoints</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.waypoints.list">List of waypoints in the file</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.waypoints.find">Button <em>Find</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.waypoints.show">Button <em>Show</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.waypoints.mark">Button <em>Mark</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.waypoints.detach">Button <em>Detach</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.waypoints.add">Button <em>Enable</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.waypoints.delete">Button <em>Disable</em></a><br/>
+<a href="#chapter.route_patterns">Route patterns</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.overview">Tab <em>Overview</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.overview.list">List <em>Existing route patterns</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.overview.refresh">Button <em>Refresh</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.overview.new">Button <em>New</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.overview.delete">Button <em>Delete</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.overview.duplicate">Button <em>Duplicate</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.overview.reflect">Button <em>Reflect</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.tags">Tab <em>Tags</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.tags.required">List <em>Required tags</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.tags.common">List <em>Common tags</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.tags.additional">List <em>Additional tags</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.tags.add">Button <em>Add a new Tag</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.itinerary">Tab <em>Itinerary</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.list">List of member ways</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.find">Button <em>Find</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.show">Button <em>Show</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.mark">Button <em>Mark</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.add">Button <em>Add</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.delete">Button <em>Delete</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.sort">Button <em>Sort</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.itinerary.reflect">Button <em>Reflect</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.stops">Tab <em>Stops</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.list">List of member nodes</a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.find">Button <em>Find</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.show">Button <em>Show</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.mark">Button <em>Mark</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.add">Button <em>Add</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.delete">Button <em>Delete</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.sort">Button <em>Sort</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.stops.reflect">Button <em>Reflect</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#section.meta">Tab <em>Meta</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.meta.rightleft">Check box <em>Stops are possible</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.meta.maxdist">Text field <em>Maximum distance from route</em></a><br/>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection.meta.suggest">Button <em>Suggest Stops</em></a><br/>
+</p>
+
+<!-- ==================================================================== //-->
+
+<div>
+<a id="chapter.introduction"/>
+<h2>Introduction</h2>
+</div>
+
+<p>The JOSM Plugin <em>Public Transport</em> is designed to simplify the mapping and editing of public transport routes according to best practice standards (see <a href="#notion.oxmoa">Oxmoa scheme</a>). After some <a href="#section.installation">installation instructions</a>, we start with a chapter about <a href="#chapter.tutorial">usage examples</a>: Mapping public transport means mapping of its stops and its routes. In the <a href="#chapter.tutorial">first three sections</a>, we present different methods of how to map stops and how this plugin can be used to simplify this. The <a href="#section.map_waypoints">first section</a> is about mapping by waypoints. The <a href="#section.map_stopwatch">second section</a> explains how to map with the help of a stopwatch. The <a href="#section.map_tracklog">third section</a> explains mapping by tracklogs only. The subsequent sections are devoted to map routes. In the <a href="#section.scratch">fourth section</a>, we describe how to create a bus route from scratch. If there exists already one or more lines running partly or completely parallel, you can take advantage of this (see <a href="#section.parallel">fifth section</a>). Also, you can easily convert routes from older data formats to the Oxmoa scheme (see <a href="#section.legacy">sixth section</a>). The <a href="#chapter.notions">following chapter</a> explains the notions used along the plug-in. The <a href="#chapter.items">last chapter</a> contains a reference manual of all items in the plug-in.</p>
+
+<p>This manual refers to the version of 2010-04-13. This plug-in is still a beta version, so <strong>don't forget to save your work before and during you use this plug-in</strong>. Feel free to make suggestions for simplifications or extra functionality or report bugs to me (mailto:roland.olbricht(at)gmx.de).</p>
+
+<div>
+<a id="section.installation"/>
+<h3>How to Install</h3>
+</div>
+
+<p>Open JOSM and select from menu <em>Edit > Preferences</em>, then there <em>Plugins > Download list</em>. Check <em>public_transport</em> in the list. Now restart JOSM.</p>
+
+<!-- ==================================================================== //-->
+
+<div>
+<a id="chapter.tutorial"/>
+<h2>Examples how to Use</h2>
+</div>
+
+<p>To map public transport, in particular bus services, means to map stops and routes. The larger part of the work is to map stops; the routes can usually be derived from other information in the map and local knowledge. To properly map the stops, you need a GPS device, because an estimation is almost always surprisingly inexact (even bus stops are often a lot larger than one would expect).</p>
+
+<p>We discuss three different approaches. The basic assumption of all three approaches is that you are mapping the public transport service by actually using it. Take the GPS device, pen and paper with you and ride on the vehicle from its starting point to its terminus. With some cleverness and fortune, you should be able to log forth and back direction within a single ride. Also, all three methods will need more or less post-processing with JOSM and the plugin.</p>
+<ul>
+<li><a href="#section.map_waypoints">Map Stops from Waypoints</a>: this is the most comfortable technique. Depending on your GPS device, you might get a worse precision than possible.</li>
+<li><a href="#section.map_stopwatch">Map Stops with a Tracklog and a Stopwatch</a>: this is the most elaborate approach. You will additionally need a stopwatch.</li>
+<li><a href="#section.map_tracklog">Map Stops with a Tracklog only</a>: simpler but less accurate than the before metioned methods.</li>
+</ul>
+
+
+<div>
+<a id="section.map_waypoints"/>
+<h3>Map Stops from Waypoints</h3>
+</div>
+
+<p>You need a GPS logger which can register waypoints and pen and paper. Get on the vehicle and mark a waypoint at each station: bus stops and tram stops are mapped on the side of the road at their respective sign, all other stops are mapped as part of the railway line. Use pen and paper to note the names of the bus stops and whether they have a shelter or not. I personally also collect stops forth and back during a single ride and thus take also a note whether the stop is in forward or backward direction.</p>
+
+<p>When you are back at your computer, download the collected data from your GPS device into a GPX file: the exact steps depend on your particular device, but in general one of the programs <em>gpsbabel</em>, <em>mtkbabel</em> or <em>bt747</em> may help. They are explained on the respective pages of the wiki.</p>
+
+<p>Once you have created the GPX file, open JOSM. Now choose <a href="#chapter.stops_from_gpx">Create Stops from GPX</a> in the menue <em>Public Transport</em>. This raises first a file selection dialogue. Select here your just generated GPX file. The plugin now generates one stop at every waypoint. Now go to the tab <a href="#section.settings">Settings</a> and select the type of stop you want to create. Open tab <a href="#section.waypoints">Waypoints</a> and click onto the table. Now you can use keyboard shortcuts to edit the stops: <em>Alt-N</em> will focus the stop of the current line in the table and activate the <a href="#subsection.waypoints.list">name</a> cell of this line. <em>Alt-S</em>, <em>Alt-T</em> and <em>Alt-U</em> help you to select the proper type of shelter: <em>Alt-S</em> yields <em>Yes</em>, <em>Alt-T</em> yields <em>No</em> and <em>Alt-U</em> yields <em>implicit</em>. If you don't want to map the shelter, just use only <em>Alt-N</em>. The key combination <em>Alt-D</em> disables the current waypoint and deletes the node associated to it. Now process all waypoints and then close the dialogue. Or process all waypoints, mark the lines they belong to and click <a href="#subsection.waypoints.detach">Detach</a> - this has the same effect. Once you have pressed <a href="#subsection.waypoints.detach">Detach</a>, the nodes are released from the dialogue and complete. Congratulations.</p>
+
+
+<div>
+<a id="section.map_stopwatch"/>
+<h3>Map Stops with a Tracklog and a Stopwatch</h3>
+</div>
+
+<p>You need a GPS logger that displays its current time, pen and paper and a stopwatch that can store sufficently much split times. First, syncronise stopwatch and GPS logger: Note the time the GPS logger has shown in the moment when you have started the stopwatch. Take a split time for every stop you pass: bus stops and tram stops are mapped on the side of the road at their respective sign, all other stops are mapped as part of the railway line. Use pen and paper to note the names of the bus stops and whether they have a shelter or not.</p>
+
+<p>When you are back at your computer, download the collected data from your GPS device into a GPX file: the exact steps depend on your particular device, but in general one of the programs <em>gpsbabel</em>, <em>mtkbabel</em> or <em>bt747</em> may help. They are explained on the respective pages of the wiki.</p>
+
+<p>Once you have created the GPX file, open JOSM. Now choose <a href="#chapter.stops_from_gpx">Create Stops from GPX</a> in the menu <em>Public Transport</em>. This raises first a file selection dialogue. Select here your just generated GPX file. Select in the tab <a href="#section.tracks">Tracks</a> the track to create stops from. Now go to the tab <a href="#section.settings">Settings</a> and select the type of stop you want to create. Put the sync time of the GPS device and the stopwatch in the respective fields. Open tab <a href="#section.trackstops">Stops</a> and click onto the table. Click the button <a href="#subsection.trackstops.add">Add</a> unless you have sufficiently much lines for all your split times. Now enter your split times in the first column. Then proceed as explained in the last paragraph of the <a href="#section.map_waypoints">section before</a>.</p>
+
+
+<div>
+<a id="section.map_tracklog"/>
+<h3>Map Stops with a Tracklog only</h3>
+</div>
+
+<p>N.B.: This apporach requires the software to do some semi-automatic guesswork. Although I've tried several approaches, the software still produces annoyingly much false positive (e.g. halts at traffic lights) and might miss stops (in particular, if the bus has passed them with no stop). Thus you should try to use one of the other two methods (with or without waypoints) first or a combination of these methods. The method might be useful to map stops you have forgotten to record.</p>
+
+<p>You need a GPS logger, pen and paper. Record a GPS track while taking a ride on the route you want to map. Note the names of the bus stops you have passed and whether they have a shelter or not.</p>
+
+<p>When you are back at your computer, download the collected data from your GPS device into a GPX file: the exact steps depend on your particular device, but in general one of the programs <em>gpsbabel</em>, <em>mtkbabel</em> or <em>bt747</em> may help. They are explained on the respective pages of the wiki.</p>
+
+<p>Once you have created the GPX file, open JOSM. Now choose <a href="#chapter.stops_from_gpx">Create Stops from GPX</a> in the menu <em>Public Transport</em>. This raises first a file selection dialogue. Select here your just generated GPX file. Select in the tab <a href="#section.tracks">Tracks</a> the track to create stops from. Now go to the tab <a href="#section.settings">Settings</a> and select the type of stop you want to create. Put the sync time of the GPS device and the stopwatch in the respective fields. Click the button <a href="#subsection.settings.suggest_stops">Suggest stops</a> and open tab <a href="#section.trackstops">Stops</a>. If there are way too much or way too few stops or clusters of stops, adapt the values <a href="#subsection.settings.time_window">Time window</a> and <a href="#subsection.settings.threshold">Move Threshold</a> in the tab <a href="#section.settings">Settings</a>. Now enter in the second column the names of the stops: Mark a line in the table and press <em>Alt-N</em>. This focuses and marks the stop and makes its name editable. If the stop is a false positive, you can delete it with the button <a href="#subsection.trackstops.delete">Delete</a> or <em>Alt-D</em>. All keyboard shortcuts are explained in the <a href="#section.map_waypoints">waypoints section</a>.</p>
+
+<div>
+<a id="section.scratch"/>
+<h3>Map a Bus Line from Scratch</h3>
+</div>
+
+<p>The <a href="#notion.oxmoa">Oxmoa schema</a> consists of a relation per direction and contains the <a href="#notion.itinerary">itinerary</a> (the way a bus actually takes from its starting stop to its terminus) and the <a href="#notion.stop">stops</a> served by the bus. Roughly, you need to enter one direction of the itinerary by hand. The stops and the back direction can mostly be derived from that by the software.</p>
+
+<p>Download the area where your <a href="#notion.bus_route">bus route</a> takes place. Choose the menu item <a href="#chapter.route_patterns">Public Transport > Route patterns</a>. This opens a <a href="#section.overview">window</a> where you can see all <a href="#notion.bus_route">public transport routes</a> existing in the downloaded data set. Create a new relation by clicking on the button <a href="#subsection.overview.new">New</a>. Now change to the tab <a href="#section.tags">Tags</a> and set appropriate values for a least <a href="#notion.route_type">route</a> (the type of public transport), <em>ref</em> (the line number) and <em>to</em> (the destination displayed).</p>
+
+<p>Change to the tab <a href="#section.itinerary">Itinerary</a>. Now select on the map the first way that belongs to your <a href="#notion.bus_route">route</a> and press <a href="#subsection.itinerary.add">Add</a>. Mark the second item and press <a href="#subsection.itinerary.add">Add</a> again. You also can select several ways at once and click <a href="#subsection.itinerary.add">Add</a>. If your ways are added in the wrong order or with wrong roles, <a href="#notion.select">mark</a> them (click the first entry in the window, then shift-click the last entry in the window) and press <a href="#subsection.itinerary.sort">Sort</a>. If there appear one or more lines <em>[gap]</em>, then your ways don't fit together. If <a href="#subsection.itinerary.sort">sorting</a> won't solve that then there are gaps in your <a href="#notion.itinerary">itinerary</a> and you need to add the missing links or split ways (mark the way, the node where to split at and then use menu <em>Tools > Split Way</em>) if your bus service only partly uses them. To help you 
+with the tasks you can:</p>
+
+<ul>
+<li>Highlight the <a href="#notion.way">way</a> in the map corresponding to a <a href="#notion.select">selected</a> <a href="#notion.entry">entry</a> by clicking <a href="#subsection.itinerary.mark">Mark</a>.</li>
+<li>Make visible the <a href="#notion.way">way</a> in the map corresponding to a <a href="#notion.select">selected</a> <a href="#notion.entry">entry</a> by clicking <a href="#subsection.itinerary.show">Show</a>.</li>
+<li>Detect whether there is an <a href="#notion.entry">entry</a> for a given <a href="#notion.way">way</a> in the map: <a href="#notion.select">select</a> the <a href="#notion.way">way</a> on the map and click <a href="#subsection.itinerary.find">Find</a>. Every <a href="#notion.entry">entry</a> in the current <a href="#notion.bus_route">route</a> that refers to that <a href="#notion.way">way</a> is <a href="#notion.select">marked</a>.</li>
+</ul>
+
+<p>There are buttons <a href="#subsection.stops.mark">Mark</a>, <a href="#subsection.stops.show">Show</a> and <a href="#subsection.stops.find">Find</a> with similar functionality in the tab <a href="#section.stops">Stops</a>.</p>
+
+<p>You can delete one or more <a href="#notion.entry">entries</a> from the list by marking them and clicking <a href="#subsection.itinerary.sort">Delete</a>. You can also move one or more entry by marking them, clicking on <a href="#subsection.itinerary.select">Mark</a> (this copies them to the clipboard, like the middle mouse button on X servers), then <a href="#subsection.itinerary.delete">Delete</a>, then mark the first item before which you want to insert the items and click <a href="#subsection.itinerary.add">Add</a>.</p>
+
+<p>Now you can add the <a href="#notion.stop">bus stops</a> in a convenient way: change to the tab <a href="#section.meta">Meta</a> and press <a href="#subsection.meta.suggest">Suggest Stops</a>. This will compile a list of stops that are <a href="#subsection.meta.maxdist">near</a> the itinerary. You can choose up to which <a href="#subsection.meta.maxdist">distance</a> from the itinerary stops should be considered and whether stops only the right hand <a href="#subsection.meta.rightleft">side</a>, only on the left hand <a href="#subsection.meta.rightleft">side</a> or on both <a href="#subsection.meta.rightleft">sides</a> are possible. Now change to the tab <a href="#section.stops">Stops</a>. You can identify the stops by their entries as follows: click <a href="#subsection.stops.mark">Mark</a> and/or <a href="#subsection.stops.sort">Show</a>. Delete spurious entries by marking them and pressing <a href="#subsection.stops.delete">Delete</a>. Add missing stops by <a href="#notion.select">marking</a> them on the map, <a href="#notion.select">marking</a> the <a href="#notion.entry">entry</a> before which you want to insert the stop (<a href="#notion.select">unmark</a> all entries if you want to append stops to the end), then press <a href="#subsection.stops.add">Add</a>.</p>
+
+<p>When you are complete with the forward direction, go back to the tab <a href="#section.overview">Overview</a>. Then click <a href="#subsection.overview.duplicate">Duplicate</a> (this adds a copy of the relation) and click <a href="#subsection.overview.reflect">Reflect</a> (this reflects the copy to become the backward direction). Review the <a href="#notion.itinerary">itinerary</a> in the tab <a href="#section.itinerary">Itinerary</a> and correct oneways passed in the now wrong direction. Then change to the tab <a href="#section.meta">Meta</a> and let you suggest bus stops. Review them. Congratulations, you are done with the entire <a href="#notion.line">bus line</a>.</p>
+
+<div>
+<a id="section.parallel"/>
+<h3>Reuse a partly parallel line</h3>
+</div>
+
+<p>The plug-in has an <a href="#notion.clipboard">internal clipboard</a> to simplify copying parts of the <a href="#section.itinerary">itinerary</a> or the <a href="#section.stops">stops</a> from one <a href="#notion.bus_route">bus route</a> to another. Data is put into the clipboard following the <a href="#notion.clipboard">X server paradigm</a>. Mark one or more <a href="#notion.entry">entries</a> from the <a href="#section.itinerary">itinerary list</a> or <a href="#section.stops">stops list</a> and click the respective button <em>Mark</em> (in <a href="#subsection.itinerary.mark">Itinerary</a>, in <a href="#subsection.stops.mark">Stops</a>). The objects themselves are kept by being marked on the map. The plug-in additionally saves their order and role. You can paste data from <a href="#notion.clipboard">clipboard</a> by using the respective button <em>Add</em> (in <a href="#subsection.itinerary.add">Itinerary</a>, in <a href="#subsection.stops.add">Stops</a>).</p>
+
+<p>To do this, first choose the source <a href="#notion.bus_route">route</a> at the tab <a href="#section.overview">Overview</a> and then change to the tab <a href="#section.itinerary">Itinerary</a>. Mark there the <a href="#notion.entry">entries</a> you want to copy and click <a href="#subsection.itinerary.mark">Mark</a>. Then choose at the tab <a href="#section.overview">Overview</a> your destination relation and mark in the tab <a href="#section.itinerary">Itinerary</a> the entry <a href="#notion.select">before which</a> you want to paste the entries or unmark all entries if you want to append the data from <a href="#notion.clipboard">clipboard</a>.</p>
+
+<p>Stops can be <a href="#notion.clipboard">copied</a> in the same way: first choose the source relation at the tab <a href="#section.overview">Overview</a> and change to the tab <a href="#section.stops">Stops</a>. Mark there the <a href="#notion.entry">entries</a> you want to <a href="#notion.clipboard">copy</a> and click <a href="#subsection.stops.mark">Mark</a>. Then choose at the tab <a href="#section.overview">Overview</a> your destination relation and mark at the tab <a href="#section.stops">Stops</a> the entry <a href="#notion.select">before which</a> you want to paste the entries or unmark all entries if you want to append the data from <a href="#notion.clipboard">clipboard</a>.</p>
+
+
+<div>
+<a id="section.legacy"/>
+<h3>Reuse an Old Relation</h3>
+</div>
+
+<p>If you have a <a href="#notion.bus_route">bus route</a> in an <a href="#notion.bus_route">old format</a>, you can spread it with the help of the plug-in into separate <a href="#notion.relation">relations</a> for both (or more) directions. Go to the tab <a href="#section.overview">Overview</a>, mark the respective relation and click <a href="#subsection.overview.duplicate">Duplicate</a>, then <a href="#subsection.overview.reflect">Reflect</a>. Now you have a relation for each direction. The remaining task is to cleanup the new relations.</p>
+
+<p>First, mark again the first relation. Go to the tab <a href="#section.itinerary">Itinerary</a> and cleanup the <a href="#notion.itinerary">itinerary</a> to contain only the forward direction as described <a href="#section.scratch">above</a>. Now you can use <a href="#subsection.meta.suggest">Suggest Stops</a> from tab <a href="#section.meta">Meta</a> to obtain a good guess for the bus stops. Use the tools in the tab <a href="#section.stops">Stops</a> to cleanup this list.</p>
+
+<p>Now go back to the tab <a href="#section.overview">Overview</a> and select the newly created <a href="#notion.bus_route">route</a>. Proceed with the same steps as for the forward direction. Congratulations, now you have corrected the <a href="#notion.line">bus line</a>.</p>
+
+<!-- ==================================================================== //-->
+
+<div>
+<a id="chapter.notions"/>
+<h2>Used Notions</h2>
+</div>
+
+<p>
+<em>Note</em>: I'm not a native English speaker. Thus, if you have suggestions for better wording, please send them to me (mailto:roland.olbricht(at)gmx.de).
+</p>
+
+<p>
+<a id="notion.clipboard"/>
+<strong>clipboard</strong> - Beside the operating system, the plug-in has an internal clipboard that allows to maintain the order and roles of relation members, in particular bus stops and ways belonging to the itinerary. The clipboard is used similar to the X window system clipboard: there you copy text into the clipboard by marking it with the mouse and paste it by clicking the middle mouse button. We can't assume that every computer has a middle mouse button. Thus, in the plug-in you copy data into the internal clipboard by <a href="#notion.select">marking</a> the entries and clicking <em>Mark</em> (in <a href="#subsection.itinerary.mark">Itinerary</a>, in <a href="#subsection.stops.mark">Stops</a>). You paste data by keeping it <a href="#notion.select">marked</a> on the map and clicking <em>Add</em> (in <a href="#subsection.itinerary.add">Itinerary</a>, in <a href="#subsection.stops.add">Stops</a>).
+</p>
+
+<p>
+<a id="notion.entry"/>
+<strong>entry</strong> - An entry in the list of objects that are members of a <a href="#notion.relation">relation</a>. Here, the relations are <a href="#notion.bus_route">public transport routes</a> and members are <a href="#notion.stop">stops or stations</a> or the <a href="#notion.way">ways</a> that constitute the <a href="#notion.itinerary">itinerary</a>. The notion <em>entry</em> is used to discriminate between the relation members (entries) and the objects referred to by the relation members (objects on the map).
+</p>
+
+<p>
+<a id="notion.gpx_file"/>
+<strong>GPX file</strong> - This is a common file format supported by most GPS loggers. The data you log in the real world, in particular logged stops and stations, get fed into this software as GPX files.
+</p>
+
+<p>
+<a id="notion.itinerary"/>
+<strong>itinerary</strong> - The way a bus service actually takes. Note that buses or other vehicles can't make jumps, thus there cannot be gaps in an itinerary. For that reason, a line <em>[gap]</em> is displayed in the <a href="#subsection.itinerary.list">itinerary list</a> whenever the first <a href="#notion.node">node</a> of a <a href="#notion.way">way</a> differs from the last <a href="#notion.node">node</a> of the preceding <a href="#notion.way">way</a>.
+</p>
+
+<p>
+<a id="notion.line"/>
+<strong>(bus) line</strong> - The notion refers usually to all bus or train services that are offered in a certain <a href="#notion.network">network</a> with the same line identifier. The line identifier for a relation is declared by the tag  <em>ref</em>.
+</p>
+
+<p>
+<a id="notion.mark"/>
+<strong>mark</strong> - see <a href="#notion.select">select</a>.
+</p>
+
+<p>
+<a id="notion.network"/>
+<strong>network</strong> - the set of all services that a organised as a whole by some kind of transport authority. Often, the network is the responsible party for ticket fares. It is used to disambiguate different routes with the same line identifier in different regions. In particular, we assume that in every network a <a href="#notion.line">line identifier</a> is unique, i.e. that all relations with the same line identifier constitute a logical unit. The network is declared by the tag <em>network</em>.
+</p>
+
+<p>
+<a id="notion.node"/>
+<strong>node</strong> - The respective OSM primitive. The only objects represented by nodes here are stops and stations. Nodes are visible in the JOSM main window and a list of nodes as members of the <a href="#notion.bus_route">route</a> <a href="#notion.relation">relation</a> constitutes the served <a href="#notion.stop">stops</a> of a <a href="#notion.bus_route">public transport route</a>.
+</p>
+
+<p>
+<a id="notion.oxmoa"/>
+<strong>Oxmoa scheme</strong>
+- see <a href="https://wiki.openstreetmap.org/wiki/User:Oxomoa/Public_transport_schema">https://wiki.openstreetmap.org/wiki/User:Oxomoa/Public_transport_schema</a>.
+This plug-in implements a subset of the Oxmoa scheme. We implement in particular here the splitting of <a href="#notion.line">bus lines</a> into <a href="#notion.bus_route">bus routes</a>. This allows to display the correct order of an itinerary and stops even if a section is passed twice or several times. The extra relations per line number on top of the bus route relations aren't implemented yet because there is no known use case for them. Also, the concept <em>stop_position</em> has not been implemented as it causes ambiguities: if it is placed on a non-oneway, the direction of the stop_position is unclear.
+</p>
+
+<p>
+In particular, the data model underlying this plug-in is as follows: Every <a href="#notion.stop">bus stop</a> is represented at its road sign by a <a href="#notion.node">node</a> with tag <em>highway=bus_stop</em> which is off the road itself, usually a few meters, depending on the width of the street. Every <a href="#notion.bus_route">bus route</a> (i.e. every service with distinct starting point, ending point or <a href="#notion.itinerary">itinerary</a>) is represented by a relation on its own with tags <em>type=route</em>, <em>route=bus|tram|light_rail|subway|rail</em> and <em>ref</em> set to the line number or <a href="#notion.line">line identifier</a> and <em>network</em> set to the <a href="#notion.network">network</a> the line belongs to. The name tag may be used if the line has a name but it won't appear somewhere. The <a href="#notion.relation">relation</a> contains as members the <a href="#notion.way">ways</a> which constitute the <a href="#notion.itinerary">itinerary</a> the bus actually takes and the <a href="#notion.stop">bus stops</a> in the order they are served. The member role of the <a href="#notion.way">ways</a> is set to either <em>forward</em> or <em>backward</em>, depending on whether the bus passes the street in or against the direction it is drawn in the map.
+</p>
+
+<p>
+<a id="notion.bus_route"/>
+<strong>public transport route</strong> - The pattern of <a href="#notion.itinerary">passed roads</a> and served <a href="#notion.stop">stops</a> by a particular public transport service. A (bus) <a href="#notion.line">line</a> usually consists of two or more (bus) routes but there are exceptions: bus services only operating in one direction or bus services with the same <a href="#notion.line">line number</a> but different branches.
+</p>
+
+<p>
+<a id="notion.relation"/>
+<strong>relation</strong> - The respective OSM primitive. The only objects represented by relations here are the <a href="#notion.bus_route">public transport routes</a>. They are not visible on the JOSM main map but can be edited with this plug-in.
+</p>
+
+<p>
+<a id="notion.route_type"/>
+<strong>Route type</strong> - You don't want to see an international high speed rail service and a local school bus to be mapped in the same way. For this purpose, we need some further taxonomy to classify public transport services into. As a preliminary classification, we use the following:
+</p>
+<ul>
+<li><em>Bus</em>: Any service that operates completely or partly on ordinary streets with rubber tyre vehicles.</li>
+<li><em>Tram</em>: A service that operates on rails, almost always on the surface and often shares space with car traffic.</li>
+<li><em>Light rail</em>: Most newer tram-like services will go into this category. Operates on rails, has most of the time separated tracks, might go underground or overgorund or use wide area railway networks and has usually a level entrance.</li>
+<li><em>Subway</em>: A service that has its tracks grade separated from street traffic but is also apart from wide area railway networks.</li>
+<li><em>Railway</em>: Services that operate on wide area railway networks.</li>
+</ul>
+
+<p>
+<a id="notion.select"/>
+<strong>select</strong> - Unfortunately, there are different things that can be selected. You can and need to mark objects (<a href="#notion.way">ways</a> and <a href="#notion.node">nodes</a>) on the map in the JOSM main window. Or you can mark <a href="#notion.entry">entries</a> in the list in one of the tabs <a href="#section.overview">Overview</a>, <a href="#section.itinerary">Itinerary</a> or <a href="#section.stops">Stops</a>. The former is usually referred to as <em>select on the map</em>, the latter as <em>select an entry</em>. For the <a href="#notion.entry">entries</a> it is sometimes useful to know that you can mark several entries at once by clicking on the first entry, then <em>shift</em>-clicking on the last entry. You can unmark all <a href="#notion.entry">entries</a> as follows: click an entry (this marks it and unmarks all other entries) then <em>Ctrl</em>-click it again (this unmarks this entry).
+</p>
+
+<p>
+<a id="notion.stop"/>
+<strong>stop</strong> - The location where a bus or train calls. It is represented here by the position of the road sign that indicates the bus stop in the real world. In particular, bus stops are always off the road. This is necessary because buses have doors only on one side. Thus, there are no two-directional bus stops. This is in contrast to railway stations: as trains have usually doors on both sides, a train station can and is often used in both directions.
+</p>
+
+<p>
+<a id="notion.track"/>
+<strong>track</strong> - A data structure from GPX files: GPX files are organised as a collection of <a href="#notion.waypoint">waypoints</a> and tracks. While waypoints are just points, each track is a sequence of points representing an arbitrary motion. The track contains the information when the vehicle was where. Usually, a GPS logger starts a new track each time you put its power on.
+</p>
+
+<p>
+<a id="notion.way"/>
+<strong>way</strong> - The respective OSM primitive. It is visible in the JOSM main window and a list of ways constitutes the <a href="#notion.itinerary">itinerary</a> of a <a href="#notion.bus_route">bus route</a>. A way has an orientation from its first <a href="#notion.node">node</a> to its last node. In JOSM, this is visualised by the direction of the arrows that represent the way. Thus, a vehicle can pass a way in or against its orientation. This is indicated by the role of the <a href="#notion.relation">relation</a> membership representing the <a href="#notion.itinerary">itinerary</a>: <em>forward</em> means that the vehicle passes the way in its orientation while <em>backward</em> means the opposite.
+</p>
+
+<!-- ==================================================================== //-->
+
+<div>
+<a id="chapter.stops_from_gpx"/>
+<h2>Create Stops from GPX</h2>
+</div>
+
+<p>If you have a <a href="#notion.gpx_file">GPX file</a> and want to create <a href="#notion.stop">bus stops or stations</a> from it, use this dialogue window. Each time you open this dialogue window, you must select from which GPX file you want to create stops. For this purpose, please choose a file in the file open dialogue window <em>Select GPX file</em>. After you have chosen a file, you can use the subsequently described items. If you close the dialogue window, the generated stops remain as ordinary <a href="#notion.node">nodes</a> in the JOSM dataset - you cannot manage them any more from this dialogue window.</p>
+
+<div>
+<a id="section.tracks"/>
+<h3>Tab <em>Tracks</em></h3>
+</div>
+
+<div><a id="subsection.tracks.list"/></div>
+<h4>List <em>Tracks in this GPX file</em></h4>
+<p> The large list in the center contains all <a href="#notion.track">tracks</a> that have been found in the <a href="#notion.gpx_file">GPX file</a>. They are described by their name. The features in the tabs <a href="#section.settings">Settings</a> and <a href="#section.trackstops">Stops</a> depend on the content of the track and can only be used if you choose a track here.</p>
+
+<div>
+<a id="section.settings"/>
+<h3>Tab <em>Settings</em></h3>
+</div>
+
+<p>In this tab you configure the values for the nodes you create or manage with the dialogue window.  Depending on the method you use to create stops, different parts of this tab might be relevant:</p>
+<ul>
+<li>If you map from <a href="#notion.waypoint">waypoints</a>, only the combo box <a href="#subsection.settings.type">Type of stops to add</a> is relevant to you.</li>
+<li>If you map with a tracklog and a stopwatch, also the text fields <a href="#subsection.settings.gps">Time on your GPS device</a> and <a href="#subsection.settings.stopwatch">Time on your stopwatch</a> are relevant.</li>
+<li>If you map with a tracklog only and want to use heuristics, every item in this dialogue window but the text field <em>Time on your stopwatch</em> is relevant.</li>
+</ul>
+
+<div><a id="subsection.settings.type"/></div>
+<h4>Combo box <em>Type of stops to add</em></h4>
+<p>Choose here which kind of <a href="#notion.stop">stops</a> you want to generate. Available options are <a href="#notion.route_type">bus</a> stops, <a href="#notion.route_type">tram</a> stops, <a href="#notion.route_type">light rail</a> stations, <a href="#notion.route_type">subway</a> stations and <a href="#notion.route_type">rail</a>way stations.</p>
+
+<div><a id="subsection.settings.gps"/></div>
+<h4>Text field <em>Time on your GPS device</em></h4>
+<p>If you map with a tracklog and a stopwatch, put here the time on your GPS device when you have synchronised your logger and your stopwatch. For other mapping methods, this field is meaningless. It is initially set to the time of the first trackpoint in the track.</p>
+
+<div><a id="subsection.settings.stopwatch"/></div>
+<h4>Text field <em>Time on your stopwatch</em></h4>
+<p>If you map with a tracklog and a stopwatch, put here the time on your stopwatch when you have synchronised your logger and your stopwatch. Usually, this will be zero. If you map with a tracklog only, set this field to the same value as <a href="#subsection.settings.gps">Time on your GPS device</a>. Then you can see the real GPS times of the points where the software guesses the <a href="#notion.stop">stops</a> to be. For other mapping methods, this field is meaningless.</p>
+
+<div><a id="subsection.settings.time_window"/></div>
+<h4>Text field <em>Time window</em></h4>
+<p>This field influences the behaviour of the <a href="#subsection.settings.suggest_stops">suggest stops</a> feature. It indicates for how much the tracklog must remain at (almost) the same position to guess the location to be a <a href="#notion.stop">stop</a>.</p>
+
+<div><a id="subsection.settings.threshold"/></div>
+<h4>Text field <em>Move Threshold</em></h4>
+<p>This field influences the behaviour of the <a href="#subsection.settings.suggest_stops">suggest stops</a> feature. It indicates for what amount of meters the position in a tracklog may move to still assume the location to be a <a href="#notion.stop">stop</a>. It also sets the minimum distance between two stops: a location is only guessed to be a stop if it is at least this amount of meters away from the last guessed stop.</p>
+
+<div><a id="subsection.settings.suggest_stops"/></div>
+<h4>Button <em>Suggest Stops</em></h4>
+<p>Creates a collection of nodes from the <a href="#subsection.tracks.list">selected track</a> at all the positions where the vehicle has stopped. This feature works with heuristics and is thus configurable to fit best to the characteristics of the GPS logger (in particular, its exactitude) and the journey made: the software assumes a stop when the tracklog remains <a href="#subsection.settings.time_window">for a certain time</a> (by default, 20 seconds) within <a href="#subsection.settings.threshold">a certain distance</a> (by default, 20 meters). If the software generates too few stops, you should try to raise distance or afterwards to lower time. If the software generates clusters of stops, you should try to raise distance. If the software generates too much stops, try to lower distance.</p>
+
+<div>
+<a id="section.trackstops"/>
+<h3>Tab <em>Stops</em></h3>
+</div>
+
+<p>This tab is only accessible if you have selected a track from <a href="#subsection.tracks.list">Tracks in this GPX file</a> in the tab <a href="#section.tracks">Tracks</a>. You can ignore this tab if you have mapped the stops by using <a href="#notion.waypoint">waypoints</a>.</p>
+
+<div><a id="subsection.trackstops.list"/></div>
+<h4>List of created stops</h4>
+<p>This list contains all the <a href="#notion.node">nodes</a> created from the current <a href="#notion.track">track</a> and still managed by the dialogue window. The tag that identifies such a node as a certain kind of <a href="#notion.stop">stop</a> is set according to <a href="#subsection.settings.type">Type of stops to add</a>. The two other important tags are <em>name</em> and <em>shelter</em>: <em>name</em> should be set to the name of the stop, <em>shelter</em> can be set to <em>yes</em> (there is a shelter), <em>no</em> (there is no shelter) or <em>implicit</em> (there is no shelter but some other kind of rain protection, e.g. the stop is situated below a bridge). If you don't have noted whether there were shelters, you can leave the tag empty (this is the default). These values are edited in the second and third column. The first column specifies the stopwatch time when the tracklog has passed this point. You can edit this column as well and input the values from you stopwatch record if you have mapped with tracklog and stopwatch.</p>
+
+<div><a id="subsection.trackstops.find"/></div>
+<h4>Button <em>Find</em></h4>
+<p>Detects lines in the <a href="#subsection.trackstops.list">list of created stops</a> whose corresponding nodes are <a href="#notion.select">marked</a> on the map. Mark one or more nodes on the map. Then a click on <em>Find</em> <a href="#notion.select">marks</a> the created nodes for the current <a href="#notion.track">track</a> that are currently marked on the map.</p>
+
+<div><a id="subsection.trackstops.show"/></div>
+<h4>Button <em>Show</em></h4>
+<p>Changes the view on the map such that all <a href="#notion.node">nodes</a> belonging to a <a href="#notion.select">marked</a> line in the <a href="#subsection.trackstops.list">list of created stops</a> become visible. If no entry is marked, then the view will show all <a href="#notion.node">nodes</a> belonging to a line in the list.</p>
+
+<div><a id="subsection.trackstops.mark"/></div>
+<h4>Button <em>Mark</em></h4>
+<p><a href="#notion.select">Marks</a> all <a href="#notion.node">nodes</a> belonging to a <a href="#notion.select">marked</a> line in the <a href="#subsection.trackstops.list">list of created stops</a> and unmarks all other <a href="#notion.node">nodes</a>.</p>
+
+<div><a id="subsection.trackstops.detach"/></div>
+<h4>Button <em>Detach</em></h4>
+<p>Detaches the nodes belonging to <a href="#notion.select">marked</a> lines in the <a href="#subsection.trackstops.list">list of created stops</a>. In particular, the dialogue window no more manages these <a href="#notion.node">nodes</a>. You can use this functionality for example to generate <a href="#notion.stop">stops</a> of one type first, then detach these nodes, then <a href="#subsection.settings.type">change the type</a> of nodes to generate and treat the other stops.</p>
+
+<div><a id="subsection.trackstops.add"/></div>
+<h4>Button <em>Add</em></h4>
+<p>Adds a line to the <a href="#subsection.trackstops.list">list of created stops</a> before the first marked entry. If no line is marked, then the new line is appended. New lines contain always <em>00:00:00.000</em> as a default time and don't have a node associated yet. The node gets associated when you start to edit this line by setting the time, a name or the shelter status.</p>
+
+<div><a id="subsection.trackstops.delete"/></div>
+<h4>Button <em>Delete</em></h4>
+<p>This button deletes all currently marked lines in the <a href="#subsection.trackstops.list">list of created stops</a> and their associated nodes. If no line is marked, then all lines are deleted.</p>
+
+<div><a id="subsection.trackstops.sort"/></div>
+<h4>Button <em>Sort</em></h4>
+<p>Exists for your convenience only and allows to sort the marked lines in the <a href="#subsection.trackstops.list">list of created stops</a> by their time. It doesn't change the associations between the lines and their <a href="#notion.node">nodes</a>. If no line is marked, then all lines are sorted.</p>
+
+<div>
+<a id="section.waypoints"/>
+<h3>Tab <em>Waypoints</em></h3>
+</div>
+
+<p>This tab only contains useful information if your <a href="#notion.gpx_file">GPX file</a> contains <a href="#notion.waypoint">waypoints</a>.</p>
+
+<div><a id="subsection.waypoints.list"/></div>
+<h4>List of waypoints in the file</h4>
+<p>This list contains all the <a href="#notion.node">nodes</a> created from the current <a href="#notion.waypoint">waypoints</a> and still managed by the dialogue window. Each line corresponds to a waypoint from the <a href="#notion.gpx_file">GPX file</a>. Thus, line can neither be deleted or added. Only the node corresponding to a particular line can be <a href="#subsection.waypoints.add">enabled</a> or <a href="#subsection.waypoints.delete">disabled</a>. The tag that identifies such a node as a certain kind of <a href="#notion.stop">stop</a> is set according to <a href="#subsection.settings.type">Type of stops to add</a>. The two other important tags are <em>name</em> and <em>shelter</em>: <em>name</em> should be set to the name of the stop, <em>shelter</em> can be set to <em>yes</em> (there is a shelter), <em>no</em> (there is no shelter) or <em>implicit</em> (there is no shelter but some other kind of rain protection, e.g. the stop is situated below a bridge). If you don't have noted whether there were shelters, you can leave the tag empty (this is the default). These values are edited in the second and third column. The first column contains the name of the respective waypoint.</p>
+
+<div><a id="subsection.waypoints.find"/></div>
+<h4>Button <em>Find</em></h4>
+<p>Detects lines in the <a href="#subsection.waypoints.list">list of waypoints</a> whose corresponding nodes are <a href="#notion.select">marked</a> on the map. Mark one or more nodes on the map. Then a click on <em>Find</em> <a href="#notion.select">marks</a> the created nodes that are currently marked on the map.</p>
+
+<div><a id="subsection.waypoints.show"/></div>
+<h4>Button <em>Show</em></h4>
+<p>Changes the view on the map such that all <a href="#notion.node">nodes</a> belonging to a <a href="#notion.select">marked</a> line in the <a href="#subsection.waypoints.list">list of waypoints</a> become visible. If no entry is marked, then the view will show all <a href="#notion.node">nodes</a> belonging to a line in the list.</p>
+
+<div><a id="subsection.waypoints.mark"/></div>
+<h4>Button <em>Mark</em></h4>
+<p><a href="#notion.select">Marks</a> all <a href="#notion.node">nodes</a> belonging to a <a href="#notion.select">marked</a> line in the <a href="#subsection.waypoints.list">list of waypoints</a> and unmarks all other <a href="#notion.node">nodes</a>.</p>
+
+<div><a id="subsection.waypoints.detach"/></div>
+<h4>Button <em>Detach</em></h4>
+<p>Detaches the nodes belonging to <a href="#notion.select">marked</a> lines in the <a href="#subsection.waypoints.list">list of waypoints</a>. In particular, the dialogue window no more manages these <a href="#notion.node">nodes</a>. You can use this functionality for example to generate <a href="#notion.stop">stops</a> of one type first, then detach these nodes, then <a href="#subsection.settings.type">change the type</a> of nodes to generate and treat the other stops.</p>
+
+<div><a id="subsection.waypoints.add"/></div>
+<h4>Button <em>Enable</em></h4>
+<p>Adds <a href="#notion.node">nodes</a> to all lines in the <a href="#subsection.waypoints.list">list of waypoints</a> that are <a href="#notion.select">marked</a> and don't have a node yet. If no line is marked, then all lines that don't have a node yet are invoked.</p>
+
+<div><a id="subsection.waypoints.delete"/></div>
+<h4>Button <em>Disable</em></h4>
+<p>Deletes <a href="#notion.node">nodes</a> from all lines in the <a href="#subsection.waypoints.list">list of waypoints</a> that are <a href="#notion.select">marked</a> and have an associated node. If no line is marked, then all lines that have an associated node are invoked.</p>
+
+<!-- ==================================================================== //-->
+
+<div>
+<a id="chapter.route_patterns"/>
+<h2>Route patterns</h2>
+</div>
+
+<div>
+<a id="section.overview"/>
+<h3>Tab <em>Overview</em></h3>
+</div>
+
+<div><a id="subsection.overview.list"/></div>
+<h4>List <em>Existing route patterns</em></h4>
+<p>The large list in the center contains all relations that are recognised as <a href="#notion.bus_route">public transport routes</a>. They are listed with the value of their tag <em>ref</em>, the value of their tag <em>to</em> and the ID of their <a href="#notion.relation">relation</a>. A relation is considered as public transport service if it has the tags <em>type=route</em> and <em>route</em> is set to one of the values <em>bus</em>, <em>tram</em>, <em>light_rail</em>, <em>subway</em> or <em>rail</em>.</p>
+
+<div><a id="subsection.overview.refresh"/></div>
+<h4>Button <em>Refresh</em></h4>
+<p>This button refreshes the list <em>Existing route patterns</em>.</p>
+
+<div><a id="subsection.overview.new"/></div>
+<h4>Button <em>New</em></h4>
+<p>This button generates a new <a href="#notion.bus_route">route pattern</a>.</p>
+
+<div><a id="subsection.overview.delete"/></div>
+<h4>Button <em>Delete</em></h4>
+<p>This button deletes the currently marked <a href="#notion.bus_route">route pattern</a>.</p>
+
+<div><a id="subsection.overview.duplicate"/></div>
+<h4>Button <em>Duplicate</em></h4>
+<p>This button makes a copy of the currently marked <a href="#notion.bus_route">route pattern</a>.</p>
+
+<div><a id="subsection.overview.reflect"/></div>
+<h4>Button <em>Reflect</em></h4>
+<p>This button changes the direction of the <a href="#notion.bus_route">route pattern</a>: the values of the tags <em>to</em> and <em>from</em> are exchanged and the <a href="#subsection.itinerary.reflect">itinerary</a> and the <a href="#subsection.stops.reflect">list of the stops</a> are reflected.</p>
+
+
+<div>
+<a id="section.tags"/>
+<h3>Tab <em>Tags</em></h3>
+</div>
+
+<div><a id="subsection.tags.required"/></div>
+<h4>List <em>Required tags</em></h4>
+<p>The list contains the five tags that every <a href="#notion.bus_route">public transport route</a> must have:</p>
+<ul>
+<li><em>type</em>: Must always have the value <em>route</em>.</li>
+<li><em>route</em>: Designates the kind of vehicle that performs the service. It can be set to one of the values <em>bus</em>, <em>tram</em>, <em>light_rail</em>, <em>subway</em> or <em>rail</em>.</li>
+<li><em>ref</em>: The <a href="#notion.line">line identifier</a> of the route.</li>
+<li><em>to</em>: The destination shown in front of the vehicle and/or at the platform to clarify the direction of the service. It is usually the name of the terminus. Compare the tag <a href="#subsection.tags.common">direction</a>.</li>
+<li><em>network</em>: The <a href="#notion.network">network</a> this route belongs to.</li>
+</ul>
+
+<div><a id="subsection.tags.common"/></div>
+<h4>List <em>Common tags</em></h4>
+<p>The list contains further tags which are quite common for <a href="#notion.bus_route">public transport routes</a>:</p>
+<ul>
+<li><em>direction</em>: The destination shown in front of the vehicle and/or at the platform (an alternative for the tag <a href="#subsection.tags.required">to</a>).</li>
+<li><em>from</em>: The origin of this route. Usually the first station.</li>
+<li><em>operator</em>: The company that runs this service.</li>
+<li><em>color</em>: If the <a href="#notion.line">line</a> has a designated color then set this tag to it. It should be either a valid keyword (see <a href="http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#color-units">W3C specification</a>), i.e. <span style="color:aqua;">aqua</span>, <span style="color:black;">black</span>, <span style="color:blue;">blue</span>, <span style="color:fuchsia;">fuchsia</span>, <span style="color:gray;">gray</span>, <span style="color:green;">green</span>, <span style="color:lime;">lime</span>, <span style="color:maroon;">maroon</span>, <span style="color:navy;">navy</span>, <span style="color:olive;">olive</span>, <span style="color:purple;">purple</span>, <span style="color:red;">red</span>, <span style="color:silver;">silver</span>, <span style="color:teal;">teal</span>, <em>white</em> or <span style="color:yellow;">yellow</span>. Or a RGB value, i.e. a # followed by six hexadecimal values.</li>
+<li><em>name</em>: If the <a href="#notion.bus_route">route</a> has a particular name, then add it here. Unlike ref, this is neither displayed anywhere nor needs it to fulfil any uniqueness properties.</li>
+</ul>
+
+<div><a id="subsection.tags.additional"/></div>
+<h4>List <em>Additional tags</em></h4>
+<p>Additional tags can be added here. These tags might be of use for specific software or describe special local features but aren't part of the <a href="#notion.oxmoa">standard data format</a>. If you leave a key empty or delete the key, the respective key will be removed from the <a href="#notion.relation">relation</a>.</p>
+
+<div><a id="subsection.tags.add"/></div>
+<h4>Button <em>Add a new Tag</em></h4>
+<p>This adds an empty line to the <a href="#subsection.tags.additional">additional tags list</a>.</p>
+
+<div>
+<a id="section.itinerary"/>
+<h3>Tab <em>Itinerary</em></h3>
+</div>
+
+<div><a id="subsection.itinerary.list"/></div>
+<h4>List of member ways</h4>
+<p>This list contains all the current members of the <a href="#notion.relation">relation</a> you are editing that are <a href="#notion.way">ways</a>. The <a href="#notion.oxmoa">intended format</a> of a route relation expects a continuous list of ways that represents the <a href="#notion.itinerary">itinerary</a> the vehicle takes in reality. Whenever two <a href="#notion.way">ways</a> don't fit head on tail, a marker <em>[gap]</em> is put between the two corresponding <a href="#notion.entry">entries</a> in an extra line to make breaks clearly visible. This is not a member of the <a href="#notion.relation">relation</a> but just a marker. You can change the role of a way in the right column. Choose <em>forward</em> if the vehicle passes the way <a href="#notion.way">along</a> the orientation of the way and <em>backward</em> if the vehicle passes the way <a href="#notion.way">against</a> the orientation of the way. To properly display <a href="#notion.relation">relations</a> that don't follow the <a href="#notion.oxmoa">Oxmoa scheme</a>, all other roles including the empty role are also displayed and you can choose despite <em>forward</em> and <em>backward</em> also an empty role.</p>
+
+<div><a id="subsection.itinerary.find"/></div>
+<h4>Button <em>Find</em></h4>
+<p>Detects <a href="#notion.entry">entries</a> whose corresponding objects are <a href="#notion.select">marked</a> on the map. Mark one or more ways on the map. Then a click on <em>Find</em> <a href="#notion.select">marks</a> every <a href="#notion.entry">entry</a> in the current <a href="#notion.relation">relation</a> that corresponds to a <a href="#notion.way">way</a> currently marked on the map.</p>
+
+<div><a id="subsection.itinerary.show"/></div>
+<h4>Button <em>Show</em></h4>
+<p>This button changes the view on the map such that all <a href="#notion.way">ways</a> belonging to a <a href="#notion.select">marked</a> <a href="#notion.entry">entry</a> become visible. If no entry is marked, then the view will show all <a href="#notion.way">ways</a> belonging to an entry.</p>
+
+<div><a id="subsection.itinerary.mark"/></div>
+<h4>Button <em>Mark</em></h4>
+<p>This button <a href="#notion.select">marks</a> all <a href="#notion.entry">entries</a> that are marked in the list as ways on the map and unmarks all other <a href="#notion.way">ways</a>. It also copies a list of the marked entries to the plug-in's <a href="#notion.clipboard">internal clipboard</a>, such that roles and the order can be reconstructed. If no <a href="#notion.entry">entry</a> is marked, then all objects belonging to an entry are marked and copied to the clipboard.</p>
+
+<div><a id="subsection.itinerary.add"/></div>
+<h4>Button <em>Add</em></h4>
+<p>This button adds all <a href="#notion.way">ways</a> that are currently <a href="#notion.select">marked</a> on the map as <a href="#notion.entry">entries</a> in the list. The entries are added in arbitrary order before the first marked entry. If no entry is marked, then the new entries will be appended. You can order the just added elements by marking them and clicking <a href="#subsection.itinerary.sort">Sort</a>.</p>
+
+<div><a id="subsection.itinerary.delete"/></div>
+<h4>Button <em>Delete</em></h4>
+<p>This button deletes all currently marked <a href="#notion.entry">entries</a>.</p>
+
+<div><a id="subsection.itinerary.sort"/></div>
+<h4>Button <em>Sort</em></h4>
+<p>If one or more <a href="#notion.entry">entries</a> are marked, all marked <a href="#notion.entry">entries</a> are sorted. I.e. their order and role is changed such that they form a continuous <a href="#notion.itinerary">itinerary</a>. If this is not possible, the plug-in tries to construct long continuous sequences of sections. If no <a href="#notion.entry">entries</a> are <a href="#notion.select">marked</a>, the <a href="#subsection.itinerary.list">entire list</a> is sorted.</p>
+
+<div><a id="subsection.itinerary.reflect"/></div>
+<h4>Button <em>Reflect</em></h4>
+<p>If one or more <a href="#notion.entry">entries</a> are <a href="#notion.select">marked</a>, their order is reflected and their roles get swapped between <em>forward</em> and <em>backward</em>, i.e. every <a href="#notion.entry">entry</a> is put after its successor. If no entry is marked, then the <a href="#subsection.itinerary.list">entire list</a> will be reflected.</p>
+
+
+<div>
+<a id="section.stops"/>
+<h3>Tab <em>Stops</em></h3>
+</div>
+
+<div><a id="subsection.stops.list"/></div>
+<h4>List of member nodes</h4>
+<p>This list contains all the current members of the <a href="#notion.relation">relation</a> you are editing that are <a href="#notion.node">nodes</a>. The <a href="#notion.oxmoa">intended format</a> of a route relation expects a list of <a href="#notion.node">nodes</a> that represents the <a href="#notion.stop">stops</a> in the order the bus takes them in reality. The roles can be changed to <em>forward_stop</em> or <em>backward_stop</em> but according to <a href="#notion.oxmoa">Oxmoa scheme</a>, they should remain empty.</p>
+
+<div><a id="subsection.stops.find"/></div>
+<h4>Button <em>Find</em></h4>
+<p>Detects <a href="#notion.entry">entries</a> whose corresponding objects are <a href="#notion.select">marked</a> on the map. Mark one or more nodes on the map. Then a click on <em>Find</em> <a href="#notion.select">marks</a> every <a href="#notion.entry">entry</a> in the current <a href="#notion.relation">relation</a> that corresponds to a <a href="#notion.node">node</a> currently marked on the map.</p>
+
+<div><a id="subsection.stops.show"/></div>
+<h4>Button <em>Show</em></h4>
+<p>This button changes the view on the map such that all <a href="#notion.node">nodes</a> belonging to a <a href="#notion.select">marked</a> <a href="#notion.entry">entry</a> become visible. If no entry is marked, then the view will show all <a href="#notion.node">nodes</a> belonging to an entry.</p>
+
+<div><a id="subsection.stops.mark"/></div>
+<h4>Button <em>Mark</em></h4>
+<p>This button <a href="#notion.select">marks</a> all <a href="#notion.entry">entries</a> that are marked in the list as nodes on the map and unmarks all other <a href="#notion.node">nodes</a>. It also copies a list of the marked entries to the plug-in's <a href="#notion.clipboard">internal clipboard</a>, such that roles and the order can be reconstructed. If no <a href="#notion.entry">entry</a> is marked, then all objects belonging to an entry are marked and copied to the clipboard.</p>
+
+<div><a id="subsection.stops.add"/></div>
+<h4>Button <em>Add</em></h4>
+<p>This button adds all <a href="#notion.node">nodes</a> that are currently <a href="#notion.select">marked</a> on the map as <a href="#notion.entry">entries</a> in the list. The entries are added in arbitrary order before the first marked entry. If no entry is marked, then the new entries will be appended. You can order the just added elements by marking them and clicking <a href="#subsection.stops.sort">Sort</a>.</p>
+
+<div><a id="subsection.stops.delete"/></div>
+<h4>Button <em>Delete</em></h4>
+<p>This button deletes all currently marked <a href="#notion.entry">entries</a>.</p>
+
+<div><a id="subsection.stops.sort"/></div>
+<h4>Button <em>Sort</em></h4>
+<p>If one or more <a href="#notion.entry">entries</a> are <a href="#notion.select">marked</a>, all marked entries are sorted. The sorting order depends on the <a href="#notion.itinerary">itinerary</a>, the settings for the <a href="#subsection.meta.maxdist">distance limit</a> and the <a href="#subsection.meta.rightleft">orientation check box</a>: the sorting algorithm attaches each <a href="#notion.stop">stop</a> to the nearest segment of the <a href="#notion.itinerary">itinerary</a> and then orders them in the order they are passed on the <a href="#notion.itinerary">itinerary</a>. Then all <a href="#notion.stop">stops</a> that can't be attached are added to the end of the list. If no <a href="#notion.entry">entry</a> is marked, all entries are sorted.</p>
+
+<div><a id="subsection.stops.reflect"/></div>
+<h4>Button <em>Reflect</em></h4>
+<p>If one or more <a href="#notion.entry">entries</a> are marked, their order is reflected. I.e. every <a href="#notion.entry">entry</a> is put after its successor.</p>
+
+<div>
+<a id="section.meta"/>
+<h3>Tab <em>Meta</em></h3>
+</div>
+
+<div><a id="subsection.meta.rightleft"/></div>
+<h4>Check box <em>Stops are possible</em></h4>
+<p>This check box controls the behaviour of the button <a href="#subsection.meta.suggest">Suggest stops</a> and the button <a href="#subsection.stops.sort">Sort</a> in the tab <a href="#section.stops">Stops</a>. If you <a href="#notion.select">mark</a> only one of the boxes <em>Right hand side</em> or <em>Left hand side</em>, only <a href="#notion.stop">stops</a> on the respective side are taken into account. If you mark both boxes, stops on both sides are taken into account.</p>
+
+<div><a id="subsection.meta.maxdist"/></div>
+<h4>Text field <em>Maximum distance from route</em></h4>
+<p>This text field also controls the behaviour of the button <a href="#subsection.meta.suggest">Suggest stops</a> and the button <a href="#subsection.stops.sort">Sort</a> in the tab <a href="#section.stops">Stops</a>. Only <a href="#notion.stop">stops</a> that have a distance less or equal the limit set here are taken into account.</p>
+
+<div><a id="subsection.meta.suggest"/></div>
+<h4>Button <em>Suggest Stops</em></h4>
+<p>This button replaces the current <a href="#subsection.stops.list">list of stops</a> by a list of all stops that are close to the <a href="#notion.itinerary">itinerary</a> with regard to the setting of the <a href="#subsection.meta.rightleft">check boxes</a> and the <a href="#subsection.meta.maxdist">text field</a> described above.</p>
+
+</body>
+</html>
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/AStarAlgorithm.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/AStarAlgorithm.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/AStarAlgorithm.java	(revision 34718)
@@ -0,0 +1,121 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Vector;
+
+public abstract class AStarAlgorithm {
+    // The following abstract functions and subclasses must be overridden by a class using
+    // AStarAlgorithm.
+
+    public abstract static class Vertex implements Comparable<Vertex> {
+        @Override
+        public abstract int compareTo(Vertex v);
+    }
+
+    public abstract static class Edge {
+        public abstract Vertex getBegin();
+
+        public abstract Vertex getEnd();
+
+        public abstract double getLength();
+    }
+
+    public abstract Vector<Edge> getNeighbors(Vertex vertex);
+
+    public abstract double estimateDistance(Vertex vertex);
+
+    // end of interface to override -------------------------------------------
+
+    public AStarAlgorithm(Vertex begin, Vertex end) {
+        this.begin = begin;
+        this.end = end;
+        openList = new TreeMap<>();
+        closedList = new TreeSet<>();
+        pathTail = new TreeMap<>();
+    }
+
+    public Vertex determineCurrentStart() {
+        Vertex minVertex = null;
+        double minDist = 0;
+        Iterator<Map.Entry<Vertex, Double>> iter = openList.entrySet().iterator();
+        while (iter.hasNext()) {
+            Map.Entry<Vertex, Double> entry = iter.next();
+            double distance = entry.getValue().doubleValue() + estimateDistance(entry.getKey());
+            if (minVertex == null || distance < minDist) {
+                minDist = distance;
+                minVertex = entry.getKey();
+            }
+        }
+        if (minVertex != null) {
+            System.out.print(openList.get(minVertex).doubleValue());
+            System.out.print("\t");
+            System.out.println(minDist);
+        }
+
+        return minVertex;
+    }
+
+    Vector<Edge> shortestPath() {
+        // Travel through the network
+        Vertex currentStart = begin;
+        openList.put(currentStart, 0.0);
+        while (currentStart != null && !currentStart.equals(end)) {
+            double startDistance = openList.get(currentStart).doubleValue();
+
+            // Mark currentStart as visited.
+            openList.remove(currentStart);
+            closedList.add(currentStart);
+
+            Iterator<Edge> neighbors = getNeighbors(currentStart).iterator();
+            while (neighbors.hasNext()) {
+                Edge edge = neighbors.next();
+
+                // Don't walk back.
+                if (closedList.contains(edge.getEnd()))
+                    continue;
+
+                // Update entry in openList
+                Double knownDistance = openList.get(edge.getEnd());
+                double distance = startDistance + edge.getLength();
+
+                if (knownDistance == null || distance < knownDistance.doubleValue()) {
+                    openList.put(edge.getEnd(), distance);
+                    pathTail.put(edge.getEnd(), edge);
+                }
+            }
+
+            currentStart = determineCurrentStart();
+        }
+
+        if (currentStart == null)
+            return null;
+
+        // Reconstruct the found path
+        Vector<Edge> backwards = new Vector<>();
+        Vertex currentEnd = end;
+        while (!currentEnd.equals(begin)) {
+            backwards.add(pathTail.get(currentEnd));
+            currentEnd = pathTail.get(currentEnd).getBegin();
+        }
+
+        Vector<Edge> result = new Vector<>();
+        for (int i = backwards.size() - 1; i >= 0; --i) {
+            result.add(backwards.elementAt(i));
+        }
+        return result;
+    }
+
+    protected Vertex begin;
+
+    protected Vertex end;
+
+    private TreeSet<Vertex> closedList;
+
+    private TreeMap<Vertex, Double> openList;
+
+    private TreeMap<Vertex, Edge> pathTail;
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/PublicTransportAStar.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/PublicTransportAStar.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/PublicTransportAStar.java	(revision 34718)
@@ -0,0 +1,143 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport;
+
+import java.util.Iterator;
+import java.util.Objects;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Vector;
+
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.MainApplication;
+
+public class PublicTransportAStar extends AStarAlgorithm {
+    public PublicTransportAStar(Node start, Node end) {
+        super(new NodeVertex(start), new NodeVertex(end));
+    }
+
+    public static class NodeVertex extends AStarAlgorithm.Vertex {
+        public NodeVertex(Node node) {
+            this.node = node;
+        }
+
+        @Override
+        public int compareTo(AStarAlgorithm.Vertex v) {
+            return this.node.compareTo(((NodeVertex) v).node);
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof NodeVertex))
+                return false;
+            return node.equals(((NodeVertex) o).node);
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(node);
+        }
+
+        public Node node;
+    }
+
+    public static class PartialWayEdge extends AStarAlgorithm.Edge {
+        public PartialWayEdge(Way way, int beginIndex, int endIndex) {
+            this.way = way;
+            this.beginIndex = beginIndex;
+            this.endIndex = endIndex;
+        }
+
+        @Override
+        public AStarAlgorithm.Vertex getBegin() {
+            return new NodeVertex(way.getNode(beginIndex));
+        }
+
+        @Override
+        public AStarAlgorithm.Vertex getEnd() {
+            return new NodeVertex(way.getNode(endIndex));
+        }
+
+        @Override
+        public double getLength() {
+            int min = beginIndex;
+            int max = endIndex;
+            if (endIndex < beginIndex) {
+                min = endIndex;
+                max = beginIndex;
+            }
+
+            double totalDistance = 0;
+            for (int i = min; i < max; ++i) {
+                totalDistance += way.getNode(i).getCoor().greatCircleDistance(way.getNode(i + 1).getCoor());
+            }
+            return totalDistance;
+        }
+
+        public Way way;
+
+        public int beginIndex;
+
+        public int endIndex;
+    }
+
+    @Override
+    public Vector<AStarAlgorithm.Edge> getNeighbors(AStarAlgorithm.Vertex vertex) {
+        if (waysPerNode == null) {
+            waysPerNode = new TreeMap<>();
+
+            Iterator<Way> iter = MainApplication.getLayerManager().getEditDataSet().getWays().iterator();
+            while (iter.hasNext()) {
+                Way way = iter.next();
+
+                // Only consider ways that are usable
+                if (!way.isUsable())
+                    continue;
+
+                // Further tests whether the way is eligible.
+
+                for (int i = 0; i < way.getNodesCount(); ++i) {
+                    if (waysPerNode.get(way.getNode(i)) == null)
+                        waysPerNode.put(way.getNode(i), new TreeSet<Way>());
+                    waysPerNode.get(way.getNode(i)).add(way);
+                }
+            }
+        }
+
+        NodeVertex nodeVertex = (NodeVertex) vertex;
+        System.out.println(nodeVertex.node.getUniqueId());
+
+        Vector<AStarAlgorithm.Edge> result = new Vector<>();
+        // Determine all ways in which nodeVertex.node is contained.
+        Iterator<Way> iter = waysPerNode.get(nodeVertex.node).iterator();
+        while (iter.hasNext()) {
+            Way way = iter.next();
+
+            // Only consider ways that are usable
+            if (!way.isUsable())
+                continue;
+
+            // Further tests whether the way is eligible.
+
+            for (int i = 0; i < way.getNodesCount(); ++i) {
+                if (way.getNode(i).equals(nodeVertex.node)) {
+                    if (i > 0)
+                        result.add(new PartialWayEdge(way, i, i - 1));
+                    if (i < way.getNodesCount() - 1)
+                        result.add(new PartialWayEdge(way, i, i + 1));
+                }
+            }
+        }
+
+        return result;
+    }
+
+    TreeMap<Node, TreeSet<Way>> waysPerNode = null;
+
+    @Override
+    public double estimateDistance(AStarAlgorithm.Vertex vertex) {
+        NodeVertex nodeVertex = (NodeVertex) vertex;
+        return ((NodeVertex) super.end).node.getCoor()
+                .greatCircleDistance(nodeVertex.node.getCoor());
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/PublicTransportPlugin.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/PublicTransportPlugin.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/PublicTransportPlugin.java	(revision 34718)
@@ -0,0 +1,52 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.KeyEvent;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.MainMenu;
+import org.openstreetmap.josm.plugins.Plugin;
+import org.openstreetmap.josm.plugins.PluginInformation;
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.actions.RoutePatternAction;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+
+public class PublicTransportPlugin extends Plugin {
+
+    static JMenu jMenu;
+
+    public PublicTransportPlugin(PluginInformation info) {
+        super(info);
+        refreshMenu();
+    }
+
+    public static void refreshMenu() {
+        MainMenu menu = MainApplication.getMenu();
+
+        if (jMenu == null)
+            jMenu = menu.addMenu("Public Transport", tr("Public Transport"), KeyEvent.VK_COMMA,
+                    menu.getDefaultMenuPos(), "help");
+        else
+            jMenu.removeAll();
+
+        jMenu.addSeparator();
+        jMenu.add(new JMenuItem(new StopImporterAction()));
+        jMenu.add(new JMenuItem(new RoutePatternAction()));
+        jMenu.add(new JMenuItem(new GTFSImporterAction()));
+        setEnabledAll(true);
+    }
+
+    private static void setEnabledAll(boolean isEnabled) {
+        for (int i = 0; i < jMenu.getItemCount(); i++) {
+            JMenuItem item = jMenu.getItem(i);
+
+            if (item != null)
+                item.setEnabled(isEnabled);
+        }
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/TransText.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/TransText.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/TransText.java	(revision 34718)
@@ -0,0 +1,17 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+public class TransText {
+    public String text;
+
+    public TransText(String t) {
+        text = t;
+    }
+
+    @Override
+    public String toString() {
+        return text == null ? "" : tr(text);
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/GTFSImporterAction.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/GTFSImporterAction.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/GTFSImporterAction.java	(revision 34718)
@@ -0,0 +1,523 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.actions;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultListModel;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.UndoRedoHandler;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.commands.GTFSAddCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.GTFSCatchCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.GTFSDeleteCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.GTFSJoinCommand;
+import org.openstreetmap.josm.plugins.public_transport.dialogs.GTFSImporterDialog;
+import org.openstreetmap.josm.plugins.public_transport.models.GTFSStopTableModel;
+import org.openstreetmap.josm.plugins.public_transport.refs.TrackReference;
+import org.openstreetmap.josm.spi.preferences.Config;
+import org.openstreetmap.josm.tools.Logging;
+
+/**
+ * Create Stops from GTFS
+ */
+public class GTFSImporterAction extends JosmAction {
+    private static GTFSImporterDialog dialog = null;
+
+    private static DefaultListModel<?> tracksListModel = null;
+
+    private static Vector<String> data = null;
+
+    private static TrackReference currentTrack = null;
+
+    private static GTFSStopTableModel gtfsStopTM = null;
+
+    public boolean inEvent = false;
+
+    /**
+     * Constructs a new {@code GTFSImporterAction}.
+     */
+    public GTFSImporterAction() {
+        super(tr("Create Stops from GTFS ..."), null, tr("Create Stops from a GTFS file"), null,
+                false);
+        putValue("toolbar", "publictransport/gtfsimporter");
+        MainApplication.getToolbar().register(this);
+    }
+
+    public GTFSStopTableModel getGTFSStopTableModel() {
+        return gtfsStopTM;
+    }
+
+    public GTFSImporterDialog getDialog() {
+        return dialog;
+    }
+
+    public DefaultListModel<?> getTracksListModel() {
+        if (tracksListModel == null)
+            tracksListModel = new DefaultListModel<>();
+        return tracksListModel;
+    }
+
+    public TrackReference getCurrentTrack() {
+        return currentTrack;
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent event) {
+
+        if (dialog == null)
+            dialog = new GTFSImporterDialog(this);
+
+        dialog.setVisible(true);
+
+        if (tr("Create Stops from GTFS ...").equals(event.getActionCommand())) {
+            String curDir = Config.getPref().get("lastDirectory");
+            if (curDir.isEmpty()) {
+                curDir = ".";
+            }
+            JFileChooser fc = new JFileChooser(new File(curDir));
+            fc.setDialogTitle(tr("Select GTFS file (stops.txt)"));
+            fc.setMultiSelectionEnabled(false);
+
+            int answer = fc.showOpenDialog(MainApplication.getMainFrame());
+            if (answer != JFileChooser.APPROVE_OPTION)
+                return;
+
+            if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
+                Config.getPref().put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
+
+            importData(fc.getSelectedFile());
+
+            refreshData();
+
+/*    } else if ("stopImporter.settingsGPSTimeStart".equals(event.getActionCommand()))
+    {
+      if ((!inEvent) && (dialog.gpsTimeStartValid()) && (currentTrack != null))
+    UndoRedoHandler.getInstance().add(new TrackStoplistRelocateCommand(this));
+    }
+    else if ("stopImporter.settingsStopwatchStart".equals(event.getActionCommand()))
+    {
+      if ((!inEvent) && (dialog.stopwatchStartValid()) && (currentTrack != null))
+    UndoRedoHandler.getInstance().add(new TrackStoplistRelocateCommand(this));
+    }
+    else if ("stopImporter.settingsTimeWindow".equals(event.getActionCommand()))
+    {
+      if (currentTrack != null)
+    currentTrack.timeWindow = dialog.getTimeWindow();
+    }
+    else if ("stopImporter.settingsThreshold".equals(event.getActionCommand()))
+    {
+      if (currentTrack != null)
+    currentTrack.threshold = dialog.getThreshold();
+    }
+    else if ("stopImporter.settingsSuggestStops".equals(event.getActionCommand()))
+      UndoRedoHandler.getInstance().add(new TrackSuggestStopsCommand(this));
+    else if ("stopImporter.stoplistFind".equals(event.getActionCommand()))
+      findNodesInTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes());
+    else if ("stopImporter.stoplistShow".equals(event.getActionCommand()))
+      showNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes());
+    else if ("stopImporter.stoplistMark".equals(event.getActionCommand()))
+      markNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes());
+    else if ("stopImporter.stoplistDetach".equals(event.getActionCommand()))
+    {
+      UndoRedoHandler.getInstance().add(new TrackStoplistDetachCommand(this));
+      dialog.getStoplistTable().clearSelection();
+    */
+        } else if ("gtfsImporter.gtfsStopsAdd".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new GTFSAddCommand(this));
+        else if ("gtfsImporter.gtfsStopsDelete".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new GTFSDeleteCommand(this));
+        else if ("gtfsImporter.gtfsStopsCatch".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new GTFSCatchCommand(this));
+        else if ("gtfsImporter.gtfsStopsJoin".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new GTFSJoinCommand(this));
+        else if ("gtfsImporter.gtfsStopsFind".equals(event.getActionCommand()))
+            findNodesInTable(dialog.getGTFSStopTable(), gtfsStopTM.nodes);
+        else if ("gtfsImporter.gtfsStopsShow".equals(event.getActionCommand()))
+            showNodesFromTable(dialog.getGTFSStopTable(), gtfsStopTM.nodes);
+        else if ("gtfsImporter.gtfsStopsMark".equals(event.getActionCommand()))
+            markNodesFromTable(dialog.getGTFSStopTable(), gtfsStopTM.nodes);
+    }
+
+    private void importData(final File file) {
+        try (BufferedReader r = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
+            if (data == null)
+                data = new Vector<>();
+            else
+                data.clear();
+
+            while (r.ready()) {
+                data.add(r.readLine());
+            }
+        } catch (FileNotFoundException e) {
+            Logging.error(e);
+            JOptionPane.showMessageDialog(null, tr("File \"{0}\" does not exist", file.getName()));
+        } catch (IOException e) {
+            Logging.error(e);
+            JOptionPane.showMessageDialog(null, tr("IOException \"{0}\" occurred", e.toString()));
+        }
+    }
+
+    private void refreshData() {
+        if (data != null) {
+            Vector<Node> existingStops = new Vector<>();
+
+            DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+            if (ds == null) {
+                JOptionPane.showMessageDialog(null,
+                        tr("There exists no dataset. Try to download data from the server or open an OSM file."),
+                        tr("No data found"), JOptionPane.ERROR_MESSAGE);
+
+                return;
+            } else {
+                Iterator<Node> iter = ds.getNodes().iterator();
+                while (iter.hasNext()) {
+                    Node node = iter.next();
+                    if ("bus_stop".equals(node.get("highway")))
+                        existingStops.add(node);
+                }
+            }
+
+            Iterator<String> iter = data.iterator();
+            if (iter.hasNext())
+                gtfsStopTM = new GTFSStopTableModel(this, iter.next());
+            else {
+                JOptionPane.showMessageDialog(null, tr("The GTFS file was empty."),
+                        tr("No data found"), JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+
+            while (iter.hasNext()) {
+                String s = iter.next();
+                gtfsStopTM.addRow(s, existingStops);
+            }
+            dialog.setGTFSStopTableModel(gtfsStopTM);
+        } else {
+            JOptionPane.showMessageDialog(null, tr("The GTFS file was empty."), tr("No data found"),
+                    JOptionPane.ERROR_MESSAGE);
+        }
+    }
+
+//   public void tracksSelectionChanged(int selectedPos)
+//   {
+//     if (selectedPos >= 0)
+//     {
+//       currentTrack = ((TrackReference)tracksListModel.elementAt(selectedPos));
+//       dialog.setTrackValid(true);
+//
+//       //Prepare Settings
+//       dialog.setSettings
+//    (currentTrack.gpsSyncTime, currentTrack.stopwatchStart,
+//     currentTrack.timeWindow, currentTrack.threshold);
+//
+//       //Prepare Stoplist
+//       dialog.setStoplistTableModel
+//           (((TrackReference)tracksListModel.elementAt(selectedPos)).stoplistTM);
+//     }
+//     else
+//     {
+//       currentTrack = null;
+//       dialog.setTrackValid(false);
+//     }
+//   }
+
+    public static Node createNode(LatLon latLon, String id, String name) {
+        Node node = new Node(latLon);
+        node.put("highway", "bus_stop");
+        node.put("stop_id", id);
+        node.put("name", name);
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        if (ds == null) {
+            JOptionPane.showMessageDialog(null,
+                    tr("There exists no dataset."
+                            + " Try to download data from the server or open an OSM file."),
+                    tr("No data found"), JOptionPane.ERROR_MESSAGE);
+
+            return null;
+        }
+        ds.addPrimitive(node);
+        return node;
+    }
+
+    /**
+     * returns a collection of all selected lines or a collection of all lines otherwise
+     * @param table table
+     * @return all selected lines or a collection of all lines otherwise
+     */
+    public static Vector<Integer> getConsideredLines(JTable table) {
+        int[] selectedLines = table.getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < table.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+        return consideredLines;
+    }
+
+    /**
+     * marks the table items whose nodes are marked on the map
+     * @param table table
+     * @param nodes nodes
+     */
+    public static void findNodesInTable(JTable table, Vector<Node> nodes) {
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        if (ds == null)
+            return;
+
+        table.clearSelection();
+
+        for (int i = 0; i < table.getRowCount(); ++i) {
+            if (nodes.elementAt(i) != null && ds.isSelected(nodes.elementAt(i)))
+                table.addRowSelectionInterval(i, i);
+        }
+    }
+
+    /**
+     * shows the nodes that correspond to the marked lines in the table.
+     * If no lines are marked in the table, show all nodes from the vector
+     * @param table table
+     * @param nodes nodes
+     */
+    public static void showNodesFromTable(JTable table, Vector<Node> nodes) {
+        BoundingXYVisitor box = new BoundingXYVisitor();
+        Vector<Integer> consideredLines = getConsideredLines(table);
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            int j = consideredLines.elementAt(i);
+            if (nodes.elementAt(j) != null)
+                nodes.elementAt(j).accept((PrimitiveVisitor) box);
+        }
+        if (box.getBounds() == null)
+            return;
+        box.enlargeBoundingBox();
+        MainApplication.getMap().mapView.zoomTo(box);
+    }
+
+    /**
+     * marks the nodes that correspond to the marked lines in the table.
+     * If no lines are marked in the table, mark all nodes from the vector
+     * @param table table
+     * @param nodes nodes
+     */
+    public static void markNodesFromTable(JTable table, Vector<Node> nodes) {
+        OsmPrimitive[] osmp = {null};
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        ds.setSelected(osmp);
+        Vector<Integer> consideredLines = getConsideredLines(table);
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            int j = consideredLines.elementAt(i);
+            if (nodes.elementAt(j) != null)
+                ds.addSelected(nodes.elementAt(j));
+        }
+    }
+
+    public static String timeOf(double t) {
+        t -= Math.floor(t / 24 / 60 / 60) * 24 * 60 * 60;
+
+        int hour = (int) Math.floor(t / 60 / 60);
+        t -= Math.floor(t / 60 / 60) * 60 * 60;
+        int minute = (int) Math.floor(t / 60);
+        t -= Math.floor(t / 60) * 60;
+        double second = t;
+
+        Format format = new DecimalFormat("00");
+        Format formatS = new DecimalFormat("00.###");
+        return format.format(hour) + ":" + format.format(minute) + ":" + formatS.format(second);
+    }
+
+    public Action getFocusAddAction() {
+        return new FocusAddAction();
+    }
+
+    private class FocusAddAction extends AbstractAction {
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            UndoRedoHandler.getInstance().add(new GTFSAddCommand(GTFSImporterAction.this));
+            showNodesFromTable(dialog.getGTFSStopTable(), gtfsStopTM.nodes);
+        }
+    }
+
+/*  public Action getFocusWaypointShelterAction(String shelter)
+  {
+    return new FocusWaypointShelterAction(shelter);
+  }
+
+  public Action getFocusWaypointDeleteAction()
+  {
+    return new AbstractAction()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+    JTable table = dialog.getWaypointsTable();
+    int row = table.getEditingRow();
+    if (row < 0)
+      return;
+    table.clearSelection();
+    table.addRowSelectionInterval(row, row);
+/*  UndoRedoHandler.getInstance().add
+        (new WaypointsDisableCommand(GTFSImporterAction.this));*
+      }
+    };
+  }
+
+  public Action getFocusTrackStoplistNameAction()
+  {
+    return new FocusTrackStoplistNameAction();
+  }
+
+  public Action getFocusTrackStoplistShelterAction(String shelter)
+  {
+    return new FocusTrackStoplistShelterAction(shelter);
+  }
+
+  public Action getFocusStoplistDeleteAction()
+  {
+    return new AbstractAction()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+    JTable table = dialog.getStoplistTable();
+    int row = table.getEditingRow();
+    if (row < 0)
+      return;
+    table.clearSelection();
+    table.addRowSelectionInterval(row, row);
+/*  UndoRedoHandler.getInstance().add
+        (new TrackStoplistDeleteCommand(GTFSImporterAction.this));*
+      }
+    };
+  }
+
+  private class FocusWaypointNameAction extends AbstractAction
+  {
+    public void actionPerformed(ActionEvent e)
+    {
+      JTable table = dialog.getWaypointsTable();
+      showNodesFromTable(table, waypointTM.nodes);
+      markNodesFromTable(table, waypointTM.nodes);
+      int row = table.getEditingRow();
+      if (row < 0)
+    row = 0;
+      waypointTM.inEvent = true;
+      if (table.getCellEditor() != null)
+      {
+    if (!table.getCellEditor().stopCellEditing())
+      table.getCellEditor().cancelCellEditing();
+      }
+      table.editCellAt(row, 1);
+      table.getCellEditor().getTableCellEditorComponent
+      (table, "", true, row, 1);
+      waypointTM.inEvent = false;
+    }
+  };
+
+  private class FocusWaypointShelterAction extends AbstractAction
+  {
+    private String defaultShelter = null;
+
+    public FocusWaypointShelterAction(String defaultShelter)
+    {
+      this.defaultShelter = defaultShelter;
+    }
+
+    public void actionPerformed(ActionEvent e)
+    {
+      JTable table = dialog.getWaypointsTable();
+      showNodesFromTable(table, waypointTM.nodes);
+      markNodesFromTable(table, waypointTM.nodes);
+      int row = table.getEditingRow();
+      if (row < 0)
+    row = 0;
+      waypointTM.inEvent = true;
+      if (table.getCellEditor() != null)
+      {
+    if (!table.getCellEditor().stopCellEditing())
+      table.getCellEditor().cancelCellEditing();
+      }
+      table.editCellAt(row, 2);
+      waypointTM.inEvent = false;
+      table.getCellEditor().getTableCellEditorComponent
+          (table, defaultShelter, true, row, 2);
+    }
+  };
+
+  private class FocusTrackStoplistNameAction extends AbstractAction
+  {
+    public void actionPerformed(ActionEvent e)
+    {
+      JTable table = dialog.getStoplistTable();
+      showNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+      markNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+      int row = table.getEditingRow();
+      if (row < 0)
+    row = 0;
+      currentTrack.inEvent = true;
+      if (table.getCellEditor() != null)
+      {
+    if (!table.getCellEditor().stopCellEditing())
+      table.getCellEditor().cancelCellEditing();
+      }
+      table.editCellAt(row, 1);
+      table.getCellEditor().getTableCellEditorComponent
+          (table, "", true, row, 1);
+      currentTrack.inEvent = false;
+    }
+  };
+
+  private class FocusTrackStoplistShelterAction extends AbstractAction
+  {
+    private String defaultShelter = null;
+
+    public FocusTrackStoplistShelterAction(String defaultShelter)
+    {
+      this.defaultShelter = defaultShelter;
+    }
+
+    public void actionPerformed(ActionEvent e)
+    {
+      JTable table = dialog.getStoplistTable();
+      showNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+      markNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+      int row = table.getEditingRow();
+      if (row < 0)
+    row = 0;
+      currentTrack.inEvent = true;
+      if (table.getCellEditor() != null)
+      {
+    if (!table.getCellEditor().stopCellEditing())
+      table.getCellEditor().cancelCellEditing();
+      }
+      table.editCellAt(row, 2);
+      currentTrack.inEvent = false;
+      table.getCellEditor().getTableCellEditorComponent
+          (table, defaultShelter, true, row, 2);
+    }
+  };*/
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/RoutePatternAction.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/RoutePatternAction.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/RoutePatternAction.java	(revision 34718)
@@ -0,0 +1,1978 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.actions;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Vector;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.actions.mapmode.DeleteAction;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.RelationMember;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.models.ItineraryTableModel;
+import org.openstreetmap.josm.plugins.public_transport.refs.RouteReference;
+import org.openstreetmap.josm.plugins.public_transport.refs.StopReference;
+
+public class RoutePatternAction extends JosmAction {
+
+    public static int STOPLIST_ROLE_COLUMN = 2;
+
+    private static class RoutesLSL implements ListSelectionListener {
+        RoutePatternAction root = null;
+
+        RoutesLSL(RoutePatternAction rpa) {
+            root = rpa;
+        }
+
+        @Override
+        public void valueChanged(ListSelectionEvent e) {
+            root.routesSelectionChanged();
+        }
+    }
+
+    private static class TagTableModel extends DefaultTableModel implements TableModelListener {
+        Relation relation = null;
+
+        TreeSet<String> blacklist = null;
+
+        boolean hasFixedKeys = true;
+
+        TagTableModel(boolean hasFixedKeys) {
+            this.hasFixedKeys = hasFixedKeys;
+        }
+
+        @Override
+        public boolean isCellEditable(int row, int column) {
+            if (column == 0 && hasFixedKeys)
+                return false;
+            return true;
+        }
+
+        public void readRelation(Relation rel) {
+            relation = rel;
+
+            for (int i = 0; i < getRowCount(); ++i) {
+                String value = rel.get((String) getValueAt(i, 0));
+                if (value == null)
+                    value = "";
+                setValueAt(value, i, 1);
+            }
+        }
+
+        public void readRelation(Relation rel, TreeSet<String> blacklist) {
+            relation = rel;
+            this.blacklist = blacklist;
+
+            setRowCount(0);
+            Iterator<Map.Entry<String, String>> iter = rel.getKeys().entrySet().iterator();
+            while (iter.hasNext()) {
+                Map.Entry<String, String> entry = iter.next();
+                if (!blacklist.contains(entry.getKey())) {
+                    Vector<String> newRow = new Vector<>();
+                    newRow.add(entry.getKey());
+                    newRow.add(entry.getValue());
+                    addRow(newRow);
+                }
+            }
+
+            for (int i = 0; i < getRowCount(); ++i) {
+                String value = rel.get((String) getValueAt(i, 0));
+                if (value == null)
+                    value = "";
+                setValueAt(value, i, 1);
+            }
+        }
+
+        @Override
+        public void tableChanged(TableModelEvent e) {
+            if (e.getType() == TableModelEvent.UPDATE) {
+                relation.setModified(true);
+
+                String key = (String) getValueAt(e.getFirstRow(), 0);
+                if (key == null)
+                    return;
+                if (blacklist == null || !blacklist.contains(key)) {
+                    relation.setModified(true);
+                    if ("".equals(getValueAt(e.getFirstRow(), 1)))
+                        relation.remove(key);
+                    else
+                        relation.put(key, (String) getValueAt(e.getFirstRow(), 1));
+                } else {
+                    if (e.getColumn() == 0)
+                        setValueAt("", e.getFirstRow(), 0);
+                }
+            }
+        }
+    }
+
+    private static class CustomCellEditorTable extends JTable {
+        TreeMap<Integer, TableCellEditor> col1 = null;
+
+        TreeMap<Integer, TableCellEditor> col2 = null;
+
+        CustomCellEditorTable() {
+            col1 = new TreeMap<>();
+            col2 = new TreeMap<>();
+        }
+
+        @Override
+        public TableCellEditor getCellEditor(int row, int column) {
+            TableCellEditor editor = null;
+            if (column == 0)
+                editor = col1.get(Integer.valueOf(row));
+            else
+                editor = col2.get(Integer.valueOf(row));
+            if (editor == null)
+                return new DefaultCellEditor(new JTextField());
+            else
+                return editor;
+        }
+
+        public void setCellEditor(int row, int column, TableCellEditor editor) {
+            if (column == 0)
+                col1.put(Integer.valueOf(row), editor);
+            else
+                col2.put(Integer.valueOf(row), editor);
+        }
+    }
+
+    private static class StoplistTableModel extends DefaultTableModel {
+
+        public Vector<Node> nodes = new Vector<>();
+
+        @Override
+        public boolean isCellEditable(int row, int column) {
+            if (column != STOPLIST_ROLE_COLUMN)
+                return false;
+            return true;
+        }
+
+        @Override
+        public void addRow(Object[] obj) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void insertRow(int insPos, Object[] obj) {
+            throw new UnsupportedOperationException();
+        }
+
+        public void addRow(Node node, String role, double distance) {
+            insertRow(-1, node, role, distance);
+        }
+
+        public void insertRow(int insPos, Node node, String role, double distance) {
+            String[] buf = {"", "", "", ""};
+            String curName = node.get("name");
+            if (curName != null) {
+                buf[0] = curName;
+            } else {
+                buf[0] = tr("[ID] {0}", Long.valueOf(node.getId()).toString());
+            }
+            String curRef = node.get("ref");
+            if (curRef != null) {
+                buf[1] = curRef;
+            }
+            buf[STOPLIST_ROLE_COLUMN] = role;
+            buf[3] = Double.toString(((double) (int) (distance * 40000 / 360.0 * 100)) / 100);
+
+            if (insPos == -1) {
+                nodes.addElement(node);
+                super.addRow(buf);
+            } else {
+                nodes.insertElementAt(node, insPos);
+                super.insertRow(insPos, buf);
+            }
+        }
+
+        public void clear() {
+            nodes.clear();
+            super.setRowCount(0);
+        }
+    }
+
+    private class StoplistTableModelListener implements TableModelListener {
+        @Override
+        public void tableChanged(TableModelEvent e) {
+            if (e.getType() == TableModelEvent.UPDATE) {
+                rebuildNodes();
+            }
+        }
+    }
+
+    private static class SegmentMetric {
+        public double aLat, aLon;
+
+        public double length;
+
+        public double d1, d2, o1, o2;
+
+        public double distance;
+
+        SegmentMetric(double fromLat, double fromLon, double toLat, double toLon,
+                double distance) {
+            this.distance = distance;
+
+            aLat = fromLat;
+            aLon = fromLon;
+
+            // Compute length and direction
+            // length is in units of latitude degrees
+            d1 = toLat - fromLat;
+            d2 = (toLon - fromLon) * Math.cos(fromLat * Math.PI / 180.0);
+            length = Math.sqrt(d1 * d1 + d2 * d2);
+
+            // Normalise direction
+            d1 = d1 / length;
+            d2 = d2 / length;
+
+            // Compute orthogonal direction (right hand size is positive)
+            o1 = -d2;
+            o2 = d1;
+
+            // Prepare lon direction to reduce the number of necessary multiplications
+            d2 = d2 * Math.cos(fromLat * Math.PI / 180.0);
+            o2 = o2 * Math.cos(fromLat * Math.PI / 180.0);
+        }
+    }
+
+    private static JDialog jDialog = null;
+
+    private static JTabbedPane tabbedPane = null;
+
+    private static DefaultListModel<RouteReference> relsListModel = null;
+
+    private static TagTableModel requiredTagsData = null;
+
+    private static CustomCellEditorTable requiredTagsTable = null;
+
+    private static TagTableModel commonTagsData = null;
+
+    private static CustomCellEditorTable commonTagsTable = null;
+
+    private static TagTableModel otherTagsData = null;
+
+    private static TreeSet<String> tagBlacklist = null;
+
+    private static CustomCellEditorTable otherTagsTable = null;
+
+    private static ItineraryTableModel itineraryData = null;
+
+    private static JTable itineraryTable = null;
+
+    private static StoplistTableModel stoplistData = null;
+
+    private static JTable stoplistTable = null;
+
+    private static JList<RouteReference> relsList = null;
+
+    private static JCheckBox cbRight = null;
+
+    private static JCheckBox cbLeft = null;
+
+    private static JTextField tfSuggestStopsLimit = null;
+
+    private static Relation currentRoute = null;
+
+    private static Vector<SegmentMetric> segmentMetrics = null;
+
+    private static Vector<RelationMember> markedWays = new Vector<>();
+
+    private static Vector<RelationMember> markedNodes = new Vector<>();
+
+    public RoutePatternAction() {
+        super(tr("Route patterns ..."), null, tr("Edit Route patterns for public transport"), null,
+                false);
+        putValue("toolbar", "publictransport/routepattern");
+        MainApplication.getToolbar().register(this);
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent event) {
+        Frame frame = JOptionPane.getFrameForComponent(MainApplication.getMainFrame());
+        DataSet mainDataSet = MainApplication.getLayerManager().getEditDataSet();
+
+        if (jDialog == null) {
+            jDialog = new JDialog(frame, tr("Route Patterns"), false);
+            tabbedPane = new JTabbedPane();
+            JPanel tabOverview = new JPanel();
+            tabbedPane.addTab(tr("Overview"), tabOverview);
+            JPanel tabTags = new JPanel();
+            tabbedPane.addTab(tr("Tags"), tabTags);
+            JPanel tabItinerary = new JPanel();
+            tabbedPane.addTab(tr("Itinerary"), tabItinerary);
+            JPanel tabStoplist = new JPanel();
+            tabbedPane.addTab(tr("Stops"), tabStoplist);
+            JPanel tabMeta = new JPanel();
+            tabbedPane.addTab(tr("Meta"), tabMeta);
+            tabbedPane.setEnabledAt(0, true);
+            tabbedPane.setEnabledAt(1, false);
+            tabbedPane.setEnabledAt(2, false);
+            tabbedPane.setEnabledAt(3, false);
+            tabbedPane.setEnabledAt(4, false);
+            jDialog.add(tabbedPane);
+
+            // Overview Tab
+            Container contentPane = tabOverview;
+            GridBagLayout gridbag = new GridBagLayout();
+            GridBagConstraints layoutCons = new GridBagConstraints();
+            contentPane.setLayout(gridbag);
+
+            JLabel headline = new JLabel(tr("Existing route patterns:"));
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 0;
+            layoutCons.gridwidth = 3;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(headline, layoutCons);
+            contentPane.add(headline);
+
+            relsListModel = new DefaultListModel<>();
+            relsList = new JList<>(relsListModel);
+            JScrollPane rpListSP = new JScrollPane(relsList);
+            String[] data = {"1", "2", "3", "4", "5", "6"};
+            relsListModel.copyInto(data);
+            relsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+            relsList.addListSelectionListener(new RoutesLSL(this));
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 1;
+            layoutCons.gridwidth = 3;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 1.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(rpListSP, layoutCons);
+            contentPane.add(rpListSP);
+
+            JButton bRefresh = new JButton(tr("Refresh"));
+            bRefresh.setActionCommand("routePattern.refresh");
+            bRefresh.addActionListener(this);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.gridheight = 2;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bRefresh, layoutCons);
+            contentPane.add(bRefresh);
+
+            JButton bNew = new JButton(tr("New"));
+            bNew.setActionCommand("routePattern.overviewNew");
+            bNew.addActionListener(this);
+
+            layoutCons.gridx = 1;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.gridheight = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bNew, layoutCons);
+            contentPane.add(bNew);
+
+            JButton bDelete = new JButton(tr("Delete"));
+            bDelete.setActionCommand("routePattern.overviewDelete");
+            bDelete.addActionListener(this);
+
+            layoutCons.gridx = 1;
+            layoutCons.gridy = 3;
+            layoutCons.gridwidth = 1;
+            layoutCons.gridheight = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bDelete, layoutCons);
+            contentPane.add(bDelete);
+
+            JButton bDuplicate = new JButton(tr("Duplicate"));
+            bDuplicate.setActionCommand("routePattern.overviewDuplicate");
+            bDuplicate.addActionListener(this);
+
+            layoutCons.gridx = 2;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.gridheight = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bDuplicate, layoutCons);
+            contentPane.add(bDuplicate);
+
+            JButton bReflect = new JButton(tr("Reflect"));
+            bReflect.setActionCommand("routePattern.overviewReflect");
+            bReflect.addActionListener(this);
+
+            layoutCons.gridx = 2;
+            layoutCons.gridy = 3;
+            layoutCons.gridwidth = 1;
+            layoutCons.gridheight = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bReflect, layoutCons);
+            contentPane.add(bReflect);
+
+            // Tags Tab
+            /* Container */ contentPane = tabTags;
+            /* GridBagLayout */ gridbag = new GridBagLayout();
+            /* GridBagConstraints */ layoutCons = new GridBagConstraints();
+            contentPane.setLayout(gridbag);
+
+            /* JLabel */ headline = new JLabel(tr("Required tags:"));
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 0;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(headline, layoutCons);
+            contentPane.add(headline);
+
+            requiredTagsTable = new CustomCellEditorTable();
+            requiredTagsData = new TagTableModel(true);
+            requiredTagsData.addColumn(tr("Key"));
+            requiredTagsData.addColumn(tr("Value"));
+            tagBlacklist = new TreeSet<>();
+            Vector<String> rowContent = new Vector<>();
+            /* TODO: keys and values should also be translated using TransText class */
+            rowContent.add("type");
+            tagBlacklist.add("type");
+            rowContent.add("route");
+            requiredTagsData.addRow(rowContent);
+            JComboBox<String> comboBox = new JComboBox<>();
+            comboBox.addItem("route");
+            requiredTagsTable.setCellEditor(0, 1, new DefaultCellEditor(comboBox));
+            rowContent = new Vector<>();
+            rowContent.add(0, "route");
+            tagBlacklist.add("route");
+            rowContent.add(1, "bus");
+            requiredTagsData.addRow(rowContent);
+            /* JComboBox */ comboBox = new JComboBox<>();
+            comboBox.addItem("bus");
+            comboBox.addItem("trolleybus");
+            comboBox.addItem("tram");
+            comboBox.addItem("light_rail");
+            comboBox.addItem("subway");
+            comboBox.addItem("rail");
+            requiredTagsTable.setCellEditor(1, 1, new DefaultCellEditor(comboBox));
+            rowContent = new Vector<>();
+            rowContent.add(0, "ref");
+            tagBlacklist.add("ref");
+            rowContent.add(1, "");
+            requiredTagsData.addRow(rowContent);
+            rowContent = new Vector<>();
+            rowContent.add(0, "to");
+            tagBlacklist.add("to");
+            rowContent.add(1, "");
+            requiredTagsData.addRow(rowContent);
+            rowContent = new Vector<>();
+            rowContent.add(0, "network");
+            tagBlacklist.add("network");
+            rowContent.add(1, "");
+            requiredTagsData.addRow(rowContent);
+            requiredTagsTable.setModel(requiredTagsData);
+            JScrollPane tableSP = new JScrollPane(requiredTagsTable);
+            requiredTagsData.addTableModelListener(requiredTagsData);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.25;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(tableSP, layoutCons);
+            Dimension preferredSize = tableSP.getPreferredSize();
+            preferredSize.setSize(tableSP.getPreferredSize().getWidth(),
+                    tableSP.getPreferredSize().getHeight() / 4.0);
+            tableSP.setPreferredSize(preferredSize);
+            contentPane.add(tableSP);
+
+            headline = new JLabel(tr("Common tags:"));
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 2;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(headline, layoutCons);
+            contentPane.add(headline);
+
+            commonTagsTable = new CustomCellEditorTable();
+            commonTagsData = new TagTableModel(true);
+            commonTagsData.addColumn(tr("Key"));
+            commonTagsData.addColumn(tr("Value"));
+            rowContent = new Vector<>();
+            rowContent.add(0, "loc_ref");
+            tagBlacklist.add("loc_ref");
+            rowContent.add(1, "");
+            commonTagsData.addRow(rowContent);
+            rowContent = new Vector<>();
+            rowContent.add(0, "direction");
+            tagBlacklist.add("direction");
+            rowContent.add(1, "");
+            commonTagsData.addRow(rowContent);
+            rowContent = new Vector<>();
+            rowContent.add(0, "from");
+            tagBlacklist.add("from");
+            rowContent.add(1, "");
+            commonTagsData.addRow(rowContent);
+            rowContent = new Vector<>();
+            rowContent.add(0, "operator");
+            tagBlacklist.add("operator");
+            rowContent.add(1, "");
+            commonTagsData.addRow(rowContent);
+            rowContent = new Vector<>();
+            rowContent.add(0, "color");
+            tagBlacklist.add("color");
+            rowContent.add(1, "");
+            commonTagsData.addRow(rowContent);
+            rowContent = new Vector<>();
+            rowContent.add(0, "name");
+            tagBlacklist.add("name");
+            rowContent.add(1, "");
+            commonTagsData.addRow(rowContent);
+            commonTagsTable.setModel(commonTagsData);
+            /* JScrollPane */ tableSP = new JScrollPane(commonTagsTable);
+            commonTagsData.addTableModelListener(commonTagsData);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 3;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.25;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(tableSP, layoutCons);
+            /* Dimension */ preferredSize = tableSP.getPreferredSize();
+            preferredSize.setSize(tableSP.getPreferredSize().getWidth(),
+                    tableSP.getPreferredSize().getHeight() / 4.0);
+            tableSP.setPreferredSize(preferredSize);
+            contentPane.add(tableSP);
+
+            headline = new JLabel(tr("Additional tags:"));
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 4;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(headline, layoutCons);
+            contentPane.add(headline);
+
+            otherTagsTable = new CustomCellEditorTable();
+            otherTagsData = new TagTableModel(false);
+            otherTagsData.addColumn(tr("Key"));
+            otherTagsData.addColumn(tr("Value"));
+            otherTagsTable.setModel(otherTagsData);
+            /* JScrollPane */ tableSP = new JScrollPane(otherTagsTable);
+            otherTagsData.addTableModelListener(otherTagsData);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 5;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 1.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(tableSP, layoutCons);
+            /* Dimension */ preferredSize = tableSP.getPreferredSize();
+            preferredSize.setSize(tableSP.getPreferredSize().getWidth(),
+                    tableSP.getPreferredSize().getHeight() / 2.0);
+            tableSP.setPreferredSize(preferredSize);
+            contentPane.add(tableSP);
+
+            JButton bAddTag = new JButton(tr("Add a new Tag"));
+            bAddTag.setActionCommand("routePattern.tagAddTag");
+            bAddTag.addActionListener(this);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 6;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bAddTag, layoutCons);
+            contentPane.add(bAddTag);
+
+            // Itinerary Tab
+            contentPane = tabItinerary;
+            gridbag = new GridBagLayout();
+            layoutCons = new GridBagConstraints();
+            contentPane.setLayout(gridbag);
+
+            itineraryTable = new JTable();
+            itineraryData = new ItineraryTableModel();
+            itineraryData.addColumn(tr("Name/Id"));
+            itineraryData.addColumn(tr("Role"));
+            itineraryTable.setModel(itineraryData);
+            /* JScrollPane */ tableSP = new JScrollPane(itineraryTable);
+            /* JComboBox */ comboBox = new JComboBox<>();
+            comboBox.addItem("");
+            comboBox.addItem("forward");
+            comboBox.addItem("backward");
+            itineraryTable.getColumnModel().getColumn(1)
+                    .setCellEditor(new DefaultCellEditor(comboBox));
+            itineraryData.addTableModelListener(itineraryData);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 0;
+            layoutCons.gridwidth = 4;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 1.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(tableSP, layoutCons);
+            contentPane.add(tableSP);
+
+            JButton bFind = new JButton(tr("Find"));
+            bFind.setActionCommand("routePattern.itineraryFind");
+            bFind.addActionListener(this);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 1;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bFind, layoutCons);
+            contentPane.add(bFind);
+
+            JButton bShow = new JButton(tr("Show"));
+            bShow.setActionCommand("routePattern.itineraryShow");
+            bShow.addActionListener(this);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bShow, layoutCons);
+            contentPane.add(bShow);
+
+            JButton bMark = new JButton(tr("Mark"));
+            bMark.setActionCommand("routePattern.itineraryMark");
+            bMark.addActionListener(this);
+
+            layoutCons.gridx = 1;
+            layoutCons.gridy = 1;
+            layoutCons.gridheight = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bMark, layoutCons);
+            contentPane.add(bMark);
+
+            JButton bAdd = new JButton(tr("Add"));
+            bAdd.setActionCommand("routePattern.itineraryAdd");
+            bAdd.addActionListener(this);
+
+            layoutCons.gridx = 2;
+            layoutCons.gridy = 1;
+            layoutCons.gridheight = 1;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bAdd, layoutCons);
+            contentPane.add(bAdd);
+
+            /* JButton */ bDelete = new JButton(tr("Delete"));
+            bDelete.setActionCommand("routePattern.itineraryDelete");
+            bDelete.addActionListener(this);
+
+            layoutCons.gridx = 2;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bDelete, layoutCons);
+            contentPane.add(bDelete);
+
+            JButton bSort = new JButton(tr("Sort"));
+            bSort.setActionCommand("routePattern.itinerarySort");
+            bSort.addActionListener(this);
+
+            layoutCons.gridx = 3;
+            layoutCons.gridy = 1;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bSort, layoutCons);
+            contentPane.add(bSort);
+
+            /* JButton */ bReflect = new JButton(tr("Reflect"));
+            bReflect.setActionCommand("routePattern.itineraryReflect");
+            bReflect.addActionListener(this);
+
+            layoutCons.gridx = 3;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bReflect, layoutCons);
+            contentPane.add(bReflect);
+
+            // Stoplist Tab
+            contentPane = tabStoplist;
+            gridbag = new GridBagLayout();
+            layoutCons = new GridBagConstraints();
+            contentPane.setLayout(gridbag);
+
+            stoplistTable = new JTable();
+            stoplistData = new StoplistTableModel();
+            stoplistData.addColumn(tr("Name/Id"));
+            stoplistData.addColumn(tr("Ref"));
+            stoplistData.addColumn(tr("Role"));
+            stoplistData.addColumn(tr("km"));
+            stoplistTable.setModel(stoplistData);
+            /* JScrollPane */ tableSP = new JScrollPane(stoplistTable);
+            /* JComboBox */ comboBox = new JComboBox<>();
+            comboBox.addItem("");
+            comboBox.addItem("forward_stop");
+            comboBox.addItem("backward_stop");
+            stoplistTable.getColumnModel().getColumn(STOPLIST_ROLE_COLUMN)
+                    .setCellEditor(new DefaultCellEditor(comboBox));
+            stoplistData.addTableModelListener(new StoplistTableModelListener());
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 0;
+            layoutCons.gridwidth = 4;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 1.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(tableSP, layoutCons);
+            contentPane.add(tableSP);
+
+            /* JButton */ bFind = new JButton(tr("Find"));
+            bFind.setActionCommand("routePattern.stoplistFind");
+            bFind.addActionListener(this);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 1;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bFind, layoutCons);
+            contentPane.add(bFind);
+
+            /* JButton */ bShow = new JButton(tr("Show"));
+            bShow.setActionCommand("routePattern.stoplistShow");
+            bShow.addActionListener(this);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bShow, layoutCons);
+            contentPane.add(bShow);
+
+            /* JButton */ bMark = new JButton(tr("Mark"));
+            bMark.setActionCommand("routePattern.stoplistMark");
+            bMark.addActionListener(this);
+
+            layoutCons.gridx = 1;
+            layoutCons.gridy = 1;
+            layoutCons.gridheight = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bMark, layoutCons);
+            contentPane.add(bMark);
+
+            /* JButton */ bAdd = new JButton(tr("Add"));
+            bAdd.setActionCommand("routePattern.stoplistAdd");
+            bAdd.addActionListener(this);
+
+            layoutCons.gridx = 2;
+            layoutCons.gridy = 1;
+            layoutCons.gridheight = 1;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bAdd, layoutCons);
+            contentPane.add(bAdd);
+
+            /* JButton */ bDelete = new JButton(tr("Delete"));
+            bDelete.setActionCommand("routePattern.stoplistDelete");
+            bDelete.addActionListener(this);
+
+            layoutCons.gridx = 2;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bDelete, layoutCons);
+            contentPane.add(bDelete);
+
+            /* JButton */ bSort = new JButton(tr("Sort"));
+            bSort.setActionCommand("routePattern.stoplistSort");
+            bSort.addActionListener(this);
+
+            layoutCons.gridx = 3;
+            layoutCons.gridy = 1;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bSort, layoutCons);
+            contentPane.add(bSort);
+
+            /* JButton */ bReflect = new JButton(tr("Reflect"));
+            bReflect.setActionCommand("routePattern.stoplistReflect");
+            bReflect.addActionListener(this);
+
+            layoutCons.gridx = 3;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bReflect, layoutCons);
+            contentPane.add(bReflect);
+
+            // Meta Tab
+            contentPane = tabMeta;
+            gridbag = new GridBagLayout();
+            layoutCons = new GridBagConstraints();
+            contentPane.setLayout(gridbag);
+
+            JLabel rightleft = new JLabel(tr("Stops are possible on the"));
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 1;
+            layoutCons.gridwidth = 2;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(rightleft, layoutCons);
+            contentPane.add(rightleft);
+
+            cbRight = new JCheckBox(tr("right hand side"), true);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 2;
+            layoutCons.gridwidth = 2;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(cbRight, layoutCons);
+            contentPane.add(cbRight);
+
+            cbLeft = new JCheckBox(tr("left hand side"), false);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 3;
+            layoutCons.gridwidth = 2;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(cbLeft, layoutCons);
+            contentPane.add(cbLeft);
+
+            JLabel maxdist = new JLabel(tr("Maximum distance from route"));
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 4;
+            layoutCons.gridwidth = 2;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(maxdist, layoutCons);
+            contentPane.add(maxdist);
+
+            tfSuggestStopsLimit = new JTextField("20", 4);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 5;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(tfSuggestStopsLimit, layoutCons);
+            contentPane.add(tfSuggestStopsLimit);
+
+            JLabel meters = new JLabel(tr("meters"));
+
+            layoutCons.gridx = 1;
+            layoutCons.gridy = 5;
+            layoutCons.gridwidth = 1;
+            layoutCons.weightx = 0.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(meters, layoutCons);
+            contentPane.add(meters);
+
+            JButton bSuggestStops = new JButton(tr("Suggest Stops"));
+            bSuggestStops.setActionCommand("routePattern.metaSuggestStops");
+            bSuggestStops.addActionListener(this);
+
+            layoutCons.gridx = 0;
+            layoutCons.gridy = 6;
+            layoutCons.gridwidth = 3;
+            layoutCons.weightx = 1.0;
+            layoutCons.weighty = 0.0;
+            layoutCons.fill = GridBagConstraints.BOTH;
+            gridbag.setConstraints(bSuggestStops, layoutCons);
+            contentPane.add(bSuggestStops);
+
+            jDialog.pack();
+        }
+
+        if ("routePattern.refresh".equals(event.getActionCommand())) {
+            refreshData();
+        } else if ("routePattern.overviewNew".equals(event.getActionCommand())) {
+            currentRoute = new Relation();
+            currentRoute.put("type", "route");
+            currentRoute.put("route", "bus");
+            mainDataSet.addPrimitive(currentRoute);
+
+            refreshData();
+
+            for (int i = 0; i < relsListModel.size(); ++i) {
+                if (currentRoute == relsListModel.elementAt(i).route)
+                    relsList.setSelectedIndex(i);
+            }
+        } else if ("routePattern.overviewDuplicate".equals(event.getActionCommand())) {
+            currentRoute = new Relation(currentRoute, true);
+            currentRoute.put("type", "route");
+            currentRoute.put("route", "bus");
+            mainDataSet.addPrimitive(currentRoute);
+
+            refreshData();
+
+            for (int i = 0; i < relsListModel.size(); ++i) {
+                if (currentRoute == relsListModel.elementAt(i).route)
+                    relsList.setSelectedIndex(i);
+            }
+        } else if ("routePattern.overviewReflect".equals(event.getActionCommand())) {
+            currentRoute.setModified(true);
+            String tag_from = currentRoute.get("from");
+            String tag_to = currentRoute.get("to");
+            currentRoute.put("from", tag_to);
+            currentRoute.put("to", tag_from);
+
+            Vector<RelationMember> itemsToReflect = new Vector<>();
+            Vector<RelationMember> otherItems = new Vector<>();
+
+            // Temp
+            // Node firstNode = null;
+            // Node lastNode = null;
+
+            for (int i = 0; i < currentRoute.getMembersCount(); ++i) {
+                RelationMember item = currentRoute.getMember(i);
+
+                if (item.isWay()) {
+                    String role = item.getRole();
+                    if ("backward".equals(role))
+                        role = "forward";
+                    else if ("forward".equals(role))
+                        role = "backward";
+                    else
+                        role = "backward";
+
+                    itemsToReflect.add(new RelationMember(role, item.getWay()));
+
+                    // Temp
+                    // if (firstNode == null) {
+                    //     firstNode = item.getWay().getNode(0);
+                    // }
+                    // lastNode = item.getWay().getNode(item.getWay().getNodesCount() - 1);
+                } else if (item.isNode())
+                    itemsToReflect.add(item);
+                else
+                    otherItems.add(item);
+            }
+
+            currentRoute.setMembers(null);
+            for (int i = itemsToReflect.size() - 1; i >= 0; --i) {
+                currentRoute.addMember(itemsToReflect.elementAt(i));
+            }
+            for (int i = 0; i < otherItems.size(); ++i) {
+                currentRoute.addMember(otherItems.elementAt(i));
+            }
+
+            refreshData();
+
+            for (int i = 0; i < relsListModel.size(); ++i) {
+                if (currentRoute == relsListModel.elementAt(i).route)
+                    relsList.setSelectedIndex(i);
+            }
+
+            // Temp
+            /*
+             * if (firstNode != null) {
+             * Vector< AStarAlgorithm.Edge > path = new PublicTransportAStar(firstNode, lastNode).shortestPath(); Iterator<
+             * AStarAlgorithm.Edge > iter = path.iterator(); while (iter.hasNext()) { PublicTransportAStar.PartialWayEdge edge =
+             * (PublicTransportAStar.PartialWayEdge)iter.next(); System.out.print(edge.way.getUniqueId()); System.out.print("\t");
+             * System.out.print(edge.beginIndex); System.out.print("\t"); System.out.print(edge.endIndex); System.out.print("\n"); } }
+             */
+        } else if ("routePattern.overviewDelete".equals(event.getActionCommand())) {
+            DeleteAction.deleteRelation(MainApplication.getLayerManager().getEditLayer(), currentRoute);
+
+            currentRoute = null;
+            tabbedPane.setEnabledAt(1, false);
+            tabbedPane.setEnabledAt(2, false);
+            tabbedPane.setEnabledAt(3, false);
+            tabbedPane.setEnabledAt(4, false);
+
+            refreshData();
+        } else if ("routePattern.tagAddTag".equals(event.getActionCommand())) {
+            Vector<String> rowContent = new Vector<>();
+            rowContent.add("");
+            rowContent.add("");
+            otherTagsData.addRow(rowContent);
+        } else if ("routePattern.itineraryFind".equals(event.getActionCommand())) {
+            if (mainDataSet == null)
+                return;
+
+            itineraryTable.clearSelection();
+
+            for (int i = 0; i < itineraryData.getRowCount(); ++i) {
+                if (itineraryData.ways.elementAt(i) != null
+                        && mainDataSet.isSelected(itineraryData.ways.elementAt(i)))
+                    itineraryTable.addRowSelectionInterval(i, i);
+            }
+        } else if ("routePattern.itineraryShow".equals(event.getActionCommand())) {
+            BoundingXYVisitor box = new BoundingXYVisitor();
+            if (itineraryTable.getSelectedRowCount() > 0) {
+                for (int i = 0; i < itineraryData.getRowCount(); ++i) {
+                    if (itineraryTable.isRowSelected(i)
+                            && itineraryData.ways.elementAt(i) != null) {
+                        itineraryData.ways.elementAt(i).accept((PrimitiveVisitor) box);
+                    }
+                }
+            } else {
+                for (int i = 0; i < itineraryData.getRowCount(); ++i) {
+                    if (itineraryData.ways.elementAt(i) != null) {
+                        itineraryData.ways.elementAt(i).accept((PrimitiveVisitor) box);
+                    }
+                }
+            }
+            if (box.getBounds() == null)
+                return;
+            box.enlargeBoundingBox();
+            MainApplication.getMap().mapView.zoomTo(box);
+        } else if ("routePattern.itineraryMark".equals(event.getActionCommand())) {
+            OsmPrimitive[] osmp = {null};
+            MainApplication.getLayerManager().getEditDataSet().setSelected(osmp);
+            markedWays.clear();
+            if (itineraryTable.getSelectedRowCount() > 0) {
+                for (int i = 0; i < itineraryData.getRowCount(); ++i) {
+                    if (itineraryTable.isRowSelected(i)
+                            && itineraryData.ways.elementAt(i) != null) {
+                        mainDataSet.addSelected(itineraryData.ways.elementAt(i));
+
+                        RelationMember markedWay = new RelationMember(
+                                (String) itineraryData.getValueAt(i, 1),
+                                itineraryData.ways.elementAt(i));
+                        markedWays.addElement(markedWay);
+                    }
+                }
+            } else {
+                for (int i = 0; i < itineraryData.getRowCount(); ++i) {
+                    if (itineraryData.ways.elementAt(i) != null) {
+                        mainDataSet.addSelected(itineraryData.ways.elementAt(i));
+
+                        RelationMember markedWay = new RelationMember(
+                                (String) itineraryData.getValueAt(i, 1),
+                                itineraryData.ways.elementAt(i));
+                        markedWays.addElement(markedWay);
+                    }
+                }
+            }
+        } else if ("routePattern.itineraryAdd".equals(event.getActionCommand())) {
+            int insPos = itineraryTable.getSelectedRow();
+            Iterator<RelationMember> relIter = markedWays.iterator();
+            TreeSet<Way> addedWays = new TreeSet<>();
+            if (mainDataSet == null)
+                return;
+
+            while (relIter.hasNext()) {
+                RelationMember curMember = relIter.next();
+                if (curMember.isWay() && mainDataSet.isSelected(curMember.getWay())) {
+                    itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
+                    if (insPos >= 0)
+                        ++insPos;
+
+                    addedWays.add(curMember.getWay());
+                }
+            }
+
+            Collection<Way> selectedWays = mainDataSet.getSelectedWays();
+            Iterator<Way> wayIter = selectedWays.iterator();
+
+            while (wayIter.hasNext()) {
+                Way curMember = wayIter.next();
+                if (!addedWays.contains(curMember)) {
+                    itineraryData.insertRow(insPos, curMember, "");
+                    if (insPos >= 0)
+                        ++insPos;
+                }
+            }
+
+            if ((insPos > 0) && (insPos < itineraryData.getRowCount())) {
+                while ((insPos < itineraryData.getRowCount())
+                        && (itineraryData.ways.elementAt(insPos) == null)) {
+                    ++insPos;
+                }
+                itineraryTable.removeRowSelectionInterval(0, itineraryData.getRowCount() - 1);
+                if (insPos < itineraryData.getRowCount())
+                    itineraryTable.addRowSelectionInterval(insPos, insPos);
+            }
+
+            itineraryData.cleanupGaps();
+            segmentMetrics = fillSegmentMetrics();
+            rebuildWays();
+        } else if ("routePattern.itineraryDelete".equals(event.getActionCommand())) {
+            for (int i = itineraryData.getRowCount() - 1; i >= 0; --i) {
+                if (itineraryTable.isRowSelected(i)
+                        && itineraryData.ways.elementAt(i) != null) {
+                    itineraryData.ways.removeElementAt(i);
+                    itineraryData.removeRow(i);
+                }
+            }
+
+            itineraryData.cleanupGaps();
+            segmentMetrics = fillSegmentMetrics();
+            rebuildWays();
+        } else if ("routePattern.itinerarySort".equals(event.getActionCommand())) {
+            TreeSet<Way> usedWays = new TreeSet<>();
+            TreeMap<Node, LinkedList<RelationMember>> frontNodes = new TreeMap<>();
+            TreeMap<Node, LinkedList<RelationMember>> backNodes = new TreeMap<>();
+            Vector<LinkedList<RelationMember>> loops = new Vector<>();
+            int insPos = itineraryTable.getSelectedRow();
+
+            if (itineraryTable.getSelectedRowCount() > 0) {
+                for (int i = itineraryData.getRowCount() - 1; i >= 0; --i) {
+                    if (itineraryTable.isRowSelected(i)
+                            && itineraryData.ways.elementAt(i) != null) {
+                        if (!usedWays.contains(itineraryData.ways.elementAt(i))) {
+                            addWayToSortingData(itineraryData.ways.elementAt(i), frontNodes,
+                                    backNodes, loops);
+                            usedWays.add(itineraryData.ways.elementAt(i));
+                        }
+
+                        itineraryData.ways.removeElementAt(i);
+                        itineraryData.removeRow(i);
+                    }
+                }
+            } else {
+                for (int i = itineraryData.getRowCount() - 1; i >= 0; --i) {
+                    if (itineraryData.ways.elementAt(i) != null) {
+                        if (!usedWays.contains(itineraryData.ways.elementAt(i))) {
+                            addWayToSortingData(itineraryData.ways.elementAt(i), frontNodes,
+                                    backNodes, loops);
+                            usedWays.add(itineraryData.ways.elementAt(i));
+                        }
+                    }
+                }
+
+                itineraryData.clear();
+            }
+
+            Iterator<Map.Entry<Node, LinkedList<RelationMember>>> entryIter = frontNodes.entrySet()
+                    .iterator();
+            while (entryIter.hasNext()) {
+                Iterator<RelationMember> relIter = entryIter.next().getValue().iterator();
+                while (relIter.hasNext()) {
+                    RelationMember curMember = relIter.next();
+                    itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
+                    if (insPos >= 0)
+                        ++insPos;
+                }
+            }
+
+            Iterator<LinkedList<RelationMember>> listIter = loops.iterator();
+            while (listIter.hasNext()) {
+                Iterator<RelationMember> relIter = listIter.next().iterator();
+                while (relIter.hasNext()) {
+                    RelationMember curMember = relIter.next();
+                    itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
+                    if (insPos >= 0)
+                        ++insPos;
+                }
+            }
+
+            itineraryData.cleanupGaps();
+            segmentMetrics = fillSegmentMetrics();
+            rebuildWays();
+        } else if ("routePattern.itineraryReflect".equals(event.getActionCommand())) {
+            Vector<RelationMember> itemsToReflect = new Vector<>();
+            int insPos = itineraryTable.getSelectedRow();
+
+            if (itineraryTable.getSelectedRowCount() > 0) {
+                for (int i = itineraryData.getRowCount() - 1; i >= 0; --i) {
+                    if (itineraryTable.isRowSelected(i)
+                            && itineraryData.ways.elementAt(i) != null) {
+                        String role = (String) itineraryData.getValueAt(i, 1);
+                        if ("backward".equals(role))
+                            role = "forward";
+                        else if ("forward".equals(role))
+                            role = "backward";
+                        else
+                            role = "backward";
+                        RelationMember markedWay = new RelationMember(role,
+                                itineraryData.ways.elementAt(i));
+                        itemsToReflect.addElement(markedWay);
+
+                        itineraryData.ways.removeElementAt(i);
+                        itineraryData.removeRow(i);
+                    }
+                }
+            } else {
+                for (int i = itineraryData.getRowCount() - 1; i >= 0; --i) {
+                    if (itineraryData.ways.elementAt(i) != null) {
+                        String role = (String) itineraryData.getValueAt(i, 1);
+                        if ("backward".equals(role))
+                            role = "forward";
+                        else if ("forward".equals(role))
+                            role = "backward";
+                        else
+                            role = "backward";
+                        RelationMember markedWay = new RelationMember(role,
+                                itineraryData.ways.elementAt(i));
+                        itemsToReflect.addElement(markedWay);
+                    }
+                }
+
+                itineraryData.clear();
+            }
+
+            int startPos = insPos;
+            Iterator<RelationMember> relIter = itemsToReflect.iterator();
+            while (relIter.hasNext()) {
+                RelationMember curMember = relIter.next();
+                if (curMember.isWay()) {
+                    itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
+                    if (insPos >= 0)
+                        ++insPos;
+                }
+            }
+            if (insPos >= 0)
+                itineraryTable.addRowSelectionInterval(startPos, insPos - 1);
+
+            itineraryData.cleanupGaps();
+            segmentMetrics = fillSegmentMetrics();
+            rebuildWays();
+        } else if ("routePattern.stoplistFind".equals(event.getActionCommand())) {
+            if (mainDataSet == null)
+                return;
+
+            stoplistTable.clearSelection();
+
+            for (int i = 0; i < stoplistData.getRowCount(); ++i) {
+                if (stoplistData.nodes.elementAt(i) != null
+                        && mainDataSet.isSelected(stoplistData.nodes.elementAt(i)))
+                    stoplistTable.addRowSelectionInterval(i, i);
+            }
+        } else if ("routePattern.stoplistShow".equals(event.getActionCommand())) {
+            BoundingXYVisitor box = new BoundingXYVisitor();
+            if (stoplistTable.getSelectedRowCount() > 0) {
+                for (int i = 0; i < stoplistData.getRowCount(); ++i) {
+                    if (stoplistTable.isRowSelected(i)) {
+                        stoplistData.nodes.elementAt(i).accept((PrimitiveVisitor) box);
+                    }
+                }
+            } else {
+                for (int i = 0; i < stoplistData.getRowCount(); ++i) {
+                    stoplistData.nodes.elementAt(i).accept((PrimitiveVisitor) box);
+                }
+            }
+            if (box.getBounds() == null)
+                return;
+            box.enlargeBoundingBox();
+            MainApplication.getMap().mapView.zoomTo(box);
+        } else if ("routePattern.stoplistMark".equals(event.getActionCommand())) {
+            OsmPrimitive[] osmp = {null};
+            MainApplication.getLayerManager().getEditDataSet().setSelected(osmp);
+            markedNodes.clear();
+            if (stoplistTable.getSelectedRowCount() > 0) {
+                for (int i = 0; i < stoplistData.getRowCount(); ++i) {
+                    if (stoplistTable.isRowSelected(i)) {
+                        mainDataSet.addSelected(stoplistData.nodes.elementAt(i));
+
+                        RelationMember markedNode = new RelationMember(
+                                (String) stoplistData.getValueAt(i, 1),
+                                stoplistData.nodes.elementAt(i));
+                        markedNodes.addElement(markedNode);
+                    }
+                }
+            } else {
+                for (int i = 0; i < stoplistData.getRowCount(); ++i) {
+                    mainDataSet.addSelected(stoplistData.nodes.elementAt(i));
+
+                    RelationMember markedNode = new RelationMember(
+                            (String) stoplistData.getValueAt(i, 1),
+                            stoplistData.nodes.elementAt(i));
+                    markedNodes.addElement(markedNode);
+                }
+            }
+        } else if ("routePattern.stoplistAdd".equals(event.getActionCommand())) {
+            int insPos = stoplistTable.getSelectedRow();
+            Iterator<RelationMember> relIter = markedNodes.iterator();
+            TreeSet<Node> addedNodes = new TreeSet<>();
+            if (mainDataSet == null)
+                return;
+
+            while (relIter.hasNext()) {
+                RelationMember curMember = relIter.next();
+                if (curMember.isNode() && mainDataSet.isSelected(curMember.getNode())) {
+                    StopReference sr = detectMinDistance(curMember.getNode(), segmentMetrics,
+                            cbRight.isSelected(), cbLeft.isSelected());
+                    stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole(),
+                            calcOffset(sr, segmentMetrics));
+                    if (insPos >= 0)
+                        ++insPos;
+
+                    addedNodes.add(curMember.getNode());
+                }
+            }
+
+            Collection<Node> selectedNodes = mainDataSet.getSelectedNodes();
+            Iterator<Node> nodeIter = selectedNodes.iterator();
+
+            while (nodeIter.hasNext()) {
+                Node curMember = nodeIter.next();
+                if (!addedNodes.contains(curMember)) {
+                    StopReference sr = detectMinDistance(curMember, segmentMetrics,
+                            cbRight.isSelected(), cbLeft.isSelected());
+                    stoplistData.insertRow(insPos, curMember, "", calcOffset(sr, segmentMetrics));
+                    if (insPos >= 0)
+                        ++insPos;
+                }
+            }
+
+            if ((insPos > 0) && (insPos < stoplistData.getRowCount())) {
+                while ((insPos < stoplistData.getRowCount())
+                        && (stoplistData.nodes.elementAt(insPos) == null)) {
+                    ++insPos;
+                }
+                stoplistTable.removeRowSelectionInterval(0, stoplistData.getRowCount() - 1);
+                if (insPos < stoplistData.getRowCount())
+                    stoplistTable.addRowSelectionInterval(insPos, insPos);
+            }
+
+            rebuildNodes();
+        } else if ("routePattern.stoplistDelete".equals(event.getActionCommand())) {
+            for (int i = stoplistData.getRowCount() - 1; i >= 0; --i) {
+                if (stoplistTable.isRowSelected(i)) {
+                    stoplistData.nodes.removeElementAt(i);
+                    stoplistData.removeRow(i);
+                }
+            }
+
+            rebuildNodes();
+        } else if ("routePattern.stoplistSort".equals(event.getActionCommand())) {
+            // Prepare Segments: The segments of all usable ways are arranged in a linear
+            // list such that a coor can directly be checked concerning position and offset
+            Vector<StopReference> srm = new Vector<>();
+            int insPos = stoplistTable.getSelectedRow();
+            if (stoplistTable.getSelectedRowCount() > 0) {
+                // Determine for each member its position on the itinerary: position means here the
+                // point on the itinerary that has minimal distance to the coor
+                for (int i = stoplistData.getRowCount() - 1; i >= 0; --i) {
+                    if (stoplistTable.isRowSelected(i)) {
+                        StopReference sr = detectMinDistance(stoplistData.nodes.elementAt(i),
+                                segmentMetrics, cbRight.isSelected(), cbLeft.isSelected());
+                        if (sr != null) {
+                            if (sr.distance < Double.parseDouble(tfSuggestStopsLimit.getText())
+                                    * 9.0 / 1000000.0) {
+                                sr.role = (String) stoplistData.getValueAt(i, STOPLIST_ROLE_COLUMN);
+                                srm.addElement(sr);
+                            } else {
+                                sr.role = (String) stoplistData.getValueAt(i, STOPLIST_ROLE_COLUMN);
+                                sr.index = segmentMetrics.size() * 2;
+                                sr.pos = 0;
+                                srm.addElement(sr);
+                            }
+
+                            stoplistData.nodes.removeElementAt(i);
+                            stoplistData.removeRow(i);
+                        }
+                    }
+                }
+            } else {
+                // Determine for each member its position on the itinerary: position means here the
+                // point on the itinerary that has minimal distance to the coor
+                for (int i = stoplistData.getRowCount() - 1; i >= 0; --i) {
+                    StopReference sr = detectMinDistance(stoplistData.nodes.elementAt(i),
+                            segmentMetrics, cbRight.isSelected(), cbLeft.isSelected());
+                    if (sr != null) {
+                        if (sr.distance < Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0
+                                / 1000000.0) {
+                            sr.role = (String) stoplistData.getValueAt(i, STOPLIST_ROLE_COLUMN);
+                            srm.addElement(sr);
+                        } else {
+                            sr.role = (String) stoplistData.getValueAt(i, STOPLIST_ROLE_COLUMN);
+                            sr.index = segmentMetrics.size() * 2;
+                            sr.pos = 0;
+                            srm.addElement(sr);
+                        }
+                    }
+                }
+
+                stoplistData.clear();
+            }
+
+            Collections.sort(srm);
+
+            for (int i = 0; i < srm.size(); ++i) {
+                StopReference sr = detectMinDistance(srm.elementAt(i).node, segmentMetrics,
+                        cbRight.isSelected(), cbLeft.isSelected());
+                stoplistData.insertRow(insPos, srm.elementAt(i).node, srm.elementAt(i).role,
+                        calcOffset(sr, segmentMetrics));
+                if (insPos >= 0)
+                    ++insPos;
+            }
+
+            rebuildNodes();
+        } else if ("routePattern.stoplistReflect".equals(event.getActionCommand())) {
+            Vector<RelationMember> itemsToReflect = new Vector<>();
+            int insPos = stoplistTable.getSelectedRow();
+
+            if (stoplistTable.getSelectedRowCount() > 0) {
+                for (int i = stoplistData.getRowCount() - 1; i >= 0; --i) {
+                    if (stoplistTable.isRowSelected(i)) {
+                        String role = (String) stoplistData.getValueAt(i, STOPLIST_ROLE_COLUMN);
+                        RelationMember markedNode = new RelationMember(role,
+                                stoplistData.nodes.elementAt(i));
+                        itemsToReflect.addElement(markedNode);
+
+                        stoplistData.nodes.removeElementAt(i);
+                        stoplistData.removeRow(i);
+                    }
+                }
+            } else {
+                for (int i = stoplistData.getRowCount() - 1; i >= 0; --i) {
+                    String role = (String) stoplistData.getValueAt(i, STOPLIST_ROLE_COLUMN);
+                    RelationMember markedNode = new RelationMember(role,
+                            stoplistData.nodes.elementAt(i));
+                    itemsToReflect.addElement(markedNode);
+                }
+
+                stoplistData.clear();
+            }
+
+            int startPos = insPos;
+            Iterator<RelationMember> relIter = itemsToReflect.iterator();
+            while (relIter.hasNext()) {
+                RelationMember curMember = relIter.next();
+                if (curMember.isNode()) {
+                    StopReference sr = detectMinDistance(curMember.getNode(), segmentMetrics,
+                            cbRight.isSelected(), cbLeft.isSelected());
+                    stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole(),
+                            calcOffset(sr, segmentMetrics));
+                    if (insPos >= 0)
+                        ++insPos;
+                }
+            }
+            if (insPos >= 0)
+                stoplistTable.addRowSelectionInterval(startPos, insPos - 1);
+
+            rebuildNodes();
+        } else if ("routePattern.metaSuggestStops".equals(event.getActionCommand())) {
+            // Prepare Segments: The segments of all usable ways are arranged in a linear
+            // list such that a coor can directly be checked concerning position and offset
+            Vector<StopReference> srm = new Vector<>();
+            // Determine for each member its position on the itinerary: position means here the
+            // point on the itinerary that has minimal distance to the coor
+            mainDataSet = MainApplication.getLayerManager().getEditDataSet();
+            if (mainDataSet != null) {
+                String stopKey = "";
+                String stopValue = "";
+                if ("bus".equals(currentRoute.get("route"))) {
+                    stopKey = "highway";
+                    stopValue = "bus_stop";
+                } else if ("trolleybus".equals(currentRoute.get("route"))) {
+                    stopKey = "highway";
+                    stopValue = "bus_stop";
+                } else if ("tram".equals(currentRoute.get("route"))) {
+                    stopKey = "railway";
+                    stopValue = "tram_stop";
+                } else if ("light_rail".equals(currentRoute.get("route"))) {
+                    stopKey = "railway";
+                    stopValue = "station";
+                } else if ("subway".equals(currentRoute.get("route"))) {
+                    stopKey = "railway";
+                    stopValue = "station";
+                } else if ("rail".equals(currentRoute.get("route"))) {
+                    stopKey = "railway";
+                    stopValue = "station";
+                }
+
+                Collection<Node> nodeCollection = mainDataSet.getNodes();
+                Iterator<Node> nodeIter = nodeCollection.iterator();
+                while (nodeIter.hasNext()) {
+                    Node currentNode = nodeIter.next();
+                    if (!currentNode.isUsable())
+                        continue;
+                    if (stopValue.equals(currentNode.get(stopKey))) {
+                        StopReference sr = detectMinDistance(currentNode, segmentMetrics,
+                                cbRight.isSelected(), cbLeft.isSelected());
+                        if ((sr != null)
+                                && (sr.distance < Double.parseDouble(tfSuggestStopsLimit.getText())
+                                        * 9.0 / 1000000.0))
+                            srm.addElement(sr);
+                    }
+                }
+            } else {
+                JOptionPane.showMessageDialog(null,
+                        tr("There exists no dataset."
+                                + " Try to download data from the server or open an OSM file."),
+                        tr("No data found"), JOptionPane.ERROR_MESSAGE);
+            }
+
+            Collections.sort(srm);
+
+            stoplistData.clear();
+            for (int i = 0; i < srm.size(); ++i) {
+                StopReference sr = detectMinDistance(srm.elementAt(i).node, segmentMetrics,
+                        cbRight.isSelected(), cbLeft.isSelected());
+                stoplistData.addRow(srm.elementAt(i).node, srm.elementAt(i).role,
+                        calcOffset(sr, segmentMetrics));
+            }
+
+            rebuildNodes();
+        } else {
+            refreshData();
+
+            jDialog.setLocationRelativeTo(frame);
+            jDialog.setVisible(true);
+        }
+    }
+
+    private void refreshData() {
+        Relation copy = currentRoute;
+        relsListModel.clear();
+        currentRoute = copy;
+
+        DataSet mainDataSet = MainApplication.getLayerManager().getEditDataSet();
+        if (mainDataSet != null) {
+            Vector<RouteReference> relRefs = new Vector<>();
+            Collection<Relation> relCollection = mainDataSet.getRelations();
+            Iterator<Relation> relIter = relCollection.iterator();
+
+            while (relIter.hasNext()) {
+                Relation currentRel = relIter.next();
+                if (!currentRel.isDeleted()) {
+                    String routeVal = currentRel.get("route");
+                    if ("bus".equals(routeVal))
+                        relRefs.add(new RouteReference(currentRel));
+                    else if ("trolleybus".equals(routeVal))
+                        relRefs.add(new RouteReference(currentRel));
+                    else if ("tram".equals(routeVal))
+                        relRefs.add(new RouteReference(currentRel));
+                    else if ("light_rail".equals(routeVal))
+                        relRefs.add(new RouteReference(currentRel));
+                    else if ("subway".equals(routeVal))
+                        relRefs.add(new RouteReference(currentRel));
+                    else if ("rail".equals(routeVal))
+                        relRefs.add(new RouteReference(currentRel));
+                }
+            }
+
+            Collections.sort(relRefs);
+
+            Iterator<RouteReference> iter = relRefs.iterator();
+            while (iter.hasNext()) {
+                relsListModel.addElement(iter.next());
+            }
+        } else {
+            JOptionPane.showMessageDialog(null,
+                    tr("There exists no dataset."
+                            + " Try to download data from the server or open an OSM file."),
+                    tr("No data found"), JOptionPane.ERROR_MESSAGE);
+        }
+    }
+
+    // Rebuild ways in the relation currentRoute
+    public static void rebuildWays() {
+        currentRoute.setModified(true);
+        List<RelationMember> members = currentRoute.getMembers();
+        ListIterator<RelationMember> iter = members.listIterator();
+        while (iter.hasNext()) {
+            if (iter.next().isWay())
+                iter.remove();
+        }
+        for (int i = 0; i < itineraryData.getRowCount(); ++i) {
+            if (itineraryData.ways.elementAt(i) != null) {
+                RelationMember member = new RelationMember(
+                        (String) itineraryData.getValueAt(i, 1), itineraryData.ways.elementAt(i));
+                members.add(member);
+            }
+        }
+        currentRoute.setMembers(members);
+    }
+
+    // Rebuild nodes in the relation currentRoute
+    private void rebuildNodes() {
+        currentRoute.setModified(true);
+        for (int i = currentRoute.getMembersCount() - 1; i >= 0; --i) {
+            if (currentRoute.getMember(i).isNode()) {
+                currentRoute.removeMember(i);
+            }
+        }
+        for (int i = 0; i < stoplistData.getRowCount(); ++i) {
+            RelationMember member = new RelationMember(
+                    (String) stoplistData.getValueAt(i, STOPLIST_ROLE_COLUMN),
+                    stoplistData.nodes.elementAt(i));
+            currentRoute.addMember(member);
+        }
+    }
+
+    private void addWayToSortingData(Way way, TreeMap<Node, LinkedList<RelationMember>> frontNodes,
+            TreeMap<Node, LinkedList<RelationMember>> backNodes,
+            Vector<LinkedList<RelationMember>> loops) {
+        if (way.getNodesCount() < 1)
+            return;
+
+        Node firstNode = way.getNode(0);
+        Node lastNode = way.getNode(way.getNodesCount() - 1);
+
+        if (frontNodes.get(firstNode) != null) {
+            LinkedList<RelationMember> list = frontNodes.get(firstNode);
+            list.addFirst(new RelationMember("backward", way));
+            frontNodes.remove(firstNode);
+
+            Node lastListNode;
+            if ("backward".equals(list.getLast().getRole()))
+                lastListNode = list.getLast().getWay().getNode(0);
+            else
+                lastListNode = list.getLast().getWay()
+                        .getNode(list.getLast().getWay().getNodesCount() - 1);
+            if (lastNode.equals(lastListNode)) {
+                backNodes.remove(lastListNode);
+                loops.add(list);
+            } else if (frontNodes.get(lastNode) != null) {
+                backNodes.remove(lastListNode);
+                LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode);
+                Iterator<RelationMember> memberIter = list.iterator();
+                while (memberIter.hasNext()) {
+                    RelationMember member = memberIter.next();
+                    if ("backward".equals(member.getRole()))
+                        listToAppend.addFirst(new RelationMember("forward", member.getWay()));
+                    else
+                        listToAppend.addFirst(new RelationMember("backward", member.getWay()));
+                }
+                frontNodes.remove(lastNode);
+                frontNodes.put(lastListNode, listToAppend);
+            } else if (backNodes.get(lastNode) != null) {
+                backNodes.remove(lastListNode);
+                LinkedList<RelationMember> listToAppend = backNodes.get(lastNode);
+                Iterator<RelationMember> memberIter = list.iterator();
+                while (memberIter.hasNext()) {
+                    RelationMember member = memberIter.next();
+                    listToAppend.addLast(member);
+                }
+                backNodes.remove(lastNode);
+                backNodes.put(lastListNode, listToAppend);
+            } else
+                frontNodes.put(lastNode, list);
+        } else if (backNodes.get(firstNode) != null) {
+            LinkedList<RelationMember> list = backNodes.get(firstNode);
+            list.addLast(new RelationMember("forward", way));
+            backNodes.remove(firstNode);
+
+            Node firstListNode;
+            if ("backward".equals(list.getFirst().getRole()))
+                firstListNode = list.getFirst().getWay()
+                        .getNode(list.getFirst().getWay().getNodesCount() - 1);
+            else
+                firstListNode = list.getFirst().getWay().getNode(0);
+            if (lastNode.equals(firstListNode)) {
+                frontNodes.remove(firstListNode);
+                loops.add(list);
+            } else if (frontNodes.get(lastNode) != null) {
+                frontNodes.remove(firstListNode);
+                LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode);
+                ListIterator<RelationMember> memberIter = list.listIterator(list.size());
+                while (memberIter.hasPrevious()) {
+                    RelationMember member = memberIter.previous();
+                    listToAppend.addFirst(member);
+                }
+                frontNodes.remove(lastNode);
+                frontNodes.put(firstListNode, listToAppend);
+            } else if (backNodes.get(lastNode) != null) {
+                frontNodes.remove(firstListNode);
+                LinkedList<RelationMember> listToAppend = backNodes.get(lastNode);
+                ListIterator<RelationMember> memberIter = list.listIterator(list.size());
+                while (memberIter.hasPrevious()) {
+                    RelationMember member = memberIter.previous();
+                    if ("backward".equals(member.getRole()))
+                        listToAppend.addLast(new RelationMember("forward", member.getWay()));
+                    else
+                        listToAppend.addLast(new RelationMember("backward", member.getWay()));
+                }
+                backNodes.remove(lastNode);
+                backNodes.put(firstListNode, listToAppend);
+            } else
+                backNodes.put(lastNode, list);
+        } else if (frontNodes.get(lastNode) != null) {
+            LinkedList<RelationMember> list = frontNodes.get(lastNode);
+            list.addFirst(new RelationMember("forward", way));
+            frontNodes.remove(lastNode);
+            frontNodes.put(firstNode, list);
+        } else if (backNodes.get(lastNode) != null) {
+            LinkedList<RelationMember> list = backNodes.get(lastNode);
+            list.addLast(new RelationMember("backward", way));
+            backNodes.remove(lastNode);
+            backNodes.put(firstNode, list);
+        } else {
+            LinkedList<RelationMember> newList = new LinkedList<>();
+            newList.add(new RelationMember("forward", way));
+            frontNodes.put(firstNode, newList);
+            backNodes.put(lastNode, newList);
+        }
+    }
+
+    private void routesSelectionChanged() {
+        int selectedPos = relsList.getAnchorSelectionIndex();
+        if (relsList.isSelectedIndex(selectedPos)) {
+            currentRoute = relsListModel.elementAt(selectedPos).route;
+            tabbedPane.setEnabledAt(1, true);
+            tabbedPane.setEnabledAt(2, true);
+            tabbedPane.setEnabledAt(3, true);
+            tabbedPane.setEnabledAt(4, true);
+
+            // Prepare Tags
+            requiredTagsData.readRelation(currentRoute);
+            commonTagsData.readRelation(currentRoute);
+            otherTagsData.readRelation(currentRoute, tagBlacklist);
+
+            // Prepare Itinerary
+            itineraryData.clear();
+            List<RelationMember> relMembers = currentRoute.getMembers();
+            Iterator<RelationMember> relIter = relMembers.iterator();
+            fillItineraryTable(relIter, 0, -1);
+
+            // Prepare Stoplist
+            stoplistData.clear();
+            /* List<RelationMember> */ relMembers = currentRoute.getMembers();
+            /* Iterator<RelationMember> */ relIter = relMembers.iterator();
+            fillStoplistTable(relIter, -1);
+        } else {
+            currentRoute = null;
+            tabbedPane.setEnabledAt(1, false);
+            tabbedPane.setEnabledAt(2, false);
+            tabbedPane.setEnabledAt(3, false);
+            tabbedPane.setEnabledAt(4, false);
+        }
+    }
+
+    private void fillItineraryTable(Iterator<RelationMember> relIter, long lastNodeId, int insPos) {
+        while (relIter.hasNext()) {
+            RelationMember curMember = relIter.next();
+            if (curMember.isWay()) {
+                itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
+                if (insPos >= 0)
+                    ++insPos;
+            }
+        }
+        itineraryData.cleanupGaps();
+        segmentMetrics = fillSegmentMetrics();
+    }
+
+    private double calcOffset(StopReference sr, Vector<SegmentMetric> segmentMetrics) {
+        double offset = 0;
+        int size = segmentMetrics.size();
+        if ((sr.index + 1) / 2 < size) {
+            offset = segmentMetrics.elementAt((sr.index + 1) / 2).distance;
+            if (sr.index % 2 == 0)
+                offset += sr.pos;
+        } else if (size > 0) {
+            offset = segmentMetrics.elementAt(size - 1).distance
+                   + segmentMetrics.elementAt(size - 1).length;
+        }
+        return offset;
+    }
+
+    private void fillStoplistTable(Iterator<RelationMember> relIter, int insPos) {
+
+        while (relIter.hasNext()) {
+            RelationMember curMember = relIter.next();
+            if (curMember.isNode()) {
+                StopReference sr = detectMinDistance(curMember.getNode(), segmentMetrics,
+                        cbRight.isSelected(), cbLeft.isSelected());
+                if (sr == null)
+                    stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole(), 360.0);
+                else {
+                    stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole(),
+                            calcOffset(sr, segmentMetrics));
+                    if (insPos >= 0)
+                        ++insPos;
+                }
+            }
+        }
+    }
+
+    private Vector<SegmentMetric> fillSegmentMetrics() {
+        Vector<SegmentMetric> segmentMetrics = new Vector<>();
+        double distance = 0;
+        for (int i = 0; i < itineraryData.getRowCount(); ++i) {
+            if (itineraryData.ways.elementAt(i) != null) {
+                Way way = itineraryData.ways.elementAt(i);
+                if (!way.isIncomplete()) {
+                    if ("backward".equals(itineraryData.getValueAt(i, 1))) {
+                        for (int j = way.getNodesCount() - 2; j >= 0; --j) {
+                            SegmentMetric sm = new SegmentMetric(way.getNode(j + 1).getCoor().lat(),
+                                    way.getNode(j + 1).getCoor().lon(),
+                                    way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(),
+                                    distance);
+                            segmentMetrics.add(sm);
+                            distance += sm.length;
+                        }
+                    } else {
+                        for (int j = 0; j < way.getNodesCount() - 1; ++j) {
+                            SegmentMetric sm = new SegmentMetric(way.getNode(j).getCoor().lat(),
+                                    way.getNode(j).getCoor().lon(),
+                                    way.getNode(j + 1).getCoor().lat(),
+                                    way.getNode(j + 1).getCoor().lon(), distance);
+                            segmentMetrics.add(sm);
+                            distance += sm.length;
+                        }
+                    }
+                }
+            } else
+                segmentMetrics.add(null);
+        }
+        return segmentMetrics;
+    }
+
+    private StopReference detectMinDistance(Node node, Vector<SegmentMetric> segmentMetrics,
+            boolean rhsPossible, boolean lhsPossible) {
+        if (node == null || node.getCoor() == null)
+            return null;
+
+        int minIndex = -1;
+        double position = -1.0;
+        double distance = 180.0;
+        double lat = node.getCoor().lat();
+        double lon = node.getCoor().lon();
+
+        int curIndex = -2;
+        double angleLat = 100.0;
+        double angleLon = 200.0;
+        Iterator<SegmentMetric> iter = segmentMetrics.iterator();
+        while (iter.hasNext()) {
+            curIndex += 2;
+            SegmentMetric sm = iter.next();
+
+            if (sm == null) {
+                angleLat = 100.0;
+                angleLon = 200.0;
+
+                continue;
+            }
+
+            double curPosition = (lat - sm.aLat) * sm.d1 + (lon - sm.aLon) * sm.d2;
+
+            if (curPosition < 0) {
+                if (angleLat <= 90.0) {
+                    double lastSegAngle = Math.atan2(angleLat - sm.aLat, angleLon - sm.aLon);
+                    double segAngle = Math.atan2(sm.d1, -sm.o1);
+                    double vertexAngle = Math.atan2(lat - sm.aLat, lon - sm.aLon);
+
+                    boolean vertexOnSeg = (vertexAngle == segAngle)
+                            || (vertexAngle == lastSegAngle);
+                    boolean vertexOnTheLeft = !vertexOnSeg
+                            && (((lastSegAngle > vertexAngle) && (vertexAngle > segAngle))
+                                    || ((vertexAngle > segAngle) && (segAngle > lastSegAngle))
+                                    || ((segAngle > lastSegAngle) && (lastSegAngle > vertexAngle)));
+
+                    double currentDistance = Math
+                            .sqrt((lat - sm.aLat) * (lat - sm.aLat) + (lon - sm.aLon)
+                                    * (lon - sm.aLon) * Math.cos(sm.aLat * Math.PI / 180.0)
+                                    * Math.cos(sm.aLat * Math.PI / 180.0));
+                    curPosition = vertexAngle - segAngle;
+                    if (vertexOnTheLeft)
+                        curPosition = -curPosition;
+                    if (curPosition < 0)
+                        curPosition += 2 * Math.PI;
+                    if ((Math.abs(currentDistance) < distance)
+                            && ((!vertexOnTheLeft && rhsPossible)
+                                    || (vertexOnTheLeft && lhsPossible) || vertexOnSeg)) {
+                        distance = Math.abs(currentDistance);
+                        minIndex = curIndex - 1;
+                        position = curPosition;
+                    }
+                }
+                angleLat = 100.0;
+                angleLon = 200.0;
+            } else if (curPosition > sm.length) {
+                angleLat = sm.aLat;
+                angleLon = sm.aLon;
+            } else {
+                double currentDistance = (lat - sm.aLat) * sm.o1 + (lon - sm.aLon) * sm.o2;
+                if ((Math.abs(currentDistance) < distance)
+                        && ((currentDistance >= 0 && rhsPossible)
+                                || (currentDistance <= 0 && lhsPossible))) {
+                    distance = Math.abs(currentDistance);
+                    minIndex = curIndex;
+                    position = curPosition;
+                }
+
+                angleLat = 100.0;
+                angleLon = 200.0;
+            }
+        }
+
+        if (minIndex == -1)
+            return new StopReference(segmentMetrics.size() * 2, 0, 180.0, node.get("name"), "",
+                    node);
+
+        return new StopReference(minIndex, position, distance, node.get("name"), "", node);
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/StopImporterAction.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/StopImporterAction.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/StopImporterAction.java	(revision 34718)
@@ -0,0 +1,522 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.actions;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.zip.GZIPInputStream;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultListModel;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.UndoRedoHandler;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.GpxData;
+import org.openstreetmap.josm.data.gpx.GpxTrack;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.io.GpxReader;
+import org.openstreetmap.josm.plugins.public_transport.commands.SettingsStoptypeCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.TrackStoplistAddCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.TrackStoplistDeleteCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.TrackStoplistDetachCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.TrackStoplistRelocateCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.TrackStoplistSortCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.TrackSuggestStopsCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.WaypointsDetachCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.WaypointsDisableCommand;
+import org.openstreetmap.josm.plugins.public_transport.commands.WaypointsEnableCommand;
+import org.openstreetmap.josm.plugins.public_transport.dialogs.StopImporterDialog;
+import org.openstreetmap.josm.plugins.public_transport.models.WaypointTableModel;
+import org.openstreetmap.josm.plugins.public_transport.refs.TrackReference;
+import org.openstreetmap.josm.spi.preferences.Config;
+import org.xml.sax.SAXException;
+
+/**
+ * Create Stops from GPX
+ */
+public class StopImporterAction extends JosmAction {
+    private static StopImporterDialog dialog = null;
+
+    private static DefaultListModel<TrackReference> tracksListModel = null;
+
+    private static GpxData data = null;
+
+    private static TrackReference currentTrack = null;
+
+    private static WaypointTableModel waypointTM = null;
+
+    public boolean inEvent = false;
+
+    /**
+     * Constructs a new {@code StopImporterAction}.
+     */
+    public StopImporterAction() {
+        super(tr("Create Stops from GPX ..."), null, tr("Create Stops from a GPX file"), null,
+                false);
+        putValue("toolbar", "publictransport/stopimporter");
+        MainApplication.getToolbar().register(this);
+    }
+
+    public WaypointTableModel getWaypointTableModel() {
+        return waypointTM;
+    }
+
+    public StopImporterDialog getDialog() {
+        return dialog;
+    }
+
+    public DefaultListModel<TrackReference> getTracksListModel() {
+        if (tracksListModel == null)
+            tracksListModel = new DefaultListModel<>();
+        return tracksListModel;
+    }
+
+    public TrackReference getCurrentTrack() {
+        return currentTrack;
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent event) {
+        if (dialog == null)
+            dialog = new StopImporterDialog(this);
+
+        dialog.setVisible(true);
+
+        if (tr("Create Stops from GPX ...").equals(event.getActionCommand())) {
+            String curDir = Config.getPref().get("lastDirectory");
+            if (curDir.equals("")) {
+                curDir = ".";
+            }
+            JFileChooser fc = new JFileChooser(new File(curDir));
+            fc.setDialogTitle(tr("Select GPX file"));
+            fc.setMultiSelectionEnabled(false);
+
+            int answer = fc.showOpenDialog(MainApplication.getMainFrame());
+            if (answer != JFileChooser.APPROVE_OPTION)
+                return;
+
+            if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
+                Config.getPref().put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
+
+            importData(fc.getSelectedFile());
+
+            refreshData();
+        } else if ("stopImporter.settingsGPSTimeStart".equals(event.getActionCommand())) {
+            if (!inEvent && dialog.gpsTimeStartValid() && currentTrack != null)
+                UndoRedoHandler.getInstance().add(new TrackStoplistRelocateCommand(this));
+        } else if ("stopImporter.settingsStopwatchStart".equals(event.getActionCommand())) {
+            if (!inEvent && dialog.stopwatchStartValid() && currentTrack != null)
+                UndoRedoHandler.getInstance().add(new TrackStoplistRelocateCommand(this));
+        } else if ("stopImporter.settingsTimeWindow".equals(event.getActionCommand())) {
+            if (currentTrack != null)
+                currentTrack.timeWindow = dialog.getTimeWindow();
+        } else if ("stopImporter.settingsThreshold".equals(event.getActionCommand())) {
+            if (currentTrack != null)
+                currentTrack.threshold = dialog.getThreshold();
+        } else if ("stopImporter.settingsSuggestStops".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new TrackSuggestStopsCommand(this));
+        else if ("stopImporter.stoplistFind".equals(event.getActionCommand()))
+            findNodesInTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes());
+        else if ("stopImporter.stoplistShow".equals(event.getActionCommand()))
+            showNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes());
+        else if ("stopImporter.stoplistMark".equals(event.getActionCommand()))
+            markNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes());
+        else if ("stopImporter.stoplistDetach".equals(event.getActionCommand())) {
+            UndoRedoHandler.getInstance().add(new TrackStoplistDetachCommand(this));
+            dialog.getStoplistTable().clearSelection();
+        } else if ("stopImporter.stoplistAdd".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new TrackStoplistAddCommand(this));
+        else if ("stopImporter.stoplistDelete".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new TrackStoplistDeleteCommand(this));
+        else if ("stopImporter.stoplistSort".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new TrackStoplistSortCommand(this));
+        else if ("stopImporter.waypointsFind".equals(event.getActionCommand()))
+            findNodesInTable(dialog.getWaypointsTable(), waypointTM.nodes);
+        else if ("stopImporter.waypointsShow".equals(event.getActionCommand()))
+            showNodesFromTable(dialog.getWaypointsTable(), waypointTM.nodes);
+        else if ("stopImporter.waypointsMark".equals(event.getActionCommand()))
+            markNodesFromTable(dialog.getWaypointsTable(), waypointTM.nodes);
+        else if ("stopImporter.waypointsDetach".equals(event.getActionCommand())) {
+            UndoRedoHandler.getInstance().add(new WaypointsDetachCommand(this));
+            dialog.getWaypointsTable().clearSelection();
+        } else if ("stopImporter.waypointsAdd".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new WaypointsEnableCommand(this));
+        else if ("stopImporter.waypointsDelete".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new WaypointsDisableCommand(this));
+        else if ("stopImporter.settingsStoptype".equals(event.getActionCommand()))
+            UndoRedoHandler.getInstance().add(new SettingsStoptypeCommand(this));
+    }
+
+    private void importData(final File file) {
+        try {
+            InputStream is;
+            if (file.getName().endsWith(".gpx.gz"))
+                is = new GZIPInputStream(new FileInputStream(file));
+            else
+                is = new FileInputStream(file);
+            // Workaround for SAX BOM bug
+            // https://bugs.openjdk.java.net/browse/JDK-6206835
+            if (!((is.read() == 0xef) && (is.read() == 0xbb) && (is.read() == 0xbf))) {
+                is.close();
+                if (file.getName().endsWith(".gpx.gz"))
+                    is = new GZIPInputStream(new FileInputStream(file));
+                else
+                    is = new FileInputStream(file);
+            }
+            final GpxReader r = new GpxReader(is);
+            final boolean parsedProperly = r.parse(true);
+            data = r.getGpxData();
+
+            if (!parsedProperly) {
+                JOptionPane.showMessageDialog(null,
+                        tr("Error occurred while parsing gpx file {0}. Only a part of the file will be available.",
+                                file.getName()));
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+            JOptionPane.showMessageDialog(null, tr("File \"{0}\" does not exist", file.getName()));
+        } catch (SAXException e) {
+            e.printStackTrace();
+            JOptionPane.showMessageDialog(null, tr("Parsing file \"{0}\" failed", file.getName()));
+        } catch (IOException e) {
+            e.printStackTrace();
+            JOptionPane.showMessageDialog(null, tr("IOException \"{0}\" occurred", e.toString()));
+        }
+    }
+
+    private void refreshData() {
+        tracksListModel.clear();
+        if (data != null) {
+            Vector<TrackReference> trackRefs = new Vector<>();
+            Iterator<GpxTrack> trackIter = data.tracks.iterator();
+            while (trackIter.hasNext()) {
+                GpxTrack track = trackIter.next();
+                trackRefs.add(new TrackReference(track, this));
+            }
+
+            Collections.sort(trackRefs);
+
+            Iterator<TrackReference> iter = trackRefs.iterator();
+            while (iter.hasNext()) {
+                tracksListModel.addElement(iter.next());
+            }
+
+            waypointTM = new WaypointTableModel(this);
+            Iterator<WayPoint> waypointIter = data.waypoints.iterator();
+            while (waypointIter.hasNext()) {
+                WayPoint waypoint = waypointIter.next();
+                waypointTM.addRow(waypoint);
+            }
+            dialog.setWaypointsTableModel(waypointTM);
+        } else {
+            JOptionPane.showMessageDialog(null,
+                    tr("The GPX file contained no tracks or waypoints."), tr("No data found"),
+                    JOptionPane.ERROR_MESSAGE);
+        }
+    }
+
+    public void tracksSelectionChanged(int selectedPos) {
+        if (selectedPos >= 0) {
+            currentTrack = tracksListModel.elementAt(selectedPos);
+            dialog.setTrackValid(true);
+
+            // Prepare Settings
+            dialog.setSettings(currentTrack.gpsSyncTime, currentTrack.stopwatchStart,
+                    currentTrack.timeWindow, currentTrack.threshold);
+
+            // Prepare Stoplist
+            dialog.setStoplistTableModel(tracksListModel.elementAt(selectedPos).stoplistTM);
+        } else {
+            currentTrack = null;
+            dialog.setTrackValid(false);
+        }
+    }
+
+    public Node createNode(LatLon latLon, String name) {
+        return createNode(latLon, dialog.getStoptype(), name);
+    }
+
+    public static Node createNode(LatLon latLon, String type, String name) {
+        Node node = new Node(latLon);
+        setTagsWrtType(node, type);
+        node.put("name", name);
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        if (ds == null) {
+            JOptionPane.showMessageDialog(null,
+                    tr("There exists no dataset."
+                            + " Try to download data from the server or open an OSM file."),
+                    tr("No data found"), JOptionPane.ERROR_MESSAGE);
+
+            return null;
+        }
+        ds.addPrimitive(node);
+        return node;
+    }
+
+    /**
+     * sets the tags of the node according to the type
+     * @param node node
+     * @param type type
+     */
+    public static void setTagsWrtType(Node node, String type) {
+        node.remove("highway");
+        node.remove("railway");
+        if ("bus".equals(type))
+            node.put("highway", "bus_stop");
+        else if ("tram".equals(type))
+            node.put("railway", "tram_stop");
+        else if ("light_rail".equals(type))
+            node.put("railway", "station");
+        else if ("subway".equals(type))
+            node.put("railway", "station");
+        else if ("rail".equals(type))
+            node.put("railway", "station");
+    }
+
+    /**
+     * returns a collection of all selected lines or a collection of all lines otherwise
+     * @param table table
+     * @return all selected lines or a collection of all lines otherwise
+     */
+    public static Vector<Integer> getConsideredLines(JTable table) {
+        int[] selectedLines = table.getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < table.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+        return consideredLines;
+    }
+
+    /**
+     * marks the table items whose nodes are marked on the map
+     * @param table table
+     * @param nodes nodes
+     */
+    public static void findNodesInTable(JTable table, Vector<Node> nodes) {
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        if (ds == null)
+            return;
+
+        table.clearSelection();
+
+        for (int i = 0; i < table.getRowCount(); ++i) {
+            if (nodes.elementAt(i) != null && ds.isSelected(nodes.elementAt(i)))
+                table.addRowSelectionInterval(i, i);
+        }
+    }
+
+    /**
+     * shows the nodes that correspond to the marked lines in the table. If no lines are marked in the table, show all nodes from the vector
+     * @param table table
+     * @param nodes nodes
+     */
+    public static void showNodesFromTable(JTable table, Vector<Node> nodes) {
+        BoundingXYVisitor box = new BoundingXYVisitor();
+        Vector<Integer> consideredLines = getConsideredLines(table);
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            int j = consideredLines.elementAt(i);
+            if (nodes.elementAt(j) != null)
+                nodes.elementAt(j).accept((PrimitiveVisitor) box);
+        }
+        if (box.getBounds() == null)
+            return;
+        box.enlargeBoundingBox();
+        MainApplication.getMap().mapView.zoomTo(box);
+    }
+
+    /**
+     * marks the nodes that correspond to the marked lines in the table. If no lines are marked in the table, mark all nodes from the vector
+     * @param table table
+     * @param nodes nodes
+     */
+    public static void markNodesFromTable(JTable table, Vector<Node> nodes) {
+        OsmPrimitive[] osmp = {null};
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        ds.setSelected(osmp);
+        Vector<Integer> consideredLines = getConsideredLines(table);
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            int j = consideredLines.elementAt(i);
+            if (nodes.elementAt(j) != null)
+                ds.addSelected(nodes.elementAt(j));
+        }
+    }
+
+    public static String timeOf(double t) {
+        t -= Math.floor(t / 24 / 60 / 60) * 24 * 60 * 60;
+
+        int hour = (int) Math.floor(t / 60 / 60);
+        t -= Math.floor(t / 60 / 60) * 60 * 60;
+        int minute = (int) Math.floor(t / 60);
+        t -= Math.floor(t / 60) * 60;
+        double second = t;
+
+        Format format = new DecimalFormat("00");
+        Format formatS = new DecimalFormat("00.###");
+        return (format.format(hour) + ":" + format.format(minute) + ":" + formatS.format(second));
+    }
+
+    public Action getFocusWaypointNameAction() {
+        return new FocusWaypointNameAction();
+    }
+
+    public Action getFocusWaypointShelterAction(String shelter) {
+        return new FocusWaypointShelterAction(shelter);
+    }
+
+    public Action getFocusWaypointDeleteAction() {
+        return new AbstractAction() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                JTable table = dialog.getWaypointsTable();
+                int row = table.getEditingRow();
+                if (row < 0)
+                    return;
+                table.clearSelection();
+                table.addRowSelectionInterval(row, row);
+                UndoRedoHandler.getInstance().add(new WaypointsDisableCommand(StopImporterAction.this));
+            }
+        };
+    }
+
+    public Action getFocusTrackStoplistNameAction() {
+        return new FocusTrackStoplistNameAction();
+    }
+
+    public Action getFocusTrackStoplistShelterAction(String shelter) {
+        return new FocusTrackStoplistShelterAction(shelter);
+    }
+
+    public Action getFocusStoplistDeleteAction() {
+        return new AbstractAction() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                JTable table = dialog.getStoplistTable();
+                int row = table.getEditingRow();
+                if (row < 0)
+                    return;
+                table.clearSelection();
+                table.addRowSelectionInterval(row, row);
+                UndoRedoHandler.getInstance().add(new TrackStoplistDeleteCommand(StopImporterAction.this));
+            }
+        };
+    }
+
+    private static class FocusWaypointNameAction extends AbstractAction {
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            JTable table = dialog.getWaypointsTable();
+            showNodesFromTable(table, waypointTM.nodes);
+            markNodesFromTable(table, waypointTM.nodes);
+            int row = table.getEditingRow();
+            if (row < 0)
+                row = 0;
+            waypointTM.inEvent = true;
+            if (table.getCellEditor() != null) {
+                if (!table.getCellEditor().stopCellEditing())
+                    table.getCellEditor().cancelCellEditing();
+            }
+            table.editCellAt(row, 1);
+            table.getCellEditor().getTableCellEditorComponent(table, "", true, row, 1);
+            waypointTM.inEvent = false;
+        }
+    }
+
+    private static class FocusWaypointShelterAction extends AbstractAction {
+        private String defaultShelter = null;
+
+        FocusWaypointShelterAction(String defaultShelter) {
+            this.defaultShelter = defaultShelter;
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            JTable table = dialog.getWaypointsTable();
+            showNodesFromTable(table, waypointTM.nodes);
+            markNodesFromTable(table, waypointTM.nodes);
+            int row = table.getEditingRow();
+            if (row < 0)
+                row = 0;
+            waypointTM.inEvent = true;
+            if (table.getCellEditor() != null) {
+                if (!table.getCellEditor().stopCellEditing())
+                    table.getCellEditor().cancelCellEditing();
+            }
+            table.editCellAt(row, 2);
+            waypointTM.inEvent = false;
+            table.getCellEditor().getTableCellEditorComponent(table, defaultShelter, true, row, 2);
+        }
+    }
+
+    private static class FocusTrackStoplistNameAction extends AbstractAction {
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            JTable table = dialog.getStoplistTable();
+            showNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+            markNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+            int row = table.getEditingRow();
+            if (row < 0)
+                row = 0;
+            currentTrack.inEvent = true;
+            if (table.getCellEditor() != null) {
+                if (!table.getCellEditor().stopCellEditing())
+                    table.getCellEditor().cancelCellEditing();
+            }
+            table.editCellAt(row, 1);
+            table.getCellEditor().getTableCellEditorComponent(table, "", true, row, 1);
+            currentTrack.inEvent = false;
+        }
+    }
+
+    private static class FocusTrackStoplistShelterAction extends AbstractAction {
+        private String defaultShelter = null;
+
+        FocusTrackStoplistShelterAction(String defaultShelter) {
+            this.defaultShelter = defaultShelter;
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            JTable table = dialog.getStoplistTable();
+            showNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+            markNodesFromTable(table, currentTrack.stoplistTM.getNodes());
+            int row = table.getEditingRow();
+            if (row < 0)
+                row = 0;
+            currentTrack.inEvent = true;
+            if (table.getCellEditor() != null) {
+                if (!table.getCellEditor().stopCellEditing())
+                    table.getCellEditor().cancelCellEditing();
+            }
+            table.editCellAt(row, 2);
+            currentTrack.inEvent = false;
+            table.getCellEditor().getTableCellEditorComponent(table, defaultShelter, true, row, 2);
+        }
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/AbstractGTFSCatchJoinCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/AbstractGTFSCatchJoinCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/AbstractGTFSCatchJoinCommand.java	(revision 34718)
@@ -0,0 +1,117 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.GTFSStopTableModel;
+
+public abstract class AbstractGTFSCatchJoinCommand extends Command {
+    private List<Integer> workingLines = null;
+
+    private Node undoMapNode = null;
+
+    private Node undoTableNode = null;
+
+    private GTFSStopTableModel gtfsStopTM = null;
+
+    private String type = null;
+
+    private final boolean isCatch;
+
+    public AbstractGTFSCatchJoinCommand(GTFSImporterAction controller, boolean isCatch) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        gtfsStopTM = controller.getGTFSStopTableModel();
+        workingLines = new ArrayList<>();
+        this.isCatch = isCatch;
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getGTFSStopTable().getSelectedRows();
+        if (selectedLines.length != 1)
+            return;
+        workingLines.add(selectedLines[0]);
+    }
+
+    @Override
+    public boolean executeCommand() {
+        if (workingLines.size() != 1)
+            return false;
+        Node dest = null;
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        Iterator<Node> iter = ds.getSelectedNodes().iterator();
+        int j = workingLines.get(0);
+        while (iter.hasNext()) {
+            Node n = iter.next();
+            if (n != null && n.equals(gtfsStopTM.nodes.elementAt(j)))
+                continue;
+            if (dest != null)
+                return false;
+            dest = n;
+        }
+        if (dest == null)
+            return false;
+        undoMapNode = new Node(dest);
+
+        Node node = gtfsStopTM.nodes.elementAt(j);
+        undoTableNode = node;
+        if (node != null) {
+            ds.removePrimitive(node);
+            node.setDeleted(true);
+        }
+
+        if (isCatch)
+            dest.setCoor(gtfsStopTM.coors.elementAt(j));
+        dest.put("highway", "bus_stop");
+        dest.put("stop_id", (String) gtfsStopTM.getValueAt(j, 0));
+        if (dest.get("name") == null)
+            dest.put("name", (String) gtfsStopTM.getValueAt(j, 1));
+        if (isCatch)
+            dest.put("note", "moved by gtfs import");
+        gtfsStopTM.nodes.set(j, dest);
+        type = (String) gtfsStopTM.getValueAt(j, 2);
+        gtfsStopTM.setValueAt(isCatch ? "fed" : tr("moved"), j, 2);
+
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        if (workingLines.size() != 1)
+            return;
+        int j = workingLines.get(0);
+
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        Node node = gtfsStopTM.nodes.elementAt(j);
+        if (node != null) {
+            ds.removePrimitive(node);
+            node.setDeleted(true);
+        }
+
+        if (undoMapNode != null) {
+            undoMapNode.setDeleted(false);
+            ds.addPrimitive(undoMapNode);
+        }
+        if (undoTableNode != null) {
+            undoTableNode.setDeleted(false);
+            ds.addPrimitive(undoTableNode);
+        }
+        gtfsStopTM.nodes.set(j, undoTableNode);
+        gtfsStopTM.setValueAt(type, j, 2);
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+        // Do nothing
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSAddCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSAddCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSAddCommand.java	(revision 34718)
@@ -0,0 +1,89 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.GTFSStopTableModel;
+
+public class GTFSAddCommand extends Command {
+    private Vector<Integer> workingLines = null;
+
+    private Vector<String> typesForUndo = null;
+
+    private GTFSStopTableModel gtfsStopTM = null;
+
+    private String type = null;
+
+    public GTFSAddCommand(GTFSImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        gtfsStopTM = controller.getGTFSStopTableModel();
+        type = controller.getDialog().getStoptype();
+        workingLines = new Vector<>();
+        typesForUndo = new Vector<>();
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getGTFSStopTable().getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < gtfsStopTM.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+
+        // keep only lines where a node can be added
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            if (gtfsStopTM.nodes.elementAt(consideredLines.elementAt(i)) == null)
+                workingLines.add(consideredLines.elementAt(i));
+        }
+    }
+
+    @Override
+    public boolean executeCommand() {
+        typesForUndo.clear();
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            typesForUndo.add((String) gtfsStopTM.getValueAt(j, 2));
+            Node node = GTFSImporterAction.createNode(gtfsStopTM.coors.elementAt(j),
+                    (String) gtfsStopTM.getValueAt(j, 0), (String) gtfsStopTM.getValueAt(j, 1));
+            gtfsStopTM.nodes.set(j, node);
+            gtfsStopTM.setValueAt(tr("added"), j, 2);
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = gtfsStopTM.nodes.elementAt(j);
+            gtfsStopTM.nodes.set(j, null);
+            gtfsStopTM.setValueAt(typesForUndo.elementAt(i), j, 2);
+            if (node == null)
+                continue;
+            MainApplication.getLayerManager().getEditDataSet().removePrimitive(node);
+            node.setDeleted(true);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Enable GTFSStops");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSCatchCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSCatchCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSCatchCommand.java	(revision 34718)
@@ -0,0 +1,18 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+
+public class GTFSCatchCommand extends AbstractGTFSCatchJoinCommand {
+
+    public GTFSCatchCommand(GTFSImporterAction controller) {
+        super(controller, true);
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Catch GTFS stops");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSDeleteCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSDeleteCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSDeleteCommand.java	(revision 34718)
@@ -0,0 +1,94 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.GTFSStopTableModel;
+
+public class GTFSDeleteCommand extends Command {
+    private Vector<Integer> workingLines = null;
+
+    private Vector<Node> nodesForUndo = null;
+
+    private Vector<String> typesForUndo = null;
+
+    private GTFSStopTableModel gtfsStopTM = null;
+
+    public GTFSDeleteCommand(GTFSImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        gtfsStopTM = controller.getGTFSStopTableModel();
+        workingLines = new Vector<>();
+        nodesForUndo = new Vector<>();
+        typesForUndo = new Vector<>();
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getGTFSStopTable().getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < gtfsStopTM.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+
+        // keep only lines where a node can be added
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            if (gtfsStopTM.nodes.elementAt(consideredLines.elementAt(i)) != null)
+                workingLines.add(consideredLines.elementAt(i));
+        }
+    }
+
+    @Override
+    public boolean executeCommand() {
+        nodesForUndo.clear();
+        typesForUndo.clear();
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = gtfsStopTM.nodes.elementAt(j);
+            nodesForUndo.add(node);
+            typesForUndo.add((String) gtfsStopTM.getValueAt(j, 2));
+            if (node == null)
+                continue;
+            gtfsStopTM.nodes.set(j, null);
+            gtfsStopTM.setValueAt(tr("skipped"), j, 2);
+            MainApplication.getLayerManager().getEditDataSet().removePrimitive(node);
+            node.setDeleted(true);
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = nodesForUndo.elementAt(i);
+            gtfsStopTM.nodes.set(j, node);
+            gtfsStopTM.setValueAt(typesForUndo.elementAt(i), j, 2);
+            if (node == null)
+                continue;
+            node.setDeleted(false);
+            MainApplication.getLayerManager().getEditDataSet().addPrimitive(node);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Disable GTFS");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSJoinCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSJoinCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/GTFSJoinCommand.java	(revision 34718)
@@ -0,0 +1,18 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+
+public class GTFSJoinCommand extends AbstractGTFSCatchJoinCommand {
+
+    public GTFSJoinCommand(GTFSImporterAction controller) {
+        super(controller, false);
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Join GTFS stops");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/SettingsStoptypeCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/SettingsStoptypeCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/SettingsStoptypeCommand.java	(revision 34718)
@@ -0,0 +1,91 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import javax.swing.DefaultListModel;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.WaypointTableModel;
+import org.openstreetmap.josm.plugins.public_transport.refs.TrackReference;
+
+public class SettingsStoptypeCommand extends Command {
+    private static class HighwayRailway {
+        HighwayRailway(Node node) {
+            this.node = node;
+            highway = node.get("highway");
+            railway = node.get("railway");
+        }
+
+        public Node node;
+
+        public String highway;
+
+        public String railway;
+    }
+
+    private Vector<HighwayRailway> oldStrings = null;
+
+    private WaypointTableModel waypointTM = null;
+
+    private DefaultListModel<?> tracksListModel = null;
+
+    private String type = null;
+
+    public SettingsStoptypeCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        waypointTM = controller.getWaypointTableModel();
+        tracksListModel = controller.getTracksListModel();
+        type = controller.getDialog().getStoptype();
+        oldStrings = new Vector<>();
+    }
+
+    @Override
+    public boolean executeCommand() {
+        oldStrings.clear();
+        for (int i = 0; i < waypointTM.getRowCount(); ++i) {
+            if (waypointTM.nodes.elementAt(i) != null) {
+                Node node = waypointTM.nodes.elementAt(i);
+                oldStrings.add(new HighwayRailway(node));
+                StopImporterAction.setTagsWrtType(node, type);
+            }
+        }
+        for (int j = 0; j < tracksListModel.size(); ++j) {
+            TrackReference track = (TrackReference) tracksListModel.elementAt(j);
+            for (int i = 0; i < track.stoplistTM.getRowCount(); ++i) {
+                if (track.stoplistTM.nodeAt(i) != null) {
+                    Node node = track.stoplistTM.nodeAt(i);
+                    oldStrings.add(new HighwayRailway(node));
+                    StopImporterAction.setTagsWrtType(node, type);
+                }
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < oldStrings.size(); ++i) {
+            HighwayRailway hr = oldStrings.elementAt(i);
+            hr.node.put("highway", hr.highway);
+            hr.node.put("railway", hr.railway);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Change stop type");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistAddCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistAddCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistAddCommand.java	(revision 34718)
@@ -0,0 +1,48 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.TrackStoplistTableModel;
+
+public class TrackStoplistAddCommand extends Command {
+    private int workingLine;
+
+    private TrackStoplistTableModel stoplistTM = null;
+
+    public TrackStoplistAddCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        stoplistTM = controller.getCurrentTrack().stoplistTM;
+        workingLine = controller.getDialog().getStoplistTable().getSelectedRow();
+    }
+
+    @Override
+    public boolean executeCommand() {
+        stoplistTM.insertRow(workingLine, "00:00:00");
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        int workingLine = this.workingLine;
+        if (workingLine < 0)
+            workingLine = stoplistTM.getRowCount() - 1;
+        stoplistTM.removeRow(workingLine);
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Add track stop");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistDeleteCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistDeleteCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistDeleteCommand.java	(revision 34718)
@@ -0,0 +1,99 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.TrackStoplistTableModel;
+
+public class TrackStoplistDeleteCommand extends Command {
+    private static class NodeTimeName {
+        NodeTimeName(Node node, String time, String name, TransText shelter) {
+            this.node = node;
+            this.time = time;
+            this.name = name;
+            this.shelter = shelter;
+        }
+
+        public Node node;
+
+        public String time;
+
+        public String name;
+
+        public TransText shelter;
+    }
+
+    private Vector<Integer> workingLines = null;
+
+    private Vector<NodeTimeName> nodesForUndo = null;
+
+    private TrackStoplistTableModel stoplistTM = null;
+
+    public TrackStoplistDeleteCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        stoplistTM = controller.getCurrentTrack().stoplistTM;
+        workingLines = new Vector<>();
+        nodesForUndo = new Vector<>();
+
+        // use selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getStoplistTable().getSelectedRows();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                workingLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < stoplistTM.getRowCount(); ++i) {
+                workingLines.add(Integer.valueOf(i));
+            }
+        }
+    }
+
+    @Override
+    public boolean executeCommand() {
+        nodesForUndo.clear();
+        for (int i = workingLines.size() - 1; i >= 0; --i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = stoplistTM.nodeAt(j);
+            nodesForUndo.add(new NodeTimeName(node, (String) stoplistTM.getValueAt(j, 0),
+                    (String) stoplistTM.getValueAt(j, 1), (TransText) stoplistTM.getValueAt(j, 2)));
+            stoplistTM.removeRow(j);
+            if (node == null)
+                continue;
+            MainApplication.getLayerManager().getEditDataSet().removePrimitive(node);
+            node.setDeleted(true);
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            NodeTimeName ntn = nodesForUndo.elementAt(workingLines.size() - i - 1);
+            stoplistTM.insertRow(j, ntn.node, ntn.time, ntn.name, ntn.shelter);
+            if (ntn.node == null)
+                continue;
+            ntn.node.setDeleted(false);
+            MainApplication.getLayerManager().getEditDataSet().addPrimitive(ntn.node);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Delete track stop");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistDetachCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistDetachCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistDetachCommand.java	(revision 34718)
@@ -0,0 +1,79 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.TrackStoplistTableModel;
+
+public class TrackStoplistDetachCommand extends Command {
+    private Vector<Integer> workingLines = null;
+
+    private Vector<Node> nodesForUndo = null;
+
+    private TrackStoplistTableModel stoplistTM = null;
+
+    public TrackStoplistDetachCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        stoplistTM = controller.getCurrentTrack().stoplistTM;
+        workingLines = new Vector<>();
+        nodesForUndo = new Vector<>();
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getStoplistTable().getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < stoplistTM.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+
+        // keep only lines where a node can be added
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            if (stoplistTM.nodeAt(consideredLines.elementAt(i)) != null)
+                workingLines.add(consideredLines.elementAt(i));
+        }
+    }
+
+    @Override
+    public boolean executeCommand() {
+        nodesForUndo.clear();
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = stoplistTM.nodeAt(j);
+            nodesForUndo.add(node);
+            stoplistTM.setNodeAt(j, null);
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = nodesForUndo.elementAt(i);
+            stoplistTM.setNodeAt(j, node);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Detach track stop list");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistNameCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistNameCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistNameCommand.java	(revision 34718)
@@ -0,0 +1,107 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.dialogs.StopImporterDialog;
+import org.openstreetmap.josm.plugins.public_transport.refs.TrackReference;
+
+public class TrackStoplistNameCommand extends Command {
+    private int workingLine = 0;
+
+    private TrackReference trackref = null;
+
+    private String oldName = null;
+
+    private String name = null;
+
+    private String oldTime = null;
+
+    private String time = null;
+
+    private String oldShelter = null;
+
+    private TransText shelter = null;
+
+    private LatLon oldLatLon = null;
+
+    public TrackStoplistNameCommand(TrackReference trackref, int workingLine) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        this.trackref = trackref;
+        this.workingLine = workingLine;
+        Node node = trackref.stoplistTM.nodeAt(workingLine);
+        if (node != null) {
+            oldName = node.get("name");
+            oldTime = trackref.stoplistTM.timeAt(workingLine);
+            oldShelter = node.get("shelter");
+            oldLatLon = node.getCoor();
+        }
+        this.time = (String) trackref.stoplistTM.getValueAt(workingLine, 0);
+        this.name = (String) trackref.stoplistTM.getValueAt(workingLine, 1);
+        this.shelter = (TransText) trackref.stoplistTM.getValueAt(workingLine, 2);
+        if ("".equals(this.shelter.text))
+            this.shelter = null;
+    }
+
+    @Override
+    public boolean executeCommand() {
+        Node node = trackref.stoplistTM.nodeAt(workingLine);
+        if (node != null) {
+            node.put("name", name);
+            node.put("shelter", shelter.text);
+            double dTime = StopImporterDialog.parseTime(time);
+            node.setCoor(trackref.computeCoor(dTime));
+        }
+        trackref.inEvent = true;
+        if (time == null)
+            trackref.stoplistTM.setValueAt("", workingLine, 0);
+        else
+            trackref.stoplistTM.setValueAt(time, workingLine, 0);
+        if (name == null)
+            trackref.stoplistTM.setValueAt("", workingLine, 1);
+        else
+            trackref.stoplistTM.setValueAt(name, workingLine, 1);
+        trackref.stoplistTM.setValueAt(shelter, workingLine, 2);
+        trackref.inEvent = false;
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        Node node = trackref.stoplistTM.nodeAt(workingLine);
+        if (node != null) {
+            node.put("name", oldName);
+            node.put("shelter", oldShelter);
+            node.setCoor(oldLatLon);
+        }
+        trackref.inEvent = true;
+        if (oldTime == null)
+            trackref.stoplistTM.setValueAt("", workingLine, 0);
+        else
+            trackref.stoplistTM.setValueAt(oldTime, workingLine, 0);
+        if (oldName == null)
+            trackref.stoplistTM.setValueAt("", workingLine, 1);
+        else
+            trackref.stoplistTM.setValueAt(oldName, workingLine, 1);
+        trackref.stoplistTM.setValueAt(new TransText(oldShelter), workingLine, 2);
+        trackref.inEvent = false;
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Edit track stop list");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistRelocateCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistRelocateCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistRelocateCommand.java	(revision 34718)
@@ -0,0 +1,92 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.dialogs.StopImporterDialog;
+import org.openstreetmap.josm.plugins.public_transport.refs.TrackReference;
+
+public class TrackStoplistRelocateCommand extends Command {
+    private StopImporterAction controller = null;
+
+    private TrackReference currentTrack = null;
+
+    private String oldGpsSyncTime = null;
+
+    private String oldStopwatchStart = null;
+
+    private String gpsSyncTime = null;
+
+    private String stopwatchStart = null;
+
+    public TrackStoplistRelocateCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        this.controller = controller;
+        this.currentTrack = controller.getCurrentTrack();
+        this.gpsSyncTime = controller.getDialog().getGpsTimeStart();
+        this.stopwatchStart = controller.getDialog().getStopwatchStart();
+        this.oldGpsSyncTime = currentTrack.gpsSyncTime;
+        this.oldStopwatchStart = currentTrack.stopwatchStart;
+    }
+
+    @Override
+    public boolean executeCommand() {
+        currentTrack.gpsSyncTime = gpsSyncTime;
+        currentTrack.stopwatchStart = stopwatchStart;
+        for (int i = 0; i < currentTrack.stoplistTM.getNodes().size(); ++i) {
+            Node node = currentTrack.stoplistTM.nodeAt(i);
+            if (node == null)
+                continue;
+
+            double time = StopImporterDialog
+                    .parseTime((String) currentTrack.stoplistTM.getValueAt(i, 0));
+            node.setCoor(currentTrack.computeCoor(time));
+        }
+        if (currentTrack == controller.getCurrentTrack()) {
+            controller.inEvent = true;
+            controller.getDialog().setGpsTimeStart(gpsSyncTime);
+            controller.getDialog().setStopwatchStart(stopwatchStart);
+            controller.inEvent = false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        currentTrack.gpsSyncTime = oldGpsSyncTime;
+        currentTrack.stopwatchStart = oldStopwatchStart;
+        for (int i = 0; i < currentTrack.stoplistTM.getNodes().size(); ++i) {
+            Node node = currentTrack.stoplistTM.nodeAt(i);
+            if (node == null)
+                continue;
+
+            double time = StopImporterDialog
+                    .parseTime((String) currentTrack.stoplistTM.getValueAt(i, 0));
+            node.setCoor(currentTrack.computeCoor(time));
+        }
+        if (currentTrack == controller.getCurrentTrack()) {
+            controller.inEvent = true;
+            controller.getDialog().setGpsTimeStart(oldGpsSyncTime);
+            controller.getDialog().setStopwatchStart(oldStopwatchStart);
+            controller.inEvent = false;
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Relocate nodes in track stoplist");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistSortCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistSortCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackStoplistSortCommand.java	(revision 34718)
@@ -0,0 +1,139 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.dialogs.StopImporterDialog;
+import org.openstreetmap.josm.plugins.public_transport.models.TrackStoplistTableModel;
+
+public class TrackStoplistSortCommand extends Command {
+    private TrackStoplistTableModel stoplistTM = null;
+
+    private Vector<Vector<Object>> tableDataModel = null;
+
+    private Vector<Node> nodes = null;
+
+    private Vector<String> times = null;
+
+    private Vector<Integer> workingLines = null;
+
+    private int insPos;
+
+    private String stopwatchStart;
+
+    public TrackStoplistSortCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        stoplistTM = controller.getCurrentTrack().stoplistTM;
+        workingLines = new Vector<>();
+        insPos = controller.getDialog().getStoplistTable().getSelectedRow();
+        stopwatchStart = controller.getCurrentTrack().stopwatchStart;
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getStoplistTable().getSelectedRows();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                workingLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < stoplistTM.getRowCount(); ++i) {
+                workingLines.add(Integer.valueOf(i));
+            }
+        }
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public boolean executeCommand() {
+        tableDataModel = (Vector<Vector<Object>>) stoplistTM.getDataVector().clone();
+        nodes = (Vector<Node>) stoplistTM.getNodes().clone();
+        times = (Vector<String>) stoplistTM.getTimes().clone();
+
+        Vector<NodeSortEntry> nodesToSort = new Vector<>();
+        for (int i = workingLines.size() - 1; i >= 0; --i) {
+            int j = workingLines.elementAt(i).intValue();
+            nodesToSort.add(new NodeSortEntry(stoplistTM.nodeAt(j),
+                    (String) stoplistTM.getValueAt(j, 0), (String) stoplistTM.getValueAt(j, 1),
+                    (TransText) stoplistTM.getValueAt(j, 2),
+                    StopImporterDialog.parseTime(stopwatchStart)));
+            stoplistTM.removeRow(j);
+        }
+
+        Collections.sort(nodesToSort);
+
+        int insPos = this.insPos;
+        Iterator<NodeSortEntry> iter = nodesToSort.iterator();
+        while (iter.hasNext()) {
+            NodeSortEntry nse = iter.next();
+            stoplistTM.insertRow(insPos, nse.node, nse.time, nse.name, nse.shelter);
+            if (insPos >= 0)
+                ++insPos;
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        stoplistTM.setDataVector(tableDataModel);
+        stoplistTM.setNodes(nodes);
+        stoplistTM.setTimes(times);
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: sort track stop list");
+    }
+
+    private static class NodeSortEntry implements Comparable<NodeSortEntry> {
+        public Node node = null;
+
+        public String time = null;
+
+        public String name = null;
+
+        public TransText shelter = null;
+
+        public double startTime = 0;
+
+        NodeSortEntry(Node node, String time, String name, TransText shelter,
+                double startTime) {
+            this.node = node;
+            this.time = time;
+            this.name = name;
+            this.shelter = shelter;
+        }
+
+        @Override
+        public int compareTo(NodeSortEntry nse) {
+            double time = StopImporterDialog.parseTime(this.time);
+            if (time - startTime > 12 * 60 * 60)
+                time -= 24 * 60 * 60;
+
+            double nseTime = StopImporterDialog.parseTime(nse.time);
+            if (nseTime - startTime > 12 * 60 * 60)
+                nseTime -= 24 * 60 * 60;
+
+            if (time < nseTime)
+                return -1;
+            else if (time > nseTime)
+                return 1;
+            else
+                return 0;
+        }
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackSuggestStopsCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackSuggestStopsCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/TrackSuggestStopsCommand.java	(revision 34718)
@@ -0,0 +1,240 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.dialogs.StopImporterDialog;
+import org.openstreetmap.josm.plugins.public_transport.models.TrackStoplistTableModel;
+
+public class TrackSuggestStopsCommand extends Command {
+    private TrackStoplistTableModel stoplistTM = null;
+
+    private String type = null;
+
+    private String stopwatchStart;
+
+    private String gpsStartTime;
+
+    private String gpsSyncTime;
+
+    private double timeWindow;
+
+    private double threshold;
+
+    private Collection<GpxTrackSegment> segments = null;
+
+    private Vector<Vector<Object>> tableDataModel = null;
+
+    private Vector<Node> nodes = null;
+
+    private Vector<String> times = null;
+
+    public TrackSuggestStopsCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        if (controller.getCurrentTrack() == null)
+            return;
+        stoplistTM = controller.getCurrentTrack().stoplistTM;
+        type = controller.getDialog().getStoptype();
+        stopwatchStart = controller.getCurrentTrack().stopwatchStart;
+        gpsStartTime = controller.getCurrentTrack().gpsStartTime;
+        gpsSyncTime = controller.getCurrentTrack().gpsSyncTime;
+        timeWindow = controller.getCurrentTrack().timeWindow;
+        threshold = controller.getCurrentTrack().threshold;
+        segments = controller.getCurrentTrack().getGpxTrack().getSegments();
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public boolean executeCommand() {
+        if (stoplistTM == null)
+            return false;
+        tableDataModel = (Vector<Vector<Object>>) stoplistTM.getDataVector().clone();
+        nodes = (Vector<Node>) stoplistTM.getNodes().clone();
+        times = (Vector<String>) stoplistTM.getTimes().clone();
+
+        for (int i = 0; i < stoplistTM.getNodes().size(); ++i) {
+            Node node = stoplistTM.nodeAt(i);
+            if (node == null)
+                continue;
+            MainApplication.getLayerManager().getEditDataSet().removePrimitive(node);
+            node.setDeleted(true);
+        }
+        stoplistTM.clear();
+
+        Vector<WayPoint> wayPoints = new Vector<>();
+        Iterator<GpxTrackSegment> siter = segments.iterator();
+        while (siter.hasNext()) {
+            Iterator<WayPoint> witer = siter.next().getWayPoints().iterator();
+            while (witer.hasNext()) {
+                wayPoints.add(witer.next());
+            }
+        }
+        Vector<Double> wayPointsDist = new Vector<>(wayPoints.size());
+
+        int i = 0;
+        double time = -48 * 60 * 60;
+        double dGpsStartTime = StopImporterDialog.parseTime(gpsStartTime);
+        while ((i < wayPoints.size()) && (time < dGpsStartTime + timeWindow / 2)) {
+            if (wayPoints.elementAt(i).getString("time") != null)
+                time = StopImporterDialog
+                        .parseTime(wayPoints.elementAt(i).getString("time").substring(11, 19));
+            if (time < dGpsStartTime)
+                time += 24 * 60 * 60;
+            wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));
+            ++i;
+        }
+        while (i < wayPoints.size()) {
+            int j = i;
+            double time2 = time;
+            while ((j > 0) && (time - timeWindow / 2 < time2)) {
+                --j;
+                if (wayPoints.elementAt(j).getString("time") != null)
+                    time2 = StopImporterDialog
+                            .parseTime(wayPoints.elementAt(j).getString("time").substring(11, 19));
+                if (time2 < dGpsStartTime)
+                    time2 += 24 * 60 * 60;
+            }
+            int k = i + 1;
+            time2 = time;
+            while ((k < wayPoints.size()) && (time + timeWindow / 2 > time2)) {
+                if (wayPoints.elementAt(k).getString("time") != null)
+                    time2 = StopImporterDialog
+                            .parseTime(wayPoints.elementAt(k).getString("time").substring(11, 19));
+                if (time2 < dGpsStartTime)
+                    time2 += 24 * 60 * 60;
+                ++k;
+            }
+
+            if (j < k) {
+                double dist = 0;
+                LatLon latLonI = wayPoints.elementAt(i).getCoor();
+                for (int l = j; l < k; ++l) {
+                    double distL = latLonI.greatCircleDistance(wayPoints.elementAt(l).getCoor());
+                    if (distL > dist)
+                        dist = distL;
+                }
+                wayPointsDist.add(Double.valueOf(dist));
+            } else
+                wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));
+
+            if (wayPoints.elementAt(i).getString("time") != null)
+                time = StopImporterDialog
+                        .parseTime(wayPoints.elementAt(i).getString("time").substring(11, 19));
+            if (time < dGpsStartTime)
+                time += 24 * 60 * 60;
+            ++i;
+        }
+
+        LatLon lastStopCoor = null;
+        for (i = 1; i < wayPoints.size() - 1; ++i) {
+            if (wayPointsDist.elementAt(i).doubleValue() >= threshold)
+                continue;
+            if ((wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i - 1)) != -1)
+                    || (wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i + 1)) != -1))
+                continue;
+
+            LatLon latLon = wayPoints.elementAt(i).getCoor();
+            if ((lastStopCoor != null) && (lastStopCoor.greatCircleDistance(latLon) < threshold))
+                continue;
+
+            if (wayPoints.elementAt(i).getString("time") != null) {
+                time = StopImporterDialog
+                        .parseTime(wayPoints.elementAt(i).getString("time").substring(11, 19));
+                double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime);
+                if (gpsSyncTime < dGpsStartTime - 12 * 60 * 60)
+                    gpsSyncTime += 24 * 60 * 60;
+                double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);
+                time -= timeDelta;
+                Node node = StopImporterAction.createNode(latLon, type, "");
+                stoplistTM.insertRow(-1, node, StopImporterAction.timeOf(time), "",
+                        new TransText(null));
+            }
+
+            lastStopCoor = latLon;
+        }
+
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        if (stoplistTM == null)
+            return;
+        for (int i = 0; i < stoplistTM.getNodes().size(); ++i) {
+            Node node = stoplistTM.nodeAt(i);
+            if (node == null)
+                continue;
+            MainApplication.getLayerManager().getEditDataSet().removePrimitive(node);
+            node.setDeleted(true);
+        }
+
+        stoplistTM.setDataVector(tableDataModel);
+        stoplistTM.setNodes(nodes);
+        stoplistTM.setTimes(times);
+
+        for (int i = 0; i < stoplistTM.getNodes().size(); ++i) {
+            Node node = stoplistTM.nodeAt(i);
+            if (node == null)
+                continue;
+            node.setDeleted(false);
+            MainApplication.getLayerManager().getEditDataSet().addPrimitive(node);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Suggest stops");
+    }
+/*
+    private class NodeSortEntry implements Comparable<NodeSortEntry> {
+        public Node node = null;
+
+        public String time = null;
+
+        public String name = null;
+
+        public double startTime = 0;
+
+        public NodeSortEntry(Node node, String time, String name, double startTime) {
+            this.node = node;
+            this.time = time;
+            this.name = name;
+        }
+
+        @Override
+        public int compareTo(NodeSortEntry nse) {
+            double time = StopImporterDialog.parseTime(this.time);
+            if (time - startTime > 12 * 60 * 60)
+                time -= 24 * 60 * 60;
+
+            double nseTime = StopImporterDialog.parseTime(nse.time);
+            if (nseTime - startTime > 12 * 60 * 60)
+                nseTime -= 24 * 60 * 60;
+
+            if (time < nseTime)
+                return -1;
+            else if (time > nseTime)
+                return 1;
+            else
+                return 0;
+        }
+    }*/
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsDetachCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsDetachCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsDetachCommand.java	(revision 34718)
@@ -0,0 +1,79 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.WaypointTableModel;
+
+public class WaypointsDetachCommand extends Command {
+    private Vector<Integer> workingLines = null;
+
+    private Vector<Node> nodesForUndo = null;
+
+    private WaypointTableModel waypointTM = null;
+
+    public WaypointsDetachCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        waypointTM = controller.getWaypointTableModel();
+        workingLines = new Vector<>();
+        nodesForUndo = new Vector<>();
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getWaypointsTable().getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < waypointTM.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+
+        // keep only lines where a node can be added
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            if (waypointTM.nodes.elementAt(consideredLines.elementAt(i)) != null)
+                workingLines.add(consideredLines.elementAt(i));
+        }
+    }
+
+    @Override
+    public boolean executeCommand() {
+        nodesForUndo.clear();
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = waypointTM.nodes.elementAt(j);
+            nodesForUndo.add(node);
+            waypointTM.nodes.set(j, null);
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = nodesForUndo.elementAt(i);
+            waypointTM.nodes.set(j, node);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Detach waypoints");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsDisableCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsDisableCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsDisableCommand.java	(revision 34718)
@@ -0,0 +1,87 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.WaypointTableModel;
+
+public class WaypointsDisableCommand extends Command {
+    private Vector<Integer> workingLines = null;
+
+    private Vector<Node> nodesForUndo = null;
+
+    private WaypointTableModel waypointTM = null;
+
+    public WaypointsDisableCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        waypointTM = controller.getWaypointTableModel();
+        workingLines = new Vector<>();
+        nodesForUndo = new Vector<>();
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getWaypointsTable().getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < waypointTM.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+
+        // keep only lines where a node can be added
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            if (waypointTM.nodes.elementAt(consideredLines.elementAt(i)) != null)
+                workingLines.add(consideredLines.elementAt(i));
+        }
+    }
+
+    @Override
+    public boolean executeCommand() {
+        nodesForUndo.clear();
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = waypointTM.nodes.elementAt(j);
+            nodesForUndo.add(node);
+            if (node == null)
+                continue;
+            waypointTM.nodes.set(j, null);
+            MainApplication.getLayerManager().getEditDataSet().removePrimitive(node);
+            node.setDeleted(true);
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = nodesForUndo.elementAt(i);
+            waypointTM.nodes.set(j, node);
+            if (node == null)
+                continue;
+            node.setDeleted(false);
+            MainApplication.getLayerManager().getEditDataSet().addPrimitive(node);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Disable waypoints");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsEnableCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsEnableCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsEnableCommand.java	(revision 34718)
@@ -0,0 +1,85 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+import java.util.Vector;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.WaypointTableModel;
+
+public class WaypointsEnableCommand extends Command {
+    private Vector<Integer> workingLines = null;
+
+    private WaypointTableModel waypointTM = null;
+
+    private String type = null;
+
+    public WaypointsEnableCommand(StopImporterAction controller) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        waypointTM = controller.getWaypointTableModel();
+        type = controller.getDialog().getStoptype();
+        workingLines = new Vector<>();
+
+        // use either selected lines or all lines if no line is selected
+        int[] selectedLines = controller.getDialog().getWaypointsTable().getSelectedRows();
+        Vector<Integer> consideredLines = new Vector<>();
+        if (selectedLines.length > 0) {
+            for (int i = 0; i < selectedLines.length; ++i) {
+                consideredLines.add(selectedLines[i]);
+            }
+        } else {
+            for (int i = 0; i < waypointTM.getRowCount(); ++i) {
+                consideredLines.add(Integer.valueOf(i));
+            }
+        }
+
+        // keep only lines where a node can be added
+        for (int i = 0; i < consideredLines.size(); ++i) {
+            if (waypointTM.nodes.elementAt(consideredLines.elementAt(i)) == null)
+                workingLines.add(consideredLines.elementAt(i));
+        }
+    }
+
+    @Override
+    public boolean executeCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = StopImporterAction.createNode(waypointTM.coors.elementAt(j), type,
+                    (String) waypointTM.getValueAt(j, 1));
+            TransText shelter = (TransText) waypointTM.getValueAt(j, 2);
+            node.put("shelter", shelter.text);
+            waypointTM.nodes.set(j, node);
+        }
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        for (int i = 0; i < workingLines.size(); ++i) {
+            int j = workingLines.elementAt(i).intValue();
+            Node node = waypointTM.nodes.elementAt(j);
+            waypointTM.nodes.set(j, null);
+            if (node == null)
+                continue;
+            MainApplication.getLayerManager().getEditDataSet().removePrimitive(node);
+            node.setDeleted(true);
+        }
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Enable waypoints");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsNameCommand.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsNameCommand.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/commands/WaypointsNameCommand.java	(revision 34718)
@@ -0,0 +1,80 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.commands;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.models.WaypointTableModel;
+
+public class WaypointsNameCommand extends Command {
+    private int workingLine = 0;
+
+    private WaypointTableModel waypointTM = null;
+
+    private String oldName = null;
+
+    private String name = null;
+
+    private String oldShelter = null;
+
+    private TransText shelter;
+
+    public WaypointsNameCommand(WaypointTableModel waypointTM, int workingLine, String name,
+            TransText shelter) {
+        super(MainApplication.getLayerManager().getEditDataSet());
+        this.waypointTM = waypointTM;
+        this.workingLine = workingLine;
+        if (waypointTM.nodes.elementAt(workingLine) != null) {
+            oldName = waypointTM.nodes.elementAt(workingLine).get("name");
+            oldShelter = waypointTM.nodes.elementAt(workingLine).get("shelter");
+        }
+        this.name = name;
+        this.shelter = shelter;
+    }
+
+    @Override
+    public boolean executeCommand() {
+        if (waypointTM.nodes.elementAt(workingLine) != null) {
+            waypointTM.nodes.elementAt(workingLine).put("name", name);
+            waypointTM.nodes.elementAt(workingLine).put("shelter", shelter.text);
+        }
+        waypointTM.inEvent = true;
+        if (name == null)
+            waypointTM.setValueAt("", workingLine, 1);
+        else
+            waypointTM.setValueAt(name, workingLine, 1);
+        waypointTM.setValueAt(shelter, workingLine, 2);
+        waypointTM.inEvent = false;
+        return true;
+    }
+
+    @Override
+    public void undoCommand() {
+        if (waypointTM.nodes.elementAt(workingLine) != null) {
+            waypointTM.nodes.elementAt(workingLine).put("name", oldName);
+            waypointTM.nodes.elementAt(workingLine).put("shelter", oldShelter);
+        }
+        waypointTM.inEvent = true;
+        if (oldName == null)
+            waypointTM.setValueAt("", workingLine, 1);
+        else
+            waypointTM.setValueAt(oldName, workingLine, 1);
+        waypointTM.setValueAt(new TransText(oldShelter), workingLine, 2);
+        waypointTM.inEvent = false;
+    }
+
+    @Override
+    public void fillModifiedData(Collection<OsmPrimitive> modified,
+            Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+    }
+
+    @Override
+    public String getDescriptionText() {
+        return tr("Public Transport: Edit waypoint name");
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/AbstractImporterDialog.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/AbstractImporterDialog.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/AbstractImporterDialog.java	(revision 34718)
@@ -0,0 +1,158 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.dialogs;
+
+import static org.openstreetmap.josm.tools.I18n.marktr;
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.Frame;
+
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
+
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+
+/**
+ * Abstract superclass of {@link GTFSImporterDialog} and {@link StopImporterDialog}.
+ */
+public abstract class AbstractImporterDialog<T extends JosmAction> {
+
+    private static final String[] stoptypes = new String[] {
+            marktr("bus"),
+            marktr("tram"),
+            marktr("light_rail"),
+            marktr("subway"),
+            marktr("rail") };
+
+    private final JDialog jDialog;
+
+    protected final JTabbedPane tabbedPane;
+
+    protected final JComboBox<TransText> cbStoptype;
+
+    protected final JTextField tfGPSTimeStart;
+
+    protected final JTextField tfStopwatchStart;
+
+    protected final JTextField tfTimeWindow;
+
+    protected final JTextField tfThreshold;
+
+    public AbstractImporterDialog(T controller, String dialogTitle, String actionPrefix) {
+        Frame frame = JOptionPane.getFrameForComponent(MainApplication.getMainFrame());
+        jDialog = new JDialog(frame, dialogTitle, false);
+        tabbedPane = new JTabbedPane();
+        jDialog.add(tabbedPane);
+
+        cbStoptype = new JComboBox<>();
+        cbStoptype.setEditable(false);
+        for (String type : stoptypes) {
+            cbStoptype.addItem(new TransText(type));
+        }
+        cbStoptype.setActionCommand(actionPrefix + ".settingsStoptype");
+        cbStoptype.addActionListener(controller);
+
+        tfGPSTimeStart = new JTextField("00:00:00", 15);
+        tfGPSTimeStart.setActionCommand(actionPrefix + ".settingsGPSTimeStart");
+        tfGPSTimeStart.addActionListener(controller);
+
+        tfStopwatchStart = new JTextField("00:00:00", 15);
+        tfStopwatchStart.setActionCommand(actionPrefix + ".settingsStopwatchStart");
+        tfStopwatchStart.addActionListener(controller);
+
+        tfTimeWindow = new JTextField("15", 4);
+        tfTimeWindow.setActionCommand(actionPrefix + ".settingsTimeWindow");
+        tfTimeWindow.addActionListener(controller);
+
+        tfThreshold = new JTextField("20", 4);
+        tfThreshold.setActionCommand(actionPrefix + ".settingsThreshold");
+        tfThreshold.addActionListener(controller);
+
+        initDialog(controller);
+
+        jDialog.pack();
+        jDialog.setLocationRelativeTo(frame);
+    }
+
+    protected abstract void initDialog(T controller);
+
+    public void setTrackValid(boolean valid) {
+        tabbedPane.setEnabledAt(2, valid);
+    }
+
+    public void setVisible(boolean visible) {
+        jDialog.setVisible(visible);
+    }
+
+    public void setSettings(String gpsSyncTime, String stopwatchStart, double timeWindow,
+            double threshold) {
+        tfGPSTimeStart.setText(gpsSyncTime);
+        tfStopwatchStart.setText(stopwatchStart);
+        tfTimeWindow.setText(Double.toString(timeWindow));
+        tfThreshold.setText(Double.toString(threshold));
+    }
+
+    public String getStoptype() {
+        return ((TransText) cbStoptype.getSelectedItem()).text;
+    }
+
+    public boolean gpsTimeStartValid() {
+        if (parseTime(tfGPSTimeStart.getText()) >= 0) {
+            return true;
+        } else {
+            JOptionPane.showMessageDialog(null, tr("Can''t parse a time from this string."),
+                    tr("Invalid value"), JOptionPane.ERROR_MESSAGE);
+            return false;
+        }
+    }
+
+    public String getGpsTimeStart() {
+        return tfGPSTimeStart.getText();
+    }
+
+    public void setGpsTimeStart(String s) {
+        tfGPSTimeStart.setText(s);
+    }
+
+    public boolean stopwatchStartValid() {
+        if (parseTime(tfStopwatchStart.getText()) >= 0) {
+            return true;
+        } else {
+            JOptionPane.showMessageDialog(null, tr("Can''t parse a time from this string."),
+                    tr("Invalid value"), JOptionPane.ERROR_MESSAGE);
+            return false;
+        }
+    }
+
+    public String getStopwatchStart() {
+        return tfStopwatchStart.getText();
+    }
+
+    public void setStopwatchStart(String s) {
+        tfStopwatchStart.setText(s);
+    }
+
+    public double getTimeWindow() {
+        return Double.parseDouble(tfTimeWindow.getText());
+    }
+
+    public double getThreshold() {
+        return Double.parseDouble(tfThreshold.getText());
+    }
+
+    public static double parseTime(String s) {
+        if ((s.charAt(2) != ':') || (s.charAt(5) != ':') || (s.length() < 8))
+            return -1;
+        int hour = Integer.parseInt(s.substring(0, 2));
+        int minute = Integer.parseInt(s.substring(3, 5));
+        double second = Double.parseDouble(s.substring(6, s.length()));
+        if ((hour < 0) || (hour > 23) || (minute < 0) || (minute > 59) || (second < 0)
+                || (second >= 60.0))
+            return -1;
+        return (second + minute * 60 + hour * 60 * 60);
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/GTFSImporterDialog.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/GTFSImporterDialog.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/GTFSImporterDialog.java	(revision 34718)
@@ -0,0 +1,368 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.dialogs;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.KeyStroke;
+
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.GTFSStopTableModel;
+
+public class GTFSImporterDialog extends AbstractImporterDialog<GTFSImporterAction> {
+    private final JTable gtfsStopTable = new JTable();
+
+    public GTFSImporterDialog(GTFSImporterAction controller) {
+        super(controller, tr("Create Stops from GTFS"), "gtfsImporter");
+    }
+
+    @Override
+    protected void initDialog(GTFSImporterAction controller) {
+        JPanel tabSettings = new JPanel();
+        tabbedPane.addTab(tr("Settings"), tabSettings);
+        JPanel tabWaypoints = new JPanel();
+        tabbedPane.addTab(tr("GTFS-Stops"), tabWaypoints);
+        tabbedPane.setEnabledAt(0, false);
+        tabbedPane.setEnabledAt(1, true);
+
+        // Settings Tab
+        JPanel contentPane = tabSettings;
+        GridBagLayout gridbag = new GridBagLayout();
+        GridBagConstraints layoutCons = new GridBagConstraints();
+        contentPane.setLayout(gridbag);
+
+        JLabel label = new JLabel(tr("Type of stops to add"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 0;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(cbStoptype, layoutCons);
+        contentPane.add(cbStoptype);
+
+        label = new JLabel(tr("Time on your GPS device"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 3;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfGPSTimeStart, layoutCons);
+        contentPane.add(tfGPSTimeStart);
+
+        /* I18n: Don't change the time format, you only may translate the letters */
+        label = new JLabel(tr("HH:MM:SS.sss"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 3;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        label = new JLabel(tr("Time on your stopwatch"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 4;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 5;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfStopwatchStart, layoutCons);
+        contentPane.add(tfStopwatchStart);
+
+        /* I18n: Don't change the time format, you only may translate the letters */
+        label = new JLabel(tr("HH:MM:SS.sss"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 5;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        label = new JLabel(tr("Time window"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 6;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 7;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfTimeWindow, layoutCons);
+        contentPane.add(tfTimeWindow);
+
+        label = new JLabel(tr("seconds"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 7;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        label = new JLabel(tr("Move Threshold"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 8;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 9;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfThreshold, layoutCons);
+        contentPane.add(tfThreshold);
+
+        label = new JLabel(tr("meters"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 9;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        JButton bSuggestStops = new JButton(tr("Suggest Stops"));
+        bSuggestStops.setActionCommand("gtfsImporter.settingsSuggestStops");
+        bSuggestStops.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 10;
+        layoutCons.gridwidth = 3;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bSuggestStops, layoutCons);
+        contentPane.add(bSuggestStops);
+
+        // Waypoints Tab
+        contentPane = tabWaypoints;
+        gridbag = new GridBagLayout();
+        layoutCons = new GridBagConstraints();
+        contentPane.setLayout(gridbag);
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt N"), "gtfsImporter.gtfsStopsFocusAdd");
+        contentPane.getActionMap().put("gtfsImporter.gtfsStopsFocusAdd",
+                controller.getFocusAddAction());
+/*    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
+        (KeyStroke.getKeyStroke("alt S"), "gtfsImporter.focusShelterYes");
+    contentPane.getActionMap().put
+    ("gtfsImporter.focusShelterYes",
+     controller.getFocusWaypointShelterAction("yes"));
+    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
+        (KeyStroke.getKeyStroke("alt T"), "gtfsImporter.focusShelterNo");
+    contentPane.getActionMap().put
+    ("gtfsImporter.focusShelterNo",
+     controller.getFocusWaypointShelterAction("no"));
+    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
+        (KeyStroke.getKeyStroke("alt U"), "gtfsImporter.focusShelterImplicit");
+    contentPane.getActionMap().put
+    ("gtfsImporter.focusShelterImplicit",
+     controller.getFocusWaypointShelterAction("implicit"));
+    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
+        (KeyStroke.getKeyStroke("alt D"), "gtfsImporter.gtfsStopsDelete");
+    contentPane.getActionMap().put
+    ("gtfsImporter.gtfsStopsDelete",
+     controller.getFocusWaypointDeleteAction());*/
+
+        JScrollPane tableSP = new JScrollPane(gtfsStopTable);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 0;
+        layoutCons.gridwidth = 4;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 1.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tableSP, layoutCons);
+        contentPane.add(tableSP);
+
+        JButton bFind = new JButton(tr("Find"));
+        bFind.setActionCommand("gtfsImporter.gtfsStopsFind");
+        bFind.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bFind, layoutCons);
+        contentPane.add(bFind);
+
+        JButton bShow = new JButton(tr("Show"));
+        bShow.setActionCommand("gtfsImporter.gtfsStopsShow");
+        bShow.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bShow, layoutCons);
+        contentPane.add(bShow);
+
+        JButton bMark = new JButton(tr("Mark"));
+        bMark.setActionCommand("gtfsImporter.gtfsStopsMark");
+        bMark.addActionListener(controller);
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bMark, layoutCons);
+        contentPane.add(bMark);
+
+        JButton bCatch = new JButton(tr("Catch"));
+        bCatch.setActionCommand("gtfsImporter.gtfsStopsCatch");
+        bCatch.addActionListener(controller);
+
+        layoutCons.gridx = 2;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bCatch, layoutCons);
+        contentPane.add(bCatch);
+
+        JButton bJoin = new JButton(tr("Join"));
+        bJoin.setActionCommand("gtfsImporter.gtfsStopsJoin");
+        bJoin.addActionListener(controller);
+
+        layoutCons.gridx = 2;
+        layoutCons.gridy = 2;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bJoin, layoutCons);
+        contentPane.add(bJoin);
+
+        JButton bAdd = new JButton(tr("Enable"));
+        bAdd.setActionCommand("gtfsImporter.gtfsStopsAdd");
+        bAdd.addActionListener(controller);
+
+        layoutCons.gridx = 3;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bAdd, layoutCons);
+        contentPane.add(bAdd);
+
+        JButton bDelete = new JButton(tr("Disable"));
+        bDelete.setActionCommand("gtfsImporter.gtfsStopsDelete");
+        bDelete.addActionListener(controller);
+
+        layoutCons.gridx = 3;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bDelete, layoutCons);
+        contentPane.add(bDelete);
+    }
+
+    public JTable getGTFSStopTable() {
+        return gtfsStopTable;
+    }
+
+    public void setGTFSStopTableModel(GTFSStopTableModel model) {
+        gtfsStopTable.setModel(model);
+        int width = gtfsStopTable.getPreferredSize().width;
+        gtfsStopTable.getColumnModel().getColumn(0).setPreferredWidth((int) (width * 0.3));
+        gtfsStopTable.getColumnModel().getColumn(1).setPreferredWidth((int) (width * 0.6));
+        gtfsStopTable.getColumnModel().getColumn(2).setPreferredWidth((int) (width * 0.1));
+    }
+
+/*  private class TracksLSL implements ListSelectionListener
+  {
+    GTFSImporterAction root = null;
+
+    public TracksLSL(GTFSImporterAction sia)
+    {
+      root = sia;
+    }
+
+    public void valueChanged(ListSelectionEvent e)
+    {
+      int selectedPos = tracksList.getAnchorSelectionIndex();
+      if (tracksList.isSelectedIndex(selectedPos))
+    root.tracksSelectionChanged(selectedPos);
+      else
+    root.tracksSelectionChanged(-1);
+    }
+  };*/
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/StopImporterDialog.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/StopImporterDialog.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/dialogs/StopImporterDialog.java	(revision 34718)
@@ -0,0 +1,557 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.dialogs;
+
+import static org.openstreetmap.josm.tools.I18n.marktr;
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.KeyStroke;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.models.TrackStoplistTableModel;
+import org.openstreetmap.josm.plugins.public_transport.models.WaypointTableModel;
+import org.openstreetmap.josm.plugins.public_transport.refs.TrackReference;
+
+public class StopImporterDialog extends AbstractImporterDialog<StopImporterAction> {
+    private JList<TrackReference> tracksList = null;
+
+    private final JTable stoplistTable = new JTable();
+
+    private final JTable waypointTable = new JTable();
+
+    public StopImporterDialog(StopImporterAction controller) {
+        super(controller, tr("Create Stops from GPX"), "stopImporter");
+    }
+
+    @Override
+    protected void initDialog(StopImporterAction controller) {
+        JPanel tabTracks = new JPanel();
+        tabbedPane.addTab(tr("Tracks"), tabTracks);
+        JPanel tabSettings = new JPanel();
+        tabbedPane.addTab(tr("Settings"), tabSettings);
+        JPanel tabStops = new JPanel();
+        tabbedPane.addTab(tr("Stops"), tabStops);
+        JPanel tabWaypoints = new JPanel();
+        tabbedPane.addTab(tr("Waypoints"), tabWaypoints);
+        tabbedPane.setEnabledAt(0, true);
+        tabbedPane.setEnabledAt(1, true);
+        tabbedPane.setEnabledAt(2, false);
+        tabbedPane.setEnabledAt(3, true);
+
+        // Tracks Tab
+        JPanel contentPane = tabTracks;
+        GridBagLayout gridbag = new GridBagLayout();
+        GridBagConstraints layoutCons = new GridBagConstraints();
+        contentPane.setLayout(gridbag);
+
+        JLabel label = new JLabel(tr("Tracks in this GPX file:"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 0;
+        layoutCons.gridwidth = 3;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        DefaultListModel<TrackReference> tracksListModel = controller.getTracksListModel();
+        tracksList = new JList<>(tracksListModel);
+        JScrollPane rpListSP = new JScrollPane(tracksList);
+        String[] data = {"1", "2", "3", "4", "5", "6"};
+        tracksListModel.copyInto(data);
+        tracksList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        tracksList.addListSelectionListener(new TracksLSL(controller));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 1;
+        layoutCons.gridwidth = 3;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 1.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(rpListSP, layoutCons);
+        contentPane.add(rpListSP);
+
+        // Settings Tab
+        contentPane = tabSettings;
+        gridbag = new GridBagLayout();
+        layoutCons = new GridBagConstraints();
+        contentPane.setLayout(gridbag);
+
+        label = new JLabel(tr("Type of stops to add"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 0;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(cbStoptype, layoutCons);
+        contentPane.add(cbStoptype);
+
+        label = new JLabel(tr("Time on your GPS device"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 3;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfGPSTimeStart, layoutCons);
+        contentPane.add(tfGPSTimeStart);
+
+        label = new JLabel(tr("HH:MM:SS.sss"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 3;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        label = new JLabel(tr("Time on your stopwatch"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 4;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 5;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfStopwatchStart, layoutCons);
+        contentPane.add(tfStopwatchStart);
+
+        label = new JLabel(tr("HH:MM:SS.sss"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 5;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        label = new JLabel(tr("Time window"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 6;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 7;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfTimeWindow, layoutCons);
+        contentPane.add(tfTimeWindow);
+
+        label = new JLabel(tr("seconds"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 7;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        label = new JLabel(tr("Move Threshold"));
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 8;
+        layoutCons.gridwidth = 2;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 9;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tfThreshold, layoutCons);
+        contentPane.add(tfThreshold);
+
+        label = new JLabel(tr("meters"));
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 9;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 0.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(label, layoutCons);
+        contentPane.add(label);
+
+        JButton bSuggestStops = new JButton(tr("Suggest Stops"));
+        bSuggestStops.setActionCommand("stopImporter.settingsSuggestStops");
+        bSuggestStops.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 10;
+        layoutCons.gridwidth = 3;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bSuggestStops, layoutCons);
+        contentPane.add(bSuggestStops);
+
+        // Stops Tab
+        contentPane = tabStops;
+        gridbag = new GridBagLayout();
+        layoutCons = new GridBagConstraints();
+        contentPane.setLayout(gridbag);
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt N"), "stopImporter.focusName");
+        contentPane.getActionMap().put("stopImporter.focusName",
+                controller.getFocusTrackStoplistNameAction());
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt S"), "stopImporter.focusShelterYes");
+        contentPane.getActionMap().put("stopImporter.focusShelterYes",
+                controller.getFocusTrackStoplistShelterAction("yes"));
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt T"), "stopImporter.focusShelterNo");
+        contentPane.getActionMap().put("stopImporter.focusShelterNo",
+                controller.getFocusTrackStoplistShelterAction("no"));
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt U"), "stopImporter.focusShelterImplicit");
+        contentPane.getActionMap().put("stopImporter.focusShelterImplicit",
+                controller.getFocusTrackStoplistShelterAction("implicit"));
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt D"), "stopImporter.stoplistDelete");
+        contentPane.getActionMap().put("stopImporter.stoplistDelete",
+                controller.getFocusStoplistDeleteAction());
+
+        JScrollPane tableSP = new JScrollPane(stoplistTable);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 0;
+        layoutCons.gridwidth = 4;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 1.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tableSP, layoutCons);
+        contentPane.add(tableSP);
+
+        JButton bFind = new JButton(tr("Find"));
+        bFind.setActionCommand("stopImporter.stoplistFind");
+        bFind.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bFind, layoutCons);
+        contentPane.add(bFind);
+
+        JButton bShow = new JButton(tr("Show"));
+        bShow.setActionCommand("stopImporter.stoplistShow");
+        bShow.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bShow, layoutCons);
+        contentPane.add(bShow);
+
+        JButton bMark = new JButton(tr("Mark"));
+        bMark.setActionCommand("stopImporter.stoplistMark");
+        bMark.addActionListener(controller);
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bMark, layoutCons);
+        contentPane.add(bMark);
+
+        JButton bDetach = new JButton(tr("Detach"));
+        bDetach.setActionCommand("stopImporter.stoplistDetach");
+        bDetach.addActionListener(controller);
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 2;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bDetach, layoutCons);
+        contentPane.add(bDetach);
+
+        JButton bAdd = new JButton(tr("Add"));
+        bAdd.setActionCommand("stopImporter.stoplistAdd");
+        bAdd.addActionListener(controller);
+
+        layoutCons.gridx = 2;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bAdd, layoutCons);
+        contentPane.add(bAdd);
+
+        JButton bDelete = new JButton(tr("Delete"));
+        bDelete.setActionCommand("stopImporter.stoplistDelete");
+        bDelete.addActionListener(controller);
+
+        layoutCons.gridx = 2;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bDelete, layoutCons);
+        contentPane.add(bDelete);
+
+        JButton bSort = new JButton(tr("Sort"));
+        bSort.setActionCommand("stopImporter.stoplistSort");
+        bSort.addActionListener(controller);
+
+        layoutCons.gridx = 3;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bSort, layoutCons);
+        contentPane.add(bSort);
+
+        // Waypoints Tab
+        contentPane = tabWaypoints;
+        gridbag = new GridBagLayout();
+        layoutCons = new GridBagConstraints();
+        contentPane.setLayout(gridbag);
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt N"), "stopImporter.focusName");
+        contentPane.getActionMap().put("stopImporter.focusName",
+                controller.getFocusWaypointNameAction());
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt S"), "stopImporter.focusShelterYes");
+        contentPane.getActionMap().put("stopImporter.focusShelterYes",
+                controller.getFocusWaypointShelterAction("yes"));
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt T"), "stopImporter.focusShelterNo");
+        contentPane.getActionMap().put("stopImporter.focusShelterNo",
+                controller.getFocusWaypointShelterAction("no"));
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt U"), "stopImporter.focusShelterImplicit");
+        contentPane.getActionMap().put("stopImporter.focusShelterImplicit",
+                controller.getFocusWaypointShelterAction("implicit"));
+        contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+                .put(KeyStroke.getKeyStroke("alt D"), "stopImporter.waypointsDelete");
+        contentPane.getActionMap().put("stopImporter.waypointsDelete",
+                controller.getFocusWaypointDeleteAction());
+
+        tableSP = new JScrollPane(waypointTable);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 0;
+        layoutCons.gridwidth = 3;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 1.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(tableSP, layoutCons);
+        contentPane.add(tableSP);
+
+        bFind = new JButton(tr("Find"));
+        bFind.setActionCommand("stopImporter.waypointsFind");
+        bFind.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bFind, layoutCons);
+        contentPane.add(bFind);
+
+        bShow = new JButton(tr("Show"));
+        bShow.setActionCommand("stopImporter.waypointsShow");
+        bShow.addActionListener(controller);
+
+        layoutCons.gridx = 0;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bShow, layoutCons);
+        contentPane.add(bShow);
+
+        bMark = new JButton(tr("Mark"));
+        bMark.setActionCommand("stopImporter.waypointsMark");
+        bMark.addActionListener(controller);
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bMark, layoutCons);
+        contentPane.add(bMark);
+
+        bDetach = new JButton(tr("Detach"));
+        bDetach.setActionCommand("stopImporter.waypointsDetach");
+        bDetach.addActionListener(controller);
+
+        layoutCons.gridx = 1;
+        layoutCons.gridy = 2;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bDetach, layoutCons);
+        contentPane.add(bDetach);
+
+        bAdd = new JButton(tr("Enable"));
+        bAdd.setActionCommand("stopImporter.waypointsAdd");
+        bAdd.addActionListener(controller);
+
+        layoutCons.gridx = 2;
+        layoutCons.gridy = 1;
+        layoutCons.gridheight = 1;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bAdd, layoutCons);
+        contentPane.add(bAdd);
+
+        bDelete = new JButton(tr("Disable"));
+        bDelete.setActionCommand("stopImporter.waypointsDelete");
+        bDelete.addActionListener(controller);
+
+        layoutCons.gridx = 2;
+        layoutCons.gridy = 2;
+        layoutCons.gridwidth = 1;
+        layoutCons.weightx = 1.0;
+        layoutCons.weighty = 0.0;
+        layoutCons.fill = GridBagConstraints.BOTH;
+        gridbag.setConstraints(bDelete, layoutCons);
+        contentPane.add(bDelete);
+    }
+
+    public JTable getStoplistTable() {
+        return stoplistTable;
+    }
+
+    public void setStoplistTableModel(TrackStoplistTableModel model) {
+        stoplistTable.setModel(model);
+        JComboBox<TransText> comboBox = new JComboBox<>();
+        comboBox.addItem(new TransText(null));
+        comboBox.addItem(new TransText(marktr("yes")));
+        comboBox.addItem(new TransText(marktr("no")));
+        comboBox.addItem(new TransText(marktr("implicit")));
+        stoplistTable.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(comboBox));
+        int width = stoplistTable.getPreferredSize().width;
+        stoplistTable.getColumnModel().getColumn(0).setPreferredWidth((int) (width * 0.4));
+        stoplistTable.getColumnModel().getColumn(1).setPreferredWidth((int) (width * 0.5));
+        stoplistTable.getColumnModel().getColumn(2).setPreferredWidth((int) (width * 0.1));
+    }
+
+    public JTable getWaypointsTable() {
+        return waypointTable;
+    }
+
+    public void setWaypointsTableModel(WaypointTableModel model) {
+        waypointTable.setModel(model);
+        JComboBox<TransText> comboBox = new JComboBox<>();
+        comboBox.addItem(new TransText(null));
+        comboBox.addItem(new TransText(marktr("yes")));
+        comboBox.addItem(new TransText(marktr("no")));
+        comboBox.addItem(new TransText(marktr("implicit")));
+        waypointTable.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(comboBox));
+        int width = waypointTable.getPreferredSize().width;
+        waypointTable.getColumnModel().getColumn(0).setPreferredWidth((int) (width * 0.4));
+        waypointTable.getColumnModel().getColumn(1).setPreferredWidth((int) (width * 0.5));
+        waypointTable.getColumnModel().getColumn(2).setPreferredWidth((int) (width * 0.1));
+    }
+
+    private class TracksLSL implements ListSelectionListener {
+        StopImporterAction root = null;
+
+        TracksLSL(StopImporterAction sia) {
+            root = sia;
+        }
+
+        @Override
+        public void valueChanged(ListSelectionEvent e) {
+            int selectedPos = tracksList.getAnchorSelectionIndex();
+            if (tracksList.isSelectedIndex(selectedPos))
+                root.tracksSelectionChanged(selectedPos);
+            else
+                root.tracksSelectionChanged(-1);
+        }
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/GTFSStopTableModel.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/GTFSStopTableModel.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/GTFSStopTableModel.java	(revision 34718)
@@ -0,0 +1,215 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.models;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.swing.table.DefaultTableModel;
+
+import org.openstreetmap.josm.data.DataSource;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.plugins.public_transport.actions.GTFSImporterAction;
+
+/**
+ * GTFS stop table model
+ */
+public class GTFSStopTableModel extends DefaultTableModel {
+
+    public Vector<Node> nodes = new Vector<>();
+
+    public Vector<LatLon> coors = new Vector<>();
+
+    private int idCol = -1;
+
+    private int nameCol = -1;
+
+    private int latCol = -1;
+
+    private int lonCol = -1;
+
+    private char separator = ',';
+
+    public GTFSStopTableModel(GTFSImporterAction controller, String columnConfig) {
+        int pos = columnConfig.indexOf(separator);
+        if (pos == -1) {
+            separator = ';';
+            pos = columnConfig.indexOf(separator);
+        }
+        if (pos == -1) {
+            separator = '\t';
+            pos = columnConfig.indexOf(separator);
+        }
+        int oldPos = 0;
+        int i = 0;
+        while (pos > -1) {
+            String title = stripQuot(columnConfig.substring(oldPos, pos));
+            if ("stop_id".equals(title))
+                idCol = i;
+            else if ("stop_name".equals(title))
+                nameCol = i;
+            else if ("stop_lat".equals(title))
+                latCol = i;
+            else if ("stop_lon".equals(title))
+                lonCol = i;
+            ++i;
+            oldPos = pos + 1;
+            pos = columnConfig.indexOf(separator, oldPos);
+        }
+        String title = columnConfig.substring(oldPos);
+        if ("stop_id".equals(title))
+            idCol = i;
+        else if ("stop_name".equals(title))
+            nameCol = i;
+        else if ("stop_lat".equals(title))
+            latCol = i;
+        else if ("stop_lon".equals(title))
+            lonCol = i;
+
+        addColumn(tr("Id"));
+        addColumn(tr("Name"));
+        addColumn(tr("State"));
+    }
+
+    @Override
+    public boolean isCellEditable(int row, int column) {
+        return false;
+    }
+
+    @Override
+    public void addRow(Object[] obj) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void insertRow(int insPos, Object[] obj) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void addRow(String s) {
+        insertRow(-1, s, new Vector<Node>());
+    }
+
+    public void addRow(String s, Vector<Node> existingStops) {
+        insertRow(-1, s, existingStops);
+    }
+
+    /**
+     * tokenizes a line as follows: any comma outside a pair of double quotation marks is taken as field separator.
+     * In particular, neither \" nor \, have a special meaning.
+     * @param s the string to tokenize
+     * @param startPos  the position of the last field separator plus 1 or the value 0
+     * @return the position of the next field separator, if any. Otherwise it returns -1
+     */
+    private int tokenize(String s, int startPos) {
+        int pos = startPos;
+        boolean insideDoubleQuoted = false;
+        while (pos < s.length()) {
+            if ('"' == s.charAt(pos))
+                insideDoubleQuoted = !insideDoubleQuoted;
+            else if (separator == s.charAt(pos) && !insideDoubleQuoted)
+                break;
+            ++pos;
+        }
+        if (pos < s.length())
+            return pos;
+        else
+            return -1;
+    }
+
+    private String stripQuot(String s) {
+        int pos = s.indexOf('"');
+        while (pos > -1) {
+            s = s.substring(0, pos) + s.substring(pos + 1);
+            pos = s.indexOf('"');
+        }
+        return s;
+    }
+
+    public void insertRow(int insPos, String s, Vector<Node> existingStops) {
+        String[] buf = {"", "", tr("pending")};
+        int pos = tokenize(s, 0);
+        int oldPos = 0;
+        int i = 0;
+        double lat = 0;
+        double lon = 0;
+        while (pos > -1) {
+            if (i == idCol)
+                buf[0] = stripQuot(s.substring(oldPos, pos));
+            else if (i == nameCol)
+                buf[1] = stripQuot(s.substring(oldPos, pos));
+            else if (i == latCol)
+                lat = Double.parseDouble(stripQuot(s.substring(oldPos, pos)));
+            else if (i == lonCol)
+                lon = Double.parseDouble(stripQuot(s.substring(oldPos, pos)));
+            ++i;
+            oldPos = pos + 1;
+            pos = tokenize(s, oldPos);
+        }
+        if (i == idCol)
+            buf[0] = stripQuot(s.substring(oldPos));
+        else if (i == nameCol)
+            buf[1] = stripQuot(s.substring(oldPos));
+        else if (i == latCol)
+            lat = Double.parseDouble(stripQuot(s.substring(oldPos)));
+        else if (i == lonCol)
+            lon = Double.parseDouble(stripQuot(s.substring(oldPos)));
+
+        LatLon coor = new LatLon(lat, lon);
+
+        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
+        if (ds != null) {
+            boolean inside = false;
+            Iterator<DataSource> iter = ds.getDataSources().iterator();
+            while (iter.hasNext()) {
+                if (iter.next().bounds.contains(coor)) {
+                    inside = true;
+                    break;
+                }
+            }
+            if (!inside)
+                buf[2] = tr("outside");
+        }
+
+        boolean nearBusStop = false;
+        Iterator<Node> iter = existingStops.iterator();
+        while (iter.hasNext()) {
+            Node node = iter.next();
+            if (coor.greatCircleDistance(node.getCoor()) < 1000) {
+                nearBusStop = true;
+                break;
+            }
+        }
+
+        if (insPos == -1) {
+            if (nearBusStop || !tr("pending").equals(buf[2]))
+                nodes.addElement(null);
+            else {
+                Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);
+                nodes.addElement(node);
+                buf[2] = tr("added");
+            }
+            coors.addElement(coor);
+            super.addRow(buf);
+        } else {
+            if (nearBusStop || !tr("pending").equals(buf[2]))
+                nodes.insertElementAt(null, insPos);
+            else {
+                Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);
+                nodes.insertElementAt(node, insPos);
+                buf[2] = tr("added");
+            }
+            coors.insertElementAt(coor, insPos);
+            super.insertRow(insPos, buf);
+        }
+    }
+
+    public void clear() {
+        nodes.clear();
+        super.setRowCount(0);
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/ItineraryTableModel.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/ItineraryTableModel.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/ItineraryTableModel.java	(revision 34718)
@@ -0,0 +1,150 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.models;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Vector;
+
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableModel;
+
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.plugins.public_transport.actions.RoutePatternAction;
+
+public class ItineraryTableModel extends DefaultTableModel implements TableModelListener {
+    public Vector<Way> ways = new Vector<>();
+
+    public boolean inEvent = false;
+
+    @Override
+    public boolean isCellEditable(int row, int column) {
+        if (column != 1)
+            return false;
+        if (ways.elementAt(row) == null)
+            return false;
+        return true;
+    }
+
+    @Override
+    public void addRow(Object[] obj) {
+        ways.addElement(null);
+        super.addRow(obj);
+    }
+
+    @Override
+    public void insertRow(int insPos, Object[] obj) {
+        if (insPos == -1) {
+            ways.addElement(null);
+            super.addRow(obj);
+        } else {
+            ways.insertElementAt(null, insPos);
+            super.insertRow(insPos, obj);
+        }
+    }
+
+    public void addRow(Way way, String role) {
+        insertRow(-1, way, role);
+    }
+
+    public void insertRow(int insPos, Way way, String role) {
+        String[] buf = {"", ""};
+        String curName = way.get("name");
+        if (way.isIncomplete())
+            buf[0] = tr("[incomplete]");
+        else if (way.getNodesCount() < 1)
+            buf[0] = tr("[empty way]");
+        else if (curName != null)
+            buf[0] = curName;
+        else
+            buf[0] = tr("[ID] {0}", Long.valueOf(way.getId()));
+        buf[1] = role;
+        if (insPos == -1) {
+            ways.addElement(way);
+            super.addRow(buf);
+        } else {
+            ways.insertElementAt(way, insPos);
+            super.insertRow(insPos, buf);
+        }
+    }
+
+    public void clear() {
+        ways.clear();
+        super.setRowCount(0);
+    }
+
+    public void cleanupGaps() {
+        inEvent = true;
+        Node lastNode = null;
+
+        for (int i = 0; i < getRowCount(); ++i) {
+            if (ways.elementAt(i) == null) {
+                ++i;
+                if (i >= getRowCount())
+                    break;
+            }
+            while ((ways.elementAt(i) == null) && ((i == 0) || (ways.elementAt(i - 1) == null))) {
+                ways.removeElementAt(i);
+                removeRow(i);
+                if (i >= getRowCount())
+                    break;
+            }
+            if (i >= getRowCount())
+                break;
+
+            boolean gapRequired = gapNecessary(ways.elementAt(i), (String) getValueAt(i, 1),
+                    lastNode);
+            if (i > 0 && !gapRequired && ways.elementAt(i - 1) == null) {
+                ways.removeElementAt(i - 1);
+                removeRow(i - 1);
+                --i;
+            } else if (i > 0 && gapRequired && ways.elementAt(i - 1) != null) {
+                String[] buf = {"", ""};
+                buf[0] = tr("[gap]");
+                insertRow(i, buf);
+                ++i;
+            }
+            lastNode = getLastNode(ways.elementAt(i), (String) getValueAt(i, 1));
+        }
+        while (getRowCount() > 0 && ways.elementAt(getRowCount() - 1) == null) {
+            ways.removeElementAt(getRowCount() - 1);
+            removeRow(getRowCount() - 1);
+        }
+        inEvent = false;
+    }
+
+    @Override
+    public void tableChanged(TableModelEvent e) {
+        if (e.getType() == TableModelEvent.UPDATE) {
+            if (inEvent)
+                return;
+            cleanupGaps();
+            RoutePatternAction.rebuildWays();
+        }
+    }
+
+    private Node getLastNode(Way way, String role) {
+        if (way == null || way.isIncomplete() || way.getNodesCount() < 1)
+            return null;
+        else {
+            if ("backward".equals(role))
+                return way.getNode(0);
+            else
+                return way.getNode(way.getNodesCount() - 1);
+        }
+    }
+
+    private boolean gapNecessary(Way way, String role, Node lastNode) {
+        if (way != null && !way.isIncomplete() && way.getNodesCount() >= 1) {
+            Node firstNode = null;
+            if ("backward".equals(role))
+                firstNode = way.getNode(way.getNodesCount() - 1);
+            else
+                firstNode = way.getNode(0);
+            if (lastNode != null && !lastNode.equals(firstNode))
+                return true;
+        }
+        return false;
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/TrackStoplistTableModel.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/TrackStoplistTableModel.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/TrackStoplistTableModel.java	(revision 34718)
@@ -0,0 +1,119 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.models;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Vector;
+
+import javax.swing.table.DefaultTableModel;
+
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.refs.TrackReference;
+
+public class TrackStoplistTableModel extends DefaultTableModel {
+    private Vector<Node> nodes = null;
+
+    private Vector<String> times = null;
+
+    private static Vector<String> columns = null;
+
+    public TrackStoplistTableModel(TrackReference tr) {
+        if (columns == null) {
+            columns = new Vector<>();
+            columns.add(tr("Time"));
+            columns.add(tr("Name"));
+            columns.add(tr("Shelter"));
+        }
+        nodes = new Vector<>();
+        times = new Vector<>();
+
+        setColumnIdentifiers(columns);
+        addTableModelListener(tr);
+    }
+
+    @Override
+    public boolean isCellEditable(int row, int column) {
+        return true;
+    }
+
+    @Override
+    public void addRow(Object[] obj) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void insertRow(int insPos, Object[] obj) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void addRow(String time) {
+        insertRow(-1, time);
+    }
+
+    public void insertRow(int insPos, String time) {
+        insertRow(insPos, null, time, "", new TransText(null));
+    }
+
+    @Override
+    public void removeRow(int pos) {
+        super.removeRow(pos);
+        nodes.removeElementAt(pos);
+        times.removeElementAt(pos);
+    }
+
+    public Node nodeAt(int i) {
+        return nodes.elementAt(i);
+    }
+
+    public void setNodeAt(int i, Node node) {
+        nodes.set(i, node);
+    }
+
+    public final Vector<Node> getNodes() {
+        return nodes;
+    }
+
+    public void setNodes(Vector<Node> nodes) {
+        this.nodes = nodes;
+    }
+
+    public String timeAt(int i) {
+        return times.elementAt(i);
+    }
+
+    public void setTimeAt(int i, String time) {
+        times.set(i, time);
+    }
+
+    public final Vector<String> getTimes() {
+        return times;
+    }
+
+    public void setTimes(Vector<String> times) {
+        this.times = times;
+    }
+
+    public void insertRow(int insPos, Node node, String time, String name, TransText shelter) {
+        Object[] buf = {time, name, shelter};
+        if (insPos == -1) {
+            nodes.addElement(node);
+            times.addElement(time);
+            super.addRow(buf);
+        } else {
+            nodes.insertElementAt(node, insPos);
+            times.insertElementAt(time, insPos);
+            super.insertRow(insPos, buf);
+        }
+    }
+
+    public void clear() {
+        nodes.clear();
+        times.clear();
+        super.setRowCount(0);
+    }
+
+    public void setDataVector(Vector<Vector<Object>> dataVector) {
+        setDataVector(dataVector, columns);
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/WaypointTableModel.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/WaypointTableModel.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/models/WaypointTableModel.java	(revision 34718)
@@ -0,0 +1,95 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.models;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Vector;
+
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableModel;
+
+import org.openstreetmap.josm.data.UndoRedoHandler;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.plugins.public_transport.TransText;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.commands.WaypointsNameCommand;
+
+public class WaypointTableModel extends DefaultTableModel implements TableModelListener {
+    private StopImporterAction controller = null;
+
+    public boolean inEvent = false;
+
+    public Vector<Node> nodes = new Vector<>();
+
+    public Vector<LatLon> coors = new Vector<>();
+
+    public WaypointTableModel(StopImporterAction controller) {
+        this.controller = controller;
+        addColumn(tr("Time"));
+        addColumn(tr("Stopname"));
+        addColumn(tr("Shelter"));
+        addTableModelListener(this);
+    }
+
+    @Override
+    public boolean isCellEditable(int row, int column) {
+        if (column >= 1)
+            return true;
+        return false;
+    }
+
+    @Override
+    public void addRow(Object[] obj) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void insertRow(int insPos, Object[] obj) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void addRow(WayPoint wp) {
+        insertRow(-1, wp);
+    }
+
+    public void insertRow(int insPos, WayPoint wp) {
+        String time = wp.getString("time");
+        if (time == null)
+            time = "";
+        String name = wp.getString("name");
+        if (name == null)
+            name = "";
+
+        Node node = controller.createNode(wp.getCoor(), name);
+
+        Object[] buf = {time, name, new TransText(null)};
+        if (insPos == -1) {
+            nodes.addElement(node);
+            coors.addElement(wp.getCoor());
+            super.addRow(buf);
+        } else {
+            nodes.insertElementAt(node, insPos);
+            coors.insertElementAt(wp.getCoor(), insPos);
+            super.insertRow(insPos, buf);
+        }
+    }
+
+    public void clear() {
+        nodes.clear();
+        super.setRowCount(0);
+    }
+
+    @Override
+    public void tableChanged(TableModelEvent e) {
+        if (e.getType() == TableModelEvent.UPDATE) {
+            if (inEvent)
+                return;
+            UndoRedoHandler.getInstance().add(new WaypointsNameCommand(this, e.getFirstRow(),
+                    (String) getValueAt(e.getFirstRow(), 1),
+                    (TransText) getValueAt(e.getFirstRow(), 2)));
+        }
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/RouteReference.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/RouteReference.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/RouteReference.java	(revision 34718)
@@ -0,0 +1,77 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.refs;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import org.openstreetmap.josm.data.osm.Relation;
+
+public class RouteReference implements Comparable<RouteReference> {
+    public final Relation route;
+
+    public RouteReference(Relation route) {
+        this.route = route;
+    }
+
+    @Override
+    public int compareTo(RouteReference rr) {
+        if (route.get("route") != null) {
+            if (rr.route.get("route") == null)
+                return -1;
+            int result = route.get("route").compareTo(rr.route.get("route"));
+            if (result != 0)
+                return result;
+        } else if (rr.route.get("route") != null)
+            return 1;
+        if (route.get("ref") != null) {
+            if (rr.route.get("ref") == null)
+                return -1;
+            int result = route.get("ref").compareTo(rr.route.get("ref"));
+            if (result != 0)
+                return result;
+        } else if (rr.route.get("ref") != null)
+            return 1;
+        if (route.get("to") != null) {
+            if (rr.route.get("to") == null)
+                return -1;
+            int result = route.get("to").compareTo(rr.route.get("to"));
+            if (result != 0)
+                return result;
+        } else if (rr.route.get("to") != null)
+            return 1;
+        if (route.get("direction") != null) {
+            if (rr.route.get("direction") == null)
+                return -1;
+            int result = route.get("direction").compareTo(rr.route.get("direction"));
+            if (result != 0)
+                return result;
+        } else if (rr.route.get("direction") != null)
+            return 1;
+        if (route.getId() < rr.route.getId())
+            return -1;
+        else if (route.getId() > rr.route.getId())
+            return 1;
+        return 0;
+    }
+
+    @Override
+    public String toString() {
+        String buf = route.get("route");
+        if ((route.get("ref") != null) && (route.get("ref") != "")) {
+            buf += " " + route.get("ref");
+        }
+        if ((route.get("loc_ref") != null) && (route.get("loc_ref") != "")) {
+            buf += " [" + route.get("loc_ref") + "]";
+        }
+
+        if ((route.get("to") != null) && (route.get("to") != "")) {
+            buf += ": " + route.get("to");
+        } else if ((route.get("direction") != null) && (route.get("direction") != "")) {
+            buf += " " + route.get("ref") + ": " + route.get("direction");
+        } else {
+            buf += " " + route.get("ref");
+        }
+        buf += tr(" [ID] {0}", Long.toString(route.getId()));
+
+        return buf;
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/StopReference.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/StopReference.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/StopReference.java	(revision 34718)
@@ -0,0 +1,41 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.refs;
+
+import org.openstreetmap.josm.data.osm.Node;
+
+public class StopReference implements Comparable<StopReference> {
+    public int index = 0;
+
+    public double pos = 0;
+
+    public double distance = 0;
+
+    public String name = "";
+
+    public String role = "";
+
+    public Node node;
+
+    public StopReference(int inIndex, double inPos, double inDistance, String inName,
+            String inRole, Node inNode) {
+        index = inIndex;
+        pos = inPos;
+        distance = inDistance;
+        name = inName;
+        role = inRole;
+        node = inNode;
+    }
+
+    @Override
+    public int compareTo(StopReference sr) {
+        if (this.index < sr.index)
+            return -1;
+        if (this.index > sr.index)
+            return 1;
+        if (this.pos < sr.pos)
+            return -1;
+        if (this.pos > sr.pos)
+            return 1;
+        return 0;
+    }
+}
Index: /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/TrackReference.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/TrackReference.java	(revision 34718)
+++ /applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/refs/TrackReference.java	(revision 34718)
@@ -0,0 +1,188 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.public_transport.refs;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Iterator;
+
+import javax.swing.JOptionPane;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+
+import org.openstreetmap.josm.command.ChangeCommand;
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.UndoRedoHandler;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.GpxTrack;
+import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.plugins.public_transport.actions.StopImporterAction;
+import org.openstreetmap.josm.plugins.public_transport.commands.TrackStoplistNameCommand;
+import org.openstreetmap.josm.plugins.public_transport.dialogs.StopImporterDialog;
+import org.openstreetmap.josm.plugins.public_transport.models.TrackStoplistTableModel;
+
+public class TrackReference implements Comparable<TrackReference>, TableModelListener {
+    public GpxTrack track;
+
+    public TrackStoplistTableModel stoplistTM;
+
+    public String stopwatchStart;
+
+    public String gpsStartTime;
+
+    public String gpsSyncTime;
+
+    public double timeWindow;
+
+    public double threshold;
+
+    private StopImporterAction controller = null;
+
+    public boolean inEvent = false;
+
+    public TrackReference(GpxTrack track, StopImporterAction controller) {
+        this.track = track;
+        this.stoplistTM = new TrackStoplistTableModel(this);
+        this.stopwatchStart = "00:00:00";
+        this.gpsStartTime = null;
+        this.gpsSyncTime = null;
+        this.controller = controller;
+        if (track != null) {
+            Iterator<GpxTrackSegment> siter = track.getSegments().iterator();
+            while (siter.hasNext() && this.gpsSyncTime == null) {
+                Iterator<WayPoint> witer = siter.next().getWayPoints().iterator();
+                if (witer.hasNext()) {
+                    this.gpsStartTime = witer.next().getString("time");
+                    if (this.gpsStartTime != null)
+                        this.gpsSyncTime = this.gpsStartTime.substring(11, 19);
+                }
+            }
+            if (this.gpsSyncTime == null) {
+                JOptionPane.showMessageDialog(null,
+                        tr("The GPX file doesn''t contain valid trackpoints. "
+                                + "Please use a GPX file that has trackpoints."),
+                        tr("GPX File Trouble"), JOptionPane.ERROR_MESSAGE);
+
+                this.gpsStartTime = "1970-01-01T00:00:00Z";
+                this.gpsSyncTime = this.stopwatchStart;
+            }
+        } else
+            this.gpsSyncTime = this.stopwatchStart;
+        this.timeWindow = 20;
+        this.threshold = 20;
+    }
+
+    public GpxTrack getGpxTrack() {
+        return track;
+    }
+
+    @Override
+    public int compareTo(TrackReference tr) {
+        String name = (String) track.getAttributes().get("name");
+        String tr_name = (String) tr.track.getAttributes().get("name");
+        if (name != null) {
+            if (tr_name == null)
+                return -1;
+            return name.compareTo(tr_name);
+        }
+        return 1;
+    }
+
+    @Override
+    public String toString() {
+        String buf = (String) track.getAttributes().get("name");
+        if (buf == null)
+            return tr("unnamed");
+        return buf;
+    }
+
+    @Override
+    public void tableChanged(TableModelEvent e) {
+        if ((e.getType() == TableModelEvent.UPDATE) && (e.getFirstRow() >= 0)) {
+            if (inEvent)
+                return;
+
+            double time = StopImporterDialog
+                    .parseTime((String) stoplistTM.getValueAt(e.getFirstRow(), 0));
+            if (time < 0) {
+                stoplistTM.setValueAt(stoplistTM.timeAt(e.getFirstRow()), e.getFirstRow(), 0);
+                JOptionPane.showMessageDialog(null, tr("Can''t parse a time from this string."),
+                        tr("Invalid value"), JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+
+            UndoRedoHandler.getInstance().add(new TrackStoplistNameCommand(this, e.getFirstRow()));
+            stoplistTM.setTimeAt(e.getFirstRow(),
+                    (String) stoplistTM.getValueAt(e.getFirstRow(), 0));
+        }
+    }
+
+    public LatLon computeCoor(double time) {
+        double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime);
+        double dGpsStartTime = StopImporterDialog.parseTime(gpsStartTime);
+        if (gpsSyncTime < dGpsStartTime - 12 * 60 * 60)
+            gpsSyncTime += 24 * 60 * 60;
+        double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);
+        time += timeDelta;
+
+        WayPoint wayPoint = null;
+        WayPoint lastWayPoint = null;
+        double wayPointTime = 0;
+        double lastWayPointTime = 0;
+        Iterator<GpxTrackSegment> siter = track.getSegments().iterator();
+        while (siter.hasNext()) {
+            Iterator<WayPoint> witer = siter.next().getWayPoints().iterator();
+            while (witer.hasNext()) {
+                wayPoint = witer.next();
+                String startTime = wayPoint.getString("time");
+                wayPointTime = StopImporterDialog.parseTime(startTime.substring(11, 19));
+                if (startTime.substring(11, 19).compareTo(gpsStartTime.substring(11, 19)) == -1)
+                    wayPointTime += 24 * 60 * 60;
+                if (wayPointTime >= time)
+                    break;
+                lastWayPoint = wayPoint;
+                lastWayPointTime = wayPointTime;
+            }
+            if (wayPointTime >= time)
+                break;
+        }
+
+        double lat = 0;
+        if ((wayPointTime == lastWayPointTime) || (lastWayPoint == null))
+            lat = wayPoint.getCoor().lat();
+        else
+            lat = wayPoint.getCoor().lat() * (time - lastWayPointTime)
+                    / (wayPointTime - lastWayPointTime)
+                    + lastWayPoint.getCoor().lat() * (wayPointTime - time)
+                            / (wayPointTime - lastWayPointTime);
+        double lon = 0;
+        if ((wayPointTime == lastWayPointTime) || (lastWayPoint == null))
+            lon = wayPoint.getCoor().lon();
+        else
+            lon = wayPoint.getCoor().lon() * (time - lastWayPointTime)
+                    / (wayPointTime - lastWayPointTime)
+                    + lastWayPoint.getCoor().lon() * (wayPointTime - time)
+                            / (wayPointTime - lastWayPointTime);
+
+        return new LatLon(lat, lon);
+    }
+
+    public void relocateNodes() {
+        for (int i = 0; i < stoplistTM.getNodes().size(); ++i) {
+            Node node = stoplistTM.nodeAt(i);
+            if (node == null)
+                continue;
+
+            double time = StopImporterDialog.parseTime((String) stoplistTM.getValueAt(i, 0));
+            LatLon latLon = computeCoor(time);
+
+            Node newNode = new Node(node);
+            newNode.setCoor(latLon);
+            Command cmd = new ChangeCommand(node, newNode);
+            if (cmd != null) {
+                UndoRedoHandler.getInstance().add(cmd);
+            }
+        }
+    }
+}
