Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gis functions #192

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

### Added

- `IComparableType` implementation to `WebFile` class.
- Feature GeoDistance is implemented.

Expand All @@ -16,10 +15,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Removed

### Fixed

- Resolve hierarchy references for `Created` master only (removed excess `UPDATE`).
- Update data objects with static properties inherited from DataObject.

- Remove an external context from PutIdentifierIntoBrackets() method implementation in PostgresDataService.
- Fix the return value type of GisExtensions GeoDistance, GeomDistance LINQ gis-functions prototypes.

### Security

## [6.0.0] - 2021-05-25
Expand Down
25 changes: 15 additions & 10 deletions ICSSoft.STORMNET.Business.LINQProvider/Extensions/GisExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ICSSoft.STORMNET.Business.LINQProvider.Extensions
{
using System;
using System.IO;

using Microsoft.Spatial;
Expand All @@ -11,50 +12,54 @@ public static class GisExtensions
{
/// <summary>
/// Вычисляет расстояние между двумя объектами Geography.
/// Метод может использоваться только в запросе к LINQProvider. В остальных случаях всегда будет возвращать 0.0 .
/// Метод может использоваться только в запросе к LINQProvider,
/// в остальных случаях метод вызовет исключение NotImplementedException.
/// </summary>
/// <param name="geo1">Объект 1 Geography.</param>
/// <param name="geo2">Объект 2 Geography.</param>
/// <returns>Возвращает минимальное расстояние между двумя объектами.</returns>
public static double GeoDistance(this Geography geo1, Geography geo2)
public static double? GeoDistance(this Geography geo1, Geography geo2)
{
return 0.0;
throw new NotImplementedException();
}

/// <summary>
/// Вычисляет расстояние между двумя объектами Geometry.
/// Метод может использоваться только в запросе к LINQProvider. В остальных случаях всегда будет возвращать 0.0 .
/// Метод может использоваться только в запросе к LINQProvider,
/// в остальных случаях метод вызовет исключение NotImplementedException.
/// </summary>
/// <param name="geo1">Объект 1 Geometry.</param>
/// <param name="geo2">Объект 2 Geometry.</param>
/// <returns>Возвращает минимальное расстояние между двумя объектами.</returns>
public static double GeomDistance(this Geometry geo1, Geometry geo2)
public static double? GeomDistance(this Geometry geo1, Geometry geo2)
{
return 0.0;
throw new NotImplementedException();
}

/// <summary>
/// Тестирует пересечение двух объектов Geography.
/// Метод может использоваться только в запросе к LINQProvider. В остальных случаях всегда будет возвращать false.
/// Метод может использоваться только в запросе к LINQProvider,
/// в остальных случаях метод вызовет исключение NotImplementedException.
/// </summary>
/// <param name="geo1">Объект 1 Geography.</param>
/// <param name="geo2">Объект 2 Geography.</param>
/// <returns>Если существует пересечение двух объектов, то возвращает true, иначе false.</returns>
public static bool GeoIntersects(this Geography geo1, Geography geo2)
{
return false;
throw new NotImplementedException();
}

/// <summary>
/// Тестирует пересечение двух объектов Geometry.
/// Метод может использоваться только в запросе к LINQProvider. В остальных случаях всегда будет возвращать false.
/// Метод может использоваться только в запросе к LINQProvider,
/// в остальных случаях метод вызовет исключение NotImplementedException.
/// </summary>
/// <param name="geo1">Объект 1 Geometry.</param>
/// <param name="geo2">Объект 2 Geometry.</param>
/// <returns>Если существует пересечение двух объектов, то возвращает true, иначе false.</returns>
public static bool GeomIntersects(this Geometry geo1, Geometry geo2)
{
return false;
throw new NotImplementedException();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion ICSSoft.STORMNET.Business.LINQProvider/LcsQueryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override object Execute(Expression expression)
case LcsReturnType.Count:
return _ds.GetObjectsCount(lcs);
default:
throw new Exception("Linq провайдер не поддрживает тип: " + lcs.ReturnType);
throw new Exception("Linq провайдер не поддерживает тип: " + lcs.ReturnType);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,34 +545,7 @@ public override System.Data.IDbConnection GetConnection()
/// <returns>Identifier with brackets.</returns>
public override string PutIdentifierIntoBrackets(string identifier)
{
string postgresIdentifier = PrepareIdentifier(identifier);

// Multithreading app with single DS may be failed.
if (!isGenerateSqlSelect)
{
return postgresIdentifier;
}

if (!dictionaryShortNames.ContainsKey(postgresIdentifier))
{
dictionaryShortNames[postgresIdentifier] = null;
}

if (postgresIdentifier.IndexOf(".", StringComparison.Ordinal) != -1)
{
postgresIdentifier = "\"" + GenerateShortName(postgresIdentifier) + "\"";
}
else
{
if (dictionaryShortNames[postgresIdentifier] == null)
{
dictionaryShortNames[postgresIdentifier] = GenerateShortName(postgresIdentifier);
}

postgresIdentifier = dictionaryShortNames[postgresIdentifier];
}

return postgresIdentifier;
return PutIdentifierIntoBrackets(identifier, isGenerateSqlSelect);
}

/// <summary>
Expand Down Expand Up @@ -907,6 +880,7 @@ public override void GenerateSQLRowNumber(LoadingCustomizationStruct customizati
else if (string.IsNullOrEmpty(orderByExprForPaging))
{
orderByExprForPaging = $"{nl}ORDER BY {SQLWhereLanguageDef.StormMainObjectKey}";
query += orderByExprForPaging;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему так?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#191 вернуть как было.

}

resQuery =
Expand Down Expand Up @@ -951,6 +925,44 @@ public override IDictionary<int, string> GetObjectIndexesWithPks(
return ret;
}

/// <summary>
/// Put identifier into brackets.
/// </summary>
/// <param name="identifier">Identifier in query.</param>
/// <param name="generateSqlSelectFlag">A flag, indicating that a call is made from GenerateSQLSelect() method.</param>
/// <returns>Identifier with brackets.</returns>
protected string PutIdentifierIntoBrackets(string identifier, bool generateSqlSelectFlag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateSqlSelectFlag - тут нарушена логика уровня ответственности: функция должна быть самодостаточной и ей не нужно знать откуда её вызывают. Если нужен параметр, который как-то меняет поведение функции, то и назови его так, чтобы было понятно что внутри функции "переключится".

{
string postgresIdentifier = PrepareIdentifier(identifier);

// Multithreading app with single DS may be failed.
if (!generateSqlSelectFlag)
{
return postgresIdentifier;
}

if (!dictionaryShortNames.ContainsKey(postgresIdentifier))
{
dictionaryShortNames[postgresIdentifier] = null;
}

if (postgresIdentifier.IndexOf(".", StringComparison.Ordinal) != -1)
{
postgresIdentifier = "\"" + GenerateShortName(postgresIdentifier) + "\"";
}
else
{
if (dictionaryShortNames[postgresIdentifier] == null)
{
dictionaryShortNames[postgresIdentifier] = GenerateShortName(postgresIdentifier);
}

postgresIdentifier = dictionaryShortNames[postgresIdentifier];
}

return postgresIdentifier;
}

private IDictionary<int, string> GetObjectIndexesWithPksImplementation(
LoadingCustomizationStruct lcs,
FunctionalLanguage.Function limitFunction,
Expand Down
4 changes: 3 additions & 1 deletion NewPlatform.Flexberry.ORM.PostgresDataService.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>NewPlatform.Flexberry.ORM.PostgresDataService</id>
<version>6.1.0-beta01</version>
<version>6.1.0-beta02</version>
<title>Flexberry ORM</title>
<authors>New Platform Ltd</authors>
<owners>New Platform Ltd</owners>
Expand All @@ -14,6 +14,8 @@
<releaseNotes>
Performance
1. Remove `order by stormmainobjectkey` for inner query.
Fixed
1. Remove an external context from PutIdentifierIntoBrackets() method implementation.
</releaseNotes>
<copyright>Copyright New Platform Ltd 2021</copyright>
<tags>Flexberry ORM</tags>
Expand Down
4 changes: 2 additions & 2 deletions NewPlatform.Flexberry.ORM.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>NewPlatform.Flexberry.ORM</id>
<version>6.0.1-beta02</version>
<version>6.0.1-beta03</version>
<title>Flexberry ORM</title>
<authors>New Platform Ltd</authors>
<owners>New Platform Ltd</owners>
Expand All @@ -18,7 +18,7 @@
Fixed
1. Resolve hierarchy references for Created master only (removed excess UPDATE).
2. Update data objects with static properties inherited from DataObject.

3. Fix the return value type of GisExtensions GeoDistance, GeomDistance LINQ gis-functions prototypes.
</releaseNotes>
<copyright>Copyright New Platform Ltd 2021</copyright>
<tags>Flexberry ORM</tags>
Expand Down