Commit 6d69c949 authored by 刘乐's avatar 刘乐

1, inp文件保存接口构建

parent d5b0425e
......@@ -108,10 +108,10 @@ void CivProjSimulationTest::test(char* uri)
{
// 追踪节点编号
char projCode[512];
strcpy(projCode, "e9443d7f-d05b-4768-94b7-084a5d0fe3ba");
strcpy(projCode, "aedbda8f-29fd-40ef-bb7e-961eed178f35");
char time[512];
strcpy(time, "2020-09-24 09:00:00");
strcpy(time, "2020-12-14 15:00:00");
bool isSucc = projSimulation(uri, projCode, time);
......
#include "CivInpImpoter.h"
#include "CivSysLog.h"
#include <stdio.h>
CivInpImpoter::CivInpImpoter()
{
......@@ -10,8 +12,55 @@ CivInpImpoter::~CivInpImpoter()
}
int CivInpImpoter::handleline(int linenum, char* text)
{
printf("line[%d]=[%s]\n", linenum, text);
return 0;
}
bool CivInpImpoter::load(const std::string& inppath)
{
FILE* fp;
int linenum;
char* p, buf[1024];
CivSysLog::getInstance()->info("开始解析:"+inppath, "CivInpImpoter", __FUNCTION__);
// 打开文件
fp = fopen(inppath.c_str(), "r");
if (fp == NULL)
{
std::string errInfo = "打开文件: " + inppath + "失败!";
CivSysLog::getInstance()->error(errInfo, "CivInpImpoter", __FUNCTION__);
return false;
}
// 按行解析数据
for (linenum = 1; fgets(buf, sizeof(buf), fp) != NULL; ++linenum) {
if ((p = strchr(buf, '\n')) == NULL) {
p = buf + strlen(buf);
}
if (p > buf && p[-1] == '\r') {
--p;
}
*p = '\0';
//空格跳过
for (p = buf; *p != '\0' && isspace((int)*p); ++p)
{
;
}
if (*p == '\0' || *p == ';') {
continue;
}
// 处理解析的行数据
if (handleline(linenum, p) != 0) {
std::string errInfo = "不能解析第:" + std::to_string(linenum) + "行,跳过";
CivSysLog::getInstance()->warning(errInfo, "CivInpImpoter", __FUNCTION__);
continue;
}
}
fclose(fp);
return true;
}
......
......@@ -10,10 +10,16 @@ public:
CivInpImpoter();
~CivInpImpoter();
/**
* @brief 读取和解析inp文件
* @param [inppath] inp文件路径
*/
bool load(const std::string& inppath);
bool import();
private:
//
int handleline(int linenum, char* text);
};
......@@ -133,12 +133,14 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;PANDAINPCORE_DLL;PANDAINPCORE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(OUTDIR)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>pandaLog.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
......
#include "CivAttributeTable.h"
CivAttributeTable::CivAttributeTable(AttributeType attriType)
:mAttriType(attriType)
{
}
void CivAttributeTable::regist(CivConnection* civconn)
{
mConn = civconn;
}
void CivAttributeTable::unregist()
{
mConn = nullptr;
}
bool CivAttributeTable::commitChanges()
{
if (!mConn)
return false;
}
\ No newline at end of file
#pragma once
class CivConnection;
/**
属性表类
*/
class CivAttributeTable
{
public:
// 属性表类型
enum AttributeType
{
Geometry, // 空间几何信息表类型
System // 系统属性表
};
// 构造函数
explicit CivAttributeTable(AttributeType attriType);
// 注册数据库
void regist(CivConnection* civconn);
// 取消注册的数据库链接对象
void unregist();
// 提交保存
bool commitChanges();
private:
AttributeType mAttriType;
CivConnection* mConn = nullptr;
};
......@@ -18,6 +18,7 @@ public:
CivAttributes() = default;
CivAttributes(const Params& params);
/**
* @brief 添加单个属性
* @param [name] 属性名
......@@ -41,6 +42,7 @@ public:
*@brief 获取所有属性
*/
Params attributes() const;
private:
Params mParams;
};
......@@ -16,7 +16,17 @@ void CivFeature::setGeometry(const CivGeometry& geo)
mGeometry = geo;
}
CivGeometry CivFeature::geometry() const
{
return mGeometry;
}
void CivFeature::addAttributes(const CivAttributes& attributes)
{
mAttributes.merge(attributes);
}
std::string CivFeature::params() const
{
}
......@@ -14,12 +14,27 @@ public:
CivFeature(const CivGeometry& geom );
CivFeature() = default;
~CivFeature();
/**
* @brief 要素的几何体
* @param [geo] 几何体
*/
void setGeometry(const CivGeometry& geo);
// 返回几何体对象
CivGeometry geometry() const;
/**
* @brief 属性集合
* @param [attributes] 属性对象
*/
void addAttributes(const CivAttributes& attributes);
/**
* @brief 按属性拼接字符串
* @param
*/
std::string params() const;
private:
FeatureId mFeaId; // 要素id
CivGeometry mGeometry; // 几何体类型
......
......@@ -14,3 +14,9 @@ CivGeometry CivGeometry::fromWktext(const std::string& json)
{
}
String CivGeometry::toJson() const
{
std::string jsonStr;
}
\ No newline at end of file
......@@ -3,6 +3,9 @@
#include <vector>
#include <map>
#include "CivPoint.h"
typedef std::string String;
/**
空间几何体对象
*/
......@@ -30,6 +33,10 @@ public:
// 几何体类型
GeometryType type() const { return mGeometryType; }
/*几何体对象序列化*/
String toJson() const;
private:
GeometryType mGeometryType;
std::vector<CivPoint> mPoints;
};
#include "CivPoint.h"
CivPoint::CivPoint(double x, double y, double z)
:mX(x),mY(y),mZ(z)
{
}
CivPoint CivPoint::operator=(const CivPoint& others)
{
return CivPoint(others.mX, others.mY, others.mZ);
}
bool CivPoint::operator==(const CivPoint& others)
{
return mX == others.mX &&
mY == others.mY &&
mZ == others.mZ;
}
\ No newline at end of file
#pragma once
/**
*/
class CivPoint
{
public:
/**
* @brief ࣬
* @param [x]
* @param [y]
* @param [z]
*/
CivPoint(double x, double y, double z = 0.0);
CivPoint operator=(const CivPoint& others);
bool operator==(const CivPoint& others);
private:
double mX;
double mY;
double mZ;
};
#pragma once
# if defined(PANDAWATERCORELIB_EXPORTS)
# if defined(_MSC_VER)
# define PANDAWATERCORELIB_API __declspec(dllexport)
# else
# define PANDAWATERCORELIB_API
# endif
# else
# if defined(_MSC_VER)
# define PANDAWATERCORELIB_API __declspec(dllimport)
# else
# define PANDAWATERCORELIB_API
# endif
# endif
\ No newline at end of file
......@@ -130,7 +130,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;PANDAWATERCORELIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
......@@ -142,15 +142,20 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CivAttributes.h" />
<ClInclude Include="CivAttributeTable.h" />
<ClInclude Include="CivFeature.h" />
<ClInclude Include="CivGeometry.h" />
<ClInclude Include="CivMetaType.h" />
<ClInclude Include="CivPoint.h" />
<ClInclude Include="CivVariant.h" />
<ClInclude Include="pandaWaterCore.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivAttributes.cpp" />
<ClCompile Include="CivAttributeTable.cpp" />
<ClCompile Include="CivFeature.cpp" />
<ClCompile Include="CivGeometry.cpp" />
<ClCompile Include="CivPoint.cpp" />
<ClCompile Include="CivVariant.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
......@@ -30,6 +30,15 @@
<ClInclude Include="CivVariant.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivPoint.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="pandaWaterCore.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CivAttributeTable.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CivAttributes.cpp">
......@@ -44,5 +53,11 @@
<ClCompile Include="CivVariant.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivPoint.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivAttributeTable.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment