0

gpxpy lib を試していますが、おそらく動作していますが、PointField を作成できません...ドキュメントが見つかりません。

また、gpx トラックから GDAL を使用して一連の PointFields を作成するにはどうすればよいですか?

必要な場合に備えて、これが私のコードです。

def upload(request):
    'Upload waypoints'
    # If the form contains an upload,
    if 'gpx' in request.FILES:
        # Get
        gpxFile = request.FILES['gpx']
        track = FiberTrack(name=request.POST.get('track_name'))
        track.save()
        #parse_gpx(gpxFile, track)

        # Save
        targetPath = tempfile.mkstemp()[1]
        destination = open(targetPath, 'wt')
        for chunk in gpxFile.chunks():
            destination.write(chunk)
        destination.close()
        # Parse
        dataSource = DataSource(targetPath)
        print(dataSource)
        layer = dataSource[0]
        waypointNames = layer.get_fields('name')
        waypointGeometries = layer.get_geoms()
        for waypointName, waypointGeometry in itertools.izip(waypointNames, waypointGeometries):
            vertex = FiberTrackVertex(track = track, number=5, point=waypointGeometry.wkt)
            vertex.save()
        # Clean up

        os.remove(targetPath)

    # Redirect
    return HttpResponseRedirect(reverse(edit_map))

def parse_gpx(file, fiber_track):
    Point.set_coords()
    gpx = gpxpy.parse(file)
    for segment in gpx.tracks[0].segments:
        for point in segment.points:
            vertex = FiberTrackVertex(track=fiber_track, number=5, point=point)
            vertex.save()
    return

def toGeoDjangoPoint(point):
    to_point = gismodels.PointField
    to_point.geography
4

1 に答える 1

0

それでもわからない場合は、これがまさにあなたが探しているものだと思います。 http://ipasic.com/article/uploading-parsing-and-saving-gpx-data-postgis-geodjango/

それが役立つことを願っています!

于 2013-12-08T13:46:46.470 に答える