using System;
|
using System.Collections.Generic;
|
using System.Configuration;
|
using System.IO;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Threading;
|
using System.Web.Http;
|
using Turf.cs;
|
|
namespace Turf.Controllers
|
{
|
public class AiController : ApiController
|
{
|
private string getDataCache()
|
{
|
return ConfigurationManager.AppSettings["dataCache"];
|
}
|
|
[HttpPost]
|
[Route("footprint/predict/2")]
|
[Route("riverface/predict/2")]
|
[Route("roadface/predict/2")]
|
[Route("woodland/predict/2")]
|
public R<Result> footprint([FromBody]Args args)
|
{
|
try
|
{
|
if (null == args || string.IsNullOrEmpty(args.data_dir))
|
{
|
return new R<Result>(2, "Sorry, the parameter is wrong");
|
}
|
|
//Thread.Sleep(10000);
|
String target = Path.Combine(getDataCache(), args.data_dir, "results");
|
if (!Directory.Exists(target)) Directory.CreateDirectory(target);
|
|
String source = Path.Combine(getDataCache(), "1722828277901", "results");
|
string[] files = Directory.GetFiles(source, "*.geojson");
|
foreach (string file in files)
|
{
|
string newFile = Path.Combine(target, Path.GetFileName(file));
|
File.Copy(file, newFile, true);
|
}
|
|
Result rs = new Result();
|
|
return new R<Result>(0, "ok", rs);
|
}
|
catch (Exception ex)
|
{
|
return new R<Result>(5, ex.Message);
|
}
|
}
|
}
|
}
|