Пример #1
0
func RunThin(cmd *cobra.Command, args []string) {
	if input == "" || output == "" {
		fmt.Println("input and output filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	readerType, _ := utils.InferReaderFromExt(input)
	writerType, _ := utils.InferWriterFromExt(output)

	stepOpt := "--filters.decimation.step=" + strconv.Itoa(step)
	offsetOpt := "--filters.decimation.offset=" + strconv.Itoa(offset)
	limitOpt := "--filters.decimation.limit=" + strconv.Itoa(limit)

	utils.RunPdalTranslate(input, output,
		"-r", readerType, "-w", writerType, "--filter", "filters.decimation",
		stepOpt, offsetOpt, limitOpt, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}
Пример #2
0
// RunConvert runs a PDAL pipeline with colorization filter.
func RunConvert(cmd *cobra.Command, args []string) {
	if input == "" || output == "" {
		fmt.Println("input and output filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	if reader == "" {
		reader, _ = utils.InferReaderFromExt(input)
	}
	if writer == "" {
		writer, _ = utils.InferWriterFromExt(output)
	}

	utils.RunPdalTranslate(input, output,
		"-r", reader, "-w", writer, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}
Пример #3
0
func RunGround(cmd *cobra.Command, args []string) {
	if input == "" || output == "" {
		fmt.Println("input and output filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	readerType, _ := utils.InferReaderFromExt(input)
	writerType, _ := utils.InferWriterFromExt(output)

	json := `
		{
		  "pipeline": {
		    "filters": [{
		      "name": "ProgressiveMorphologicalFilter",
		      "setMaxWindowSize": ` + strconv.Itoa(winSize) + `,
		      "setSlope": ` + strconv.FormatFloat(slope, 'f', -1, 64) + `,
		      "setMaxDistance": ` + strconv.FormatFloat(maxDist, 'f', -1, 64) + `,
		      "setInitialDistance": ` + strconv.FormatFloat(initDist, 'f', -1, 64) + `,
		      "setCellSize": ` + strconv.FormatFloat(cellSize, 'f', -1, 64) + `,
		      "setBase": ` + strconv.FormatFloat(base, 'f', -1, 64) + `,
		      "setExponential": ` + strconv.FormatBool(isExp) + `,
		      "setNegative": ` + strconv.FormatBool(isNeg) + `
		    }]
		  }
		}
	`

	vg := `--filters.pclblock.json=` + json

	utils.RunPdalTranslate(input, output,
		"-r", readerType, "-w", writerType, "--filter", "filters.pclblock",
		vg, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}
Пример #4
0
func RunCrop(cmd *cobra.Command, args []string) {
	if input == "" || output == "" {
		fmt.Println("input and output filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	readerType, _ := utils.InferReaderFromExt(input)
	writerType, _ := utils.InferWriterFromExt(output)

	if (bounds == "" && polygon == "") || (bounds != "" && polygon != "") {
		fmt.Println("must provide bounds OR polygon, but not both")
	}

	var geometry string
	if bounds != "" {
		geometry = "--filters.crop.bounds=" + bounds
	} else if polygon != "" {
		geometry = "--filters.crop.polygon=" + polygon
	}

	var invert string
	if outside {
		invert = "--filters.crop.outside=true"
	} else {
		invert = "--filters.crop.outside=false"
	}

	utils.RunPdalTranslate(input, output,
		"-r", readerType, "-w", writerType, "--filter", "filters.crop",
		geometry, invert, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}
Пример #5
0
func RunVoxelGrid(cmd *cobra.Command, args []string) {
	if input == "" || output == "" {
		fmt.Println("input and output filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	readerType, _ := utils.InferReaderFromExt(input)
	writerType, _ := utils.InferWriterFromExt(output)

	json := `
		{
		  "pipeline": {
		    "filters": [{
		      "name": "VoxelGrid",
		      "setLeafSize":
		      {
		        "x": ` + strconv.FormatFloat(gridX, 'f', -1, 64) + `,
		        "y": ` + strconv.FormatFloat(gridY, 'f', -1, 64) + `,
		        "z": ` + strconv.FormatFloat(gridZ, 'f', -1, 64) + `
		      }
		    }]
		  }
		}
	`

	vg := `--filters.pclblock.json=` + json

	utils.RunPdalTranslate(input, output,
		"-r", readerType, "-w", writerType, "--filter", "filters.pclblock",
		vg, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}
Пример #6
0
func RunRadius(cmd *cobra.Command, args []string) {
	if input == "" || output == "" {
		fmt.Println("input and output filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	readerType, _ := utils.InferReaderFromExt(input)
	writerType, _ := utils.InferWriterFromExt(output)

	json := `
		{
		  "pipeline": {
		    "filters": [{
		      "name": "RadiusOutlierRemoval",
		      "setMinNeighborsRadius": ` + strconv.Itoa(minNeighbors) + `,
		      "setRadiusSearch": ` + strconv.FormatFloat(radius, 'f', -1, 64) + `
		    }]
		  }
		}
	`

	vg := `--filters.pclblock.json=` + json

	utils.RunPdalTranslate(input, output,
		"-r", readerType, "-w", writerType, "--filter", "filters.pclblock",
		vg, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}
Пример #7
0
func RunPCL(cmd *cobra.Command, args []string) {
	if input == "" || output == "" || pcl == "" {
		fmt.Println("input, output, and pcl filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(pcl); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", pcl)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	readerType, _ := utils.InferReaderFromExt(input)
	writerType, _ := utils.InferWriterFromExt(output)

	vg := `--filters.pclblock.filename=` + pcl

	utils.RunPdalTranslate(input, output,
		"-r", readerType, "-w", writerType, "--filter", "filters.pclblock",
		vg, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}
Пример #8
0
// RunColorize runs a PDAL pipeline with colorization filter.
func RunColorize(cmd *cobra.Command, args []string) {
	if input == "" || output == "" || raster == "" {
		fmt.Println("input, raster, and output filenames must be provided")
		cmd.Usage()
		return
	}

	if _, err := os.Stat(input); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", input)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(raster); os.IsNotExist(err) {
		fmt.Printf("No such file or directory: %s\n", raster)
		cmd.Usage()
		return
	}

	if _, err := os.Stat(output); err == nil {
		fmt.Printf("%s exists; overwriting...\n", output)
	}

	readerType, _ := utils.InferReaderFromExt(input)
	writerType, _ := utils.InferWriterFromExt(output)

	rasterOpt := "--filters.colorization.raster=" + raster

	utils.RunPdalTranslate(input, output,
		"-r", readerType, "-w", writerType, "--filter", "filters.colorization",
		rasterOpt, "-v10", "--debug")

	if view {
		utils.OpenData(output)
	}
}