Ejemplo n.º 1
0
	"strings"
	"sync"

	osmcache "imposm3/cache"
	"imposm3/element"
	"imposm3/geom/geos"
	"imposm3/geom/limit"
	"imposm3/logging"
	"imposm3/mapping"
	"imposm3/parser/pbf"
	"imposm3/proj"
	"imposm3/stats"
	"imposm3/util"
)

var log = logging.NewLogger("reader")

var skipCoords, skipNodes, skipWays bool
var nParser, nWays, nRels, nNodes, nCoords int64

func init() {
	if os.Getenv("IMPOSM_SKIP_COORDS") != "" {
		skipCoords = true
	}
	if os.Getenv("IMPOSM_SKIP_NODES") != "" {
		skipNodes = true
	}
	if os.Getenv("IMPOSM_SKIP_WAYS") != "" {
		skipWays = true
	}
	if procConf := os.Getenv("IMPOSM_READ_PROCS"); procConf != "" {
Ejemplo n.º 2
0
import (
	"bufio"
	"errors"
	"fmt"
	"imposm3/logging"
	"imposm3/parser/pbf"
	"io"
	"net/http"
	"os"
	"path"
	"strconv"
	"strings"
	"time"
)

var log = logging.NewLogger("diff")

type DiffState struct {
	Time     time.Time
	Sequence int32
	Url      string
}

func (d DiffState) String() string {
	return fmt.Sprintf("Diff #%d from %s", d.Sequence, d.Time.Local())
}

func (d DiffState) WriteToFile(file string) error {
	f, err := os.Create(file)
	if err != nil {
		return err
Ejemplo n.º 3
0
#include <stdlib.h>

extern void goLogString(char *msg);
extern void debug_wrap(const char *fmt, ...);
extern GEOSContextHandle_t initGEOS_r_debug();
extern void initGEOS_debug();
*/
import "C"

import (
	"imposm3/logging"
	"runtime"
	"unsafe"
)

var log = logging.NewLogger("GEOS")

//export goLogString
func goLogString(msg *C.char) {
	log.Printf(C.GoString(msg))
}

type Geos struct {
	v    C.GEOSContextHandle_t
	srid int
}

type Geom struct {
	v *C.GEOSGeometry
}
Ejemplo n.º 4
0
package limit

import (
	"errors"
	"imposm3/geom/geos"
	"imposm3/geom/ogr"
	"imposm3/logging"
	"math"
	"strings"
	"sync"
)

var log = logging.NewLogger("limiter")

// Tile bbox into multiple sub-boxes, each of `width` size.

// >>> list(tile_bbox((-1, 1, 0.49, 1.51), 0.5)) #doctest: +NORMALIZE_WHITESPACE
// [(-1.0, 1.0, -0.5, 1.5),
//  (-1.0, 1.5, -0.5, 2.0),
//  (-0.5, 1.0, 0.0, 1.5),
//  (-0.5, 1.5, 0.0, 2.0),
//  (0.0, 1.0, 0.5, 1.5),
//  (0.0, 1.5, 0.5, 2.0)]
func tileBounds(bounds geos.Bounds, width float64) []geos.Bounds {
	var results []geos.Bounds
	minX := math.Floor(bounds.MinX/width) * width
	minY := math.Floor(bounds.MinY/width) * width
	maxX := math.Ceil(bounds.MaxX/width) * width
	maxY := math.Ceil(bounds.MaxY/width) * width

	xSteps := math.Ceil((maxX - minX) / width)
Ejemplo n.º 5
0
import (
	"database/sql"
	"errors"
	"fmt"
	pq "github.com/olt/pq"
	"imposm3/database"
	"imposm3/logging"
	"imposm3/mapping"
	"runtime"
	"strings"
	"sync"
	"sync/atomic"
)

var log = logging.NewLogger("PostGIS")

type SQLError struct {
	query         string
	originalError error
}

func (e *SQLError) Error() string {
	return fmt.Sprintf("SQL Error: %s in query %s", e.originalError.Error(), e.query)
}

type SQLInsertError struct {
	SQLError
	data interface{}
}
Ejemplo n.º 6
0
	"imposm3/cache"
	"imposm3/config"
	"imposm3/database"
	_ "imposm3/database/postgis"
	state "imposm3/diff/state"
	"imposm3/geom/limit"
	"imposm3/logging"
	"imposm3/mapping"
	"imposm3/parser/pbf"
	"imposm3/reader"
	"imposm3/stats"
	"imposm3/writer"
)

var log = logging.NewLogger("")

func Import() {
	if config.BaseOptions.Quiet {
		logging.SetQuiet(true)
	}

	if (config.ImportOptions.Write || config.ImportOptions.Read != "") && (config.ImportOptions.RevertDeploy || config.ImportOptions.RemoveBackup) {
		log.Fatal("-revertdeploy and -removebackup not compatible with -read/-write")
	}

	if config.ImportOptions.RevertDeploy && (config.ImportOptions.RemoveBackup || config.ImportOptions.DeployProduction) {
		log.Fatal("-revertdeploy not compatible with -deployproduction/-removebackup")
	}

	var geometryLimiter *limit.Limiter
Ejemplo n.º 7
0
package mapping

import (
	"errors"
	"imposm3/element"
	"imposm3/logging"
	"regexp"
	"strconv"
	"strings"
)

var log = logging.NewLogger("mapping")

var AvailableFieldTypes map[string]FieldType

func init() {
	AvailableFieldTypes = map[string]FieldType{
		"bool":                 {"bool", "bool", Bool, nil},
		"boolint":              {"boolint", "int8", BoolInt, nil},
		"id":                   {"id", "int64", Id, nil},
		"string":               {"string", "string", String, nil},
		"direction":            {"direction", "int8", Direction, nil},
		"integer":              {"integer", "int32", Integer, nil},
		"mapping_key":          {"mapping_key", "string", Key, nil},
		"mapping_value":        {"mapping_value", "string", Value, nil},
		"geometry":             {"geometry", "geometry", Geometry, nil},
		"validated_geometry":   {"validated_geometry", "validated_geometry", Geometry, nil},
		"wayzorder":            {"wayzorder", "int32", WayZOrder, nil},
		"pseudoarea":           {"pseudoarea", "float32", PseudoArea, nil},
		"zorder":               {"zorder", "int32", nil, MakeZOrder},
		"string_suffixreplace": {"string_suffixreplace", "string", nil, MakeSuffixReplace},
Ejemplo n.º 8
0
package parser

import (
	"compress/gzip"
	"encoding/xml"
	"imposm3/element"
	"imposm3/logging"
	"os"
	"strconv"
)

var log = logging.NewLogger("osc parser")

type DiffElem struct {
	Add  bool
	Mod  bool
	Del  bool
	Node *element.Node
	Way  *element.Way
	Rel  *element.Relation
}

func Parse(diff string) (chan DiffElem, chan error) {
	elems := make(chan DiffElem)
	errc := make(chan error)
	go parse(diff, elems, errc)
	return elems, errc
}

func parse(diff string, elems chan DiffElem, errc chan error) {
	defer close(elems)
Ejemplo n.º 9
0
package writer

import (
	"imposm3/cache"
	"imposm3/database"
	"imposm3/expire"
	"imposm3/geom/limit"
	"imposm3/logging"
	"imposm3/stats"
	"runtime"
	"sync"
)

var log = logging.NewLogger("writer")

type ErrorLevel interface {
	Level() int
}

type looper interface {
	loop()
}

type OsmElemWriter struct {
	osmCache   *cache.OSMCache
	diffCache  *cache.DiffCache
	progress   *stats.Statistics
	inserter   database.Inserter
	wg         *sync.WaitGroup
	limiter    *limit.Limiter
	writer     looper