Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output wrong format #8

Closed
jdleung opened this issue Jan 18, 2019 · 5 comments
Closed

Output wrong format #8

jdleung opened this issue Jan 18, 2019 · 5 comments

Comments

@jdleung
Copy link

jdleung commented Jan 18, 2019

In current version, tag trkpt looks like below which will cause the GPX file error.

<trk>
		<name>track 1</name>
		<desc>track desc</desc>
		<trkseg>
			<trkpt>
				<time>2019-01-18T12:13:57Z</time>
				<extensions>
				</extensions>
			</trkpt>
			<trkpt>

It should be like below

<trk>
		<name>track 1</name>
		<desc>track desc</desc>
		<trkseg>
			<trkpt lat="22.281960" lon="114.163171">
				<time>2019-01-18T12:24:36Z</time>
				<extensions>
				</extensions>
			</trkpt>

todo this, the following need to be added in class GPXTrackPoint

    public override init(latitude: CGFloat, longitude: CGFloat) {
        super.init()
        self.latitude = latitude
        self.longitude = longitude
    }

and add one more method addOpenTag

    override func addOpenTag(toGPX gpx: NSMutableString, indentationLevel: Int) {

        let attribute: NSMutableString = ""
       
        if latitude != nil {
            attribute.appendFormat(" lat=\"%f\"", latitude!)
        }
        
        if longitude != nil {
            attribute.appendFormat(" lon=\"%f\"", longitude!)
        }
        
        gpx.appendFormat("%@<%@%@>\r\n", indent(forIndentationLevel: indentationLevel), self.tagName(), attribute)
    }

@vincentneo
Copy link
Owner

Thanks for your contribution! I will look into this issue in the next week!

@vincentneo
Copy link
Owner

class GPXTrackPoint should inherit from GPXWaypoint, which already has the init for coordinates. This does not appear to be right, as it should just work using
GPXTrackPoint(latitude: INSERT longitude: INSERT)

@vincentneo
Copy link
Owner

There does seem to have a problem. My apologies. Will reopen this and check more in-depth

@vincentneo vincentneo reopened this Jan 22, 2019
vincentneo added a commit that referenced this issue Jan 23, 2019
@vincentneo
Copy link
Owner

This should fix it.

vincentneo added a commit that referenced this issue Jan 23, 2019
@jdleung
Copy link
Author

jdleung commented Jan 24, 2019

You're right, there should be no timestamp in trkpt, but still it needs an opentag for coordinates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants