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

Add new CZML properties #166

Merged
merged 1 commit into from
Jun 12, 2019
Merged
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
3 changes: 3 additions & 0 deletions DotNet/CesiumLanguageWriter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Schema", "Schema", "{04E49F
..\Schema\Box.json = ..\Schema\Box.json
..\Schema\BoxDimensions.json = ..\Schema\BoxDimensions.json
..\Schema\CheckerboardMaterial.json = ..\Schema\CheckerboardMaterial.json
..\Schema\ClassificationType.json = ..\Schema\ClassificationType.json
..\Schema\Clock.json = ..\Schema\Clock.json
..\Schema\Color.json = ..\Schema\Color.json
..\Schema\ColorBlendMode.json = ..\Schema\ColorBlendMode.json
Expand Down Expand Up @@ -167,6 +168,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ValueProperties", "ValuePro
..\Schema\ValueProperties\CartographicRadiansValueProperty.json = ..\Schema\ValueProperties\CartographicRadiansValueProperty.json
..\Schema\ValueProperties\CartographicRectangleDegreesValueProperty.json = ..\Schema\ValueProperties\CartographicRectangleDegreesValueProperty.json
..\Schema\ValueProperties\CartographicRectangleRadiansValueProperty.json = ..\Schema\ValueProperties\CartographicRectangleRadiansValueProperty.json
..\Schema\ValueProperties\ClassificationTypeValueProperty.json = ..\Schema\ValueProperties\ClassificationTypeValueProperty.json
..\Schema\ValueProperties\ColorBlendModeValueProperty.json = ..\Schema\ValueProperties\ColorBlendModeValueProperty.json
..\Schema\ValueProperties\CornerTypeValueProperty.json = ..\Schema\ValueProperties\CornerTypeValueProperty.json
..\Schema\ValueProperties\DistanceDisplayConditionValueProperty.json = ..\Schema\ValueProperties\DistanceDisplayConditionValueProperty.json
Expand Down Expand Up @@ -212,6 +214,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Values", "Values", "{A9C205
..\Schema\Values\CartographicRadiansValue.json = ..\Schema\Values\CartographicRadiansValue.json
..\Schema\Values\CartographicRectangleDegreesValue.json = ..\Schema\Values\CartographicRectangleDegreesValue.json
..\Schema\Values\CartographicRectangleRadiansValue.json = ..\Schema\Values\CartographicRectangleRadiansValue.json
..\Schema\Values\ClassificationTypeValue.json = ..\Schema\Values\ClassificationTypeValue.json
..\Schema\Values\ClockRangeValue.json = ..\Schema\Values\ClockRangeValue.json
..\Schema\Values\ClockStepValue.json = ..\Schema\Values\ClockStepValue.json
..\Schema\Values\ColorBlendModeValue.json = ..\Schema\Values\ColorBlendModeValue.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using JetBrains.Annotations;

namespace CesiumLanguageWriter.Advanced
{
/// <summary>
/// Adapts a class that implements <see cref="ICesiumClassificationTypeValuePropertyWriter"/> to implement
/// <see cref="ICesiumPropertyWriter"/> for <see cref="CesiumClassificationType"/> values.
/// </summary>
/// <typeparam name="TFrom">The class that implements <see cref="ICesiumClassificationTypeValuePropertyWriter"/> to adapt.</typeparam>
public class CesiumClassificationTypeValuePropertyAdaptor<TFrom> : CesiumWriterAdaptor<TFrom, CesiumClassificationType>
where TFrom : class, ICesiumClassificationTypeValuePropertyWriter
{
/// <summary>
/// Initializes a new instance.
/// </summary>
/// <param name="parent">The instance to wrap.</param>
/// <param name="writeValueCallback">The callback to write values of type <see cref="CesiumClassificationType"/>.</param>
/// <param name="writeDeleteValueCallback">The callback to write an indication that the client should delete existing data.</param>
public CesiumClassificationTypeValuePropertyAdaptor([NotNull] TFrom parent,
[NotNull] CesiumWriterAdaptorWriteCallback<TFrom, CesiumClassificationType> writeValueCallback,
[NotNull] CesiumWriterAdaptorWriteDeleteCallback<TFrom> writeDeleteValueCallback)
: base(parent, writeValueCallback, writeDeleteValueCallback)
{
}
}
}
21 changes: 21 additions & 0 deletions DotNet/CesiumLanguageWriter/Advanced/CesiumFormattingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,27 @@ public static string CornerTypeToString(CesiumCornerType value)
}
}

/// <summary>
/// Converts a <see cref="CesiumClassificationType"/> to the corresponding string in a CZML stream.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>The string representing the specified value.</returns>
[NotNull]
public static string ClassificationTypeToString(CesiumClassificationType value)
{
switch (value)
{
case CesiumClassificationType.Terrain:
return "TERRAIN";
case CesiumClassificationType.Cesium3DTile:
return "CESIUM_3D_TILE";
case CesiumClassificationType.Both:
return "BOTH";
default:
throw new ArgumentException(CesiumLocalization.UnknownEnumerationValue, "value");
}
}

/// <summary>
/// Converts a <see cref="CesiumColorBlendMode"/> to the corresponding string in a CZML stream.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ public static CesiumCartographicRectangleDegreesValuePropertyAdaptor<TFrom> Crea
return new CesiumCartographicRectangleDegreesValuePropertyAdaptor<TFrom>(parent, (writer, value) => writer.WriteWsenDegrees(value), (writer, dates, values, startIndex, length) => writer.WriteWsenDegrees(dates, values, startIndex, length), CreateWriteDeleteCallback<TFrom>());
}

/// <summary>
/// Create an adaptor for <see cref="CesiumClassificationType"/> values.
/// </summary>
/// <typeparam name="TFrom">The class that implements <see cref="ICesiumClassificationTypeValuePropertyWriter"/> to adapt.</typeparam>
/// <param name="parent">The instance to wrap.</param>
/// <returns>The new adaptor.</returns>
public static CesiumClassificationTypeValuePropertyAdaptor<TFrom> CreateClassificationType<TFrom>([NotNull] TFrom parent)
where TFrom : class, ICesiumClassificationTypeValuePropertyWriter, ICesiumDeletablePropertyWriter
{
return new CesiumClassificationTypeValuePropertyAdaptor<TFrom>(parent, (writer, value) => writer.WriteClassificationType(value), CreateWriteDeleteCallback<TFrom>());
}

/// <summary>
/// Create an adaptor for <see cref="CesiumColorBlendMode"/> values.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace CesiumLanguageWriter.Advanced
{
/// <summary>
/// A writer that can write a value as a classification type.
/// </summary>
public interface ICesiumClassificationTypeValuePropertyWriter : ICesiumPropertyWriter
{
/// <summary>
/// Writes the value expressed as a classification type.
/// </summary>
/// <param name="value">The classification type.</param>
void WriteClassificationType(CesiumClassificationType value);
}
}
23 changes: 23 additions & 0 deletions DotNet/CesiumLanguageWriter/CesiumClassificationType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace CesiumLanguageWriter
{
/// <summary>
/// Whether a classification affects terrain, 3D Tiles or both.
/// </summary>
public enum CesiumClassificationType
{
/// <summary>
/// Only terrain will be classified.
/// </summary>
Terrain,

/// <summary>
/// Only 3D Tiles will be classified.
/// </summary>
Cesium3DTile,

/// <summary>
/// Both terrain and 3D Tiles will be classified.
/// </summary>
Both,
}
}
4 changes: 4 additions & 0 deletions DotNet/CesiumLanguageWriter/CesiumLanguageWriter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<Compile Include="Advanced\CesiumCartographicRadiansListValuePropertyAdaptor.cs" />
<Compile Include="Advanced\CesiumCartographicRectangleDegreesValuePropertyAdaptor.cs" />
<Compile Include="Advanced\CesiumCartographicRadiansValuePropertyAdaptor.cs" />
<Compile Include="Advanced\CesiumClassificationTypeValuePropertyAdaptor.cs" />
<Compile Include="Advanced\CesiumColorBlendModeValuePropertyAdaptor.cs" />
<Compile Include="Advanced\CesiumCornerTypeValuePropertyAdaptor.cs" />
<Compile Include="Advanced\CesiumDistanceDisplayConditionValuePropertyAdaptor.cs" />
Expand Down Expand Up @@ -111,6 +112,7 @@
<Compile Include="Advanced\ICesiumCartographicRadiansListValuePropertyWriter.cs" />
<Compile Include="Advanced\ICesiumCartographicRectangleDegreesValuePropertyWriter.cs" />
<Compile Include="Advanced\ICesiumCartographicRadiansValuePropertyWriter.cs" />
<Compile Include="Advanced\ICesiumClassificationTypeValuePropertyWriter.cs" />
<Compile Include="Advanced\ICesiumColorBlendModeValuePropertyWriter.cs" />
<Compile Include="Advanced\ICesiumCornerTypeValuePropertyWriter.cs" />
<Compile Include="Advanced\ICesiumDeletablePropertyWriter.cs" />
Expand Down Expand Up @@ -162,6 +164,7 @@
<Compile Include="Cartesian.cs" />
<Compile Include="Cartographic.cs" />
<Compile Include="CartographicExtent.cs" />
<Compile Include="CesiumClassificationType.cs" />
<Compile Include="CesiumColorBlendMode.cs" />
<Compile Include="CesiumArcType.cs" />
<Compile Include="CesiumCornerType.cs" />
Expand Down Expand Up @@ -205,6 +208,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Generated\CheckerboardMaterialCesiumWriter.cs" />
<Compile Include="Generated\ClassificationTypeCesiumWriter.cs" />
<Compile Include="Generated\ClockCesiumWriter.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
87 changes: 87 additions & 0 deletions DotNet/CesiumLanguageWriter/Generated/BoxCesiumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public class BoxCesiumWriter : CesiumPropertyWriter<BoxCesiumWriter>
/// </summary>
public const string DimensionsPropertyName = "dimensions";

/// <summary>
/// The name of the <c>heightReference</c> property.
/// </summary>
public const string HeightReferencePropertyName = "heightReference";

/// <summary>
/// The name of the <c>fill</c> property.
/// </summary>
Expand Down Expand Up @@ -63,6 +68,7 @@ public class BoxCesiumWriter : CesiumPropertyWriter<BoxCesiumWriter>

private readonly Lazy<BooleanCesiumWriter> m_show = new Lazy<BooleanCesiumWriter>(() => new BooleanCesiumWriter(ShowPropertyName), false);
private readonly Lazy<BoxDimensionsCesiumWriter> m_dimensions = new Lazy<BoxDimensionsCesiumWriter>(() => new BoxDimensionsCesiumWriter(DimensionsPropertyName), false);
private readonly Lazy<HeightReferenceCesiumWriter> m_heightReference = new Lazy<HeightReferenceCesiumWriter>(() => new HeightReferenceCesiumWriter(HeightReferencePropertyName), false);
private readonly Lazy<BooleanCesiumWriter> m_fill = new Lazy<BooleanCesiumWriter>(() => new BooleanCesiumWriter(FillPropertyName), false);
private readonly Lazy<MaterialCesiumWriter> m_material = new Lazy<MaterialCesiumWriter>(() => new MaterialCesiumWriter(MaterialPropertyName), false);
private readonly Lazy<BooleanCesiumWriter> m_outline = new Lazy<BooleanCesiumWriter>(() => new BooleanCesiumWriter(OutlinePropertyName), false);
Expand Down Expand Up @@ -285,6 +291,87 @@ public void WriteDimensionsPropertyReference(string identifier, string[] propert
}
}

/// <summary>
/// Gets the writer for the <c>heightReference</c> property. The returned instance must be opened by calling the <see cref="CesiumElementWriter.Open"/> method before it can be used for writing. The <c>heightReference</c> property defines the height reference of the box, which indicates if the position is relative to terrain or not. If not specified, the default value is NONE.
/// </summary>
[NotNull]
public HeightReferenceCesiumWriter HeightReferenceWriter
{
get { return m_heightReference.Value; }
}

/// <summary>
/// Opens and returns the writer for the <c>heightReference</c> property. The <c>heightReference</c> property defines the height reference of the box, which indicates if the position is relative to terrain or not. If not specified, the default value is NONE.
/// </summary>
[NotNull]
public HeightReferenceCesiumWriter OpenHeightReferenceProperty()
{
OpenIntervalIfNecessary();
return OpenAndReturn(HeightReferenceWriter);
}

/// <summary>
/// Writes a value for the <c>heightReference</c> property as a <c>heightReference</c> value. The <c>heightReference</c> property specifies the height reference of the box, which indicates if the position is relative to terrain or not. If not specified, the default value is NONE.
/// </summary>
/// <param name="value">The height reference.</param>
public void WriteHeightReferenceProperty(CesiumHeightReference value)
{
using (var writer = OpenHeightReferenceProperty())
{
writer.WriteHeightReference(value);
}
}

/// <summary>
/// Writes a value for the <c>heightReference</c> property as a <c>reference</c> value. The <c>heightReference</c> property specifies the height reference of the box, which indicates if the position is relative to terrain or not. If not specified, the default value is NONE.
/// </summary>
/// <param name="value">The reference.</param>
public void WriteHeightReferencePropertyReference(Reference value)
{
using (var writer = OpenHeightReferenceProperty())
{
writer.WriteReference(value);
}
}

/// <summary>
/// Writes a value for the <c>heightReference</c> property as a <c>reference</c> value. The <c>heightReference</c> property specifies the height reference of the box, which indicates if the position is relative to terrain or not. If not specified, the default value is NONE.
/// </summary>
/// <param name="value">The reference.</param>
public void WriteHeightReferencePropertyReference(string value)
{
using (var writer = OpenHeightReferenceProperty())
{
writer.WriteReference(value);
}
}

/// <summary>
/// Writes a value for the <c>heightReference</c> property as a <c>reference</c> value. The <c>heightReference</c> property specifies the height reference of the box, which indicates if the position is relative to terrain or not. If not specified, the default value is NONE.
/// </summary>
/// <param name="identifier">The identifier of the object which contains the referenced property.</param>
/// <param name="propertyName">The property on the referenced object.</param>
public void WriteHeightReferencePropertyReference(string identifier, string propertyName)
{
using (var writer = OpenHeightReferenceProperty())
{
writer.WriteReference(identifier, propertyName);
}
}

/// <summary>
/// Writes a value for the <c>heightReference</c> property as a <c>reference</c> value. The <c>heightReference</c> property specifies the height reference of the box, which indicates if the position is relative to terrain or not. If not specified, the default value is NONE.
/// </summary>
/// <param name="identifier">The identifier of the object which contains the referenced property.</param>
/// <param name="propertyNames">The hierarchy of properties to be indexed on the referenced object.</param>
public void WriteHeightReferencePropertyReference(string identifier, string[] propertyNames)
{
using (var writer = OpenHeightReferenceProperty())
{
writer.WriteReference(identifier, propertyNames);
}
}

/// <summary>
/// Gets the writer for the <c>fill</c> property. The returned instance must be opened by calling the <see cref="CesiumElementWriter.Open"/> method before it can be used for writing. The <c>fill</c> property defines whether or not the box is filled. If not specified, the default value is <see langword="true"/>.
/// </summary>
Expand Down
Loading