diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 14439ea..e545488 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -43,6 +43,7 @@ DefaultViewportMouseLockMode=LockOnCapture +ActionMappings=(ActionName="ActionX",Key=MouseX,bShift=False,bCtrl=False,bAlt=False,bCmd=False) +ActionMappings=(ActionName="ActionY",Key=MouseY,bShift=False,bCtrl=False,bAlt=False,bCmd=False) +ActionMappings=(ActionName="Pause",Key=SpaceBar,bShift=False,bCtrl=False,bAlt=False,bCmd=False) ++ActionMappings=(ActionName="SearchBarToggle",Key=F,bShift=False,bCtrl=True,bAlt=False,bCmd=False) +AxisMappings=(AxisName="LeftRight",Key=Right,Scale=1.000000) +AxisMappings=(AxisName="LeftRight",Key=Left,Scale=-1.000000) +AxisMappings=(AxisName="DownUp",Key=Up,Scale=1.000000) diff --git a/Content/BPs/Birdview.uasset b/Content/BPs/Birdview.uasset index f2a667e..cb2475b 100644 Binary files a/Content/BPs/Birdview.uasset and b/Content/BPs/Birdview.uasset differ diff --git a/Content/BPs/GI.uasset b/Content/BPs/GI.uasset index e309f09..e075058 100644 Binary files a/Content/BPs/GI.uasset and b/Content/BPs/GI.uasset differ diff --git a/Content/BPs/PC.uasset b/Content/BPs/PC.uasset index fde9405..0fff346 100644 Binary files a/Content/BPs/PC.uasset and b/Content/BPs/PC.uasset differ diff --git a/Content/BPs/StreetMap_Static.uasset b/Content/BPs/StreetMap_Static.uasset index 837210e..efa6ded 100644 Binary files a/Content/BPs/StreetMap_Static.uasset and b/Content/BPs/StreetMap_Static.uasset differ diff --git a/Content/Scenes/CentralLondon.umap b/Content/Scenes/CentralLondon.umap index 6210e9f..d772137 100644 Binary files a/Content/Scenes/CentralLondon.umap and b/Content/Scenes/CentralLondon.umap differ diff --git a/Content/Scenes/CentralLondon_BuiltData.uasset b/Content/Scenes/CentralLondon_BuiltData.uasset index b8a6c81..418562f 100644 Binary files a/Content/Scenes/CentralLondon_BuiltData.uasset and b/Content/Scenes/CentralLondon_BuiltData.uasset differ diff --git a/Content/Structs/AmenityImg.uasset b/Content/Structs/AmenityImg.uasset new file mode 100644 index 0000000..e9d8867 Binary files /dev/null and b/Content/Structs/AmenityImg.uasset differ diff --git a/Content/UI/Cursor.uasset b/Content/UI/Cursor.uasset index f882482..a220d7b 100644 Binary files a/Content/UI/Cursor.uasset and b/Content/UI/Cursor.uasset differ diff --git a/Content/UI/Icons/Amenities/Bank.uasset b/Content/UI/Icons/Amenities/Bank.uasset new file mode 100644 index 0000000..c7c7701 Binary files /dev/null and b/Content/UI/Icons/Amenities/Bank.uasset differ diff --git a/Content/UI/Icons/Amenities/Bar.uasset b/Content/UI/Icons/Amenities/Bar.uasset new file mode 100644 index 0000000..9668fb8 Binary files /dev/null and b/Content/UI/Icons/Amenities/Bar.uasset differ diff --git a/Content/UI/Icons/Amenities/Biergarten.uasset b/Content/UI/Icons/Amenities/Biergarten.uasset new file mode 100644 index 0000000..460b546 Binary files /dev/null and b/Content/UI/Icons/Amenities/Biergarten.uasset differ diff --git a/Content/UI/Icons/Amenities/Cafe.uasset b/Content/UI/Icons/Amenities/Cafe.uasset new file mode 100644 index 0000000..74b0499 Binary files /dev/null and b/Content/UI/Icons/Amenities/Cafe.uasset differ diff --git a/Content/UI/Icons/Amenities/Cinema.uasset b/Content/UI/Icons/Amenities/Cinema.uasset new file mode 100644 index 0000000..3bd477f Binary files /dev/null and b/Content/UI/Icons/Amenities/Cinema.uasset differ diff --git a/Content/UI/Icons/Amenities/Dentist.uasset b/Content/UI/Icons/Amenities/Dentist.uasset new file mode 100644 index 0000000..bee9a37 Binary files /dev/null and b/Content/UI/Icons/Amenities/Dentist.uasset differ diff --git a/Content/UI/Icons/Amenities/Doctor.uasset b/Content/UI/Icons/Amenities/Doctor.uasset new file mode 100644 index 0000000..c3943ec Binary files /dev/null and b/Content/UI/Icons/Amenities/Doctor.uasset differ diff --git a/Content/UI/Icons/Amenities/Fast_food.uasset b/Content/UI/Icons/Amenities/Fast_food.uasset new file mode 100644 index 0000000..5863246 Binary files /dev/null and b/Content/UI/Icons/Amenities/Fast_food.uasset differ diff --git a/Content/UI/Icons/Amenities/Hospital.uasset b/Content/UI/Icons/Amenities/Hospital.uasset new file mode 100644 index 0000000..e8c8117 Binary files /dev/null and b/Content/UI/Icons/Amenities/Hospital.uasset differ diff --git a/Content/UI/Icons/Amenities/Hotel.uasset b/Content/UI/Icons/Amenities/Hotel.uasset new file mode 100644 index 0000000..d8b4f52 Binary files /dev/null and b/Content/UI/Icons/Amenities/Hotel.uasset differ diff --git a/Content/UI/Icons/Amenities/Ice_cream.uasset b/Content/UI/Icons/Amenities/Ice_cream.uasset new file mode 100644 index 0000000..5c977d8 Binary files /dev/null and b/Content/UI/Icons/Amenities/Ice_cream.uasset differ diff --git a/Content/UI/Icons/Amenities/Library.uasset b/Content/UI/Icons/Amenities/Library.uasset new file mode 100644 index 0000000..2cd0e8d Binary files /dev/null and b/Content/UI/Icons/Amenities/Library.uasset differ diff --git a/Content/UI/Icons/Amenities/Marketplace.uasset b/Content/UI/Icons/Amenities/Marketplace.uasset new file mode 100644 index 0000000..d71b3cc Binary files /dev/null and b/Content/UI/Icons/Amenities/Marketplace.uasset differ diff --git a/Content/UI/Icons/Amenities/Nightclub.uasset b/Content/UI/Icons/Amenities/Nightclub.uasset new file mode 100644 index 0000000..d145c56 Binary files /dev/null and b/Content/UI/Icons/Amenities/Nightclub.uasset differ diff --git a/Content/UI/Icons/Amenities/Pharmacy.uasset b/Content/UI/Icons/Amenities/Pharmacy.uasset new file mode 100644 index 0000000..c39f102 Binary files /dev/null and b/Content/UI/Icons/Amenities/Pharmacy.uasset differ diff --git a/Content/UI/Icons/Amenities/Place_of_worship.uasset b/Content/UI/Icons/Amenities/Place_of_worship.uasset new file mode 100644 index 0000000..5a4c609 Binary files /dev/null and b/Content/UI/Icons/Amenities/Place_of_worship.uasset differ diff --git a/Content/UI/Icons/Amenities/Police.uasset b/Content/UI/Icons/Amenities/Police.uasset new file mode 100644 index 0000000..7e05651 Binary files /dev/null and b/Content/UI/Icons/Amenities/Police.uasset differ diff --git a/Content/UI/Icons/Amenities/Post_office.uasset b/Content/UI/Icons/Amenities/Post_office.uasset new file mode 100644 index 0000000..9dab37e Binary files /dev/null and b/Content/UI/Icons/Amenities/Post_office.uasset differ diff --git a/Content/UI/Icons/Amenities/Prison.uasset b/Content/UI/Icons/Amenities/Prison.uasset new file mode 100644 index 0000000..df9c7ec Binary files /dev/null and b/Content/UI/Icons/Amenities/Prison.uasset differ diff --git a/Content/UI/Icons/Amenities/Pub.uasset b/Content/UI/Icons/Amenities/Pub.uasset new file mode 100644 index 0000000..d714ad5 Binary files /dev/null and b/Content/UI/Icons/Amenities/Pub.uasset differ diff --git a/Content/UI/Icons/Amenities/Restaurant.uasset b/Content/UI/Icons/Amenities/Restaurant.uasset new file mode 100644 index 0000000..e10ed4c Binary files /dev/null and b/Content/UI/Icons/Amenities/Restaurant.uasset differ diff --git a/Content/UI/Icons/Amenities/Theatre.uasset b/Content/UI/Icons/Amenities/Theatre.uasset new file mode 100644 index 0000000..8cb3ebb Binary files /dev/null and b/Content/UI/Icons/Amenities/Theatre.uasset differ diff --git a/Content/UI/Icons/Amenities/Toilets.uasset b/Content/UI/Icons/Amenities/Toilets.uasset new file mode 100644 index 0000000..f445069 Binary files /dev/null and b/Content/UI/Icons/Amenities/Toilets.uasset differ diff --git a/Content/UI/Icons/Amenities/Veterinary.uasset b/Content/UI/Icons/Amenities/Veterinary.uasset new file mode 100644 index 0000000..5ab125e Binary files /dev/null and b/Content/UI/Icons/Amenities/Veterinary.uasset differ diff --git a/Content/UI/Icons/Amenities/all.uasset b/Content/UI/Icons/Amenities/all.uasset new file mode 100644 index 0000000..941bf26 Binary files /dev/null and b/Content/UI/Icons/Amenities/all.uasset differ diff --git a/Content/UI/Icons/Amenities/art.uasset b/Content/UI/Icons/Amenities/art.uasset new file mode 100644 index 0000000..80d97cd Binary files /dev/null and b/Content/UI/Icons/Amenities/art.uasset differ diff --git a/Content/UI/Icons/Amenities/community_centre.uasset b/Content/UI/Icons/Amenities/community_centre.uasset new file mode 100644 index 0000000..ebae1f0 Binary files /dev/null and b/Content/UI/Icons/Amenities/community_centre.uasset differ diff --git a/Content/UI/Icons/Amenities/office.uasset b/Content/UI/Icons/Amenities/office.uasset new file mode 100644 index 0000000..5838c7c Binary files /dev/null and b/Content/UI/Icons/Amenities/office.uasset differ diff --git a/Content/UI/Icons/Amenities/residential.uasset b/Content/UI/Icons/Amenities/residential.uasset new file mode 100644 index 0000000..f930b1f Binary files /dev/null and b/Content/UI/Icons/Amenities/residential.uasset differ diff --git a/Content/UI/Icons/Amenities/sports_centre.uasset b/Content/UI/Icons/Amenities/sports_centre.uasset new file mode 100644 index 0000000..5d2f5ae Binary files /dev/null and b/Content/UI/Icons/Amenities/sports_centre.uasset differ diff --git a/Content/UI/Icons/search.uasset b/Content/UI/Icons/search.uasset new file mode 100644 index 0000000..c10eea8 Binary files /dev/null and b/Content/UI/Icons/search.uasset differ diff --git a/Content/UI/ScreenTint.uasset b/Content/UI/ScreenTint.uasset index ccbf47a..8d54965 100644 Binary files a/Content/UI/ScreenTint.uasset and b/Content/UI/ScreenTint.uasset differ diff --git a/Content/UI/SearchResult.uasset b/Content/UI/SearchResult.uasset new file mode 100644 index 0000000..a7f62dc Binary files /dev/null and b/Content/UI/SearchResult.uasset differ diff --git a/Content/UI/TopRight.uasset b/Content/UI/TopRight.uasset index f427a61..c83cfbf 100644 Binary files a/Content/UI/TopRight.uasset and b/Content/UI/TopRight.uasset differ diff --git a/Plugins/StreetMap/Source/StreetMapImporting/OSMFile.cpp b/Plugins/StreetMap/Source/StreetMapImporting/OSMFile.cpp index d217b7d..2dd8cb5 100644 --- a/Plugins/StreetMap/Source/StreetMapImporting/OSMFile.cpp +++ b/Plugins/StreetMap/Source/StreetMapImporting/OSMFile.cpp @@ -390,6 +390,12 @@ bool FOSMFile::ProcessAttribute( const TCHAR* AttributeName, const TCHAR* Attrib else if( !FCString::Stricmp( AttributeValue, TEXT( "fitness_centre" ) ) ) { CurrentWayInfo->WayType = EOSMWayType::Building; + CurrentWayInfo->Amenity = AttributeValue; + } + + else if( !FCString::Stricmp( AttributeValue, TEXT( "sports_centre" ) ) ) + { + CurrentWayInfo->WayType = EOSMWayType::Building; CurrentWayInfo->Amenity = AttributeValue; } diff --git a/Plugins/StreetMap/Source/StreetMapImporting/StreetMapFactory.cpp b/Plugins/StreetMap/Source/StreetMapImporting/StreetMapFactory.cpp index 61e3831..3a289bb 100644 --- a/Plugins/StreetMap/Source/StreetMapImporting/StreetMapFactory.cpp +++ b/Plugins/StreetMap/Source/StreetMapImporting/StreetMapFactory.cpp @@ -81,6 +81,104 @@ bool UStreetMapFactory::LoadFromOpenStreetMapXMLFile( UStreetMap* StreetMap, FSt (float)( ConvertLongitudeToMeters( Longitude, Latitude ) - ConvertLongitudeToMeters( RelativeToLongitude, Latitude ) ), (float)( ConvertLatitudeToMeters( Latitude ) - ConvertLatitudeToMeters( RelativeToLatitude ) ) ); }; + + // Adds a Park to the street map using the OpenStreetMap data, flattening the road's coordinates into our map's space + auto AddParkForWay = [ConvertLatLongToMetersRelative, OSMToCentimetersScaleFactor]( + const FOSMFile& OSMFile, + UStreetMap& StreetMapRef, + const FOSMFile::FOSMWayInfo& OSMWay ) -> bool + { + if( OSMWay.WayType == FOSMFile::EOSMWayType::Park ) + { + // Require at least three points so that we don't have degenerate polygon! + if( OSMWay.Nodes.Num() > 2 ) + { + // Create a Park for this way + FStreetMapPark& NewPark = *new( StreetMapRef.Parks )FStreetMapPark(); + + FVector2D BoundsMin( TNumericLimits::Max(), TNumericLimits::Max() ); + FVector2D BoundsMax( TNumericLimits::Lowest(), TNumericLimits::Lowest() ); + + NewPark.ParkPoints.AddUninitialized( OSMWay.Nodes.Num() ); + int32 CurParkPoint = 0; + + for( const FOSMFile::FOSMNodeInfo* OSMNodePtr : OSMWay.Nodes ) + { + const FOSMFile::FOSMNodeInfo& OSMNode = *OSMNodePtr; + + // Transform all points relative to the center of the latitude/longitude bounds, so that + // we get as much precision as possible. + const double RelativeToLatitude = OSMFile.AverageLatitude; + const double RelativeToLongitude = OSMFile.AverageLongitude; + const FVector2D NodePos = ConvertLatLongToMetersRelative( + OSMNode.Latitude, + OSMNode.Longitude, + RelativeToLatitude, + RelativeToLongitude ) * OSMToCentimetersScaleFactor; + + // Update bounding box + { + if( NodePos.X < BoundsMin.X ) + { + BoundsMin.X = NodePos.X; + } + if( NodePos.Y < BoundsMin.Y ) + { + BoundsMin.Y = NodePos.Y; + } + if( NodePos.X > BoundsMax.X ) + { + BoundsMax.X = NodePos.X; + } + if( NodePos.Y > BoundsMax.Y ) + { + BoundsMax.Y = NodePos.Y; + } + } + + // Fill in the points + NewPark.ParkPoints[ CurParkPoint++ ] = NodePos; + } + + // Make sure the Park ended up with a closed polygon, then remove the final (redundant) point + const bool bIsClosed = NewPark.ParkPoints[ 0 ].Equals( NewPark.ParkPoints[ NewPark.ParkPoints.Num() - 1 ], KINDA_SMALL_NUMBER ); + if( bIsClosed ) + { + // Remove the final redundant point + NewPark.ParkPoints.Pop(); + } + else + { + // Wasn't expecting to have an unclosed shape. Our tolerances might be off, or the data was malformed. + // Either way, it shouldn't be a problem as we'll close the shape ourselves below. + // @todo: Log this for the user as an import warning + } + + NewPark.ParkName = OSMWay.Name; + if( NewPark.ParkName.IsEmpty() ) + { + NewPark.ParkName = OSMWay.Ref; + } + + NewPark.BoundsMin = BoundsMin; + NewPark.BoundsMax = BoundsMax; + + StreetMapRef.BoundsMin.X = FMath::Min( StreetMapRef.BoundsMin.X, BoundsMin.X ); + StreetMapRef.BoundsMin.Y = FMath::Min( StreetMapRef.BoundsMin.Y, BoundsMin.Y ); + StreetMapRef.BoundsMax.X = FMath::Max( StreetMapRef.BoundsMax.X, BoundsMax.X ); + StreetMapRef.BoundsMax.Y = FMath::Max( StreetMapRef.BoundsMax.Y, BoundsMax.Y ); + + return true; + } + else + { + // NOTE: Skipped adding Park for way because it has less than 3 points + // @todo: Log this for the user as an import warning + } + } + + return false; + }; // Adds a road to the street map using the OpenStreetMap data, flattening the road's coordinates into our map's space auto AddRoadForWay = [ConvertLatLongToMetersRelative, OSMToCentimetersScaleFactor]( @@ -318,7 +416,7 @@ bool UStreetMapFactory::LoadFromOpenStreetMapXMLFile( UStreetMap* StreetMap, FSt }; - + /** // Adds a water to the street map using the OpenStreetMap data, flattening the road's coordinates into our map's space auto AddWaterForWay = [ConvertLatLongToMetersRelative, OSMToCentimetersScaleFactor]( const FOSMFile& OSMFile, @@ -417,104 +515,10 @@ bool UStreetMapFactory::LoadFromOpenStreetMapXMLFile( UStreetMap* StreetMap, FSt return false; }; + */ + + - // Adds a Park to the street map using the OpenStreetMap data, flattening the road's coordinates into our map's space - auto AddParkForWay = [ConvertLatLongToMetersRelative, OSMToCentimetersScaleFactor]( - const FOSMFile& OSMFile, - UStreetMap& StreetMapRef, - const FOSMFile::FOSMWayInfo& OSMWay ) -> bool - { - if( OSMWay.WayType == FOSMFile::EOSMWayType::Park ) - { - // Require at least three points so that we don't have degenerate polygon! - if( OSMWay.Nodes.Num() > 2 ) - { - // Create a Park for this way - FStreetMapPark& NewPark = *new( StreetMapRef.Parks )FStreetMapPark(); - - FVector2D BoundsMin( TNumericLimits::Max(), TNumericLimits::Max() ); - FVector2D BoundsMax( TNumericLimits::Lowest(), TNumericLimits::Lowest() ); - - NewPark.ParkPoints.AddUninitialized( OSMWay.Nodes.Num() ); - int32 CurParkPoint = 0; - - for( const FOSMFile::FOSMNodeInfo* OSMNodePtr : OSMWay.Nodes ) - { - const FOSMFile::FOSMNodeInfo& OSMNode = *OSMNodePtr; - - // Transform all points relative to the center of the latitude/longitude bounds, so that - // we get as much precision as possible. - const double RelativeToLatitude = OSMFile.AverageLatitude; - const double RelativeToLongitude = OSMFile.AverageLongitude; - const FVector2D NodePos = ConvertLatLongToMetersRelative( - OSMNode.Latitude, - OSMNode.Longitude, - RelativeToLatitude, - RelativeToLongitude ) * OSMToCentimetersScaleFactor; - - // Update bounding box - { - if( NodePos.X < BoundsMin.X ) - { - BoundsMin.X = NodePos.X; - } - if( NodePos.Y < BoundsMin.Y ) - { - BoundsMin.Y = NodePos.Y; - } - if( NodePos.X > BoundsMax.X ) - { - BoundsMax.X = NodePos.X; - } - if( NodePos.Y > BoundsMax.Y ) - { - BoundsMax.Y = NodePos.Y; - } - } - - // Fill in the points - NewPark.ParkPoints[ CurParkPoint++ ] = NodePos; - } - - // Make sure the Park ended up with a closed polygon, then remove the final (redundant) point - const bool bIsClosed = NewPark.ParkPoints[ 0 ].Equals( NewPark.ParkPoints[ NewPark.ParkPoints.Num() - 1 ], KINDA_SMALL_NUMBER ); - if( bIsClosed ) - { - // Remove the final redundant point - NewPark.ParkPoints.Pop(); - } - else - { - // Wasn't expecting to have an unclosed shape. Our tolerances might be off, or the data was malformed. - // Either way, it shouldn't be a problem as we'll close the shape ourselves below. - // @todo: Log this for the user as an import warning - } - - NewPark.ParkName = OSMWay.Name; - if( NewPark.ParkName.IsEmpty() ) - { - NewPark.ParkName = OSMWay.Ref; - } - - NewPark.BoundsMin = BoundsMin; - NewPark.BoundsMax = BoundsMax; - - StreetMapRef.BoundsMin.X = FMath::Min( StreetMapRef.BoundsMin.X, BoundsMin.X ); - StreetMapRef.BoundsMin.Y = FMath::Min( StreetMapRef.BoundsMin.Y, BoundsMin.Y ); - StreetMapRef.BoundsMax.X = FMath::Max( StreetMapRef.BoundsMax.X, BoundsMax.X ); - StreetMapRef.BoundsMax.Y = FMath::Max( StreetMapRef.BoundsMax.Y, BoundsMax.Y ); - - return true; - } - else - { - // NOTE: Skipped adding Park for way because it has less than 3 points - // @todo: Log this for the user as an import warning - } - } - - return false; - }; @@ -543,7 +547,15 @@ bool UStreetMapFactory::LoadFromOpenStreetMapXMLFile( UStreetMap* StreetMap, FSt for( const FOSMFile::FOSMWayInfo* OSMWay : OSMFile.Ways ) { // Handle buildings differently than roads - if( OSMWay->WayType == FOSMFile::EOSMWayType::Building ) + if (OSMWay->WayType == FOSMFile::EOSMWayType::Park) + { + if (AddParkForWay(OSMFile, *StreetMap, *OSMWay)) + { + // ... + } + } + + else if( OSMWay->WayType == FOSMFile::EOSMWayType::Building ) { if( AddBuildingForWay( OSMFile, *StreetMap, *OSMWay ) ) { @@ -552,7 +564,7 @@ bool UStreetMapFactory::LoadFromOpenStreetMapXMLFile( UStreetMap* StreetMap, FSt } - + /** else if( OSMWay->WayType == FOSMFile::EOSMWayType::Water ) { if( AddWaterForWay( OSMFile, *StreetMap, *OSMWay ) ) @@ -560,14 +572,7 @@ bool UStreetMapFactory::LoadFromOpenStreetMapXMLFile( UStreetMap* StreetMap, FSt // ... } } - - else if( OSMWay->WayType == FOSMFile::EOSMWayType::Park ) - { - if( AddParkForWay( OSMFile, *StreetMap, *OSMWay ) ) - { - // ... - } - } + */ else diff --git a/Plugins/StreetMap/Source/StreetMapRuntime/PolygonTools.h b/Plugins/StreetMap/Source/StreetMapRuntime/PolygonTools.h index ce18b8d..72e2bed 100644 --- a/Plugins/StreetMap/Source/StreetMapRuntime/PolygonTools.h +++ b/Plugins/StreetMap/Source/StreetMapRuntime/PolygonTools.h @@ -77,6 +77,28 @@ bool FPolygonTools::IsPointInsidePolygon( const TArray& Polygon, cons return bIsInside; } +/** Backup +bool FPolygonTools::IsPointInsidePolygon( const TArray& Polygon, const FVector2D Point ) +{ + const int NumCorners = Polygon.Num(); + int PreviousCornerIndex = NumCorners - 1; + bool bIsInside = false; + + for( int CornerIndex = 0; CornerIndex < NumCorners; CornerIndex++ ) + { + if( ( ( Polygon[ CornerIndex ].Y < Point.Y && Polygon[ PreviousCornerIndex ].Y >= Point.Y ) || ( Polygon[ PreviousCornerIndex ].Y < Point.Y && Polygon[ CornerIndex ].Y >= Point.Y ) ) && + ( Polygon[ CornerIndex ].X <= Point.X || Polygon[ PreviousCornerIndex ].X <= Point.X ) ) + { + bIsInside ^= ( Polygon[ CornerIndex ].X + ( Point.Y - Polygon[ CornerIndex ].Y ) / ( Polygon[ PreviousCornerIndex ].Y - Polygon[ CornerIndex ].Y )*( Polygon[ PreviousCornerIndex ].X - Polygon[ CornerIndex ].X ) < Point.X ); + } + + PreviousCornerIndex = CornerIndex; + } + + return bIsInside; +} +*/ + bool FPolygonTools::Snip( const TArray& Polygon, const int32 U, const int32 V, const int32 W, const int32 PointCount, const int32* VertexIndices ) { diff --git a/Plugins/StreetMap/Source/StreetMapRuntime/Public/StreetMap.h b/Plugins/StreetMap/Source/StreetMapRuntime/Public/StreetMap.h index 290a249..155bc07 100644 --- a/Plugins/StreetMap/Source/StreetMapRuntime/Public/StreetMap.h +++ b/Plugins/StreetMap/Source/StreetMapRuntime/Public/StreetMap.h @@ -2,7 +2,6 @@ #pragma once -#include "PolygonTools.h" #include "StreetMap.generated.h" @@ -463,20 +462,16 @@ public: /** Vinfamy added */ UFUNCTION(BlueprintCallable) - FStreetMapBuilding FindBuilding(const FVector2D Point) - { - FStreetMapBuilding emptyBuilding; - for (const auto &element : Buildings) - { - if (FPolygonTools::IsPointInsidePolygon(element.BuildingPoints, Point)) - { - return element; - } - } - return emptyBuilding; - } - + FStreetMapBuilding FindBuilding(const FVector2D Point); + + UFUNCTION(BlueprintCallable) + TArray SearchByBuildingName(FString SearchTerm, FString Amenity) const; + UFUNCTION(BlueprintCallable) + TArray SearchByAmenity(FString Amenity) const; + + TArray FilterByAmenity(FString Amenity, TArray SmallBuildings) const; + protected: /** List of roads */ diff --git a/Plugins/StreetMap/Source/StreetMapRuntime/StreetMap.cpp b/Plugins/StreetMap/Source/StreetMapRuntime/StreetMap.cpp index 06c1834..760a412 100644 --- a/Plugins/StreetMap/Source/StreetMapRuntime/StreetMap.cpp +++ b/Plugins/StreetMap/Source/StreetMapRuntime/StreetMap.cpp @@ -3,6 +3,10 @@ #include "StreetMapRuntime.h" #include "StreetMap.h" #include "EditorFramework/AssetImportData.h" +#include "PolygonTools.h" +#include "Runtime/Engine/Classes/Engine/StaticMesh.h" +#include "Runtime/Engine/Public/StaticMeshResources.h" +#include "PhysicsEngine/BodySetup.h" UStreetMap::UStreetMap() @@ -27,3 +31,89 @@ void UStreetMap::GetAssetRegistryTags( TArray& OutTags ) cons Super::GetAssetRegistryTags( OutTags ); } + + +FStreetMapBuilding UStreetMap::FindBuilding(const FVector2D Point) +{ + FStreetMapBuilding emptyBuilding; + for (const auto &element : Buildings) + { + if (FPolygonTools::IsPointInsidePolygon(element.BuildingPoints, Point)) + { + return element; + } + } + return emptyBuilding; +} + +TArray UStreetMap::SearchByBuildingName(FString SearchTerm, FString Amenity) const +{ + TArray Results; + if (SearchTerm.Len() > 0) + { + for (const auto &element : Buildings) + { + if (element.BuildingName.Contains(SearchTerm)) + { + Results.Add(element); + } + } + } + else + { + Results = Buildings; + } + + if (Amenity.Len() > 0) + { + Results = FilterByAmenity(Amenity, Results); + } + + return Results; +} + +TArray UStreetMap::SearchByAmenity(FString Amenity) const +{ + TArray Results = FilterByAmenity(Amenity, Buildings); + + return Results; +} + +TArray UStreetMap::FilterByAmenity(FString Amenity, TArray SmallBuildings) const +{ + TArray Results; + for (const auto &element : SmallBuildings) + { + if (element.Amenity == Amenity) + { + Results.Add(element); + } + else if (element.Building == Amenity) + { + Results.Add(element); + } + else if (Amenity == "residential") + { + if (element.Building == "apartments" || element.Building == "flats" || element.Building == "house") + { + Results.Add(element); + } + } + else if (Amenity == "office") + { + if (element.Building == "commercial" || element.Building == "tower") + { + Results.Add(element); + } + } + else if (Amenity == "sports_centre") + { + if (element.Amenity == "gym" || element.Building == "fitness_centre") + { + Results.Add(element); + } + } + } + + return Results; +} \ No newline at end of file