func main() {

	var data = flag.String("data", "", "The data directory where WOF data lives, required")
	var cache_size = flag.Int("cache_size", 1024, "The number of WOF records with large geometries to cache")
	var cache_trigger = flag.Int("cache_trigger", 2000, "The minimum number of coordinates in a WOF record that will trigger caching")

	var lat = flag.Float64("latitude", 0.0, "")
	var lon = flag.Float64("longitude", 0.0, "")

	var loglevel = flag.String("loglevel", "info", "...")

	flag.Parse()

	logger := log.NewWOFLogger("[wof-breaches] ")
	logger.AddLogger(os.Stdout, *loglevel)

	idx, _ := rtree.NewIndex(*data, *cache_size, *cache_trigger, logger)

	for _, path := range flag.Args() {

		logger.Info("indexing %s", path)
		idx.IndexGeoJSONFile(path)
	}

	results := idx.GetIntersectsByLatLon(*lat, *lon)
	inflated := idx.InflateSpatialResults(results)

	for _, r := range inflated {
		logger.Info("%v", r)
	}
}
func NewIndex(source string, cache_size int, cache_trigger int, logger *log.WOFLogger) (*Index, error) {

	r, err := rtree.NewIndex(source, cache_size, cache_trigger, logger)

	if err != nil {
		return nil, err
	}

	idx := Index{r}

	return &idx, nil
}